# AABB vs AABB Intersection

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

## Recommended Posts

I've been googling around for how to do this, but haven't been able to get anything yet. Could anyone explain the procedure, or link me to a site with information on it? Resolving the intersection is not yet needed, I only need to know if there is a collision.

##### Share on other sites
project the boxes on X, Y, Z planes.
if the boxes colide, their projected rectangles should overlap on the 3 planes.
now, for early rejections, turn it the other way, if on one plane, the rectangles don't overlap, no need to investigate further, they don't colide.

##### Share on other sites
Projecting the boxes on the planes, means doing more work than necessary.

Using the Separate Axes theorem is much easier and faster. (Especially in the case of AABB intersection).

Here's the code:
struct AABB{	float fMinX, fMaxX;	float fMinY, fMaxY;	float fMinZ, fMaxZ;};// Use the Separate Axes theorem to determine if the boxes intersect.bool isAABBIntersect( const AABB& box1, const AABB& box2 ) {	if ( (box1.fMaxX >= box2.fMinX) && (box2.fMaxX >= box1.fMinX) && // Axis X		 (box1.fMaxY >= box2.fMinY) && (box2.fMaxY >= box1.fMinY) && // Axis Y		 (box1.fMaxZ >= box2.fMinZ) && (box2.fMaxZ >= box1.fMinZ) )  // Axis Z		 return true;	return false;}

##### Share on other sites
of course, DOING the projection on X, Y or Z is stupid because you already have the values you're interested in...
anyway, the idea is the same.

1. 1
Rutin
73
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633427
• Total Posts
3011818
• ### Who's Online (See full list)

There are no registered users currently online

×