Graphics Reference
In-Depth Information
4.2.6 AABB Recomputed from Rotated AABB
Last of the four realignment methods, the most common approach is to simply wrap
the rotated AABB itself in a new AABB. This produces an approximate rather than
a tight AABB. As the resulting AABB is larger than the one that was started with, it
is important that the approximate AABB is computed from a rotation of the original
local-space AABB. If not, repeated recomputing from the rotated AABB of the previous
time step would make the AABB grow indefinitely.
Consider an axis-aligned bounding box A affected by a rotation matrix M , resulting
in an oriented bounding box A at some orientation. The three columns (or rows,
depending on what matrix convention is used) of the rotation matrix M give the
world-coordinate axes of A in its local coordinate frame. (If vectors are column vectors
and multiplied on the right of the matrix, then the columns of M are the axes. If instead
the vectors are multiplied on the left of the matrix as row vectors, then the rows of M
are the axes.)
Say A is given using min-max representation and M is a column matrix. The axis-
aligned bounding box B that bounds A is specified by the extent intervals formed by
the projection of the eight rotated vertices of A onto the world-coordinate axes. For,
say, the x extents of B , only the x components of the column vectors of M contribute.
Therefore, finding the extents corresponds to finding the vertices that produce the
minimal and maximal products with the rows of M . Each vertex of B is a combination
of three transformed min or max values from A . The minimum extent value is the
sum of the smaller terms, and the maximum extent is the sum of the larger terms.
Translation does not affect the size calculation of the new bounding box and can just
be added in. For instance, the maximum extent along the x axis can be computed as:
B.max[0] = max(m[0][0] * A.min[0], m[0][0] * A.max[0])
+ max(m[0][1] * A.min[1], m[0][1] * A.max[1])
+ max(m[0][2] * A.min[2], m[0][2] * A.max[2]) + t[0];
Computing an encompassing bounding box for a rotated AABB using the min-max
representation can therefore be implemented as follows:
// Transform AABB a by the matrix m and translation t,
// find maximum extents, and store result into AABB b.
void UpdateAABB(AABB a, float m[3][3], float t[3], AABB &b)
{
// For all three axes
for(inti=0;i<3;i++) {
// Start by adding in translation
b.min[i] = b.max[i] = t[i];
// Form extent by summing smaller and larger terms respectively
 
Search WWH ::




Custom Search