Wednesday, July 2, 2025

Capsule to Sphere Collision

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

Capsule to Sphere Collision

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

You will 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 examine the Dot Product of AC and AB

  • If this Dot Product is lower than 0, which means 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 check with the Dot Product of BA and BC

  • As soon as once more, if the Dot Product is lower than 0, B can be the closest level on the road phase to C, so we might 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 undertaking C onto AB to get the space.
There’s an environment friendly method 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 make it possible for it’s NOT normalized.

And the ultimate step is to make use of this squared distance and evaluate 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 looks like with the values I am getting are usually not right, or the method I am doing is improper… Is anybody capable of level me in the best path?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles