#### Archived

This topic is now archived and is closed to further replies.

# Rectangle in 3D collision test

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

## Recommended Posts

Does anyone know any good tutorials on how to compute if two rectangles in 3D (i mean, like a cube but with rectangular shape) intersects? It is enough with knowing if the collided, no need to compute the actual intersection... Thanks! Daniel.

##### Share on other sites
 ` bool hit(all the arguments..){if (((x1-xs1x2-xs2) || (x1-xs1x2+xs2) || (x1-xs1>x2-xs2 && x1+xs1y2-ys2) || (y1-ys1y2+ys2) || (y1-ys1>y2-ys2 && y1+ys1z2-zs2) || (z1-zs1z2+zs2) || (z1-zs1>z2-zs2 && z1+zs1

y1=box 1, y coordinate to the center
ys1=box 1, "y size" (height)
x2=box 2, x coordinate to the center
etc.

Didn't try it and just wrote it.. So if it works might be a bit questionable . Of course the algo only works for axis-aligned "3d-rectangles" but I guess that's what your're looking for anyway.

Edited by - Hans on January 15, 2001 4:47:51 PM

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633695
• Total Posts
3013382
×