Triangle to sphere
To test if a sphere and a triangle intersect, we must first find the point on the triangle that is closest to the center of the sphere. If the distance between the center of the sphere and the closest point is less than the radius of the sphere, we have an intersection:
Getting ready
We are about to implement a function that tests if a triangle and sphere intersect. This function will return a Boolean result. We avoid the expensive square root operation involved in finding distance by checking squared distance against squared radius.
How to do it…
Follow these steps to implement a test for checking if a triangle and sphere intersect: ...
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.