Method to move two points on two rigid bodies together

Hi there,

What i'm after is an method to move two rigid bodies together in one step so that two arbitrarily chosen points (one on each body) are just touching. So it would be like a position correction impulse but with a massive time-step (the traditional method stops working very well for big angles)...

Its simple for a linear only motion:

correct = pointOnB - pointOnA;
denom = 1 / (invMassA + invMassB);
movementImpulse = -correct * denom;
bodyA.pos -= movementImpulse * invMassA;
bodyB.pos += movementImpulse * invMassB;

This biases the masses so the lighter object moves more, it would be nice the candidate linear+rotational method also did this but with inertia tensors 🙂 I'm stumped though...

Cheers, Paul.
Would it work if you just kind of botch it by attaching a RevoluteJoint to both bodies on the respective points? (letting box2d do the rest)..
android wrote:
Would it work if you just kind of botch it by attaching a RevoluteJoint to both bodies on the respective points? (letting box2d do the rest)..


No because that would suffer the same problem, because the position fix up code uses the small angle approximation for integrating angles when it solves using the position impulse... So when there are big angles involved, the bodies wouldn't necessarily be touching afterwards...
Most of the angular effects are difficult to solve exactly. However, using more position iterations should improve convergence.

Original thread: https://box2d.org/forum/viewtopic.php?t=2824