Public Group

# get colliding face of 2 AABB's?

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

## Recommended Posts

So far I have 2 AABB's, one stationary and one moving, checking against min(x,y,z) and max(x,y,z) of the 2 AABB's I can tell if they intersect.

Now I would like to implement a "slide against the wall" effect, therefore I need to get the normal of the colliding face, but I have troubles understanding how I can compute which face is colliding.

I googled a lot and found something about SAT (  http://www.codezealot.org/archives/55 ) but I am still confused, is this the only technique to get the colliding face or are there other options available?

I would appreciate some hints or pseudo code to get me started.

##### Share on other sites
SAT works by finding all the common axises (sp?) between the two colliders and see how much they overlap. If one of them doesn't overlap, there's no collision. Otherwise the collision normal can be devised from the overlaps.

AABB's, by definition, have the common axises global x, y and z. With the min/max tests you find out if all of them overlap or not. So what's left to do, is figure out, how much they overlap, and them simply pick the largest overlap, since the axises are also, by definition, the face normals.

I hope that helps!

And maybe someone can let me know what the correct plural of axis is... ;)

##### Share on other sites

thanks, indeed that helped, i got a little confused reading so much stuff about SAT.

now i calculate the distance between the 2 boxes using the min and max values for each axis and take the largest distance which gives me the correct normal.

the plural of axis is axes.

##### Share on other sites

Yes, SAT can get pretty tricky, if more complex geometries are involved. Two AABBs are probably the second easiest, right after two spheres.

I found this website to be very helpful in explaining the theorem, it also has nifty interactive examples:

http://www.metanetsoftware.com/technique/tutorialA.html

Unfortunately it only covers 2D collisions...

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 27
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632963
• Total Posts
3009518
• ### Who's Online (See full list)

There are no registered users currently online

×