Graphics Reference
In-Depth Information
for(intj=0;j<3;j++) {
float e = m[i][j] * a.min[j];
float f = m[i][j] * a.max[j];
if(e<f){
b.min[i] += e;
b.max[i] += f;
} else {
b.min[i] += f;
b.max[i] += e;
}
}
}
}
Correspondingly, the code for the center-radius AABB representation becomes
[Arvo90]:
// 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(inti=0;i<3;i++) {
b.c[i] = t[i];
b.r[i] = 0.0f;
for(intj=0;j<3;j++) {
b.c[i] += m[i][j] * a.c[j];
b.r[i] += Abs(m[i][j]) * a.r[j];
}
}
}
Note that computing an AABB from a rotated AABB is equivalent to computing it
from a freely oriented bounding box. Oriented bounding boxes and their intersection
tests will be described in more detail ahead. However, classed between the methods
presented here and those to be presented would be the method of storing oriented
bounding boxes with the objects but still intersecting them as reconstructed AABBs
(as done here). Doing so would require extra memory for storing the orientation
matrix. It would also involve an extra matrix-matrix multiplication for combining the
rotation matrix of the oriented bounding box with the transformation matrix M . The
benefit of this solution is that the reconstructed axis-aligned box would be much
tighter, starting with an oriented box. The axis-aligned test is also much cheaper than
the full-blown test for oriented boxes.
 
Search WWH ::




Custom Search