
A BoundingBox3d is a rectangular box in 3D defined by its minimum and maximum
X, Y and Z values. It is possible to generate bounding boxes for most geometric
objects; for example, Triangle3d.boundingBox takes a
Triangle3d and returns a BoundingBox3d that contains that triangle. There
are several use cases where it is more efficient to deal with the bounding box
of an object than the object itself, such as:
- Intersection checking: If (for example) the bounding boxes of a line segment
and a triangle do not overlap, then the line segment and triangle cannot
possibly intersect each other. Expensive intersection checking therefore
only has to be performed for line segments and triangles whose bounding
boxes do overlap.
- 3D rendering: When rendering a 3D scene, any object whose bounding box is
not visible must itself be not visible, and therefore does not have to be
drawn. This provides a simple form of culling.