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 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.