i
i
i
i
i
i
i
i
16.10. Plane/Box Intersection Detection 755
The advantages of the crossings test is that it is relatively fast and
robust, and requires no additional information or preprocessing for the
polygon. A disadvantage of this method is that it does not yield anything
beyond the indication of whether a point is inside or outside the polygon.
Other methods, such as the ray/triangle test in Section 16.8.1, can also
compute barycentric coordinates that can be used to interpolate additional
information about the test point [482]. Note that barycentric coordinates
can be extended to handle convex and concave polygons with more than
three vertices [346, 566].
16.10 Plane/Box Intersection Detection
One way to determine whether a box intersects a plane, π : n · x + d =0,
is to insert all the vertices of the box into the plane equation. If both
a positive and a negative result (or a zero) is obtained, then vertices are
located on both sides of (or on) the plane, and therefore, an intersection
has been detected. There are smarter,fasterwaystodothistest,which
are presented in the next two sections, one for the AABB, and one for
the OBB.
The idea behind both methods is that only two points need to be in-
serted into the plane equation. For an arbitrarily-oriented box, intersecting
a plane or not, there are two diagonally opposite corners on the box that
are the maximum distance apart, when measured along the plane’s normal.
Every box has four diagonals, formed by its corners. Taking the dot prod-
uct of each diagonal’s direction with the plane’s normal, the largest value
identifies the diagonal with these two furthest points. By testing just these
two corners, the box as a whole is tested against a plane.
16.10.1 AABB
Assume we have an AABB, B, defined by a center point, c, and a positive
half diagonal vector, h.Notethatc and h caneasilybederivedfrom
the minimum and maximum corners, b
min
and b
max
of B,thatis,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. Thereisa
surprisingly fast way of performing this test, and 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 very rapidly as
e = h
x
|n
x
|+ h
y
|n
y
|+ h
z
|n
z
|. (16.28)