184 4. 3D Math for Games
We won’t derive or prove this result any further here, but a thorough explana-
tion of why this litt le “trick” works is provided in Section 4.2.3 of [28].
4.6.4. Axis-Aligned Bounding Boxes (AABB)
An axis-aligned bounding box (AABB) is a 3D cuboid whose six rectangular
faces are aligned with a particular coordinate frame’s mutually orthogonal
axes. As such, an AABB can be represented by a six-element vector containing
the minimum and maximum coordinates along each of the 3 principal axes,
[ xmin , xmax , ymin , ymax , zmin , zmax ], or two points Pmin and Pmax.
This simple representation allows for a particularly convenient and in-
expensive method of testing whether a point P is inside or outside any given
AABB. We simply test if all of the following conditions are true:
Px ≥ xmin and Px ≤ xmax and
Py ≥ ymin and Py ≤ ymax and
Pz ≥ zmin and Pz ≤ zmax.
Because intersection tests are so speedy, AABBs are oft en used as an “early
out” collision check; if the AABBs of two objects do not intersect, then there is
no need to do a more detailed (and more expensive) collision test.
4.6.5. Oriented Bounding Boxes (OBB)
An oriented bounding box (OBB) is a cuboid that has been oriented so
as to align in some logical way with the object it bounds. Usually an OBB
aligns with the local-space axes of the object. Hence it acts like an AABB
in local space, although it may not necessarily align with the world space
axes.
Various techniques exist for testing whether or not a point lies within
an OBB, but one common approach is to transform the point into the OBB’s
“aligned” coordinate system and then use an AABB intersection test as pre-
sented above.
4.6.6. Frusta
As shown in Figure 4.29, a frustum is a group of six planes that defi ne a trun-
cated pyramid shape. Frusta are commonplace in 3D rendering because they
conveniently defi ne the viewable region of the 3D world when rendered via a
perspective projection from the point of view of a virtual camera. Four of the
planes bound the edges of the screen space, while the other two planes repre-
sent the the near and far clipping planes (i.e., they defi ne the minimum and
maximum z coordinates possible for any visible point).
Near
Far
Left
Right
Top
Bottom
Figure 4.29. A frustum.