8
\$\begingroup\$

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...

\$\endgroup\$

1 Answer 1

6
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .