Game Development Reference
tion force increases in one direction, the friction force will also increase. There will
therefore be an entry in the Jacobian to represent this connection.
The flexibility of the Jacobian to represent interactions between objects, as well as
the basic motion of the object itself, allows it to be used to create a much wider range
of joints. In our engine joints are explicitly specified and handled with their own code.
The Jacobian provides a mechanism to link the movement of any two objects in the
simulation. In fact it can link different elements of each object, so for example the
motion of one object along one axis can be fixed (i.e., any force that tries to break
this joint is resisted by an equal and opposite reaction force). In addition motors can
be implemented by adding elements to the Jacobian that generate forces regardless
of anything else going on. If you look at a physics engine such as ODE (and several
commercial middleware packages), they allow very flexible joints and motors to be
created by adding entries directly into the Jacobian.
Most force components will not directly interact with one another at all, so the
Jacobian will have zeros at the corresponding locations. In fact most of the matrix will
be filled with zeros. The Jacobian is sometimes called a “sparse matrix” for this rea-
son. The mathematics of sparse matrices can be dramatically simpler than for regular
matrices, but the algorithms are often more complex.
You may come across topics or papers on game physics that talk about Lagrange
multipliers, the Lagrange method, or Featherstone's algorithm. Each of these is related
to the method shown here. The Lagrange method works with a more complex equa-
tion than ours, where the Jacobian is decomposed into several parts, one of which
specifies the connections between objects and another (the so-called Lagrange mul-
tipliers) specifies the amount of interaction. 1 Most game physics engines use the raw
Jacobian as shown, but you may find it useful to read up on the Lagrange method.
A lot of textbooks on the mathematics of physics were not written with games in
mind, so they use the Lagrange formulation extensively. It can be useful to under-
stand how it works.
T HE L INEAR C OMPLEMENTARY P ROBLEM
Armed with the Jacobian we can formulate the mathematical problem of resolving all
contacts at the same time. It has the basic form of
where f is a vector of force and torque components for all rigid bodies and
p is the
resulting accelerations. But f is made up of two components,
f contacts +
1. Note that the Lagrange formulation isn't just an expanded Jacobian. With all the bits extracted, it can
be used in other ways and with variations on the equation I have introduced in this chapter. But all this is
well beyond the scope of this topic, and I've never needed it and have never invested the time to understand
it in depth. It is also not for the mathematically faint-hearted.