Animation.

advertisement
Lecture 8
Animation
Dr. Amy Zhang
Reading
Hill, Chapters 5 / 7 / 10
Red Book, Chapter 3, “Viewing”
Red Book, Chapter 12, “Evaluators and NURBS”



2
Outline
Computer-aided animation
Keyframing and interpolation of position
Hierarchical modeling.
Interpolation of rotation




3
Conventional Animation
Draw each frame of the animation



great control
tedious
Reduce burden with cel animation




4
Layer, keyframe, inbetween
cel panoramas (Disney’s Pinocchio)
...
ACM © 1997 “Multiperspective panoramas for cel animation”
Computer-Assisted Animation
Keyframing
 automate the inbetweening
 good control
 less tedious
 creating a good animation still
requires considerable skill and
talent

5
Computer-Assisted Animation
Procedural animation
 describes the motion algorithmically
 express animation as a function of small number of
parameters
 Example: a clock with second, minute and hour hands





Example 2: A bouncing ball

6
hands should rotate together
express the clock motions in terms of a “seconds” variable
the clock is animated by varying the seconds parameter
Abs(sin(ωt+Θ))*e-kt
Computer-Assisted Animation
Physically Based Animation




7
Assign physical properties to objects (masses, forces, inertial
properties)
Simulate physics by solving equations
Realistic but difficult to control
Computer-Assisted Animation
Motion Capture



8
Captures style, subtle nuances and realism
You must observe someone
Motion Capture
9
Motion Replay
http://www.youtube.com/watch?v=IJ4tndpwL-o
10
Outline




Computer-aided animation
Keyframing and interpolation of position
Hierarchical modeling.
Interpolation of rotation
11
Keyframing

Describe motion of objects as a function of time
from a set of key object positions. In short, compute
the inbetween frames.
12
Interpolating Positions


Given positions:
find curve
13
such that
Linear Interpolation


Simple problem: linear interpolation between first
two points assuming
:
The x-coordinate for the complete curve in the figure:
14
Polynomial Interpolation

A polynomial is a function of the form:

n is the degree of the polynomial
The order of the polynomial is the number of coefficients
it has
Always: order = degree + 1


15
Polynomial Interpolation

What degree polynomial can interpolate n+1 points?




An n-degree polynomial can interpolate any n+1 points
wikipedia: Lagrange interpolation
The resulting interpolating polynomials are called Lagrange
polynomials
We already saw the Lagrange formula for n = 1
16
Spline Interpolation


Lagrange polynomials of small degree are fine but high
degree polynomials are too wiggly
Technical term: overfitting
17
Spline Interpolation
Spline (piecewise cubic polynomial) interpolation
produces nicer interpolation

t
x(t)
18
t
t
Spline Curves



The word spline comes from ship building with wood
A wooden plank is forced between fixed posts, called
“ducks”
Real-world splines are still being used for designing
ship hulls, automobiles, and aircraft fuselage and wings
19
Splines
www.abm.org
20
Spline Curves


Spline curve - any composite curve formed with piecewise
parametric polynomials subject to certain continuity
conditions at the boundary of the pieces.
Huh?
21
Parametric Polynomial Curves

A parametric polynomial curve is a parametric curve
where each function x(t), y(t) is described by a polynomial:

Polynomial curves have certain advantages:


22
Easy to compute
Indefinitely differentiable
Why Parametric Curves?



Parametric curves are very flexible
They are not required to be functions
Curves can be multi-valued with respect to any
coordinate system
23
Piecewise Curves


To avoid overfitting we will want to represent a curve as
a series of curves pieced together
A piecewise parametric polynomial curve uses different
polynomial functions for different parts of the curve


24
Advantages: Provides flexibility
Problem: How do we fit the pieces together?
Parametric Continuity



25
C0: Curves are joined “watertight”
curve / mesh
C1: First derivative is continuous,
d/dt Q(t) = velocity is the same.
“looks smooth, no facets”
C2: Second derivative is continuous,
d2/dt2 Q(t) = acceleration is the
same (important for animation and
shading)
Specifying Splines




