## 3 thoughts on “Constraints Introduction”

1. Pieter

Hi Randy

Thanks for writing this article and for linking to Erin’s work. I’m looking forward to trying to implement it!

Regards!

2. Pieter

Hi Randy

I’ve been trying to figure this out for a while now, but I’m still stuck. I tried reading Catto’s work but it’s a bit more arcane to me for some reason, so I prefer to work from your article. My biggest problem is applying the theory to my code, except that at some point Vfinal=Vinitial+m^−1∗F .

If you could give some clarification regarding the following:

(1) “The l and a terms in (1) are my own notation. l refers to linear while a refers to angular.”

I assume this refers to body 1 and 2’s positions and orientations (not velocity and angular velocity).

(2) The variable L (or “length of the rod connecting both bodies”) is never mentioned after equation 2, so where during the computation of the time derivative Ċ is it specified?

(3) Is equation 13 really equal to equation 4? If so, again, where does L come into play?

(4) Am I correct in assuming that the Jacobian*lambda handles the “errors” in the bodies’ initial velocities (or is it positions?), i.e. if the bodies velocities and angular velocities are multiplied by Jacobian*lambda, they will increment towards constraint space?

(5) I am very confused by how Catto’s steps for hand-deriving Jacobians connect to each other, but I’m still working on that (I’m slow but determined). How is equation 2 and 9 connected? I don’t follow the derivation so well.

Apologies for all the incessant questions. I usually prefer to defer questions for as long as possible, but constraints are truly the last part of game physics I want to master before continuing to something more in my ballpark.

1. Randy Gaul Post author

1) Yes, constraints start in position form.
2) It is a constant, and disappears as part of taking the time derivative.
3) Equation 13 allows for the Jacobian to be identified, as the Jacobian’s elements are the coefficients of velocity (both angular and linear terms).
4) No, not quite correct. J represents the path of least resistance towards the solution, and is used to transform from Cartesion to Constraint space. Constraint space can be thought of as a one dimensional space where you can go along the Jacobian, or along the inverse Jacobian. Lambda scales the Jacobian. Solving for lambda solves for the scale of force needed to push a body towards the solution (solved for in constraint space). This lambda is then transformed to a force in Cartesian space via the Jacobian transposed.
5) This involves vector calculus, and can be difficult. The idea is that the constant L is zero, and the deritive of P2 – P1 (via chain rule) are the velocities of P1 and P2. The dot above a variable denotes “derivative with respect to time”. So you end up with, by chain rule, (P2 – P1)(Pdot2 – Pdot1). Then you can expand the velocity of a point into a linear and angular term, resulting in (P2 – P1)(v2 + w2 x r2 + v1 + w1 x r1). (P2 – P1) is a vector and can be written as the variable d. The dot product is then distributed and the angular terms are shifted by the scalar triple product identity to isolate the velocity term, easily showing what the coefficients of velocity are.

I hope this helps, feel free to ask more questions :)