Oldest keyframe animation Two conditions to make a moving image in 19th century 1. Higher than 10 frames per second Keyframe animation 2. A period of blackness between images Phenakistiscope 2D animation Highly skilled animators draw the keyframes Less skilled (lower paid) animators draw the inbetween frames Difficult to create physically realistic animation Time consuming process Zoetrope Praxinoscope 3D animation Animators specify important keyframes in 3D Computers generates the in-between frames Some dynamic motion can be done by computers (hair, clothes, etc) Still time consuming; Pixar spent four years to produce Toy Story From the making of toy story General pipeline Story board Keyframes Inbetweens Painting Storyboards Story boarding from “a bug’s life” The film in outline form specify the key scenes specify the camera moves and edits specify character gross motion Typically paper and pencil sketches on individual sheets taped on a wall http://www.pixar.com/featurefilms/ab!behind_pop4.html The process of keyframing A keyframe Specify the keyframes Specify the type of interpolation linear, cubic, parametric curves Specify the speed profile of the interpolation constant velocity, ease-in-ease-out, etc In 2D animation, a keyframe is usually a single image In 3D animation, each keyframe is defined by a set of parameters Computer generates the in-between frames Keyframe parameterization in-between frames What are the parameters? Position and orientation in 3D Joint angles of the hierarchy Body deformation Facial features Hair Clothing Scene elements such as lights and cameras Linear interpolation Cubic curve interpolation Linear interpolation Cubic curve interpolation Linearly interpolate the parameters between keyframes We can use three cubic functions to represent a 3D curve Each function is defined with the range 0 ≤ t ≤ 1 t=5 Q(t) = [x(t) y(t) z(t)] t = 10 or 3 t=0 Qx (t) = ax t + bx t2 + cx t + dx t = 15 end key start key Qy (t) = ay t3 + by t2 + cy t + dy t − t0 (x1 − x0 ) x = x0 + t1 − t0 end time Qz (t) = az t3 + bz t2 + cz t + dz start time Compact representation ax bx C= cx dx ay by cy dy az bz cz dz T= Q(t) = ! t3 t2 ax " bx t 1 cx dx ! ay by cy dy t3 t2 t 1 az bz = TC cz dz " 2t 1 0 matrices A · B : multiplication AB : multiplication How many constraints do we need to determine a cubic curve? 4 Redefine C as a product of the basis matrix M and the geometry vector G C=M·G Q(t) = " vectors a · b : inner product a × b : outer product ab : multiplication Constraints on the cubics ! d Q̇ = Q(t) = 3t2 dt bold: a vector or a matrix italic: a scalar ! t3 t2 C =T·M·G m11 " m21 t 1 m31 m41 m12 m22 m32 m42 m13 m23 m33 m43 G1x m14 m24 G2x m34 G3x G4x m44 G1y G2y G3y G4y G1z G2z G3z G4z Hermite curves Hermite basis matrix A Hermite curve is determined by Given desired constraints: P4 R4 P1 1. endpoints P1 and P4 R1 2. tangent vectors R1 and R4 at the endpoints Use these elements to construct the geometry vector P1x P4x Gh = R1x R4x P1y P4y R1y R4y P1 0 0 P4 1 1 R1 = Gh = 0 0 R4 3 2 0 1 1 1 ! Q(1) = ! 0 1 0 0 1 " · Mh · Gh = P1 1 1 1 " · Mh · Gh = P4 2. tangent vectors meet R1 and R4 ! Q (1) = ! ! 0 0 3 2 1 0 " · Mh · Gh = R1 1 0 " · Mh · Gh = R4 Hermite Blending functions We can solve for basis matrix Mh Q(0) = Q! (0) = P1z P4z R1z R4z Hermite basis matrix 1. endpoints meet P1 and P4 Let’s define B as a product of T and M 1 1 · Mh · Gh 0 0 Bh (t) = ! t3 t2 2 −2 1 1 " −3 3 −2 −1 t 1 0 0 1 0 1 0 0 0 Bh(t) indicates the weight of each element in Gh 0 1 Mh = 0 3 0 1 0 2 0 1 1 1 −1 1 1 0 0 2 −3 = 0 1 −2 3 0 0 1 1 −2 −1 1 0 0 0 Bh (t) P1 P4 Q(t) = Bh (t) · R1 R4 P1 P4 R1 t R4 Bézier curves Bézier basis matrix Indirectly specify tangent vectors by specifying two intermediate points R1 Establish the relation between Hermite and Bezier geometry vectors P3 R1 = 3(P2 − P1 ) P4 P2 R4 = 3(P4 − P3 ) P1 R4 P1 P2 Gb = P3 P4 Bézier basis matrix Q(t) = T · Mh · Gh = T · Mh · (Mhb · Gb ) P1 1 P4 0 Gh = R1 = −3 R4 0 0 0 0 0 3 0 0 −3 Mb = Mh Mhb 3 −3 −6 3 3 0 0 0 1 0 0 0 http://www.cs.unc.edu/~mantler/research/bezier/index.html = Mhb · Gb Bezier blending functions are also called Bernstein polynomials Bb (t) = −1 3 = −3 1 Bézier blending functions = T · (Mh · Mhb ) · Gb = T · Mb · Gb 0 P1 P2 1 0 P3 3 P4 ! t3 t2 t −1 3 −3 1 " 3 −6 3 0 1 −3 3 0 0 1 0 0 0 Bb (t) P1 P2 Q(t) = Bb (t) · P3 P4 P1 P4 P2 P3 t Complex curves What if we want to model a curve that passes through these points? Splines A piecewise polynomial function that has locally very simple form, yet be globally flexible and smooth There are three nice properties of splines we’d like to have Problem with higher order polynomials: Continuity Wiggly curves Local control No local control Interpolation Continuity Continuity C0: points coincide, velocities don’t Cubic curves are continuous and differentiable C1: points and velocities coincide We only need to worry about the derivatives at the endpoints when two curves meet What’s C2? points, velocities and accelerations coincide Local control Bezier and Hermite curves don’t have local control; moving a single control point affects the whole curve We’d like to have each control point on the spline only affect some well-defined neighborhood around that point Interpolation Bezier curves do not necessarily pass through all the control points We’d like to have a spline interpolating the control points so that the spline always passes through every control points B-splines Continuity in B-splines Suppose we want to join two Bezier curves (V0, V1, V2, V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint V1 We can join multiple Bezier curves to create Bsplines Ensure C2 continuity when two curves meet V0 V3 Qv (1) = Qw (0) Q!v (1) = Q!w (0) Q!!v (1) = Q!!w (0) W1 V2 W0 W2 W3 V3 = W0 V3 − V2 = W1 − W0 V1 − 2V2 + V3 = W0 − 2W1 + W2 W2 = V1 + 4V3 − 4V2 Continuity in B-splines What does this derived equation mean geometrically? W2 = V1 + 4V3 − 4V2 de Boor points Instead of specifying the Bezier control points, let’s specify the corners of the frames that forms a B-spline What is the relationship between a, b and c, if a = 2b - c? V1 V 2 V0 B1 W0 = V3 W1 = 2V3 − V2 V3 = W0 W2 = V1 + 4V3 − 4V2 = 2(2V3 − V2 ) − (2V2 − V1 ) W1 W3 W2 = 2W1 − B1 What is B2? de boor points What is the relationship between Bezier control points and de Boor points? These points are called de Boor points and the frames are called A-frames B-spline basis matrix Q(t) = " ! 1 1 2 V0 = B0 + (B1 − B0 ) + B1 + (B2 − B1 ) 2 3 3 1 V1 = B1 + (B2 − B1 ) 3 2 V2 = B1 + (B2 − B1 ) 3 " ! 1 1 2 V3 = B1 + (B2 − B1 ) + B2 + (B3 − B2 ) 2 3 3 Verify this by yourself ! t3 Mbs t2 t −1 3 1 3 −6 = 6 −3 0 1 4 B1 B2 " 1 Mbs B3 B4 −3 3 3 1 1 0 0 0 http://www.engin.umd.umich.edu/CIS/course.des/cis577/projects/BSP/welcome.html B-Spline properties B-Spline properties C2 continuity? C2 continuity? Local control? Local control? Interpolation? Interpolation? Catmull-Rom splines Catmull-Rom splines D0 = C1 − C0 If we are willing to sacrifice C2 continuity, we can get interpolation and local control If we set each derivative to be a constant multiple of the vector between the previous and the next controls, we get a Catmull-Rom spline C3 1 D1 = (C2 − C0 ) 2 D2 = 1 (C3 − C1 ) 2 .. . Dn = Cn − Cn−1 C1 C0 D1 D0 D2 C2 Catmull-Rom Basis matrix Q(t) = ! t3 t2 −1 "1 2 t 1 2 −1 0 3 −3 −5 4 0 1 2 0 1 P1 P2 −1 0 P3 0 P4 CATmull-Rom properties C2 continuity? Local control? Interpolation? Derive Catmull-Rom basis matrix by yourself CATmull-Rom properties C2 interpolating splines How can we keep the C2 continuity of B-splines but get interpolation property as well? C2 continuity? Local control? Suppose we have a set of Bezier control points, our goal is to find a C2 spline that that passes through all the points Interpolation? C1 C2 C0 C3 C2 interpolating splines Let’s assume we know the first derivative of the spline at these control points C1 D1 C0 C2 D2 C3 D0 D3 Derivatives of splines V0 = C0 W0 = C1 1 V1 = C0 + D0 3 1 V2 = C1 − D1 3 1 W1 = C1 + D1 3 1 W2 = C2 − D2 3 V3 = C1 W3 = C2 To solve for D’s we apply C2 continuity requirement If we want to create a Bezier curve between each pair of these points, what are the V’s and W’s control points in terms of C’s and D’s? 6(V1 − 2V2 + V3 ) = 6(W0 − 2W1 + W2 ) D0 + 4D1 + D2 = 3(C2 − C0 ) Derivatives of splines Boundary conditions D0 + 4D1 + D2 = 3(C2 − C0 ) We can impose more conditions on the spline to solve the two extra degrees of freedom D1 + 4D2 + D3 = 3(C3 − C1 ) .. . Dm−2 + 4Dm−1 + Dm = 3(Cm − Cm−2 ) How many equations do we have? How many variables are we trying to solve? Natural C2 interpolating splines require second derivative to be zero at the endpoints 6(V0 − 2V1 + V2 ) = 0 Linear system Choice of splines Collect m+1 equations into a linear system 2 1 1 4 1 1 4 1 .. . 1 4 1 D0 D1 D2 .. . 1 Dm−1 2 Dm Spline types 3(C1 − C0 ) 3(C2 − C0 ) 3(C3 − C1 ) = .. . 3(Cm − Cm−2 ) 3(Cm − Cm−1 ) Continuity Interpolation Local control Use forward elimination to zero out every thing below the diagonal, then back substitute to compute D’s Displaying Bezier curves B-Splines C2 No Yes Catmull-Rom Splines C1 Yes Yes C2 interpolating splines C2 Yes No Subdivide and Conquer V1 V0!! DisplayBezier(V0, V1, V2, V3) V0! begin V1 if (FlatEnough(V0, V1, V2, V3)) Line(V0, V3) V1! V2 V1!! V2 V2! V0 V0 else do something It would be nice if we had an adaptive algorithm that would take into account flatness V3 DisplayBezier(V0, V1, V2, V3) begin if (FlatEnough(V0, V1, V2, V3)) ! Line(V0, V3) else ! Subdivide(V) -> L, R ! DisplayBezier(L0, L1, L2, L3) ! DisplayBezier(R0, R1, R2, R3) V3 Flatness Test Endpoints of B-splines V1 V2 We can see that B-splines don’t interpolate the de Boor points V0 V3 Compare total length of control polygon to length of line connecting endpoints: It would be nice if we could at least control the endpoints of the splines explicitly There’s a trick to make the spline begin and end at the de Boor points by repeating them |V0 − V1 | + |V1 − V2 | + |V2 − V3 | <1+! |V0 − V3 | Curves in the animation Each animation parameter is determined by a 2D curve Q(u) = (x(u), y(u)) Treat this curve as θ(u) = y(u) t(u) = x(u) where θ is a variable you want to animate. We can think of the results as a function: θ(t) Apply constraints to make sure that θ(t) actually is a function Wrapping the curves Wrapping is an important feature that makes the animation restart smoothly when looping back to the beginning Create “phantom” control points before and after the first and the last control points t C−1 Cn C1 C0 C2 Cn+1 Speed control Arclength-Time function Simplest form is to have constant velocity along the path In the linear interpolation case, we can use time (t) as the parameter, increment it a constant amount, and evaluate the new position s But there is a problem in the cubic polynomial case t Non-Uniformity in the parameter Arclength reparameterization The problem is that uniform steps in the parameter (u) don’t correspond to uniform path distances We have a function Lengh(u) which evaluates the arclength for a given u, but we also want a way to find u given a particular arclength S Not possible analytically for most curves (e.g. Bsplines) We need a relationship between the parameters (u) and the distance traveled Finite Differences Finite differences Sample the curve at small intervals of the parameter and determine the distance between samples Use theses distances to build a table of arclength for this particular curve index parametric value arclength 0 1 2 3 4 0.00 0.05 0.10 0.15 0.20 0.000 0.080 0.150 0.230 0.320 Speed control recipe Given a time t, lookup the corresponding arclength S in the speed curve For S, look up the corresponding value of u in the reparameterization table Evaluate the curve at u to obtain the correct interpolated position for the animated object for the given time t If we want to know S at a particular value of the parameter u = 0.73, spacing of the table is 0.05 Find the entry in the table closest to this u Or take the u before and after it and interpolate linearly Similarly, we can find u for a given S Ease-in Ease-out curve Assume that the motion slows down at the beginning and end of the motion curve s t Do you know this? Open questions What should the key values be? When should the key values occur? Why does a movie run at 24 frames per second while a TV runs at 30 frames per second? Are there better ways to specify key values? What kind of bad things can occur from interpolation? How do we prevent them? Invalid configurations (pass through walls) Unnatural motions (painful twists) What’s next? What about rotations? Can we interpolate rotations using the these same techniques?
© Copyright 2026 Paperzz