computer animation algorithms and techniques

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

Upload: alexa-armstrong

Post on 30-Dec-2015

60 views

Category:

Documents


1 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

Computer AnimationRick Parent

Computer AnimationAlgorithms and Techniques

Interpolating Values

Computer AnimationRick Parent

Animation

Animator specifiedinterpolationkey frame

Algorithmically controlledPhysics-basedBehavioral

Data-drivenmotion capture

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

Computer AnimationRick Parent

Motivation – solution steps

1. 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)))

Computer AnimationRick Parent

Interpolating function

Interpolation v. approximation Complexity: cubicContinuity: first degree (tangential)Local v. global control: localInformation requirements: tangents needed?

Computer AnimationRick Parent

Interpolation v. Approximation

Computer AnimationRick Parent

Complexity

Low complexity reduced computational cost

CUBIC polynomial

Point of InflectionCan match arbitrary tangents at

end points

Computer AnimationRick Parent

Continuity

Computer AnimationRick Parent

Local v. Global Control

Computer AnimationRick Parent

Information requirements

just the points

tangents

interior control points

just beginning and ending tangents

Computer AnimationRick Parent

Curve Formulations

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

Lagrange Polynomial

Computer AnimationRick Parent

Lagrange Polynomial

x

jk

k kj

kjj xx

xxyxP

1

)(

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

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

Computer AnimationRick Parent

Cubic Bezier

'

'

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

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

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

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

Computer AnimationRick Parent

Reparameterizing by Arc Length

AnalyticForward differencing

SupersamplingAdaptive approach

NumericallyAdaptive Gaussian

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)(

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

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

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

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

Computer AnimationRick Parent

Reparameterizing by Arc Length

AnalyticForward differencing

SupersamplingAdaptive approach

NumericallyAdaptive Gaussian

Sufficient for many problems

Computer AnimationRick Parent

Speed Control

Time-distance functionEase-in

Cubic polynomialSinusoidal segmentSegmented sinusoidalConstant acceleration

General distance-time functions

time

distance

Computer AnimationRick Parent

Time Distance Function

s = S(t)

s

t

S

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

Computer AnimationRick Parent

Ease-in: Sinusoidal

2/)12/sin()( tteases

Computer AnimationRick Parent

Ease-in: Piecewise Sinusoidal

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

Computer AnimationRick Parent

Ease-in: Single Cubic

23 32)( ttteases

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Computer AnimationRick Parent

Ease-in: Constant Acceleration

Computer AnimationRick Parent

Arbitrary Speed Control

Animators can work in:Distance-time space curvesVelocity-time space curvesAcceleration-time space curvesSet time-distance constraintsetc.

Computer AnimationRick Parent

Curve fitting to distance-time pairs

Computer AnimationRick Parent

Working withtime-distance curves

Computer AnimationRick Parent

Interpolating distance-time pairs

Computer AnimationRick Parent

Frenet Frame – control orientation

Computer AnimationRick Parent

Frenet Frame tangent & curvature vector

Computer AnimationRick Parent

Frenet Frame tangent & curvature vector

)(''

)('

)(

uP

uP

UMBuP

123 uuuU

Computer AnimationRick Parent

Frenet Frame tangent & curvature vector

MBUuP

MBUuP

UMBuP

'')(''

')('

)(

0026''

0123'

12

23

uU

uuU

uuuU

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)

Computer AnimationRick Parent

Frenet Frame - undefined

Computer AnimationRick Parent

Frenet Frame - discontinuity

Computer AnimationRick Parent

Other ways to control orientation

Use point P(s+ds) for direction

Use auxiliary curve to define direction or up vector

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 instead of y-axis

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

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?

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

Computer AnimationRick Parent

Interpolating quaternions

Linearly interpolating unit quaternions: not equally spaced

Unit quaternions form set of points on 4D sphere

Computer AnimationRick Parent

Interpolating quaternions in great arc => equal spacing

Computer AnimationRick Parent

Interpolating quaternions

2121 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

Computer AnimationRick Parent

Smooth Orientation interpolation

Use quaternionsInterpolate 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

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

Computer AnimationRick Parent

Bezier interpolation

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

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

Computer AnimationRick Parent

Quaternion operators

pqqpqpdouble )(2),(

Bisect 2 orientations:21

2121 ),(bisect

qq

qqqq

p q

Computer AnimationRick Parent

Bezier interpolation

Need quaternion-friendly operators to form interior control points

Computer AnimationRick Parent

Bezier interpolation Construct interior control points

)),,(double(bisect 11 nnnn qqqa

),( 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

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

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)

Computer AnimationRick Parent

Working with paths

Smoothing a pathDetermining a path along a surfaceFinding downhill direction

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Smoothing data

Computer AnimationRick Parent

Path finding

Computer AnimationRick Parent

Path finding - downhill