Jump to content
• Advertisement

# edge-edge Collision Response (in 2d)

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

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hello together, I am working on 2D Physics. Vertex-Edge collision response is working fine. But I do not know how to calculate the outcome of a edge-edge collision. Any help? Thanks Nathan

#### Share this post

##### Share on other sites
Advertisement
After thinking and searching the web a little more, these are the Ideas I could find/am having. I am modeling an edge-edge collision using 2 contact points (the line between them is the area in which the bodies collide).

1. Just take the middle of the contact points and pretend its a vertex-edge collision.
Also I can not really think of a scenario in which this would result in a completly wrong outcome, this just does not seem right.

2. Evaluate the "effects" of both collision points and take the average. With effects I mean change in velocity and rotation.
But imagine a simple cube (or a square, since we are in 2D) colliding with the ground with a coefficient of elasticity of 1.0. The collision points would be at the 2 corners of the suare. There effects in changing the rotation would eliminate each other, but they would both result
in much lower "velocity change" as one would expect. The cube would loose energy despite the coefficent of elasticity of 1.0!

3. Look it this image for an example:
We project the center of mass along the collision normal onto the collision area and take the closest point on the collision area to this point (if the point is in the collision area, the point itself is taken. Otherwise the leftmost or rightmost point is taken). Use this point for vertex-edge collision.
The problem is, that the projected point is different for the objects ... and I do not know if this gives could results in all scenarios.

I do not really know ... what is the behavior in the real world?
I hope this post is not to confusing. I am having a little trouble expressing these things in English :)

Edit: Had trouble inserting the image

#### Share this post

##### Share on other sites
hmm...

usually, this is how I do it.

1) Find basic collision data.
-> time of collision
-> normal of collision (pointing up).

2) find the features on both objects along the normal of collision.
-> bottom edge on the grey blob.
-> top edge of the box.

3) Move objects to time of collision.
4) 'Clip' the two colliding edges, which give a small segment
-> gives two contact points (the extremities of the segment).
5) apply basic impulse on both contact points (examples for this is abundant on the net).
6) wayhay! objects bounce! And if the centre of gravity doesn't 'project' on the clipping result (segment), then the objects will have rotation as well.

There will be a small loss of momentum, but I think it's more due to the crappy integration I use. It's not perfect, but looks good enough.

#### Share this post

##### Share on other sites
Thanks for your reply, Oliii

What exactly do you do in 5? With "apply basic impulse", you mean appling the resulting momentum and angular momentum as in a vertex-edge collision? (With the formulars found all over the net).

So you calculate the outcome of both contact points and apply both?
Mmh ... without taking the average?
This would result in a clockwise rotation of the "grey blob", correct?

If that's what you do (and it works) I must be doing something wrong, because in my case the grey blob looses about 90% if its momentum in the collision (the box is a static object).

#### Share this post

##### Share on other sites
N Tutorials has a great tutorial on 2D collision detection. It's a different method than yours, but it's very nice.

#### Share this post

##### Share on other sites
Quote:
 Original post by LonelyStarThanks for your reply, OliiiWhat exactly do you do in 5? With "apply basic impulse", you mean appling the resulting momentum and angular momentum as in a vertex-edge collision? (With the formulars found all over the net).So you calculate the outcome of both contact points and apply both?Mmh ... without taking the average?This would result in a clockwise rotation of the "grey blob", correct?If that's what you do (and it works) I must be doing something wrong, because in my case the grey blob looses about 90% if its momentum in the collision (the box is a static object).

the collision impulse is the standard point->surface collision impulse equation, as used by Baraff and Chris Hecker.

http://www.d6.com/users/checker/dynamics.htm

So yeah, you apply it at the two points of collision independently, and the rotation should cancel out if it needs to cancel out. When you apply the momentum, you may have to be apply the sum of both momentum after both impulses are applied, or you may seem some unwanted rotation. But dont quote me on that, I haven't tried to to be sure, but it seems to be the logical way.

so,

5.a ) calculate the collision impulse for both contact points.
-> gives change in momentum, both linear and angular.
5.b) apply the changes in momentum to the objects.
-> change angular and linear velocity of objects.

#### Share this post

##### Share on other sites
Thanks for your help Oliii!
I think I am happy with my result now :)

#### Share this post

##### Share on other sites
I think an edge-edge collision is equivalent to a vertex-vertex collision at the middle of the colliding zone. To see that, imagine an extra vertex there, an infinitesimal distance out from the colliding area – the collision must be the same. I don't know if it is how you want to go, but it should work.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5
• Advertisement

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

• Total Topics
633700
• Total Posts
3013420
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!