23.4 C
New York
Tuesday, July 1, 2025

Capsule to Sphere Collision


For my Maths unit at college, we now have to manually calculate if a sphere is colliding with a capsule collider.

The knowledge I’ve to go together with is that this;

You might have the next Sphere:

  • LadyBird3 – CentrePoint = (0, 0, 0), Radius = 18.0

And the next capsule

  • Sanic – BottomPoint = (0,2,6), TopPoint = (0, 12, 6), Radius = 5.0

Decide if the next pair-wise collision happens:

Sanic & LadyBird3

In our lecture, we’re informed the next;

NOTE: Normalizing at this step is unimportant

First, we’re going to verify the Dot Product of AC and AB

  • If this Dot Product is lower than 0, meaning the closest level from the road phase to C is A

  • So we are able to simply return the squared size of AC and cease any additional calculations

  • Now we carry out the identical take a look at with the Dot Product of BA and BC

  • As soon as once more, if the Dot Product is lower than 0, B could be the closest level on the road phase to C, so we’d simply return the size of BC and cease any additional calculations.

Projection…
If the dot product returned > 0 for each factors of the road phase, we have to mission C onto AB to get the space.
There’s an environment friendly technique to get the squared distance if that is all we care about:

  • SquaredDistance = AC.LengthSq – (AC . AB) * (AC . AB) / AB.LengthSq

  • When performing the dot product right here, we have to ensure that it’s NOT normalized.

And the ultimate step is to make use of this squared distance and examine it to the sum of each radii squared to find out if there may be an intersection.


So, I am attempting to calculate if they’re intersecting or not utilizing the knowledge from above.

All I’ve managed to provide you with is that this
(Taking away the LadyBird3 positions from Sanics place (TP, BP))

AC = (0, 2, 6)

AB = (0, -10, 0)

Dot Product = -20

BA = (0, 10, 0)

BC = (0, 12, 6)

Dot Product = 120

It seems like with the values I am getting usually are not appropriate, or the method I am doing is incorrect… Is anybody capable of level me in the suitable path?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles