Paper Summaries

• Any takers? Interpolation

Projects Factoids

• Proposals due next week. • Digital Video Frame Rate – was shot at 24 fps. – Keep film look

Plan for today Motivation Films

• Keyframing and Interpolation • Two early attempts of significant use of CG elements in film

• But first…

1 Motivational Film Motivational Film

• Question from SIGGRAPH Bowl – Disney (1982) – Q: Which special effects company was – Clips shown at SIGGRAPH 82 responsible for the effects of TRON? – A: ALL OF THEM • MAGI •Triple I • Robert Abel & Associates • Digital Effects

Motivational Film Motivational Film

• Interesting TRON Factoid • The Last Starfighter (1985) – No polygons! – Effects by Digital Productions – All objects were defined using mathematical – formula. • Lesson Learned from TRON – Great effects – Bad movie – Overestimated the “Geek Factor”

Motivational Film Motivational Film

• Last Starfighter factoids • Life imitating art imitating life… – First movie to do all special effects (except makeup) on – Sort of… a computer. – A prototype for A Last Starfighter video game – All shots of spacecraft, space, etc. were generated on a Cray computer. was produced by Atari (remember them?) but was never distributed. • Lesson Learned from Last Starfighter – Great effects – Note that there WAS a TRON video game – Bad movie (made by Bally/Midway – 1983) – Overestimated the “Geek Factor”

2 Let’s get started 6. Straight ahead action and Pose-to-pose action

• Key framing and interpolation • The two main approaches to hand drawn animation. – Straight ahead action • “the animator works straight ahead from his first drawing in the scene.” – Pose-to-pose (keyframing) • the animator plans his actions, figures out just what drawings will be needed to animate the business, makes the drawings concentrating on the poses, ... and then draws the inbetweens.” •Link

Key framing Key Framing

• The simplest form of animating an object. P • Object has: P 4 2 P – A beginning state 5 Time = 50 – An end state Time = 10 P Time = 55 – A number of intermediate “key” states 1 P P6 • It is up to the keyframe system to determine 3 Time = 0 the states for inbetween frames Time = 60 Time = 35

Key Framing Interpolation

• 60 sec animation • According to webster.com – Video: 30 frames / sec = 1800 frames – in·ter·po·late (n) - to estimate values of (a – We have 6 key frames function) between two known values

– Need to create position of objects for the remaining 1794 frames. – Note: “state” can be defined as a function (in this case of time) •F(t)

3 Interpolation Interpolation

• Things to consider: • Things to consider: – Interpolation or approximation? – Continuity – defines “smoothness” of curve. • Interpolation – Control points fall on the curve – Determined by how many derivatives are • Approximation – Control points fall outside the continuous curve. •0th order – are the curves attached at the points themselves (positional continuity) •1st order – is the first derivative continuous (tangential continuity) •2nd order – is the 2nd derivative continuous (curvature continuity)

Interpolation – Continuity Interpolation

• Things to consider: – Local vs. Global control • Does changing one point change the entire function? No positional Order 0 Order 1 2nd order continuity continuity Continuity continuity – Questions?

For animation purposes, Tangential (1st Order) continuity is usually sufficient

Linear Interpolation Linear Interpolation

• The simplest solution •Pros – Straight-forward P(u) = (1− u)⋅ P0 + u ⋅ P1 – Easy to implement P(t) P(1) = P 1 Also can be – Direct relationship between time and value expressed as • Cons P(u) = (P1 − P0 )⋅u + P0 – Lacks tangential continuity P(0) = P0 – Why is this important?

4 Remember our principles of animation? Cubic Interpolation

• 8. Arcs • x, y, z given as function of t – “The visual path of action from one extreme to • Approximated by cubic polynomials another is always described by an arc.” 3 2 x(t) = axt + bxt + cxt + d x 3 2 y(t) = ayt + byt + cyt + d y 3 2 z(t) = azt + bzt + czt + d z This is not an arc!

Cubic Interpolation Cubic Interpolation • Separate C matrix into basis + geometry ⎡ax ay az ⎤ ⎢ b ⎥ Q(t) = []x(t) y(t) z(t) bx y bz G C = ⎢ ⎥ ⎡m11 m12 m13 m14 ⎤⎡G1x 1y G1z ⎤ ⎢ ⎥⎢ ⎥ ⎢cx cy cz ⎥ m m m m G G 21 22 23 24 ⎢ 2x 2 y G2z ⎥ 3 2 ⎢ ⎥ C = ⎢ ⎥ T = t t t 1 ⎢ ⎥ [ ] ⎢d d y d ⎥ ⎢m31 m32 m33 m34 ⎥ G3x G3y G3z ⎣ x z ⎦ ⎢ ⎥⎢ ⎥ G ⎣m41 m42 m43 m44 ⎦⎣⎢G4x 4 y G4z ⎦⎥ 142444 43444 1424 434 Q=T⋅C basis matrix control points

