22.10.1 AABB

Assume we have an AABB, B, defined by a center point, c , and a positive half diagonal vector, h . Note that c and h can easily be derived from the minimum and maximum corners, b min and b max of B, that is, c = ( b max + b min ) / 2 , and h = ( b max - b min ) / 2 .

Now, we want to test B against a plane n · x + d = 0 . There is a surprisingly fast way of performing this test. The idea is to compute the “extent,” here denoted e, of the box when projected onto the plane normal, n . In theory, this can be done by projecting all the eight different half diagonals of the box onto the normal, and picking the longest one. In practice, however, this can be implemented rapidly as

(22.18) ...

Get Real-Time Rendering, Fourth Edition, 4th Edition now with the O’Reilly learning platform.

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