Determine contact edge of 2 boxes

Started by
1 comment, last by schupf 12 years, 6 months ago
Hello!

I have a "simple" problem, yet I could not figure out how to solve this. Assume I have 2 boxes, 1 is static (the black one), the other one is moving (please look at the attachment).

I have sketched 3 cases in the picture. All 3 moving boxes have the same movement direction. I want to determine WHICH edge of the static black box is hit first by the moving box (I need this to resolve the collision)
So in my sketch the green and blue box will hit +Y edge of the black box. The red box will hit the -X edge of the black box. If the blue box was smaller, it would hit the -X edge. So its obvious that the contact edge depends on the extent of the static box, the moving box and the direction.

Do you know a "simple" algorithm to detect the contact edge (the edge where the first contact occurs)?
Advertisement

Hello!

I have a "simple" problem, yet I could not figure out how to solve this. Assume I have 2 boxes, 1 is static (the black one), the other one is moving (please look at the attachment).

I have sketched 3 cases in the picture. All 3 moving boxes have the same movement direction. I want to determine WHICH edge of the static black box is hit first by the moving box (I need this to resolve the collision)
So in my sketch the green and blue box will hit +Y edge of the black box. The red box will hit the -X edge of the black box. If the blue box was smaller, it would hit the -X edge. So its obvious that the contact edge depends on the extent of the static box, the moving box and the direction.

Do you know a "simple" algorithm to detect the contact edge (the edge where the first contact occurs)?


Yes :)

For each pair of boxes:

* Expand the large box by the extents of the smaller box
* Shrink the smaller box down to a point
* Ray-cast from the point along the velocity of the smaller box
* Intersection point is the first point of contact between the boxes, get the edge from this

Cheers, Paul.
Thats just brilliant! I got it working now!

Thank you very much wildbunny!:)

This topic is closed to new replies.

Advertisement