One use of AABBs in computer graphics is to approximate the shape of an object. The AABB is used to perfom fast approximated tests such as testing intersections and finding if an object is inside the view frustum. As objects are transformed (scaled, rotated and translated), we are interested in calculating the AABB of a transformed AABB.

Two computer representations of AABBs are usually used:

  1. Minimum and maximum coordinates.
  2. Center and half extents.

We are going to derive formulas to calculate the AABB of a transformed AABB for each representation, along with implementation details.

AABB as minimum and maximum coordinates

Given an AABB with minimum and maximum coordinates:

and an affine transformation matrix:

we want to transform the AABB by and calculate a new AABB.

An obvious algorithm to calculate the new AABB is to transform each corner of the original AABB and then calculate, for each coordinate, the minimum and maximum values. The eight corners of the original AABB are:

The transformed corners are:

The new minimum and maximum coordinates are:

Simplifying:

Implementation details:

AABB as center and half extents

Given an AABB with center and half extents , and an affine transformation matrix , we want to transform the AABB by and calculate a new AABB.

The new center is calculated by applying the translation of the matrix :

An obvious algorithm to calculate the new half extents is to transform each corner of the AABB and then calculate, for each coordinate, the maximum of the absolute values. The original eight corners of the AABB are:

Or expressed more concisely:

We will transform the corners and see what we can do:

The minimum and maximum values for each coordinate are:

Note that:

So we can take either the maximum coordinate or the absolute of the minimum coordinate to calculate the new half extents:

Implementation details:

Conclusion

In general, objects are not symmetric, so AABBs represented as minimum and maximum coordinates provide better shape approximation. This is the computer representation usually used because the better approximation pays off even if the implemenation needs more operations.