Sign in to follow this  
schupf

Determine contact edge of 2 boxes

Recommended Posts

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)?

Share this post


Link to post
Share on other sites
[quote name='schupf' timestamp='1318161322' post='4870761']
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)?
[/quote]

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this