Saturday, July 12, 2025
HomeGame DevelopmentCapsule to Sphere Collision

Capsule to Sphere Collision


For my Maths unit at college, now we have 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’ve 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 advised 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, which means the closest level from the road section 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 could be the closest level on the road section 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 section, we have to mission C onto AB to get the gap.
There’s an environment friendly approach 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 guarantee 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’s an intersection.


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

All I’ve managed to give you 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 should not appropriate, or the method I am doing is improper… Is anybody capable of level me in the best course?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments