Interpolaonweb.cse.ohio-state.edu/.../06-Interpolation.pdf · 2014. 2. 9. · Interpolaon$terms$...

36
Interpola*on and Curves and Mo*on on a Path

Transcript of Interpolaonweb.cse.ohio-state.edu/.../06-Interpolation.pdf · 2014. 2. 9. · Interpolaon$terms$...

  • Interpola*on  and    

    Curves    and    

    Mo*on  on  a  Path  

  • Problem  statement  

    •  How  can  we  construct  smooth  paths?  – Define  smoothness  in  terms  of  geometry  – What  is  the  input?  – Where  does  the  input  come  from?  • Pathfinding  data  • Animator  specified  

  • Interpola>on  

    •  Interpola*on:  The  process  of  inser>ng  in  a  series  an  intermediate  number  or  quan>ty  ascertained  by  calcula>on  from  those  already  known.  

    •  Examples  – Compu>ng  midpoints  – Curve  fiHng  

  • Interpola>on  terms  

    •  Order  (of  the  polynomial)  – Linear  – Quadra>c  – Cubic  

    •  Dimensions  – Bilinear  (data  in  a  2D  grid)  – Trilinear  (data  in  a  3D  grid)  

  • Linear  interpola>on  

    •  Given  two  points,  P0  and  P1  in  2D  •  Parametric  line  equa>on:  

    P  =  P0  +  t  (P1  –  P0)  ;  OR  X  =  P0.x  +  t  (P1.x  –  P0.x)  Y  =  P0.y  +  t  (P1.y  –  P0.y)  

    •  t  =  0    Beginning  point  P0  •  t  =  1    End  point  P1  

  • Linear  interpola>on  •  Rewrite  the  parametric  equa>on  

    P  =  (1-‐t)P0  +  t  P1  ;  OR  X  =  (1-‐t)P0.x  +  t  P1.x  

    Y  =  (1-‐t)P0.y  +  t  P1.y  

    •  Formula  is  equivalent  to  a  weighted  average    •  t  is  the  weight  (or  percent)  applied  to  P1  •  1  –  t  is  the  weight  (or  percent)  applied  to  P0  

    •  t  =  0.5    Midpoint  between  P0  and  P1  =  Pmid  •  t  =  0.25    1st  quar>le  =  midpoint  between  P0  and  Pmid  •  t  =  0.75    3rd  quar>le  =  midpoint  between  Pmid  and  P1  

  • Bilinear  interpola>on  process  

    •  Given  4  points  (Q’s)  

    •  Interpolate  in  one  dimension  – Q11  and  Q21  give  R1  – Q12  and  Q22  give  R2  

    •  Interpolate  with  the  results  – R1  and  R2  give  P  

  • Bilinear  interpola>on  applica>on  

    •  Resizing  an  image  

  • Curve  Fi5ng  

    Interpola>on  vs.  approxima>on    

    Polynomial  complexity  

    Con>nuity:  first  degree  (tangen>al)  

    Local  vs.  global  control:  local  

    Informa>on  requirements:  tangents  needed?  

  • Interpola>on  vs.  Approxima>on  

  • Polynomial  complexity:  Cubic  

    Low  complexity    reduced  computa>onal  cost  

    Therefore,  choose  a  cubic  polynomial  

    With  a  point  of  inflec>on,  the  curve  can  match  arbitrary  tangents  at  end  

    points  

  • Con>nuity  orders  C-‐1  discon>nuous   C0  con>nuous  

    C1:  first  deriva>ve  is  con>nuous   C2:  first  and  second  deriva>ves  are  con>nuous  

  • Local  vs.  Global  control  

  • Informa>on  requirements  

    just  the  points  

    tangents  

    interior  control  points  

    just  beginning  and  ending  tangents  

  • Cubic  Bezier  Curve  

    p0

    p1

    p2

    p3

    •  Find  the  point  x  on  the  curve  as  a  func>on  of  parameter  u:  

    x(u) •

  • de  Casteljau  Algorithm  

    •  Describe  the  curve  as  a  recursive  series  of  linear  interpola>ons  

    •  Intui>ve,  but  not  the  most  efficient  form  

  • de  Casteljau  Algorithm  

    p0

    p1

    p2

    p3

    •  Cubic  Bezier  curve  has  four  points  (though  the  algorithm  works  with  any  number  of  points)  

  • de  Casteljau  Algorithm  

    p0

    q0

    p1

    p2

    p3

    q2

    q1

    Lerp  =  linear  interpola>on  

  • de  Casteljau  Algorithm  

    q0

    q2

    q1

    r1

    r0

  • de  Casteljau  Algorithm  

    r1 x

    r0 •

  • Bezier  Curve  

    x •

    p0

    p1

    p2

    p3

  • h8p://en.wikipedia.org/wiki/B%C3%A9zier_curve  

    Bezier  Curve  Anima*on  

  • Cubic  Bezier  

    Curve runs through Pi and Pi+3 with starting tangent PiPi+1 and ending tangent Pi+2Pi+3

  • Controlling  Mo*on  along  p=P(u)    

    Step  2.  Reparameteriza*on  by  arc  length  u  =  U(s)                      where  s  is  distance  along  the  curve  

    p=P(u)

    But segments may not

    have equal length

    Step  1.  vary  u  to  create  points  on  the  curve  

    Step  3.  Speed  control  

    s  =  ease(t)              where  t  is  >me  for  example,  ease-‐in  /  ease-‐out  

  • Reparameterizing  by  Arc  Length  

    Analy>c  Forward  differencing     Supersampling     Adap>ve  approach  Numerically     Adap>ve  Gaussian  

  • Reparameterizing  by  Arc  Length  -‐  supersample  

    1. Calculate a bunch of points at small increments in u

    2. Compute summed linear distances as approximation to arc

    length

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

    Notes

    1. Often useful to normalize total distance to 1.0

    2. Often useful to normalize parametric value for multi-

    segment curve to 1.0

  • index

    u

    Arc Length

    (s)

    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  

  • Speed  Control  

    Time-‐distance  func>on  Ease-‐in  Ease-‐out     Sinusoidal     Cubic  polynomial     Constant  accelera>on  General  distance-‐>me  func>ons  

    time

    distance

  • Time  Distance  Func>on  

    s  =  S(t)  

    s  

    t    the  global                  >me  variable  

    S  

  • Ease-‐in/Ease-‐out  Func*on  

    s  =  S(t)  

    s  

    t  

    S  

    0.0

    0.0

    1.0

    1.0

    Normalize distance and time to 1.0 to facilitate reuse

  • Ease-‐in:  Sinusoidal  

  • Ease-‐in:  Single  Cubic  

  • Ease-‐in:  Constant  Accelera>on  

  • Ease-‐in:  Constant  Accelera>on  

  • Mo>on  on  a  curve  –  solu>on  steps  

    1.  Construct  a  space  curve  that  interpolates  the  given  points  with  piecewise  first  order  con>nuity  

    2.  Construct  an  arc-‐length-‐parametric-‐value  func>on  for  the  curve  

    3.  Construct  >me-‐arc-‐length  func>on  according  to  given  constraints  

    p=P(u)

    u=U(s)

    s=S(t)

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