Skip to main content
gamedev.net
🔒 Locked

box-box intersection test

Started by remdul Aug 26, 2006 at 9:23 AM 5 replies 6.1k views
Original Post
remdul
remdul
What is the best (simplest/fastest) way to do object aligned box-box intersection test? Should I do a plane-plane intersection for each 6-sides, and then check whether that line segment lies within the box dimensions, or do a line-plane test for each edge? Any other way to get the intersection points?
Zakwayda
Zakwayda
Quote:
Original post by remdul
What is the best (simplest/fastest) way to do object aligned box-box intersection test?

Should I do a plane-plane intersection for each 6-sides, and then check whether that line segment lies within the box dimensions, or do a line-plane test for each edge? Any other way to get the intersection points?
Separating Axis Theorem, currently being discussed here and here. Also try geometrictools.com for documentation and sample code.
remdul
remdul
Thanks, I've already read some of that but I doubt I can understand any of that.

Is it possible get correct results with the methods I mentioned?
Zakwayda
Zakwayda
Quote:
Original post by remdul
Thanks, I've already read some of that but I doubt I can understand any of that.

Is it possible get correct results with the methods I mentioned?
You could brute force it with point-containment and edge-face tests. I suppose it might be easier conceptually, but it'll be much slower and probably less robust as well. Also, it may be more difficult to extract meaningful contact info (depending on what you need such info for), and it'll be harder to derive a swept version of the test (if you need it).

Personally, I'd just buckle down and implement the SAT. There are plenty of good references available.
SuperNerd
SuperNerd
Assuming that the position of the box is defined by the center of the box.
if
|x1 - x2| <= width1 / 2 plus width2 / 2
and
|y1 - y2| <= height1 / 2 plus height2 / 2
and
|z1 - z2| <= depth1 / 2 plus depth2 / 2

then the boxes intercect.
Zakwayda
Zakwayda
Quote:
Original post by SuperNerd
Assuming that the position of the box is defined by the center of the box.
if
|x1 - x2| <= width1 / 2 plus width2 / 2
and
|y1 - y2| <= height1 / 2 plus height2 / 2
and
|z1 - z2| <= depth1 / 2 plus depth2 / 2

then the boxes intercect.
That's an AABB test. Although it wasn't mentioned specifically, I believe the OP is looking for an OBB test.
remdul
remdul
Quote:
Original post by jyk
That's an AABB test. Although it wasn't mentioned specifically, I believe the OP is looking for an OBB test.

Quote:
Original post by remdul
object aligned box-box

Thanks jyk, I'll give SAT another try. All I need is the penetration depth and a least one contact point.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.