# add aabb to a aabb

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

## Recommended Posts

//---------------------------------------------------------------------------
//
// Add an AABB to the box

// Expand the box as necessary.

if (box.min.x < min.x) min.x = box.min.x;
if (box.min.x > max.x) max.x = box.min.x;
if (box.min.y < min.y) min.y = box.min.y;
if (box.min.y > max.y) max.y = box.min.y;
if (box.min.z < min.z) min.z = box.min.z;
if (box.min.z > max.z) max.z = box.min.z;
}


should be this , maybe I was wrong. but where?
//---------------------------------------------------------------------------
//
// Add an AABB to the box

// Expand the box as necessary.

if (box.min.x < min.x) min.x = box.min.x;
if (box.max.x > max.x) max.x = box.max.x;
if (box.min.y < min.y) min.y = box.min.y;
if (box.max.y > max.y) max.y = box.max.y;
if (box.min.z < min.z) min.z = box.min.z;
if (box.max.z > max.z) max.z = box.max.z;
}



##### Share on other sites
I would bet on 2. [smile]

It is a box union. The intersection is the dual of that if interested.

##### Share on other sites
Pseudo code

UNION  Box.min  =  MIN(Box1.min, Box2.min)  Box.max  =  MAX(Box1.max, Box2.max)INTERSECTION  Box.min  =  MAX(Box1.min, Box2.min)  Box.max  =  MIN(Box1.max, Box2.max)where MIN(point1, point2) = Point( MIN( point1.x, point2.x ),...)      MAX(point1, point2) = Point( MAX( point1.x, point2.x ),...)NOTE  if a component in min is less than the corresponding  component in max the intersection is empty

##### Share on other sites
I tried to reedit...however the empty intersection condition is

a component in max is less than the component in min !!!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634091
• Total Posts
3015435
×