Sign in to follow this  
cdrw

i need an aabb intersection test

Recommended Posts

god this is driving me insane, ive been on the net for an hour and i cant find one example of a c++ aabb interection test

Share this post


Link to post
Share on other sites
In two dimensions:


bool AABBAABBIntersection( Vector2D p1, Vector2D p2, Vector2D p3, Vector2D p4 )
{
if( ( min( p1.x, p2.x ) > max( p3.x, p4.x ) ) |
( max( p1.x, p2.x ) < min( p3.x, p4.x ) ) |
( min( p1.y, p2.y ) > max( p3.y, p4.y ) ) |
( max( p1.y, p2.y ) < min( p3.y, p4.y ) ) )
return false;

return true;
}



Hope this helps,
Jackson Allan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this