computer animation algorithms and techniques

82
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Interpolating Values

Upload: iona-herrera

Post on 30-Dec-2015

54 views

Category:

Documents


5 download

DESCRIPTION

Computer Animation Algorithms and Techniques. Interpolating Values. Animation. Animator specified interpolation key frame Algorithmically controlled Physics-based Behavioral Data-driven motion capture. Motivation. Common problem: given a set of points - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Computer AnimationAlgorithms and Techniques

Interpolating Values

Page 2: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Animation

Animator specifiedinterpolationkey frame

Algorithmically controlledPhysics-basedBehavioral

Data-drivenmotion capture

Page 3: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Motivation

Common problem: given a set of pointsSmoothly (in time and space) move an object through the set of points

Example additional temporal constraints: From zero velocity at first point, smoothly accelerate until time t1, hold a constant velocity until time t2, then smoothly decelerate to a stop at the last point at time t3

Page 4: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Motivation – solution steps1. Construct a space curve that interpolates the given points with piecewise first order continuity

2. Construct an arc-length-parametric-value function for the curve

3. Construct time-arc-length function according to given constraints

p=P(u)

u=U(s)

s=S(t)

p=P(U(S(t)))

Page 5: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Interpolating function

Interpolation v. approximation

Complexity: cubic

Continuity: first degree (tangential)

Local v. global control: local

Information requirements: tangents needed?

Page 6: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Interpolation v. Approximation

Page 7: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Complexity

Low complexity reduced computational cost

CUBIC polynomial

Point of InflectionCan match arbitrary tangents at

end points

Page 8: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Continuity

Page 9: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Local v. Global Control

Page 10: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Information requirements

just the points

tangents

interior control points

just beginning and ending tangents

Page 11: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Curve Formulations

Piecewise cubic polynomialsHermiteCatmull-RomBlended ParabolasBezierB-splineTension-Continuity-Bias4-Point Form

Lagrange Polynomial

Page 12: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Lagrange Polynomial

x

jk

k kj

kjj xx

xxyxP

1

)(

Page 13: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Lagrange Polynomial

x

jk

k kj

kjj xx

xxyxP

1

)(

Page 14: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Polynomial Curve Formulations

Need to match real-world data v. design from scratchInformation requirements: just points? tangents?Qualities of final curve?Intuitive enough?Other shape controls?

AUFBMBUP TT

123 uuuGeometric informationCoefficient

matrix

BlendingFunctions

Algebraic coefficient matrix

Page 15: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Hermite

'

'

0.00.00.00.1

0.00.10.00.0

0.10.20.30.3

0.10.10.20.2

1

1

123

i

i

i

i

p

p

p

p

uuuP

Page 16: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Cubic Bezier

3

2

123

0.00.00.00.1

0.00.00.30.3

0.00.30.60.3

0.10.30.30.1

1

i

i

i

i

p

p

p

p

uuuP

Interior control points play the same role as the tangents of the Hermite formulation

Page 17: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Blended Parabolas/Catmull-Rom*

2

1

1

23

0010

05.005.0

5.025.21

5.05.15.15.0

1

i

i

i

i

p

p

p

p

uuuP

* End conditions are handled differently

Page 18: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Controlling Motion along p=P(u)

Step 2. Reparameterization by arc length

Step 3. Speed control

u = U(s) where s is distance along the curve

s = ease(t) where t is time

for example, ease-in / ease-out

Page 19: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Reparameterizing by Arc Length

AnalyticForward differencing

SupersamplingAdaptive approach

NumericallyAdaptive Gaussian

Page 20: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Reparameterizing by Arc Length - analytic

2

1

/u

udududPs

duudzduudyduudxdudP /)(/)(/)(/

222 /)(/)(/)(/ duudxduudyduudxdudP

Can’t always be solved analytically for our curves

dcubuauuP 23)(

Page 21: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Reparameterizing by Arc Length - supersample

1.Calculate a bunch of points at small increments in u2.Compute summed linear distances as approximation to arc

length3.Build table of (parametric value, arc length) pairs

Notes1.Often useful to normalize total distance to 1.02.Often useful to normalize parametric value for

multi-segment curve to 1.0

Page 22: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

index u Arc Length

0 0.00 0.000

1 0.05 0.080

2 0.10 0.150

3 0.15 0.230

... ... ...

20 1.00 1.000

Build table of approx. lengths

Page 23: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Adaptive ApproachHow fine to sample?Compare successive

approximations and see if they agree within some tolerance

Test can fail – subdivide to predefined level, then start testing

Page 24: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Reparameterizing by Arc Length - quadrature

i

ii ufwduuf )()(1

1

Lookup tables of weights and parametric values

dcubuauuP 23)(

1

1

234 EDuCuBuAu

Can also take adaptive approach here

Page 25: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Reparameterizing by Arc Length

AnalyticForward differencing

SupersamplingAdaptive approach

NumericallyAdaptive Gaussian

Sufficient for many problems

Page 26: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Speed Control

Time-distance functionEase-in

Cubic polynomialSinusoidal segmentSegmented sinusoidalConstant acceleration

General distance-time functions

time

distance

Page 27: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Time Distance Function

s = S(t)

s

t

S

Page 28: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in/Ease-out Function

s = S(t)

s

t

S

0.0

0.01.0

1.0

Normalize distance and time to 1.0 to facilitate reuse

Page 29: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Sinusoidal

2/)12/sin()( tteases

Page 30: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Piecewise Sinusoidal

Page 31: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Piecewise Sinusoidal

)(tease

fk

tk /))

