Graphics Reference
In-Depth Information
In terms of storage requirements, the center-radius representation is the most
efficient, as the halfwidth values can often be stored in fewer bits than the center
position values. The same is true of the width values of the min-width representation,
although to a slightly lesser degree. Worst is the min-max representation, in which
all six values have to be stored at the same precision. Reducing storage requires
representing the AABB using integers, and not floats, as used here. If the object
moves by translation only, updating the latter two representations is cheaper than
the min-max representation because only three of the six parameters have to be
updated. A useful feature of the center-radius representation is that it can be tested
as a bounding sphere as well.
4.2.1 AABB-AABB Intersection
Overlap tests between AABBs are straightforward, regardless of representation. Two
AABBs only overlap if they overlap on all three axes, where their extent along
each dimension is seen as an interval on the corresponding axis. For the min-max
representation, this interval overlap test becomes:
int TestAABBAABB(AABB a, AABB b)
{
// Exit with no intersection if separated along an axis
if (a.max[0] < b.min[0] || a.min[0] > b.max[0]) return 0;
if (a.max[1] < b.min[1] || a.min[1] > b.max[1]) return 0;
if (a.max[2] < b.min[2] || a.min[2] > b.max[2]) return 0;
// Overlapping on all axes means AABBs are intersecting
return 1;
}
The min-width representation is the least appealing. Its overlap test, even when
written in an economical way, still does not compare with the first test in terms of
number of operations performed:
int TestAABBAABB(AABB a, AABB b)
{
float t;
if ((t = a.min[0] - b.min[0]) > b.d[0] || -t > a.d[0]) return 0;
if ((t = a.min[1] - b.min[1]) > b.d[1] || -t > a.d[1]) return 0;
if ((t = a.min[2] - b.min[2]) > b.d[2] || -t > a.d[2]) return 0;
return 1;
}
 
Search WWH ::




Custom Search