# 2d Physics: Solving for 2 Contact Points

## Recommended Posts

Posted (edited)

Hi All,

I have recently been programming a very rudimentary 2d Physics Engine. I implemented SAT to check for Collision between convex polygons, and this gives me one to two contact points.

Collisions between Objects where just one Contact Point is generated get resolved just fine, but if i have 2 Contact Points, The Object begins to shake. For example, if a box falls on the ground due to gravity, it starts tilting to the right and left very fast. I believe the problem is, that on contact an Impulse gets applied to one Contact Point, and the box turns in the other direction. Then in the next step it penetrates the ground in the other Direction and gets an Impule in the other direction, and so on.

I tried several Methods by now, but nothing seems to fix the problem. Do i have to implement some kind of iterative solver?

How can you solve for 2 Contact Points efficiently? The way I am doing it right now, is to just resolve the Collision for each Contact Point, scaling the Impulse down by the ratio of the penetration depths.

If you know a possible Solution to my problem, or even just a hint in the right direction, please let me know!

Edited by SnackerB

##### Share on other sites

Your solver currently treats each contact point in isolation. Given the first contact point is perfectly solved, the second contact point, once solved, invalidates the solution to the first, thus causing jitter. A very good way to reduce jitter is to implement an iterative solver where the various contact points communicate with one another to somehow converge upon an acceptable solution altogether.

My personal favorite resource for learning one good solution is under GDC 2006 here: http://box2d.org/downloads/. Specifically this link to the powerpoint and this link to the demo code.

##### Share on other sites

Thanks, not only for the answer, but also for the Great Tutorial you've made on how to program a Physics Engine. Without it, it wouldve taken me much longer to even get here. Keep up the good work!

Ill try to implement this Arbiter mechanic from the Demo. If i have any more Questions, ill ask them here.

## Create an account

Register a new account

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633330
• Total Posts
3011389
• ### Who's Online (See full list)

There are no registered users currently online

×