Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

add aabb to a aabb

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

//---------------------------------------------------------------------------
// AABB3::add
//
// Add an AABB to the box

void    AABB3::add(const AABB3 &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?
//---------------------------------------------------------------------------
// AABB3::add
//
// Add an AABB to the box

void    AABB3::add(const AABB3 &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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!