Game Development Reference
F IGURE 13.15
Replacing face-face and edge-face contacts between boxes.
The separating axis theorem says that two objects cannot possibly be in contact as
long as there is some axis on which the objects can be projected where they are not in
As we saw for the sphere-box case, this check therefore has three parts: first we
choose an axis, second we project the objects onto the axis (this was trivial in the case
of a sphere, but will be more complex here), and third we check to see whether the
projections are overlapping. Figure 13.16 shows this.
If the projections are overlapping on this axis, it does not mean that the objects
are touching. But if they are not overlapping, then we know for sure that the objects
This test can be implemented for boxes by projecting the half-size of the box onto
the separating axis in this way:
Excerpt from src/collide_fine.cpp
real transformToAxis(const Box &box,
const Vector3 &axis)