Sphere-to-AABB

To check if a Sphere and an Axis Aligned Bounding Box (AABB) intercept, we must first find the closest point on the AABB to the Sphere. Once we have this point, we can figure out the distance between the Sphere and the closest point. Finally, we can compare this distance to the radius of the Sphere. If the distance between the closest point and the Sphere is less than the radius of the Sphere, the point is inside the Sphere:

Sphere-to-AABB

Getting ready

We are going to implement a function to test if a Sphere and an AABB are intersecting. We will also use a #define macro to implement a convenience function to see if an AABB intercepts a sphere. This ...

Get Game Physics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.