Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm writing a 2D rigid body simulator. The objects being simulated are convex polygons. My question involves how to decide on the "point" of collision, so that when I apply a response force, I can also calculate torque.

In 2D, the popular method of narrowphase collision detection seems to be the Separating Axis Theorem. However, while this gives you the "are they colliding?" as well as "by how much?", it does NOT give you a reference point (that I'm aware of) at which to apply the response force (and thus calculate torque)*.

The other method (which also interests me more, because it's what's used in 3D, which would be the logical next step) is to calculate the Minkowski difference of the two polygons, and decide that they're colliding if (0,0) is contained in the resulting polygon. But, how do you use this to decide the relative point at which to apply the response force? My hypothesis is that, since each face of this difference effectively corresponds to a face of one of the polygons, the separation distance is the shortest distance from (0,0) to the MD, and you apply this to the corresponding face on the polygon.

As a bonus, how does one do this in 3D?

*As I'm writing this, I just realized that, when using SAT, I could just keep track of which points are overlapping, and apply the force at the "average" of those points. But I would have to decide on which of the several non-separating axes to perform this little trick...

share|improve this question
add comment

1 Answer

The keywords you're looking for are "support points" and "manifold".

Erin Catto has written an excellent 2D physics engine. He regularly presents at GDC. You should be able to find some of his slides where he explains collision manifolds. The first version of his physics engine only supported box shapes to simply calculating the support points. Which is where the engine got its name Box2D.

The answer is too complex to describe fully here but the overview is you need to pick a total of 2 points from the two shapes. Then apply the restitution force equally to each. You'll also have to deal with a corner case where it's better to only use one support point.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.