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:

Point and Oriented Bounding Box

This diagram demonstrates a test point ...

Get Game Physics Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.