Cubic Interpolation Cubic Interpolation

• Hermite Curves Q(t) = T ⋅ M ⋅ G – specified by endpoints and tangent vectors from { { each endpoint basis control

• Basis & Control points distinguishes types of curves

5 Cubic Interpolation Cubic Interpolation

• Hermite Curves • Problem with Hermite Curves – Animator generally will not enjoy specifying ⎡ 2 − 2 1 1 ⎤ ⎡ P1 ⎤ ⎢ ⎥ tangent vectors − 3 3 − 2 −1 ⎢P ⎥ M = ⎢ ⎥ G = ⎢ 4 ⎥ H ⎢ 0 0 1 0 ⎥ H ⎢R ⎥ ⎢ ⎥ 1 1 0 0 0 ⎢ ⎥ – Solution: The Catmull-Rom spline ⎣ ⎦ ⎣R4 ⎦

Cubic Interpolation Cubic Interpolation

• Catmull-Rom spline • Catmull-Rom – Uses previous and next control point to determine

tangent vector ⎡−1 3 − 3 1 ⎤ ⎡Pi−1 ⎤ ⎢ ⎥ 1 2 − 5 4 −1 ⎢ P ⎥ M = ⎢ ⎥ G = ⎢ i ⎥ CR 2 ⎢−1 0 1 0 ⎥ CR ⎢P ⎥ ⎢ ⎥ i+1 0 2 0 0 ⎢ ⎥ ⎣ ⎦ ⎣Pi+2 ⎦

Note: for interpolation between Pi and Pi+1 you need 4 points – Spline goes through all control points!

Cubic Interpolation Cubic Interpolation

• Bezier Curves • Bezier Curves – specified by endpoints and intermediate points, −1 3 − 3 1 not on the curve, that approximate the tangent ⎡ ⎤ ⎡P0 ⎤ ⎢ ⎥ vectors 3 − 6 − 3 0 ⎢P ⎥ M = ⎢ ⎥ G = ⎢ 1 ⎥ B ⎢− 3 3 0 0⎥ H ⎢P ⎥ ⎢ ⎥ 2 1 0 0 0 ⎢ ⎥ ⎣ ⎦ ⎣P3 ⎦

6 Cubic Interpolation Cubic Interpolation

• Bezier Curves suffer from same problem as • B-Splines Hermite Curves – Control points are outside of the curve – Animator generally will not enjoy specifying tangent vectors…even from control points – Local control • Exception: Provide animator with an interactive curve editor • Moving one control point only affects a portion of – DeCastelau Construction the entire curve. • Algorithm to automatically define Bezier control points – Individual curve segments share control points. • Described in Parent Appendix and Shomake Quat. paper – Knots - points connecting individual curve segments.

Cubic Interpolation Cubic Interpolation

• B-Splines • B-Splines - local control

Cubic Interpolation Cubic Interpolation

• Segment Qi uses control points Pi-3, Pi-2, Pi-1 and Pi • B-Splines

⎡−1 3 − 3 1⎤ ⎡Pi−3 ⎤ ⎢ ⎥ 1 3 − 6 − 3 0 ⎢P ⎥ M = ⎢ ⎥ G = ⎢ i−2 ⎥ B 6 ⎢− 3 0 3 0⎥ H ⎢P ⎥ ⎢ ⎥ i−1 1 4 1 0 ⎢ ⎥ ⎣ ⎦ ⎣ Pi ⎦

7 Cubic Interpolation Cubic Interpolation

• Uniform Nonrational B-Splines • Rational Splines – expressed using homogeneous coordinates – uniform - knots are equally spaced – nonrational - does not use homogeneous Q(t) = [X (t) Y (t) Z(t) W (t)] coordinates (more on this later) – B - basis -- curves are weighted sums of a basis X (t) Y (t) Z(t) function x(t) = , y(t) = , z(t) = W (t) W (t) W (t)

Cubic Interpolation Cubic Interpolation

• Rational splines -- why bother? • NURBS – Invariant under rotation, scaling, translation, – Non-uniform Rational B-Splines and perspective transforms – Non-uniform - knots need not be equally – Can define precisely any of the conic sections. spaced. (spheres, ellipsoids, parabolids, etc) – Most useful and used method for representing surface curves in CG. – Probably overkill for cubic interpolation

Cubic Interpolation Cubic Splines

•Pros – We now have our tangential continuity u=0.0 – More complex than linear but not too complex

• Cons u=2/3 – Spline control does not correspond to time. u=1/3 u=1.0 – May require an interactive “curve editor” tool.

u does not correspond to t.

8 Cubic Splines Cubic Splines

• Our problem • Solution – Spline control does not correspond to time. – Determine: – What we have • u(t) – spline control w.r.t time • P(u) – position w.r.t. spline control – Then – What we need • P(t) = P (u(t)) • P(t) – position w.r.t. time (note we have this for control points)

Cubic Splines Cubic Splines

• Solution

– Determine: P4 • U(t) – spline control w.r.t time P2 P5 –Then Time = 50 • P(t) = P (U(t)) Time = 10 u=1.0 Time = 55 – Can use interpolation on u(t) using t at control points P1 •Linear P P3 6 • Cubic Time = 0 at t = 42 – Questions? Time = 35 u = 0.46 Time = 60 u = 0.0

Let’s Take this a Step Further Let’s Take this a Step Further

• 7. Slow In and Slow Out • Suppose animator knows path but wants – Refers to the spacing of the inbetween frames at more control over speed? maximum positions. – What we have – Example: • P(u) – position w.r.t. spline control • a bouncing ball moves faster as it approaches or – Note that this is NOT leaves the ground and slower as it approaches leaves • S(u) – length traveled w.r.t. spline control. its maximum position – And we need to give animator control of • S(t) – length traveled at a given time.

9 Let’s Take this a Step Further Arc Length

• Suppose animator knows path but wants more • Arc Length = distance traveled along a curve. control over speed? – Mathematically defined as: – What we have • P(u) – position w.r.t. spline control – What we need u • U(S) – length w.r.t. spline control 2 dP – And let animator define s(u ,u ) = du • S(t) – length w.r.t. time (velocity/speed) 1 2 ∫ du –Then u1 • P(t) = P (U (S (t)))

Arc Length Arc Length

• So, arc length is an integral • Forward Differencing – Sample the curve at equally spaced u values. – Ways to solve – Estimate arc length by calculating linear distance • Analytic – integral not always solvable between sampled points. • Numerical Integration – more when we talk about – For example, physics. • Given P(u) calculate at u=0.00, 0.05, 0.10, 0.15, … • Forward Differencing • Define arc length s(u) – s (0.0) = 0.0 – s (0.05) = distance between P(0.05) and P(0.0) – s (0.1) = s (0.05) + distance between P(0.10) and P(0.05) –Etc.

Arc Length Arc Length Idx u s(u) Find u corresponding to s = 0.25 • Forward Differencing 0 0.00 0.000 – This will give us a mapping from P(u) to s(u) 1 0.05 0.080 Find closest idx to s = 0.25 for sampled u values. 2 0.10 0.150 – Perform interpolation (linear or cubic) between Find relative distance to s sampled values 3 0.15 0.230 for next idx 0.25 − 0.23 4 0.20 0.320 = 0.222 0.32 − 0.23 5 0.25 0.400 Linearly interpolate u 6 0.30 0.500 u(0.25) = 0.15 + 0.22(0.20 − 0.15) 7 0.35 0.600 8 0.40 0.720

10 Animator control of speed Ease-in/ease out summary

• Animator can define s(t) • Animator defines speed – Length traveled w.r.t time – Arc length given time – Speed

Basic ease-in/ease out

Ease-in/ease out summary Ease-in/ease out summary

• Spline control determined by forward • Position determined by spline differencing – P = P (0.161) Find u corresponding to s = 0.25 Find closest idx to s = 0.25

Find relative distance to s for next idx 0.25 − 0.23 = 0.222 0.32 − 0.23 – Questions? Linearly interpolate u u(0.25) = 0.15 + 0.22(0.20 − 0.15) = 0.161

Interpolating Quaternions Interpolating Quaternions

• Normalized Quaternions are defined on the unit • Spherical Linear Interpolation 4D sphere sin((1− u)θ ) sin(uθ ) • Linear interpolation generates unequal spacing slerp (q1,q2,u) = q1 + q2 when projected onto circle sinθ sinθ

–where

cosθ = q1 • q2 = s1s2 + (v1 • v2 )

11 Let’s go to assignment 1

12