Archived

This topic is now archived and is closed to further replies.

Arkion

Finding super-AABB that encloses two smaller AABB's

Recommended Posts

What is most efficient way to find super-AABB (dashed box) that encloses two smaller AABB''s which have origins at points p1 and p2?

y
^ 
| +- - - - - - +---+
| .  p1        | o | p2
| +-----+      +---+
| |  o  |          .
| +-----+ - - - - -+
|
+------------------> x

To compute this, should AABB object have it''s min and max vector stored relative to world origin (absolute) or relative to it''s local origin?

Share this post


Link to post
Share on other sites
AABBoxes with min and max absolute vectors are usually the way to go. Then it''s a straight forward procedure

SuperBox.MinX = (Box1.MinX < Box2.MinX)? Box1.MinX : Box2.MinX;
SuperBox.MinY = (Box1.MinY < Box2.MinY)? Box1.MinY : Box2.MinY;
SuperBox.MinZ = (Box1.MinZ < Box2.MinZ)? Box1.MinZ : Box2.MinZ;

SuperBox.MaxX = (Box1.MaxX > Box2.MaxX)? Box1.MaxX : Box2.MaxX;
SuperBox.MaxY = (Box1.MaxY > Box2.MaxY)? Box1.MaxY : Box2.MaxY;
SuperBox.MaxZ = (Box1.MaxZ > Box2.MaxZ)? Box1.MaxZ : Box2.MaxZ;

if your boxes are based on a centre postion and an extent, then compute the min and max of both boxes and do the thing above.


Share this post


Link to post
Share on other sites