3-interpolatingvalues

Upload: apsaraso

Post on 06-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 3-InterpolatingValues

    1/111

    Chap 3Interpolating Values

    Animation(U), Chap 3, Interpolating Values 1

  • 8/2/2019 3-InterpolatingValues

    2/111

    2

    Outline

    Interpolating/approximating curves Controlling the motion of a point along a curve

    Interpolation of orientation

    Working with paths

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    3/111

    3

    Interpolation between key frames

    Parameters to be interpolated Position of an object

    Normal

    Joint angle between two joints Transparency attribute of an object

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    4/111

    4

    Interpolation between key frames

    Interpolation between frames is not trivial Appropriate interpolating function

    Parameterization of the function

    Maintain the desired control of the interpolated valuesover time

    Example

    (-5,0,0) at frame 22, (5,0,0) art frame 67

    Stop at frame 22 and accelerate to reach a max speed by

    frame 34

    Start to decelerate at frame 50 and come to a stop at

    frame 67

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    5/111

    5

    Interpolation between key frames

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

    desired result undesired result

    Need a smooth interpolation with user control

  • 8/2/2019 3-InterpolatingValues

    6/111

    Interpolation between key frames

    Solution Generate a space curve

    Distribute points evenly along curve

    Speed control: vary points temporally

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang6

    A

    B

    C

    D

    Time = 0

    Time = 10

    Time = 35

    Time = 60

  • 8/2/2019 3-InterpolatingValues

    7/1117

    Interpolation functions

    Interpolation vs. approximation

    Interpolation

    Hermite, Catmull-Rom

    approximation

    Bezier, B-spline

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    8/1118

    Interpolation functions

    Complexity => computational efficiency Polynomials

    Lower than cubic

    No inflection point, may not fit smoothly to some data points

    Higher than cubic

    Doesnt provide any significant advantages, costly to evaluate

    Piecewise cubic

    Provides sufficient smoothness

    Allows enough flexibility to satisfy constraints such as end-

    point position and tangents

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    9/1119

    Interpolation functions

    Continuity within a curve Zero-order

    First order (tangential)

    Suffices for most animation applications

    Second order

    Important when dealing with time-distance curve

    Continuity between curve segments Hermite, Catmull-Rom, cubic Bezier provide first

    order continuity between segments

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    10/11110

    Interpolation functions

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    11/111CS, NCTU, J. H. Chuang11

    Continuity

    noneposition(0th order)

    tangent(1st order)

    curvature(2nd order)

    At junctionof twocircular arcs

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    12/11112

    Interpolation functions

    Global vs. local control

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

  • 8/2/2019 3-InterpolatingValues

    13/111CS, NCTU, J. H. Chuang13

    Types of Curve Representation

    Explicit y = f(x)

    Good for generate points

    For each input, there is a unique output

    Implicit f(x,y) = 0

    Good for testing if a point is on a curve

    Bad for generating a sequence of points

    Parametric x = f(u), y = g(u)

    Good for generating a sequence of points

    Can be used for multi-valued function ofx

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    14/111CS, NCTU, J. H. Chuang14

    Example: Representing Unit Circle

    Cannot be represented explicitly as a functionofx

    Implicit form:f(x,y)=x2+y2=1

    Parametric form:x=cos(u),y=sin(u), 0

  • 8/2/2019 3-InterpolatingValues

    15/111CS, NCTU, J. H. Chuang15

    More on 3-D Parametric Curves

    Parametric form: P(u) = (Px(u), Py(u), Pz(u))

    x = Px(u), y = Py(u), z = Pz(u)

    Space-curve P = P(u) 0.0

  • 8/2/2019 3-InterpolatingValues

    16/111

    Polynomial Interpolation

    An n-th degree polynomial fits a curve to n+1points

    Example: fit a second degree curve to three points

    y(x)= a x2 + b x + c

    points to be interpolated(x1, y1), (x2, y2), (x3, y3)

    solve for coefficients (a, b, c):3 linear equations, 3 unknowns

    called Lagrange Interpolation

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang16

  • 8/2/2019 3-InterpolatingValues

    17/111

    Polynomial Interpolation (cont.)

    Result is a curve that is too wiggly, change toany control point affects entire curve(nonlocal)this method is poor

    We usually want the curve to be as smooth aspossible

    minimize the wiggles

    high-degree polynomials are bad Higher degree, higher the wiggles

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang17

  • 8/2/2019 3-InterpolatingValues

    18/111CS, NCTU, J. H. Chuang18

    Composite Segments

    Divide a curve into multiple segments Represent each in a parametric form

    Maintain continuity between segments

    position

    Tangent (C1-continuity vs. G1-continuity)

    curvature

    P1(u) P2(u) P3(u) Pn(u)

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    19/111CS, NCTU, J. H. Chuang19

    Splines: Piecewise Polynomials

    A spline is a piecewise polynomial - many lowdegree polynomials are used to interpolate

    (pass through) the control points

    Cubic polynomials are the most common

    lowest order polynomials that interpolate twopoints and allow the gradient at each point to bedefined - C1 continuity is possible

    Higher or lower degrees are possible, of course

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    20/111CS, NCTU, J. H. Chuang20

    A Linear Piecewise PolynomialThe simple form for interpolating two points.

    p1

    p2

    Each segment is of the form: (this is avector equation)

    u0 1

    1

    Two basis (blending) functions

    u

    21 )1()( puupup

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    21/111CS, NCTU, J. H. Chuang21

    Hermite Curvescubic polynomial for two points

    Hermite interpolation requires

    Endpoint positions

    derivatives at endpoints

    To create a composite curve, use the end of one as the

    beginning of the other and share the tangent vector

    Hermite Interpolation

    )0('P

    control points/knots

    dcubuauuP 23)(

    )0(P

    )1('P

    )1(P

    ))(),(),(()( uPuPuPuP zyx

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    22/111

    CS, NCTU, J. H. Chuang22

    Hermite Curve Formation Cubic polynomial and its derivative

    Given Px(0), Px(1),Px(0),Px(1), solve for a, b, c, d

    4 equations are given for 4 unknowns

    xxxxx ducubuauP 23)(

    xxxx cubuauP 23)(2'

    xx dP )0(xxxxx dcbaP )1(

    xx cP )0('

    xxxx

    cbaP 23)1('

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    23/111

    CS, NCTU, J. H. Chuang23

    Hermite Curve Formation (cont.)

    Problem: solve for a, b, c, d

    Solution:

    )0(

    )0(

    )1()0(2))0()1((3

    )1()0())1()0((2

    '

    ''

    ''

    xx

    xx

    xxxxx

    xxxxx

    Pd

    Pc

    PPPPb

    PPPPa

    xx dP )0(

    xxxxx dcbaP )1(

    xx cP )0('

    xxxx cbaP 23)1('

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    24/111

    CS, NCTU, J. H. Chuang24

    Hermite Curves in Matrix Form

    ith segment incomposite curves

    dcubuauuP 23)(

    MBUuPT)(

    parametertheis]1,,,[ 23 uuuUT

    matrixtcoefficientheisM

    ninformatiogeometrictheisB

    0001

    0100

    1233

    1122

    M

    )1(

    )0(

    )1(

    )0(

    B

    '

    '

    x

    x

    x

    x

    P

    P

    P

    P

    '

    1

    '

    1B

    i

    i

    i

    i

    P

    P

    PP

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    25/111

    CS, NCTU, J. H. Chuang25

    Blending Functions of Hermite Splines

    Each cubic Hermite spline is a linear combination of4blending functions

    geometric information

    2

    1

    2

    1

    23

    23

    23

    23

    '

    '2

    32

    132

    )(

    p

    p

    p

    p

    uu

    uuu

    uu

    uu

    up

    BMUuPT )(

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    26/111

    Composite Hermite Curve

    Continuity between connected segments isensured by using ending tangent vector of one

    segment as the beginning tangent vector of the

    next.

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang26

  • 8/2/2019 3-InterpolatingValues

    27/111

    Bezier Curves

    Similar to Hermite Curve Instead of endpoints and tangents, four control

    points are given

    points P1 and P4 are on the curve points P2 and P3 are used to control the shape

    p1 = P1,p2 = P4,

    p1' = 3(P2-P1),p2' = 3(P4 - P3)

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang27

    4

    3

    2

    1

    0001

    0033

    0363

    1331

    1)(23

    P

    P

    P

    P

    uuuup

  • 8/2/2019 3-InterpolatingValues

    28/111

    Bezier Curves

    Another representation Blend the control point position using Bernstein polynomials

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang28

    )!(!

    !),(

    )1(),()(

    spolynomialBernsteinare)(where

    )()(

    ,

    ,

    0

    ,

    knk

    nknC

    uuknCuB

    uB

    PuBup

    knk

    nk

    nk

    n

    k

    knk

  • 8/2/2019 3-InterpolatingValues

    29/111

    CS, NCTU, J. H. Chuang29

    Bezier Curves

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    30/111

    Composite Bezier Curves

    How to control the continuity betweenadjacent Bezier segment?

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang30

    D C lj C i f B i

  • 8/2/2019 3-InterpolatingValues

    31/111

    De Casteljau Construction of Bezier

    Curves

    How to derive a point on a Bezier curve?

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang31

  • 8/2/2019 3-InterpolatingValues

    32/111

    CS, NCTU, J. H. Chuang32

    Bezier Curves (cont.)

    Variant of the Hermite spline

    basis matrix derived from the Hermite basis (or

    from scratch)

    Gives more uniform control knobs (series of

    points) than Hermite

    Scale factor (3) is chosen to make velocity

    approximately constant

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    33/111

    CS, NCTU, J. H. Chuang33

    Catmull-Rom Splines

    With Hermite splines, the designer must arrangefor consecutive tangents to be collinear, to get C1

    continuity. Similar for Bezier. This gets tedious.

    Catmull-Rom: an interpolating cubic spline with

    built-in C1 continuity.

    Compared to Hermite/Bezier: fewer control

    points required, but less freedom.

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    34/111

    CS, NCTU, J. H. Chuang34

    Catmull-Rom Splines (cont.)

    Given n control points in 3-D:p1, p2, ,pn,

    Tangent at pi given by s(pi+1pi-1) for i=2..n-1, for

    some s.

    Curve between pi and pi+1 is determined by pi-1, pi,

    pi+1, pi+2.

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    35/111

    CS, NCTU, J. H. Chuang35

    Catmull-Rom Splines (cont.)

    Given n control points in 3-D:p1, p2, ,pn, Tangent at pi given by s(pi+1pi-1) for i=2..n-1, for

    some s

    Curve between pi and pi+1 is determined by pi-1, pi,

    pi+1, pi+2

    What about endpoint tangents? (several good

    answers: extrapolate, or use extra control points p0,

    pn+1) Now we have positions and tangents at each knot

    a Hermite specification.

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    36/111

    CS, NCTU, J. H. Chuang36

    Catmull-Rom Spline Matrix

    Derived similarly to Hermite and Bezier

    s is the tension parameter; typically s=1/2

    2

    1

    1

    0020

    01011452

    1331

    )(

    ,2/1When

    i

    i

    i

    i

    T

    P

    PP

    P

    Uup

    s

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    37/111

    CS, NCTU, J. H. Chuang37

    Catmull-Rom Spline

    What about endpoint tangents? Provided by users

    Several good answers: extrapolate, or use extra

    control points p0, pn+1

    Animation(U), Chap 3, Interpolating Values

    )2(2

    1

    )))(((2

    1

    021

    0121

    '

    0

    PPP

    PPPPP

  • 8/2/2019 3-InterpolatingValues

    38/111

    CS, NCTU, J. H. Chuang38

    Catmull-Rom Spline

    Example

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    39/111

    CS, NCTU, J. H. Chuang39

    Catmull-Rom Spline

    Drawback An internal tangent is not dependent on the

    position of the internal point relative to its two

    neighbors

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    40/111

    CS, NCTU, J. H. Chuang41

    Splines and Other Interpolation Forms

    See Computer Graphics textbooks

    Review

    Appendix B.4 in Parent

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    41/111

    CS, NCTU, J. H. Chuang42

    Now What?

    We have key frames or points

    We have a way to specify the space curve

    Now we need to specify velocity to traversethe curve

    Speed Curves

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    42/111

    CS, NCTU, J. H. Chuang43

    Speed Control

    The speed of tracing a curve needs to be under thedirect control of the animator

    Varying u at a constant rate will not necessarily

    generate P(u) at a constant speed.

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    43/111

    CS, NCTU, J. H. Chuang44

    Generally, equally spaced samples inparameter space are not equally spaced along

    the curve

    Non-uniformity in Parametrization

    A

    B

    C

    D

    Time = 0

    Time = 10

    Time = 35

    Time = 60

    )()( 1212 ususuu

    duuPuPuPus zyx222 )()()()(

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    44/111

    CS, NCTU, J. H. Chuang45

    Arc Length Reparameterization

    To ensure a constant speed for the interpolated

    value, the curve has to be parameterized by arc

    length (for most applications)

    Computing arc length

    Analytic method (many curves do not have, e.g., B-

    splines)

    Numeric methods

    Table and differencing

    Gaussian quadrature

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    45/111

    CS, NCTU, J. H. Chuang46

    Arc Length Reparameterization

    Space curve vs. time-distance function

    Relates time to the distance traveled along the

    curve, i.e.,

    Relates time to the arc length along the curve

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    46/111

    CS, NCTU, J. H. Chuang47

    Arc Length Reparameterization

    Given a space curve with arc lengthparameterization

    Allow movement along the curve at a constant speed by

    stepping at equal arc length intervals

    Allows acceleration and deceleration along the curve bycontrolling the distance traveled in a given time interval

    Problems

    Given a parametric curve and two parameter values u1 andu2, find arclength(u1,u2)

    Given an arc length s, and parameter value u1, find u2 such

    that arclength(u1,u2) = s

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    47/111

    CS, NCTU, J. H. Chuang48

    Arc Length Reparameterization

    Converting a space curve P(u) to a curve with

    arc-length parameterization

    Find s=S(u), and u=S-1(s)=U(s)

    P*(s)=P(U(s))

    Analytic arc-length parameterization is

    difficult or impossible for most curves, e.g., B-

    spline curve cannot be parameterized with arclength.

    Approximate arc-length parameterization

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    48/111

    CS, NCTU, J. H. Chuang49

    Forward Differencing

    Sample the curve at small intervals of the parameter Compute the distance between samples

    Build a table of arc length for the curve

    u Arc Length0.0 0.00

    0.1 0.08

    0.2 0.19

    0.3 0.32

    0.4 0.45

    Animation(U), Chap 3, Interpolating Values

    A L th R t i ti U i

  • 8/2/2019 3-InterpolatingValues

    49/111

    CS, NCTU, J. H. Chuang50

    Arc Length Reparameterization Using

    Forward Differencing

    Given a parameter u, find the arc length Find the entry in the table closest to this u

    Or take the u before and after it and interpolate arc

    length linearly u Arc Length0.0 0.00

    0.1 0.08

    0.2 0.19

    0.3 0.32

    0.4 0.45

    Animation(U), Chap 3, Interpolating Values

    A L th R t i ti U i

  • 8/2/2019 3-InterpolatingValues

    50/111

    CS, NCTU, J. H. Chuang51

    Arc Length Reparameterization Using

    Forward Differencing

    Given an arc length s and a parameter u1, findthe parametric value u2 such that

    arclength(u1, u2)=s

    Find the entry in the tableclosest to this u using

    binary search

    Or take the u before and after

    it and interpolate linearly

    u Arc Length

    0.0 0.00

    0.1 0.08

    0.2 0.19

    0.3 0.320.4 0.45

    Animation(U), Chap 3, Interpolating Values

    A L th R t i ti U i

  • 8/2/2019 3-InterpolatingValues

    51/111

    CS, NCTU, J. H. Chuang52

    Arc Length Reparameterization Using

    Forward Differencing

    Easy to implement, intuitive, and fast Introduce errors

    Super-sampling in forming table

    1000 equally spaced parameter values + 1000 ebtries ineach interval

    Better interpolation

    Adaptive forward differencing

    Animation(U), Chap 3, Interpolating Values

    A L th R t i ti U i

  • 8/2/2019 3-InterpolatingValues

    52/111

    CS, NCTU, J. H. Chuang53

    Arc Length Reparameterization Using

    Adaptive forward differencing

    Animation(U), Chap 3, Interpolating Values

    Arc Length Reparameterization Using

  • 8/2/2019 3-InterpolatingValues

    53/111

    Arc Length Reparameterization Using

    Numerical Integral

    Arc length integral

    Simpsons and trapezoidal integration using evenly

    spaced intervals

    Gaussian quadrature using unevenly spaced

    intervals

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang54

    duuPuPuPus zyx222 )()()()(

  • 8/2/2019 3-InterpolatingValues

    54/111

    Speed Control

    Given a arc-length parameterized space curve,

    how to control the speed at which the curve is

    traced?

    By a speed-control functions that relate an equally

    spaced time interval to arc length

    Input time t, output arc length: s=S(t)

    Linear function: constant speed control Most common: ease-in/ease-out

    Smooth motion from stopped position, accelerate, reach a max

    velocity, and then decelerate to a stop position

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang55

  • 8/2/2019 3-InterpolatingValues

    55/111

    Speed Control Function

    Relates an equally spaced time interval to arc

    length

    Input time t, output arc length: s=S(t)

    Normalized arc length parameter

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang56

    s=ease(t)

    Start at 0,

    slowly increasein value and gainspeed until themiddle value andthen decelerate asit approaches to 1.

  • 8/2/2019 3-InterpolatingValues

    56/111

    CS, NCTU, J. H. Chuang57

    Constant Velocity Speed Curve

    Moving at 1 m/s if meters and seconds are the units

    Too simple to be what we want

    Animation(U), Chap 3, Interpolating Values

    Distance Time Function

  • 8/2/2019 3-InterpolatingValues

    57/111

    Distance Time Function

    and Speed Control

    We have a space curve p=P(u) and a

    speed control function s=S(t).

    For a given t, s=S(t)

    Find the corresponding value u=U(s) by looking

    up an arc length table for a given s

    A point on the space curve with parameter u

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

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang58

  • 8/2/2019 3-InterpolatingValues

    58/111

    CS, NCTU, J. H. Chuang59

    Speed Control

    u Arc Length

    0.0 0.00

    0.1 0.08

    0.2 0.19

    0.3 0.32

    0.4 0.45

    t*

    s*u*)( *uP

    Speed Control Curve

    Arc Length Table

    Animation(U), Chap 3, Interpolating Values

  • 8/2/2019 3-InterpolatingValues

    59/111

    Distance Time Function

    Assumptions on distance time function

    The entire arc length of the curve is to be traversed

    during the given total time

    Additional optional assumptions

    The function should be monotonic in t

    The function should be continuous

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang60

  • 8/2/2019 3-InterpolatingValues

    60/111

    CS, NCTU, J. H. Chuang61

    Ease-in/Ease-out

    Most useful and most common ways to control

    motion along a curve

    (distance)

    Time

    Arc length

    Equally spaced samples in time specify arc length required for that frame

    Animation(U), Chap 3, Interpolating Values

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    61/111

    CS, NCTU, J. H. Chuang62

    Ease in/Ease out

    Sine Interpolation

    -1

    1

    p/2

    p/2

    Time

    Arc Length

    22),sin(

    p

    p

    10,2

    1)

    2(sin

    2

    1)(ease ttts pp

    Animation(U), Chap 3, Interpolating Values

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    62/111

    Ease in/Ease out

    Sine Interpolation

    The speed of s w.r.t. t is never constant over an

    interval but rather is always accelerating or

    decelerating.

    Zero derivatives at t=0 and t=1 indicating

    smooth accelerating and deceleration at end

    points.

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang63

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    63/111

    CS, NCTU, J. H. Chuang64

    Ease in/Ease out

    Piecing Curves Together for Ease In/Out

    Time

    Linear segmentArc Length

    Sinusoidal segments

    Animation(U), Chap 3, Interpolating Values

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    64/111

    CS, NCTU, J. H. Chuang65

    Ease in/Ease out

    Piecing Curves Together for Ease In/Out

    Animation(U), Chap 3, Interpolating Values

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    65/111

    CS, NCTU, J. H. Chuang66

    Ease in/Ease out

    Integrating to avoid the sine function

    acceleration

    time

    t1 t2

    A

    D

    velocity

    timet1 t2

    v

    arc length

    time

    V1 = V2A*t1 = - D*(1-t2)

    Find v such that area = 1

    Animation(U), Chap 3, Interpolating Values

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    66/111

    Ease in/Ease out

    Integrating to avoid the sine function

    To avoid the transcendental function

    evaluation while providing a constant speed

    interval between ease-in and ease-out intervals

    Acceleration-time curve

    Velocity-time curve

    Velocity-time curve is defined by integral of the

    acceleration-time curve Distance-time curve is defined by integral of the

    velocity-time curve

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang67

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    67/111

    Ease in/Ease out

    Integrating to avoid the sine function

    In ease-in/ease-out function

    Velocity starts out at 0 and ends at 0

    V1 = V2inplies A*t1 = - D*(1-t2)

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang68

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    68/111

    Ease in/Ease out

    Integrating to avoid the sine function

    Total distance = 1 implies

    1 = V0t + V0 (t2-t1)+1/2 V0 (1-t2)

    Users specifies any two of three variables t1, t2, and V0,

    and the system can solve for the third

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang69

    Ease-in/Ease-out

  • 8/2/2019 3-InterpolatingValues

    69/111

    ase / ase out

    Integrating to avoid the sine function

    The result is Parabolic ease-in/ease-out

    More flexible than the sinusoidal ease-in/ease-out

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang70

    Vid

  • 8/2/2019 3-InterpolatingValues

    70/111

    CS, NCTU, J. H. Chuang71

    Videos

    Bunny (Blue Sky Studios, 1998)

    Animation(U), Chap 3, Interpolating Values

    R i Q t i

  • 8/2/2019 3-InterpolatingValues

    71/111

    Review - Quaternions

    Similar to axis-angle representations 4-tuple of real numbers

    q=(s, x, y, z) or [s, v]s is a scalar; v is a vector

    The quaternion for rotating an angle about an

    axis (an axis-angle rotation):

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang72

    q

    X

    Y

    Z

    a=(ax, ay, az)

    If a is unit length, then q will be also

    ),,()2

    sin(),2

    cos(

    )),,(,(Rot

    zyx

    zyx

    aaa

    aaaq

    qq

    q

    R i Q t i

  • 8/2/2019 3-InterpolatingValues

    72/111

    Review - Quaternions

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang73

    Ifa is unit length, then q will be also

    11

    2sin

    2cos

    2sin

    2cos

    2sin

    2cos

    2sin2sin2sin2cos

    22222

    22222

    2222222

    2

    3

    2

    2

    2

    1

    2

    0

    qqqq

    qq

    qqqq

    a

    q

    zyx

    zyx

    aaa

    aaa

    qqqq

    R i Q t i

  • 8/2/2019 3-InterpolatingValues

    73/111

    Review - Quaternions

    Rotating some angle around an axis is the same asrotating the negative angle around the negated axis

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang74

    qzyxzyx

    ),,)(

    2

    sin(),

    2

    cos(Rot ),,(,qq

    q

    R i Q t i M th

  • 8/2/2019 3-InterpolatingValues

    74/111

    75

    Review - Quaternion Math

    Addition

    Multiplication

    Multiplication is associative but not commutative

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    21212211 ,,, vvssvsvs

    21122121212211 ,,, vvvsvsvvssvsvs

    1221 qqqq 321321 )()( qqqqqq

    R i Q t i M th ( t )

  • 8/2/2019 3-InterpolatingValues

    75/111

    76

    Review - Quaternion Math (cont.)

    Multiplicative identity: [1, 0,0,0]

    Inverse

    Normalization for unit quaternion

    2222zyxsq

    0,0,0,11 qq

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    q

    qq

    2222 zyxsq

    qq 0,0,0,1

    21 ,

    qvsq 0,0,0,11 qq

    q

    qq

    Review

  • 8/2/2019 3-InterpolatingValues

    76/111

    77

    Rotating Vectors Using Quaternion

    A point in space, v, is represented as [0, v]

    To rotate a vector v using quaternion q

    Represent the vector as v = [0, v]

    Represent the rotation as a quaternion q

    Using quaternion multiplication

    The proof isnt that hard

    Note that the result valways has zero scalar value

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    1

    )('

    qvqvRotvq

    Re ie Compo e Rotation

  • 8/2/2019 3-InterpolatingValues

    77/111

    Review - Compose Rotations

    Rotating a vector v by first quaternionpfollowed by a quaternion q is like rotation

    using qp

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang78

    )()()(

    )())((

    1

    11

    1

    vRotqpvqp

    qqpvp

    pvpRotvRotRot

    qp

    qpq

    Review Compose Rotations

  • 8/2/2019 3-InterpolatingValues

    78/111

    Review - Compose Rotations

    To rotate a vector v by quaternion q followedby its inverse quaternion q-1

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang79

    v

    qqvqq

    qvqRotvRotRot qqq

    11

    1

    )())(( 11

    Review Quaternion Interpolation

  • 8/2/2019 3-InterpolatingValues

    79/111

    80

    Review - Quaternion Interpolation

    A quaternion is a point on a 4D unit sphere

    Unit quaternion: q=(s,x,y,z), ||q|| = 1

    Form a subspace: a 4D sphere

    Interpolating quaternion means moving between two

    points on the 4D unit sphere A unit quaternion at each stepanother point

    on the 4D unit sphere

    Move with constant angular velocity

    along the greatest circle between the

    two points on the 4D unit sphere

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    Review Linear Interpolation

  • 8/2/2019 3-InterpolatingValues

    80/111

    81

    Review - Linear Interpolation

    Linear interpolation generates unequal spacingof points after projecting to circle

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    Review

  • 8/2/2019 3-InterpolatingValues

    81/111

    82

    Want equal increment along arc connecting twoquaternion on the spherical surface

    Spherical linear interpolation (slerp)

    Normalize to regain unit quaternion

    Spherical Linear Interpolation (slerp)

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    )(cosand1to0fromgoeswhere

    sin

    )sin(

    sin

    ))1sin((),,(

    21

    1

    2121

    qqu

    qu

    qu

    uqqslerp

    q

    q

    q

    q

    q

    Review

  • 8/2/2019 3-InterpolatingValues

    82/111

    83

    Spherical Linear Interpolation (slerp)

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    2121

    1

    21

    21

    sin

    )sin(

    sin

    ))1sin((),,(

    giveto

    ,

    ,1

    :givenforsolvecanWe

    Let

    qu

    qu

    uqqslerp

    uqq

    qq

    q

    qqq

    q

    q

    q

    q

    q

    q

    Review

  • 8/2/2019 3-InterpolatingValues

    83/111

    84

    Spherical Linear Interpolation (slerp)

    2q

    1q

    2q

    021 qq

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    Review

  • 8/2/2019 3-InterpolatingValues

    84/111

    85

    Spherical Linear Interpolation (slerp)

    Recall that q andq represent same rotation What is the difference between:

    Slerp(u, q1, q2) and Slerp(u, q1, -q2) ?

    One of these will travel less than 90 degrees whilethe other will travel more than 90 degrees acrossthe sphere

    This corresponds to rotating the short way or the

    long way Usually, we want to take the short way, so we

    negate one of them if their dot product is < 0

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    Review

  • 8/2/2019 3-InterpolatingValues

    85/111

    86

    Spherical Linear Interpolation (slerp)

    Animation(U), Chap 2, Tech. Background CS, NCTU, J. H. Chuang

    If we have an intermediate position q2, theinterpolation from q1-->q2-->q3 will not

    necessarily follow the same path as the

    interpolation from q1 to q3.

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    86/111

    87

    Interpolating a Series of Quaternions

    As linear interpolation in Euclidean space, wecan have first order discontinuity problem

    when interpolating a series of orientations.

    Need a cubic curve interpolation to maintain first order

    continuity in Euclidean space

    Similarly, slerp can have 1st order discontinuity

    We also need a cubic curve interpolation in 4D

    spherical space for 1st order continuity

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    87/111

    Interpolating a Series of Quaternions

    Interpolated points [, pn-1, pn, pn+1, .] in 3D Between each pair of points, two control

    points will be constructed. e.g., For pn

    an : the one intermediate after pn bn : the one immediately before pn

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang88

    pn+(pn-pn-1)

    Take average

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    88/111

    Interpolating a Series of Quaternions

    Interpolated points [, pn-1, pn, pn+1, .] in 3D

    Between each pair of points, two control

    points will be constructed. e.g., For pn

    an : the one intermediate after pn

    bn : the one immediately before pn

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang89

    bn =pn+(pn-an)

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    89/111

    Interpolating a Series of Quaternions

    Interpolated points [, pn-1, pn, pn+1, .] in 3D

    End conditions

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang90

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    90/111

    Interpolating a Series of Quaternions

    Interpolated points [, pn-1, pn, pn+1, .] in 3D

    Between any 2 interpolated points pn and pn+1,

    a cubic Bezier curve segment is defined by pn,

    an, bn+1, and pn+1

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang91

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    91/111

    Interpolating a Series of Quaternions

    How to evaluate a point on Bezier curve?

    De Casteljau Construction

    Constructing Bezier curve by multiple linear

    interpolation

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang92

    u=1/3

    p(1/3)

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    92/111

    Interpolating a Series of Quaternions

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang93

    Animation: Seehttp://en.wikipedia.org/wiki/File:Bezier_3_big.gif

    Interpolating a Series of Quaternions

    http://bezier_3_big.gif/http://bezier_3_big.gif/http://bezier_3_big.gif/http://bezier_3_big.gif/http://bezier_3_big.gif/http://en.wikipedia.org/wiki/File:Bezier_3_big.png
  • 8/2/2019 3-InterpolatingValues

    93/111

    Interpolating a Series of Quaternions

    Bezier interpolation on 4D sphere? How are control points generated?

    How are cubic Beziers defined?

    Control points are automatically generated as itis not intuitive to manually adjust them on a 4Dsphere

    Derive Bezier curve points by iterativelysubdivision s on pn, an, bn+1, and pn+1

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang94

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    94/111

    95

    1

    11

    '

    '),'(sec

    nn

    nnnn

    qq

    qqqqtBi

    Connecting Segments on 4D Sphere

    Automatically generating interior (spherical)control points

    qn-1

    qn

    qn+1

    qn

    an

    1. Double the arc

    2. Bisect the span

    111

    ' )(2),( nnnnnnn qqqqqqdoubleq

    bn

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

    ),( nnn qadoubleb

    Interpolating a Series of Quaternions

  • 8/2/2019 3-InterpolatingValues

    95/111

    96

    1nqnq

    De Casteljau Construction on 4D Sphere

    p1 slerp(qn ,an, 13)

    p2 slerp(a

    n,b

    n1, 1

    3)

    p3 slerp(bn1,qn1, 13)

    p12 slerp(p1,p2, 13)

    p23 slerp(p2,p3, 13)

    p slerp(p12,p23, 13)

    u=1/3

    P(1/3)

    na 1nb

    1p

    2p

    3p

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang

    Path Following

  • 8/2/2019 3-InterpolatingValues

    96/111

    Path Following

    Issues about path following

    Arc length parameterization and speed control

    Changing the orientation

    Smoothing a path

    Path along a surface

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang97

    Orientation Along a Curve

  • 8/2/2019 3-InterpolatingValues

    97/111

    Orientation Along a Curve

    A local coordinate system (u, v, w) is defined

    for an object to be animated

    Position along the path P(s), denoted as POS

    w-axis: the direction the object is facing

    v-axis: up vector

    u-axis: perpendicular to w and v

    (u, v, w): a right-handed coordinate system

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang98

    Orientation Along a Curve

  • 8/2/2019 3-InterpolatingValues

    98/111

    Orientation Along a Curve

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang99

    Orientation Along a Curve

  • 8/2/2019 3-InterpolatingValues

    99/111

    Frenet Frame

    Frenet frame: a moving coordinate systemdetermined by curve tangent and curvature

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang100

    wuv

    sPsPu

    sPw

    )(')("

    )('

    Orientation Along a Curve

  • 8/2/2019 3-InterpolatingValues

    100/111

    Frenet Frame

    ProblemsNo concept of up vector

    Is undefined in segments that has no curvature;

    i.e., P(u)=0

    Can be dealt with by interpolating a Frenet frame from

    the Frenet frames at segments boundary, which differ

    by only a rotation around w

    A discontinuity in the curvature vector Frenet frame has a discontinuous jump in orientation

    Resulting motions are usually too extreme and not

    natural lookingAnimation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang101

    Orientation Along a Curve

    F F

  • 8/2/2019 3-InterpolatingValues

    101/111

    Frenet Frame

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang102

    Orientation Along a Curve

    F F

  • 8/2/2019 3-InterpolatingValues

    102/111

    Frenet Frame

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang103

    Orientation Along a Curve

    C P h F ll i

  • 8/2/2019 3-InterpolatingValues

    103/111

    Camera Path Following

    COI: center of interest A fixed point in the scene

    Center point of an object in the scene

    Points along the path itself Points on a separate path in the scene

    Points on the interpolation between points in the

    scene

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang104

    wuv

    wu

    w

    y_axis

    POSCOI

    wuv

    wu

    sPsCw

    y_axis

    )()(

    wuv

    sPsUwu

    sPsCw

    ))()((

    )()(

    Smoothing a Path

    i h Li I l i

  • 8/2/2019 3-InterpolatingValues

    104/111

    with Linear Interpolation

    Two points on either sides of a point areaveraged, and this point is averaged with the

    original point.

    Repeated application

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang105

    11

    11

    41

    21

    41

    22'

    iii

    iii

    i PPP

    PPP

    P

    Smoothing a Path

    i h Li I l i

  • 8/2/2019 3-InterpolatingValues

    105/111

    with Linear Interpolation

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang106

    Smoothing a Path

    ith C bi I t l ti

  • 8/2/2019 3-InterpolatingValues

    106/111

    with Cubic Interpolation

    Four points on either sides of a point are fittedby a cubic curve, and the midpoint of the curve

    is averaged with the original point.

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang107

    dcbaPP

    dcbaPP

    dcbaPP

    dPP

    dcubuauuP

    i

    i

    i

    i

    )1(

    4

    3

    16

    9

    64

    27)4/3(

    4

    1

    16

    1

    64

    1)4/1(

    )0(

    )(

    2

    1

    1

    2

    23

    Smoothing a Path

    ith C bi I t l ti

  • 8/2/2019 3-InterpolatingValues

    107/111

    with Cubic Interpolation

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang108

    Smoothing a Path

    ith C bi I t l ti

  • 8/2/2019 3-InterpolatingValues

    108/111

    with Cubic Interpolation

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang109

    Determine a Path on a Surface

  • 8/2/2019 3-InterpolatingValues

    109/111

    If one object is to move across the surface of

    another object, we need to specify a path

    across the surface.

    Given start and destination points Find a shortest path between the pointsexpensive

    Determine a plane that contain two points and is

    generally perpendicular to the surface (averaged normal

    of two points) Intersection of the plane with the surface (mesh)

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang110

    Determine a Path on a Surface

  • 8/2/2019 3-InterpolatingValues

    110/111

    Animation(U), Chap 3, Interpolating Values CS, NCTU, J. H. Chuang111

    Determine a Path on a Parametric

    S f

  • 8/2/2019 3-InterpolatingValues

    111/111

    Surface

    Given start and destination points on parametricdomain

    Define the straight line connecting two points in the

    parametric space

    The curve on the surface corresponding to this line