AABB-to-AABB

Testing if two AABBs overlap involves performing an interval test on each of the world axes. To visualize this problem, let's consider what an interval test looks like on just one axis:

AABB-to-AABB

Given shapes A and B, we have an overlap only if the minimum of A is less than the maximum of B and the maximum of A is greater than the minimum of B. The actual overlap test would look something like this:

A.min <= B.max && a.max >= b.min

We can determine if two AABBs overlap by performing this test on the global X, Y, and Z axes.

Getting ready

We are going to implement a function to test if two AABBs are overlapping or not. This function will test for interval ...

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.