Spacetime Constraints
Andrew Witkin Michael Kass
Schlumberger Palo Alto Research 3340 Hillview Avenue, Palo Alto, CA 94304
Abstract Siggraph '87 [9]. Although Luxo, Jr. showed us that the team of animator, keyframe system, and renderer can be Spacetime constraints are a new method for creating char- a powerful one, the responsibility for de®ning the motion acter animation. The animator speci®es what the character remains almost entirely with the animator. has to do, for instance, ªjump from here to there, clearing a Some aspects of animationÐpersonalityand appeal, for hurdle in between;º how the motion should be performed, exampleÐwill surely be left to the animator's artistry and for instance ªdon't waste energy,º or ªcome down hard skill for a long time to come. However, many of the prin- enough to splatter whatever you land on;º the character's ciples of animation are concerned with making the charac- physical structureÐthe geometry, mass, connectivity, etc. ter's motionlook real at a basic mechanical level that ought of the parts; and the physical resources available to the to admit to formal physical treatment. Consider for exam- character to accomplish the motion, for instance the char- ple a jump exhibitinganticipation,squash-and-stretch, and acter's muscles, a ¯oor to push off from, etc. The require- follow-through. Any creatureÐhuman or lampÐcan only ments contained in this description, together with New- accelerate its own center of mass by pushing on something ton's laws, comprise a problem of constrained optimiza- else. In jumping, the opportunity to control acceleration tion. The solution to this problem is a physically valid mo- only exists during contact with the ¯oor, because while tion satisfying the ªwhatº constraints and optimizing the airborne there is nothing to push on. Anticipation prior to ªhowº criteria. We present as examples a Luxo lamp per- takeoff is the phase in which the needed momentum is ac- forming a variety of coordinated motions. These realistic quired by squashing then stretching to push off against the motions conform to such principles of traditional anima- ¯oor. Follow-throughis the phase in which themomentum tion as anticipation, squash-and-stretch, follow-through, on landing is absorbed. and timing. Such physical arguments make nice post hoc explana- tions, but can physics be brought to bear in creating the Keywords Ð Animation, Constraints complex active motions of characters like Luxo? If so, how much of what we regard as ªniceº motion follows 1 Introduction directly from ®rst principles, and how much is really a matter of style and convention? Computer animation has made enormous strides in the past This paper presents a physically-based approach to char- several years. In particular, Pixar's Luxo, Jr. [10] marked acter animation in which coordinated, active motion is a turning point as perhaps the ®rst computer-generated created automatically by specifying: work to compete seriously with works of traditional ani-
What the character has to do, for instance ªjump from mation on every front. Key among the reasons for Luxo, here to there.º Jr.'s success is that it was made by a talented animator who adapted the principles of traditional animation to the How the motion should be performed, for instance computer medium. Luxo, Jr., in large measure, is awork ªdon't waste energy,º or ªcome down hard enough to of traditional animation that happens to use a computer splatter whatever you land on.º to render and to interpolate between keyframes. John
Lasseter spelled this out clearly in his presentation to What the character's physical structure isÐwhat the pieces are shaped like, what they weigh, how they're connected, etc.
0ªLuxoº is a trademark of Jac Jacobsen Industries AS.
1 What physical resources are available to the character the objects end up and how they get there as where they to accomplish the desired motion, for instance the begin. Problems cast in this form are not initialvalue prob- character's muscles (or whatever an animate lamp lems. For instance, while simulating a bouncing ball is has in place of muscles,) a ¯oor to push off from, etc. easy enough, making the ball bounce to a particular place requires choosing just the right starting values for posi- Our initial experiments with this approach have aimed tion, velocity, and spin. Making these choices manually is at making a Luxo lamp execute a convincing jump just a painful matter of trial and error. Problems such as this by telling it where to start and where to end. The re- one, in which both initial and ®nal conditions are partially sults we present in this paper show that such properties or completely constrained, are called two-point boundary as anticipation, follow-through, squash-and-stretch, and problems, requiring more elaborate solution methods than timing indeed emerge from a bare description of the mo- forward simulation.[3] tion's purpose and the physical context in which it occurs. Character animation poses a still more dif®cult problem. Moreover, simple changes to the goals of the motion or Animals move by using their muscles to exert forces that to the physical model give rise to interesting variations on vary as a function of time. Calculating the motion by the basic motion. For example, doubling (or quadrupling) simulation is straightforward once these time-dependent the mass of Luxo's base creates amusingly exaggerated force functions are known, but the dif®cult problem is motion in which the base looks heavy. to calculate force functions that achieve the goals of the Our method entails the numerical solution of large con- motion. Specifying these functions by hand would be strained optimization problems, for which a variety of hopeless, equivalent to making a robot move gracefully standard algorithms exist. These algorithms, while rela- by manually varying its motor torques. tively expensive, spend most of their time solving sparse In an effort to reconcile the advantages of simulation linear systems, and are therefore amenable to accelera- with the need for control, several researchers [1, 7] have tion by array processors and other commonly available proposed methods for blending positional constraints with hardware. The greatest dif®culty arises not in comput- dynamic simulations. The idea behind these methods is ing the numerical solution, but in setting up the intricate to treat kinematic constraints as the consequences of un- sparse matrix equations that drive the solution process. To known ªconstraint forces,º solve for the forces, then add address this problem we implemented an object-oriented them intothesimulation,exactly canceling that component symbolic algebra system that automates this dif®cult task of the applied forces that ®ghts against the constraints. almost entirely. We therefore believe the method described Constraint force methods permit parts, such as a char- here can become a practical animation tool requiring no acter's hands or feet, to be moved along prede®ned more mathematical sophistication of the end user than do keyframed trajectories, but provide no help in de®ning current keyframing systems. the trajectories, which is the central problem in creat- The remainder of the paper is organized as follows: the ing character animation. While allowing a character to following section discusses the previous use of physical be dragged around manually like a marionette, constraint methods in animation. The spacetime method is then in- forces sidestep the central issue of deciding how the char- troduced using a moving particle as a toy example. Next, acter should move. our extension of the method to complex problems is dis- These shortcomingsled us to adopt a new formulationof cussed. Finally, the Luxo model and the results obtained the constraint problem, whose central characteristic is that with it are described. we solve for the character's motion and time-varying mus- cle forces over the entire time interval of interest, rather 2 Background and Motivation than progressing sequentially through time. Because we extend the model through time as well as space, we call Recently, there has been considerable interest in incorpo- the formulation spacetime constraints. rating physics into animation using simulation methods. The spacetime formulation permits the imposition of [7, 14, 15, 1, 13, 4, 6] The appeal of physical simulation as constraints throughout the time course of the motion, with an animation technique lies in its promise to produce real- the effects of constraints propagating freely backward as istic motion automatically by applying the same physical well as forward in time. Constraints on initial, ®nal, or laws that govern real objects' behavior. intermediate positions and velocities directly encode the Unfortunately, the realism of simulation comes at the goals of the motion, while constraints limiting muscle expense of control. Simulation methods solve initialvalue forces or preventing interpenetration de®ne properties of problems: the course of a simulation is completely deter- the physical situation. Additionally, Newtonian physics mined by the objects' initial positions and velocities, and provides a constraint relating the force and position func- by the forces applied to the objects along the way. An ani- tions that must hold at every instant in time. Subject mator, however, is usually concerned as much with where to these constraints we optimize functions that specify
2
how the motion should be performed, in terms of ef®- (see [12] for a good survey.) We choose instead to rep-
(t) f (t) ciency, smoothness, etc. Solving this constrained opti- resent the functions x and independently. The mization problem yields optimal, physically valid motion equation of motion then enters as a constraint that relates that achieves the goals speci®ed by the animator. the two functions, to be satis®ed along with the other constraints during the solution process. Each function is discretized, that is, represented as a sequence of values, 3 A spacetime particle with time derivatives approximated by ®nite differences. This approach leads to a classical problem in constrained As a gentle but concrete introduction to the spacetime optimization, for which a variety of standard solution al- method, this section describes a minimal example involv- gorithms are available.
ing a moving particle, in¯uenced by gravity, and equipped
(t) f (t) Let the discretized functions x and be repre-
with a ªjet engineº as a means of locomotion. With no
x f i n i sented by sequences of values i and ,0 , restrictions on the forces exerted by its engine, the particle with h the time interval between samples. To approximate
can move any way it likes. The problem we formulate
(t) the time derivatives of x we use the ®nite difference here is that of making the particle ¯y from a given start- formulas
ing point to a given destination in a ®xed period of time,
x x
i
with minimal fuel consumption. This toy problem is too i 1
_
x =
i (2)
simple to produce any really interesting motion, but it ex- h
x x + x
i+ i
hibits all the key elements of the method, and will aid in 1 2 i 1
x = i 2 (3) understanding what follows. h
Substituting these relations into equation 1 gives n
x f i
3.1 Problem formulation ªphysics constraintsº relating the i 's to the 's,
x(t)
x x + x
+ i i
Let the particle's position as a function of time be , i 1 2 1
p = m f mg = ;
i 0 1
(t) f 2
and the time-varying jet force be . Suppose for sim- h ) plicity that the mass of the fuel is negligible compared to (4
that of the particle, so the total mass may be treated as a In addition we have the two boundary constraints
mg
constant, m, with a constant gravitational force .Then
c = x a = the particle's equation of motion is a 1 0
and
x f mg = ; ( )
m 0 1
c = x b = : n
b 0
where x is the second time derivative of position. Given
(t)
Assuming that f is constant between samples, the ob-
_
(t) x x the function f , and initial values for and at some
jective function R becomes a sum
x(t) t time t0, the motion from 0 could be obtained by
integrating equation 1 to solve the initial value problem. X 2
R = h jf j ( )
i 5
Instead we wish to make the particle ¯y from a known
i b point a to a known point in a ®xed period of time. Suppose for simplicity that the rate of fuel consumption which is to be minimized subject to the constraints. The
2 discretized objective and constraint functions are now ex- f j x(t )= a
is j . In that case, we have constraints 0 and
x f i
pressed in terms of the i (t )=b x 1 subject to which 's and the 's, which are the
independent variables to be solved for. Z
t1
2
R = jf (t)j dt
t0 3.2 Numerical Solution
must be minimized. The problem then is to ®nd a force From the standpoint of the numerical solution process it is
(t) (t ;t )
function f , de®ned on the interval 0 1, such that the useful to suppress the structure of the particular problem,
(t)
position function x obtained by solving equation 1 sat- reducing it to a canonical form consisting of a collection of
S ; j n
is®es the boundary constraints, and such that the objective scalar independent variables j 1 , an objective
R R(S )
function is a constrained minimum. function j to be minimized, and a collection of scalar
C (S );
There exist a variety of standard approaches to solving constraint functions i 1 , which must be S
problems of this form. Prevalent in the optimal control driven to zero. In the current problem, the j 's are the
x y z x f i
literature are iterative methods that solve the initial value , ,and components of the i 's and the 's, while the
C p c c
i a b problem within each iteration, using the equations of mo- i 's are the components of the 's, ,and . Typically, tion to obtain the position function from the force function setting up the linearized indices is the responsibility of a
3
3
n O (n ) program that keeps track of the independent variables and Although inverting a general n matrix is , the constraint functions. the matrices arising in spacetime problems are nearly al-
In these terms, the standard constrained optimization ways extremely sparse. Exploiting the sparsity is essen-
S R(S ) j
problem is ªFind j that minimizes subject to tial to make the problem tractable. Moreover, over- and
C (S )= j i 0. For the sake of modularity, the numeri- under-constrained systems, whose matrices are non-square cal method that solves the problem is best regarded as an and/or rank-de®cient, can easily arise, in which case the object that requests answers to certain standard questions inverse is unde®ned and the system cannot be solved. The
about the system, and iteratively provides updated values latter problem is well treated by the pseudo-inverse [8, 4], S
for the solution vector j . Any method must be permitted which provides least-squares solutions to overconstrained
R C S j to request the values of and i at a given . In addi- problems, and minimal solutionsto underconstrainedones.
tion, most effective methods require access to derivatives To compute the pseudo-inverse while exploiting random
R C S j of and i with respect to , in order to move toward a sparsity, we adapted a sparse conjugate gradient (CG)
2
(n ) solution. algorithm described in [11], which is O for typical The solution method we use is a variant of Sequential problems. The CG algorithm solves the matrix equation
2
= Mb ja Mbj Quadratic Programming (SQP), described in detail in [3]. a by iteratively minimizing , giving a
Essentially, the method computes a second-order Newton- least-squares solution to overconstrained problems. Pro- R
Raphson step in , and a ®rst-order Newton-Raphson step vided that a zero starting-point is given for b, the solution
C M in the i 's, and combines the two steps by projecting vector is restricted to the null-space complement of .
the ®rst onto the null space of the second (that is, onto the C hyperplanefor which all the i 's are constant to®rst order.) 3.4 Matrix evaluation. Because it is ®rst-order in the constraint functions and second-order in theobjectivefunction,themethod requires Applying the SQP algorithm to the moving particle exam- that we be able to compute two derivative matrices: the ple requires evaluation of the sparse derivative matrices, Jacobian of the constraint functions, given by as well as the objective and constraint functions them-
selves. Apart from the bookkeeping required for indexing,
@C
i
; J =
ij these evaluations are straightforward. The Jacobian of the @S j physics constraint is given by
and the Hessian of the objective function,
@ p
i 2
m=h ; i = j
2 = 2
@ R
@ x
j
H = :
ij @S
@S 2
i j