Point and Oriented Bounding Box
To test if a point is inside an Oriented Bounding Box (OBB), we could transform the point into the local space of the OBB, and then perform an AABB containment test. However, transforming the point into the local space of the OBB is needlessly expensive.
A more efficient solution is to project the point onto each axis of the OBB, then compare the projected point to the length of the OBB on each axis. To get the closest point to a test point on the surface of the OBB, we perform the same projection. Once the point is projected, we clamp it to the length of the OBB on each axis:
Getting ready
We are going to implement two functions. The first function will test if a point is contained within an Oriented Bounding Box. The second function will find the closest point to a given test point on the surface...