Control Points - a set of
points that influence the
curve's shape
Hull - the lines that
connect the control points
Interpolating – curve passes
through the control points
Approximating – control
points merely influence
shape
26
Parametric Cubic Curves


In order to assure C2 continuity our functions must be of
at least degree three.
Here's what a 2D parametric cubic function looks like:
In matrix form:
27
Parametric Cubic Curves

This is a cubic function in 3D:

To avoid the dependency on the dimension we will use
the following notation:
28
Parametric Cubic Curves

What does the derivative of a cubic curve look like?
29
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
30
Hermite Splines

Given:



Two control points (P1, P2).
Tangents (derivatives) at the knot points (P’1, P’2):
“Control knob” vector: [P1, P2, P’1, P’2]
31
Hermite Spline

4 segments, (P1, P2) and (P’1, P’2) for each segment
32
Building it up…

Cubic curve equations:

Boundary constraints:
or:
33
Solve for the c’s
34
Cubic Hermite Curves

Curve equation in matrix form:

T = Power basis
B = Spline basis, characteristic matrix
G = Geometry (control points)


35
Bézier Curves



Developed simultaneously by Bézier (at Renault) and de
Casteljau (at Citroen), circa 1960.
Without specify consecutive tangents
A cubic Bézier curve has four control points, two of which are
knots (P1, P4).
36
Bézier Specification


Four control points (P1, P2, P3, P4).
Gradients (tangents) at the knot points (P’1, P’4) are the
line segments between adjacent control points:





Tangents: P’1 = 3 ( P2 - P1 ); P’2 = 3 ( P4 - P3 )
Scale factor (3) is chosen to make “velocity” approximately
constant
Endpoint interpolation: P(0) = P1 and P(1) = P4
P2 & P3 control the magnitude and orientation of the
tangent vectors at the end points
Geometry vector G: [P1, P2, P3, P4]
37
Cubic Bézier Curves

Repeating the same derivation gives:
38
Bézier Curves

Consider the cubic curve:

The basis functions
Bi,3(u)are given by:

39
Bézier Curves

De Casteljau representation:

where r= 1,…,k; i= 0,…,k–r; pi0(u)=pi
A point on the curve with parameter value u is given
by
,i.e.,
40
Bézier Curves

Using the de Casteljau algorithm, a Bézier curve can be
subdivided anywhere along its length into 2 smaller curves

Note that the convex hull of the smaller section lies closer to
the curve than the original convex hull, and therefore repeated
subdivision will produce a closer approximation to the curve
41
Bézier Curves




Subdivision formulae about midpoint (i.e.,u=0.5):
Let original control points be pi
Let the control points of the small sections be qi& ri
The 2 small curve segments join at
42
Properties of Bézier Curves



Convex hull: Curve is contained in the hull [P1, P2, P3, P4]
Affine Invariance:
 Transforming the control points is computationally more
efficient than transforming each point on the curve
 Useful in ensuring smoothness while scaling a curve segment
Symmetry: P(t); [P1, P2, P3, P4] ≡ P(1-t); [P4, P3, P2, P1]
43
Catmull-Rom Splines



With built-in C1 continuity.
Compared to Hermite/Bezier: fewer control points
required, but less freedom.
Given n control points in 3-D: p1, p2, …, pn,


44
Tangent at pi given by s(pi+1 –pi-1) for i=2..n-1, for some s
Curve between pi and pi+1 is determined by pi-1, pi, pi+1, pi+2
Hungry for more?



You got your Hermite and Bézier splines, CatmullRom splines
Once you know it's a piecewise cubic, you know what
game you're playing — putting conditions on the
segments and how they fit together
You should know the basic properties of Hermite and
Bézier splines
45
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 sideeffects.
46
Outline




Computer-aided animation
Keyframing and interpolation of position
Hierarchical modeling
Interpolation of rotation
47
Articulated Models

Articulated models:



rigid parts
connected by joints
They can be animated by specifying the joint angles as
functions of time.
48
Forward Kinematics

Describes the positions of the body parts as a function of
the joint angles
1 DOF: knee
49
2 DOF: wrist
3 DOF: arm
Skeleton Hierarchy


