Game Development Reference
In-Depth Information
The alternative is to resolve a set of contacts at the same time. Rather than calcu-
lating the impulse of each in turn, we need to find the impulses of all simultaneously.
Most physics engines that perform this simultaneous calculation are based on
force calculations rather than impulses. In other words, two objects in resting contact
are kept apart by a constant force, not by a series of single-frame impulses as we have
done. So the resolution calculation tries to find the forces and impulses to apply at
each contact, taking the interaction of all contacts into account.
The most common approach to doing this is called the “linear-complementary
problem.” It involves building a mathematical structure called a Jacobian, which en-
codes the interactions between different contacts. This can then (usually) be turned
into a single set of forces to apply.
Because this is such a common and important approach, we'll look at it from a
high level in this chapter. I won't go into the finer points of implementation, however,
because getting the algorithms to work in a stable way involves numerous special-case
problems and unusual complications.
18.1.1
T HE J ACOBIAN
The Jacobian is a mathematical construct that says how one contact affects another. It
is used to determine the right balance of adjustments to make with the full knowledge
of the side effects of any tweak. The Jacobian is a matrix and may be of any size.
All the forces and torques for all objects are combined into one very long vector.
There will be three force entries and three torque entries for each rigid body, so the
vector will have 6 n entries, where n is the number of rigid bodies. In the same way
all the accelerations (linear and angular) for all objects are treated as one long vector
(again having 6 n entries).
The entries in the Jacobian matrix relate the two together. The value of row a ,
column b in the matrix tells us the amount of acceleration of component a that a unit
of force or torque in direction b would cause. Some of the entries in the matrix are
very simple: they are the equations we've used throughout the topic to determine the
movement of an object. For example, a force in the X direction causes an acceleration
of magnitude m 1 (from F
ma ); so in the Jacobian the value that relates X-direction
force to X-direction acceleration will be m 1 .
While many of the values in the Jacobian are based on the simple laws of motion,
some are due to the interaction of objects at contact points. Each value in the matrix
gives the change that will occur in the row's component given a unit change in the
column's component.
Calculating the entries in the Jacobian involves working out the forces at each
contact given a unit force at each other contact. The process is similar to what we
used in our engine to calculate the effects of one contact resolution on others.
Entries in the Jacobian don't only exist because one contact affects another. It is
also possible for one axis of one contact to affect another. For a contact with friction,
the friction force generated will depend on the normal reaction force. As the reac-
=
Search Nedrilad ::




Custom Search