Transcript Animation.
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 Layer, keyframe, inbetween cel panoramas (Disney’s Pinocchio) ...
4 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 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+ Θ ))*e -kt 6
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 7
Computer-Assisted Animation
Motion Capture Captures style, subtle nuances and realism You must observe someone 8
Motion Capture
9
Motion Replay
10 http://www.youtube.com/watch?v=IJ4tndpwL-o
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 such that 13
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 t t x(t) 18
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
20 www.abm.org
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: Easy to compute Indefinitely differentiable 22
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 Advantages: Provides flexibility Problem: How do we fit the pieces together?
24
Parametric Continuity
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) 25
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 (P 1 , P 2 ).
Tangents (derivatives) at the knot points (P’ 1 , P’ 2 ): “Control knob” vector: [P 1 , P 2 , P’ 1 , P’ 2 ] 31
Hermite Spline
4 segments , (P 1 , P 2 ) 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 (P 1 , P 4 ).
36
Bézier Specification
Four control points (P 1 , P 2 , P 3 , P 4 ).
Gradients (tangents) at the knot points (P’ 1 , P’ 4 ) are the line segments between adjacent control points: Tangents: P’ 1 = 3 ( P 2 - P 1 ); P’ 2 = 3 ( P 4 - P 3 ) Scale factor (3) is chosen to make “velocity” approximately constant Endpoint interpolation: P 2 & P 3 P(0) = P 1 and P(1) = P 4 control the magnitude and orientation of the tangent vectors at the end points Geometry vector G: [P 1 , P 2 , P 3 , P 4 ] 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; p i 0 (u)=p i 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 q i & r i The 2 small curve segments join at 42
Properties of Bézier Curves
Convex hull: Curve is contained in the hull [P 1 , P 2 , P 3 , P 4 ] 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); [P 1 , P 2 , P 3 , P 4 ] ≡ P(1-t); [P 4 , P 3 , P 2 , P 1 ] 43
Catmull-Rom Splines
With built-in C
1 continuity.
Compared to Hermite/Bezier: fewer control points required, but less freedom.
Given n control points in 3-D:
p
1
, p
2
, …, p
n
,
Tangent at p i given by
s(p
i+1 Curve between p i and p i+1
–p
i-1
) for i=2..n-1,
for some
s
is determined by p i-1 , p i , p i+1 , p i+2 44
Hungry for more?
You got your Hermite and Bézier splines, Catmull Rom 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 side effects.
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 2 DOF: wrist 3 DOF: arm
49
Skeleton Hierarchy
Each bone transformation described relative to the parent in the hierarchy: Tree traversal 50
Forward Kinematics
Transformation matrix for an effecter hierarchy v s matrix composition of all joint transformation between the effecter and the root of the is a 51
Inverse Kinematics
Forward Kinematics Given the skeleton parameters p and the position of the effecter in local coordinates v s , what is the position of the sensor in the world coordinates v w ?
Inverse Kinematics Given the position of the effecter in local coordinates v s and the desired position v w world coordinates, what are the skeleton parameters p?
in 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 orthornormal columns/rows bad for interpolation Fixed Angle rotate about global axes bad for interpolation, gimbal lock Euler Angle rotate about local axes bad for interpolation, gimbal lock 55
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 axis rotation (90,45,90) is a 45-degree x Directly interpolating between (0,90,0) and produces a halfway orientation (45, 67.5, 45) (90,45,90) 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 rotate about
A by ,
(Ax,Ay,Az, )
good interpolation, no gimbal lock cannot compose rotations efficiently 61
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 q = {cos( Θ /2); v sin( Θ /2)} Often noted (s, v) or {a; b, c, d}
v
is: 62
Quaternions
q = {cos( /2); v sin( /2)} What if we use -v ?
Rotation of – around –v The quaternion of the identity rotation:
q
i q{1; 0; 0; 0}= q = {1; 0; 0; 0} Is there exactly one quaternion per rotation?
No.
q={cos( /2); v sin( /2)} is the same rotation as -q={cos(( +2 )/2); v sin(( +2 )/2)} The inverse
-1
q
= {1; 0; 0; 0} -1 of quaternion q {a, b, c, d}: {a, -b, -c, -d} 63
Quaternion Algebra
Multiplication: http://www.genesis3d.com/~kdtop/Quaternions UsingToRepresentRotation.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) interpolats along the arc lines instead of the secant lines.
produce equal increment along arc connecting two quaternions on the spherical surface 69
Useful Analogies
Euclidean Space Position Linear interpolation • • • 4D Spherical Space Orientation Spherical linear interpolation (slerp) 70