22(sin(

2(

11

fktk

/)12/

( 1

fk

ktkkk

k/))

)1(2

)(sin(

2)1(

2/(

2

2212

1

1kt

21 ktk

tk 2

Provides linear (constant velocity) middle segment

2

)1(2

2121 kkkkf where

Page 32: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Single Cubic

23 32)( ttteases

Page 33: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Page 34: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Page 35: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Page 36: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Page 37: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Constant Acceleration

1

2

0 2t

tvd

10.0 tt

)(2 101

0 ttvt

vd 21 ttt

))()1(2

)(1()(

2 22

20120

10 tt

t

ttvttv

tvd

0.12 tt

Page 38: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Motivation – solution steps1. Construct a space curve that interpolates the given points with piecewise first order continuity

2. Construct an arc-length-parametric-value function for the curve

3. Construct time-arc-length function according to given constraints

p=P(u)

u=U(s)

s=S(t)

p=P(U(S(t)))

Page 39: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Arbitrary Speed Control

Animators can work in:

Distance-time space curves

Velocity-time space curves

Acceleration-time space curves

Set time-distance constraints

etc.

Page 40: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Curve fitting to distance-time pairs

Page 41: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Working withtime-distance curves

Page 42: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Interpolating distance-time pairs

Page 43: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame – control orientation

Page 44: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame tangent & curvature vector

Page 45: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame tangent & curvature vector

)(''

)('

)(

uP

uP

UMBuP

123 uuuU

Page 46: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame tangent & curvature vector

MBUuP

MBUuP

UMBuP

'')(''

')('

)(

0026''

0123'

12

23

uU

uuU

uuuU

Page 47: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame local coordinate system

•Directly control orientation of object/camera

•Use for direction and bank into turn, especially for ground-planar curves (e.g. roads)

•v is perpendicular to w if curve is parameterized by arclength;

otherwise probably not perpendicular

•For general curve must v = wxu

Page 48: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame - undefined

Page 49: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Frenet Frame - discontinuity

Page 50: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Other ways to control orientation

Use point P(s+ds) for direction

Use auxiliary curve to define direction or up vector

Page 51: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Direction & Up vector

Direction vector

w

u=w x y-axis

v = u x wTo keep ‘head up’, use y-axis to compute over and up vectors perpendicular to direction vector

If up vector supplied, use that instead of y-axis

Page 52: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Orientation interpolation

Preliminary note:1. Remember that2. Affects of scale are divided out by the inverse

appearing in quaternion rotation3.When interpolating quaternions, use UNIT quaternions

– otherwise magnitudes can interfere with spacing of results of interpolation

)()( vRotvRot kqq

Page 53: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Orientation interpolation

2 problems analogous to issues when interpolating positions:

1. How to take equi-distant steps along orientation path?

2. How to pass through orientations smoothly (1st order continuous)

Quaternions can be interpolated to produce in-between orientations:

21)1( kqqkq

3. And another particular to quaternions: with dual unit quaternion representations, which to use?

Page 54: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Dual representation

Dual unit quaternion representations

)()( vRotvRot kqq

For Interpolation between q1 and q2, compute cosine between q1 and q2 and between q1 and –q2; choose smallest angle

Page 55: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Interpolating quaternions

Linearly interpolating unit quaternions: not equally spaced

Unit quaternions form set of points on 4D sphere

Page 56: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Interpolating quaternions in great arc => equal spacing

Page 57: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Interpolating quaternions with

equal spacing2121 sin

sin

sin

)1sin(),,(slerp q

uq

uuqq

‘slerp’, sphereical linear interpolation is a function of • the beginning quaternion orientation, q1• the ending quaternion orientation, q2• the interpolant, u

cos21 qqwhere

Page 58: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smooth Orientation interpolation

Use quaternions

Interpolate along great arc (in 4-space) using cubic Bezier on sphere

1. Select representation to use from duals2. Construct interior control points for cubic Bezier3. use DeCastelajue construction of cubic Bezier

Page 59: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smooth quaternion interpolation

How to smoothly interpolate through orientations q1, q2, q3,…qn

Similar to first order continuity desires with positional interpolation

Bezier interpolation – geometric construction

Page 60: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Bezier interpolation

Page 61: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Bezier interpolationConstruct interior control points

pn-1

pn

pn+1

pn+2an

tn

pn-1

pn

pn+1

pn+2an

bn

pn-1

pn

pn+1

pn+2an

tn+1

an+1bn+1

p2

p1

p0

a0

Page 62: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Quaternion operators

Similar to forming a vector between 2 points, form the rotation between 2 orientations

Given 2 orientations, form result of applying rotation between the two to 2nd orientation

q1

q2

q1

q2

qd

double(q1, q2)

bisect(q1, q2) qb

Page 63: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Quaternion operators:

pqqppqqrqpdouble )(2)'('),(

Bisect 2 orientations: if p and r are unit length

qqpqq )cos('

If p and q are unit quaternions,Then q’ = cos()q and cos()= qp

p q

r

q’

‘Double’ where q’ is the mid-orientation between p and the yet-to-be-determined r

Given p and q, form rrqpdouble ),(

qrp

rprp

),(bisect

qrp ),(bisectGiven p and r, form q

Page 64: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Bezier interpolation

Need quaternion-friendly operators to form interior control points

Page 65: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Bezier interpolation Construct interior control points

)),,(double(bisect 11 nnnn pppa

),( nnn qadoubleb

Bezier segment:qn, an, bn+1, qn+1

pn-1

pn

pn+1

pn+2an

tn

pn-1

pn

pn+1

pn+2an

bn

pn-1

pn

pn+1

pn+2an

tn+1

an+1bn+1

Page 66: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Bezier construction using quaternion operators

Need quaternion-friendly operations to interpolate cubic Bezier curve using ‘quaternion’ points

de Casteljau geometric construction algorithm

Page 67: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Bezier construction using quaternion operators

t1=slerp(qn, an,1/3)t2=slerp(an, bn+1,1/3)t3=slerp(bn+1, qn+1,1/3)

t12=slerp(t1, t2,1/3)t23=slerp(t12, t23,1/3)

q=slerp(t12, t23,1/3)

For p(1/3)

Page 68: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Working with paths

Smoothing a pathDetermining a path along a surfaceFinding downhill direction

Page 69: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 70: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 71: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 72: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 73: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 74: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 75: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 76: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 77: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 78: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 79: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 80: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Smoothing data

Page 81: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Path finding

Page 82: Computer Animation Algorithms and Techniques

Computer AnimationRick Parent

Path finding - downhill