Each bone transformation described relative to the
parent in the hierarchy:
Tree traversal
50
Forward Kinematics

51
Transformation matrix for an effecter vs is a
matrix composition of all joint transformation
between the effecter and the root of the
hierarchy
Inverse Kinematics




Forward Kinematics
 Given the skeleton parameters p and the
position of the effecter in local coordinates
vs, what is the position of the sensor in the
world coordinates vw?
Inverse Kinematics
 Given the position of the effecter in local
coordinates vs and the desired position vw in
world coordinates, what are the skeleton
parameters p?
Much harder; requires solving the inverse
Underdetermined problem with many
solutions
52
Outline




Computer-aided animation
Keyframing and interpolation of position
Hierarchical modeling
Interpolation of rotation
53
3D rotations



How many degrees of freedom for 3D orientations?
3 degrees of freedom:
e.g. direction of rotation and angle
54
3D Rotation Representations

Rotation Matrix



Fixed Angle



orthornormal columns/rows
bad for interpolation
rotate about global axes
bad for interpolation, gimbal lock
Euler Angle


55
rotate about local axes
bad for interpolation, gimbal lock
Fixed Angle

(0,90,0) in x-y-z order
(0,90,0)

(90,45,90) in x-y-z order
(90,45,90)
56
Interpolation Problem



The rotation from (0,90,0) to (90,45,90) is a 45-degree xaxis rotation
Directly interpolating between (0,90,0) and (90,45,90)
produces a halfway orientation (45, 67.5, 45)
Desired halfway orientation is (90, 22.5, 90)
57
Euler Angles


An Euler angle is a rotation about a single axis. Any
orientation can be described composing three
rotation around each coordinate axis.
Roll, pitch and yaw
58
Euler Angles

Gimbal lock: two or more axis align resulting in a
loss of rotation dof.
59
http://www.fho-emden.de/~hoffmann/gimbal09082002.pdf
Demo

See
http://www.gamedev.net/reference/programming/featu
res/qpowers/page7.asp

See also
http://www.cgl.uwaterloo.ca/GALLERY/image_html/gi
mbal.jpg.html
60
3D Rotation Representations

Axis angle



61
rotate about A by , (Ax,Ay,Az, )
good interpolation, no gimbal lock
cannot compose rotations efficiently
Solution: Quaternion Interpolation

4-tuple of real numbers




q=(s,x,y,z) or [s,v]
s is a scalar; v is a vector
Same information as axis/angle but in a different form
Right-hand rotation of Θ radians about v is:
q = {cos(Θ/2); v sin(Θ /2)}

62
Often noted (s, v) or {a; b, c, d}
Quaternions


q = {cos( /2); v sin( /2)}
What if we use -v?


q{1; 0; 0; 0}= q
Is there exactly one quaternion per rotation?



around –v
The quaternion of the identity rotation: qi = {1; 0; 0; 0}


Rotation of –
No.
q={cos( /2); v sin( /2)} is the same rotation as
-q={cos(( +2 )/2); v sin(( +2 )/2)}
The inverse q-1 of quaternion q {a, b, c, d}: {a, -b, -c, -d}

63
qq-1 = {1; 0; 0; 0}
Quaternion Algebra

Multiplication:

http://www.genesis3d.com/~kdtop/QuaternionsUsingToRepresentRotation.htm

Quaternions are associative:

But not commutative:
64
Rotation Example

To rotate 3D point/vector p by a rotation q, compute:
65
Compose Rotations
66
Quaternion Interpolation



A quaternion is a point on a 4D unit sphere
Unit quaternion: q=(s,x,y,z), ||q|| = 1
Interpolating rotations means moving on 4D sphere
67
Quaternion Interpolation

Linear interpolation generates unequal spacing of
points after projecting to circle
68
Quaternion Interpolation

Spherical linear interpolation (slerp)


69
interpolats along the arc lines instead of the secant lines.
produce equal increment along arc connecting two quaternions
on the spherical surface
Useful Analogies



Euclidean Space
Position
Linear interpolation
70
• 4D Spherical Space
• Orientation
• Spherical linear
interpolation
(slerp)
Download