I am trying to implement joint constraints for connected rods. I was looking at the derivation for the particular Jacobian on this site:
http://myselph.de/gamePhysics/equalityConstraints.html
They chose the constraint to be C = (Pa - Pb)*(Pa - Pb), which makes the jacobian [-d -r1Xd d r2Xd]
d=current distance between constraint point on each object
r=lever arm from center of mass of each object to its constraint point
They also have a javascript demo at the bottom which appears to work. My question is, why does this work. Looking at the math, it looks like it should not.
Because:
When the constraint is valid, Pa - Pb should equal 0. Then the jacobian is 0, so JV is 0 as well, therefore lambda is 0 whenever the constraint itself is valid, even if the derivative of the constraint is invalid. It won't attempt to create any corrective velocity until Pa and Pb are no longer equal.
This is different from a pendulum constraint where Pa - Pb is supposed to be non zero, allowing lambda to be nonzero even when the constraint position is valid.
Is there something I am missing, or is this formula for joint constraint wrong? It looks like the only reason their demo works is because the B term fixes it on the next frame.
I can't find any other decent explanations of how this is supposed to work other than the classic pendulum or penetration constraints.