Animation
Lecture 10
Slide 1
6.837 Fall 2003
Conventional Animation Draw each frame of the animation
great control tedious
Reduce burden with cel animation
layer keyframe inbetween cel panoramas (Disney’s Pinocchio) ...
Lecture 10
Slide 2
6.837 Fall 2003
Computer-Assisted Animation Keyframing automate the inbetweening good control less tedious creating a good animation still requires considerable skill and talent
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Procedural animation
describes the motion algorithmically express animation as a function of small number of parameteres Example: a clock with second, minute and hour hands
hands should rotate together express the clock motions in terms of a “seconds” variable the clock is animated by varying the seconds parameter
Example 2: A bouncing ball
Abs(sin(ωt+θ0))*e-kt Lecture 10
Slide 3
6.837 Fall 2003
Computer-Assisted Animation Physically Based Animation Assign physical properties to objects (masses, forces, inertial properties) Simulate physics by solving equations Realistic but difficult to control
Image removed due to copyright considerations.
Motion Capture
Captures style, subtle nuances and realism You must observe someone do something
Lecture 10
Slide 4
6.837 Fall 2003
Overview Squash & Stretch in Luxo Jr.'s Hop
Hermite Splines Keyframing Traditional Principles Articulated Models Forward Kinematics Inverse Kinematics Optimization Differential Constraints
Lecture 10
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Slide 5
6.837 Fall 2003
Keyframing
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Describe motion of objects as a function of time from a set of key object positions. In short, compute the inbetween frames.
Lecture 10
Slide 6
6.837 Fall 2003
Interpolating Positions Given positions: (x i , y i ,t i ), i = 0,K , n ⎡ x (t )⎤ find curve C (t ) = ⎢ such that C (t i ) = ⎥ ⎣ y (t ) ⎦ (x 2 , y 2 ,t 2 )
C (t )
⎡x i ⎤ ⎢y ⎥ ⎣ i⎦
( xu0 , y 0 , t 0 ) 0
(x 1 , y 1 ,t 1 )
Lecture 10
Slide 7
6.837 Fall 2003
Linear Interpolation (x 2 , y 2 ,t 2 )
(x 0 , y 0 ,t 0 )
(x 1 , y 1 ,t 1 ) Simple problem: linear interpolation between first two points assuming t 0 =0 and t 1 =1: x (t ) = x 0 (1 − t ) + x 1t The x-coordinate for the complete curve in the figure:
t −t0 ⎧ t1 − t x + ⎪ t − t 0 t − t x 1 , t ∈ ⎡⎣t 0 , t 1 ) ⎪ 1 0 1 0 x (t ) = ⎨ ⎪ t 2 − t x + t − t 1 x , t ∈ ⎡t , t ⎤ ⎣ 1 2⎦ ⎪⎩t 2 − t 1 1 t 2 − t 1 2 Lecture 10
Slide 8
Derivation?
6.837 Fall 2003
Polynomial Interpolation (x 2 , y 2 ,t 2 )
(x 0 , y 0 ,t 0 )
(x 1 , y 1 ,t 1 )
parabola
An n-degree polynomial can interpolate any n+1 points. The Lagrange formula gives the n+1 coefficients of an n-degree polynomial that interpolates n+1 points. The resulting interpolating polynomials are called Lagrange polynomials. On the previous slide, we saw the Lagrange formula for n = 1.
Lecture 10
Slide 9
6.837 Fall 2003
Spline Interpolation Lagrange polynomials of small degree are fine but high degree polynomials are too wiggly.
t
t
t
x (t )
8-degree polynomial
spline
spline vs. polynomial
How many n-degree polynomials interpolate n+1 points? Lecture 10
Slide 10
6.837 Fall 2003
Spline Interpolation Lagrange polynomials of small degree are fine but high degree polynomials are too wiggly. Spline (piecewise cubic polynomial) interpolation produces nicer interpolation.
t
t
t
x (t )
8-degree polynomial
Lecture 10
spline
Slide 11
spline vs. polynomial
6.837 Fall 2003
Spline Interpolation A cubic polynomial between each pair of points: x (t ) = c 0 + c 1t + c 2t 2 + c 3t 3 Four parameters (degrees of freedom) for each spline segment. Number of parameters: n+1 points ⇒ n cubic polynomials ⇒ 4n degrees of freedom Number of constraints: interpolation constraints n+1 points ⇒ 2 + 2 (n-1) = 2n interpolation constraints
“endpoints” + “each side of an internal point” rest by requiring smooth velocity, acceleration, etc.
Lecture 10
Slide 12
6.837 Fall 2003
Hermite Splines We want to support general constraints: not just smooth velocity and acceleration. For example, a bouncing ball does not always have continuous velocity:
Solution: specify position AND velocity at each point Derivation? c 0 , c 1 , c 2 , c 3 = ? for x 0 ,v 0 : t = t 0 and x 1 ,v 1 : t = t 1
Lecture 10
Slide 13
6.837 Fall 2003
Keyframing
(
)
0 1 Given keyframes K i = p i , p i ,K ,t i , i = 0,K , n
⎡ p 0 (t ) ⎤ ⎢ 1 ⎥ find curves K (t ) = ⎢ p (t ) ⎥ such that K (t i ) = K i ⎢ M ⎥ ⎣ ⎦
What are parameters p i0 , p i1 ,K?
position, orientation, size, visibility, …
Interpolate each curve separately
Lecture 10
Slide 14
6.837 Fall 2003
Interpolating Key Frames Interpolation is not fool proof. The splines may undershoot and cause interpenetration. The animator must also keep an eye out for these types of side-effects.
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Lecture 10
Slide 15
6.837 Fall 2003
Traditional Animation Principles The in-betweening, was once a job for apprentice animators. We described the automatic interpolation techniques that accomplish these tasks automatically. However, the animator still has to draw the key frames. This is an art form and precisely why the experienced animators were spared the inbetweening work even before automatic techniques. The classical paper on animation by John Lasseter from Pixar surveys some the standard animation techniques: "Principles of Traditional Animation Applied to 3D Computer Graphics,“ SIGGRAPH'87, pp. 35-44.
Lecture 10
Slide 16
6.837 Fall 2003
Squash and stretch Squash: flatten an object or character by pressure or by its own power Stretch: used to increase the sense of speed and emphasize the squash by contrast
Squash & Stretch in Luxo Jr.'s Hop
Squash & Stretch In Bouncing Ball
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Lecture 10
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Slide 17
6.837 Fall 2003
Timing Timing affects weight:
Light object move quickly Heavier objects move slower
Timing completely changes the interpretation of the motion. Because the timing is critical, the animators used the draw a time scale next to the keyframe to indicate how to generate the inbetween frames.
TIMING CHART FOR BALL BOUNCE
EXTREME
EXTREME
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Lecture 10
Slide 18
6.837 Fall 2003
Anticipation An action breaks down into:
Anticipation Action Reaction
Anatomical motivation: a muscle must extend before it can contract. Prepares audience for action so they know what to expect. Directs audience’s attention. Amount of anticipation can affect perception of speed and weight.
Squash & Stretch in Luxo Jr.'s Hop
Image adapted from: Lasseter, John. "Principles of Traditional Animation applied to 3D Computer Animation." ACM SIGGRAPH Computer Graphics 21, no. 4 (July 1987): 35-44.
Lecture 10
Slide 19
6.837 Fall 2003
Articulated Models Articulated models: „ „
rigid parts connected by joints
They can be animated by specifying the joint angles as functions of time.
qi
t1 Lecture 10
qi (t )
t2
t1 Slide 20
t2 6.837 Fall 2003
Forward Kinematics Describes the positions of the body parts as a function of the joint angles. 1 DOF: knee
Lecture 10
2 DOF: wrist
Slide 21
3 DOF: arm
6.837 Fall 2003
Skeleton Hierarchy Each bone transformation described relative to the parent in the hierarchy:
x h , y h , z h , θh , φh , σh hips
θt , φt , σt
left-leg
θc
... r-thigh
r-calf y
θf , φf
vs
x
r-foot
z
Derive world coordinates Lecture 10
v w for an effecter with local coordinates v s ? Slide 22
6.837 Fall 2003
Forward Kinematics x h , y h , z h , θh , φh , σh
Transformation matrix for an effecter vs is a matrix composition of all joint transformation between the effecter and the root of the hierarchy.
θt , φt , σt θc
y
θf , φf
vs
vs
x z
vw = T(xh , yh , zh )R(θh , φh , σh ) TR(θt , φt , σt ) TR(θc ) TR(θf , φf ) vs ⎛ ⎞ v w =S ⎜ x h , y h , z h ,θh , φh , σ h ,θt , φt , σ t ,θc ,θf , φf ⎟v s =S ( p )v s ⎜ 14444444244444443 ⎟ p ⎝ ⎠ Lecture 10
Slide 23
6.837 Fall 2003
Inverse Kinematics Forward Kinematics
Given the skeleton parameters (position of the root and the joint angles) p and the position of the effecter in local coordinates vs, what is the position of the sensor in the world coordinates vw? Not too hard, we can solve it by evaluating S ( p )v s
Inverse Kinematics Given the position of the effecter in local coordinates vs and the desired position ṽw in world coordinates, what are the skeleton parameters p?
x h , y h , z h , θh , φh , σh θt , φt , σt θc
Much harder requires solving the inverse of the non-linear function: p? such that S ( p )v s = v%w Underdetermined problem with many solutions
Lecture 10
Slide 24
θf , φf
6.837 Fall 2003
vs
v%w
Real IK Problem Find a “natural” skeleton configuration for a given collection of pose constraints. Definition: A scalar objective function g(p) measures the quality of a pose. The objective g(p) reaches its minimum for the most natural skeleton configurations p. Definition: A vector constraint function C(p) = 0 collects all pose constraints: ⎡S 0 ( p )v 0 − v%0 ⎤ ⎢ ⎥ % ⎢ S 1 ( p )v 1 − v 1 ⎥ = 0 ⎢⎣ ⎥⎦ M 1442443 C (p )
Lecture 10
Slide 25
6.837 Fall 2003
Optimization Compute the optimal parameters p* that satisfy pose constraints and maximize the natural quality of skeleton configuration:
p * = argmin p
s.t.
g (p ) C (p ) = 0
Example objective functions g(p): T deviation from natural pose: g ( p ) = ( p − p ) M ( p − p )
joint stiffness power consumption …
Lecture 10
Slide 26
6.837 Fall 2003
Unconstrained Optimization Define an objective function f(p) that penalizes violation of pose constraints:
f ( p ) = g ( p ) + ∑w i ⎡⎣C i ( p ) ⎤⎦
2
i
p * = argmin Necessary condition:
p
f ( p * + ∆p ) − f ( p * ) ≥ 0 ∇f ( p * )T ∆p + L ≥ 0
f (p ) ( p * is local minimum) (Taylor series)
⇓ ∇f ( p * ) = 0
Lecture 10
(∆p is arbitrary)
Slide 27
6.837 Fall 2003
Numerical Solution Gradient methods
Guess initial solution x0 Iterate x k +1 = x k + α k d k , Until ∇f (x k ) = 0
α k > 0,
∇f (x k )T d k < 0
The conditions α k > 0, ∇f (x k )T d k < 0 guarantee that each new iterate is more optimal f (x k +1 ) < f (x k ) . Derive? Some choices for direction dk:
Steepest descent d k = −∇f (x k ) = −
∂g ∂C i − 2∑w i C i ∂p ∂p i −1
Newton’s method d k = − ⎡⎣∇ f (x k ) ⎤⎦ ∇f (x k ) Quasi-Newton methods d k = −D k ∇f (x k ) 2
Lecture 10
Slide 28
6.837 Fall 2003
Gradient Computation Requires computation of constraint derivatives:
Compute derivatives of each transformation primitive Apply chain rule
Example:
C (p ) ≡ T(x h , y h , z h )R(θh ,φh , σh ) TR(θt ,φt , σt ) TR(θc ) TR(θf ,φf ) v s −v w ∂R(θc ) ∂C = T(x h , y h , z h )R(θh ,φh , σh ) TR(θt , φt , σt ) T TR(θf ,φf ) v s ∂θc
∂θc
∂R(θc ) Derive if R is a rotation around z-axis? ∂θc
Lecture 10
Slide 29
6.837 Fall 2003
Constrained Optimization Unconstrained formulation has drawbacks:
Sloppy constraints The setting of penalty weights wi must balance the constraints and the natural quality of the pose
Necessary condition for equality constraints:
Lagrange multiplier theorem:
∇f ( p * ) + ∑ λi ∇C i ( p * ) = 0 i
λ0 , λ1, … are scalars called Lagrange multipliers
Interpretations:
Cost gradient (direction of improving the cost) belongs to the subspace spanned by constraint gradients (normals to the constraints surface). Cost gradient is orthogonal to subspace of feasible variations. Lecture 10
Slide 30
6.837 Fall 2003
Example p * = argmin p
s.t.
p1 + p 2 p12 + p 22 = 2
⎡1⎤ ∇f ( p * ) = ⎢ ⎥ ⎣1⎦ ⎡ −2 ⎤ ∇C ( p * ) = ⎢ ⎥ ⎣ −2 ⎦
Lecture 10
Slide 31
6.837 Fall 2003
Nonlinear Programming Use Lagrange multipliers and nonlinear programming techniques to solve the IK problem:
p = argmin *
p
s.t.
⎫ g (p )⎬ ⎭ C ( p ) = 0}
nonlinear objective nonlinear constraints
In general, slow for interactive use!
Lecture 10
Slide 32
6.837 Fall 2003
Differential Constraints Differential constraints linearize original pose constraints.
⎡S 0 ( p )v 0 ⎤ ⎡v%0 ⎤ ⎢ ⎥ ⎢% ⎥ ⎢ S 1 ( p )v 1 ⎥ = ⎢v 1 ⎥ ⎢⎣ ⎥⎦ ⎢⎣ M ⎥⎦ M 14243
Rewrite constraints by pulling the desired effecter locations to the right hand side
C (p )
Construct linear approximation around the current parameter p. Derive with Taylor series.
Lecture 10
∂C ( p ) ∆p = ∆v% ∂p
Slide 33
6.837 Fall 2003
IK with Differential Constraints Interactive Inverse Kinematics
User interface assembles desired effecter variations ∆v% Solve quadratic program with Lagrange multipliers:
∆p * = argmin ∆p
s.t.
∆p T M ∆p ∂C ( p ) ∆p = ∆v% ∂p
* Update current pose: p k +1 = p k + α k ∆p
Objective function is quadratic, differential constraints are linear. Some choices for matrix M:
Identity: minimizes parameter variations Diagonal: minimizes scaled parameter variations
Lecture 10
Slide 34
6.837 Fall 2003
Quadratic Program Elimination procedure Apply Lagrange multiplier theorem and convert to vector notation: general form in scalar notation:
T
⎛ ∂C ( p ) ⎞ M ∆p + ⎜ λ =0 ⎟ ⎝ ∂p ⎠
∇f ( p * ) + ∑ λi ∇C i ( p * ) = 0 i
T
∆p = −M
Rewrite to expose ∆p: Use this expression to replace ∆p in the differential constraint:
−1
⎛ ∂C ( p ) ⎞ ⎜ ∂p ⎟ λ ⎝ ⎠ T
∂C ( p ) −1 ⎛ ∂C ( p ) ⎞ M ⎜ λ = −∆v% ⎟ ∂p ⎝ ∂p ⎠
Solve for Lagrange multipliers and compute ∆p*
Lecture 10
Slide 35
6.837 Fall 2003
Kinematics vs. Dynamics Kinematics Describes the positions of body parts as a function of skeleton parameters. Dynamics Describes the positions of body parts as a function of applied forces.
Lecture 10
Slide 36
6.837 Fall 2003
Next Dynamics
ACM© 1988 “Spacetime Constraints”
Lecture 10
Slide 37
6.837 Fall 2003