#### Archived

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

# Finding super-AABB that encloses two smaller AABB's

This topic is 5389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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.

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631740
• Total Posts
3001965
×