parametric curves
play

Parametric Curves CS 318 Interactive Computer Graphics John C. - PowerPoint PPT Presentation

Parametric Curves CS 318 Interactive Computer Graphics John C. Hart Linear Interpolation p 1 =( x 1 , y 1 ) Need to get from point p 0 to point p 1 y Define a parametric function p ( t ) p (0) = p 0 , p (1) = p 1 Separate into


  1. Parametric Curves CS 318 Interactive Computer Graphics John C. Hart

  2. Linear Interpolation p 1 =( x 1 , y 1 ) • Need to get from point p 0 to point p 1 • y Define a parametric function p ( t ) p (0) = p 0 , p (1) = p 1 • Separate into coordinate functions p ( t ) = ( x ( t ), y ( t )) p 0 =( x 0 , y 0 ) x (0) = x 0 , x (1) = x 1 y (0) = y 0 , y (1) = y 1 x • Interpolate p ( t ) = p 0 + t ( p 1 – p 0 ) = (1- t ) p 0 + t p 1 x ( t ) = x 0 + t ( x 1 – x 0 ) = (1- t ) x 0 + t x 1 x y y ( t ) = y 0 + t ( y 1 – y 0 ) = (1- t ) y 0 + t y 1 t t

  3. Hermite Interpolation p 1 =( x 1 , y 1 ) • From point p 0 along p ’ 0 to point p 1 toward p ’ 1 • y Define a parametric function p ( t ) p (0) = p 0 , p (1) = p 1 p’ (0) = p ’ 0 , p’ (1) = p ’ 1 • Separate into coordinate functions x (0) = x 0 , x (1) = x 1 p ’ 0 =( x ’ 0 , y ’ 0 ) p 0 =( x 0 , y 0 ) x ’(0) = x ’ 0 , x ’(1) = x ’ 1 x x ’(0) = C = x ’ 0 x (0) = D = x 0 , • Need cubic function x (1) = A + B + C + D = x 1 x ( t ) = At 3 + Bt 2 + Ct + D A + B = x 1 – x 0 – x ’ 0 x ’( t ) = 3 At 2 + 2 Bt + C x ’(1) = 3 A + 2 B + C = x ’ 1 • Solve 3 A + 2 B = x ’ 1 – x ’ 0 A = 2 x 0 – 2 x 1 + x ’ 0 + x ’ 1 = x ’ 1 – x ’ 0 – 2 x 1 + 2 x 0 + 2 x ’ 0 A = x ’ 1 + x ’ 0 – 2 x 1 + 2 x 0 B = -3 x 0 + 3 x 1 – 2 x ’ 0 – x ’ 1 = x 1 – x 0 – x ’ 0 – x ’ 1 – x ’ 0 + 2 x 1 B C = x ’ 0 , D = x 0 – 2 x 0 = 3 x 1 – 3 x 0 – x ’ 1 – 2 x ’ 0

  4. Hermite Interpolation p 1 =( x 1 , y 1 ) • From point p 0 along p ’ 0 to point p 1 toward p ’ 1 • y Define a parametric function p ( t ) p (0) = p 0 , p (1) = p 1 p’ (0) = p ’ 0 , p’ (1) = p ’ 1 • Separate into coordinate functions x (0) = x 0 , x (1) = x 1 p ’ 0 =( x ’ 0 , y ’ 0 ) p 0 =( x 0 , y 0 ) x ’(0) = x ’ 0 , x ’(1) = x ’ 1 x • Need cubic function x ( t ) = At 3 + Bt 2 + Ct + D x ’( t ) = 3 At 2 + 2 Bt + C x y • Solve A = 2 x 0 – 2 x 1 + x ’ 0 + x ’ 1 t t B = -3 x 0 + 3 x 1 – 2 x ’ 0 – x ’ 1 C = x ’ 0 , D = x 0

  5. Hermite Matrix p 1 =( x 1 , y 1 ) y p ( t ) = (2 p 0 – 2 p 1 + p ’ 0 + p ’ 1 ) t 3 + (-3 p 0 + 3 p 1 – 2 p ’ 0 – p ’ 1 ) t 2 + p ’ 0 t + d 0 =( x ’ 0 , y ’ 0 ) p 0 =( x 0 , y 0 ) p 0 (1) x      1 1 2 2 1 1 p 0        3 3 2 1 p       p 0 p 1   3 2 1 p ( ) t t t t 1      0 0 1 0 p ' 0     0     0 1 0 0 0 p ' 1 t t p’ 0 p’ 1 (2 t 3 – 3 t 2 + 1) p (t) = p 0 + (-2 t 3 + 3 t 2 ) p 1 + 0 0 ( t 3 – 2 t 2 + 1) p ’ 0 + ( t 3 – t 2 ) p ’ 1 t t

  6. Linear Interpolation p 1 =( x 1 , y 1 ) • Need to get from point p 0 to point p 1 • y Define a parametric function p ( t ) p (0) = p 0 , p (1) = p 1 • Separate into coordinate functions p ( t ) = ( x ( t ), y ( t )) p 0 =( x 0 , y 0 ) x (0) = x 0 , x (1) = x 1 y (0) = y 0 , y (1) = y 1 x • Interpolate p ( t ) = p 0 + t ( p 1 – p 0 ) = (1- t ) p 0 + t p 1 x ( t ) = x 0 + t ( x 1 – x 0 ) = (1- t ) x 0 + t x 1 x y y ( t ) = y 0 + t ( y 1 – y 0 ) = (1- t ) y 0 + t y 1 t t

  7. Interpolating Interpolations n ( t ) = (1- t ) B i n -1 ( t ) + tB i n - 1 ( t ) B i - 1 = 2 ( t ) = (1-t) B 0 1 ( t ) B 0 + = 2 ( t ) = (1- t ) B 1 1 ( t ) + t B 0 1 ( t ) B 1 = 2 ( t ) = t B 1 1 ( t ) B 2

  8. 3 ( t ) 3 ( t ) B 0 B 3 Bernstein Polynomials 1 3 ( t ) B 2 3 ( t ) B 1 • Defined for any degree n ( t ) = ( n i ) t i (1- t ) n - i B i • n choose i 0 0 1/3 2/3 1 i ) = n !/( i !( n – i )!) = ( n ( n - 1 ) + ( n - 1 1 ) i i - • Partition of unity 3 ( t )+ bB 1 3 ( t )+ cB 2 3 ( t )+ dB 3 3 ( t ) x ( t ) =aB 0 – Sum to one for any t in [0,1] x 1 S i =0.. n B i n ( t ) = 1 x ( t ) • Higher degrees lerps of lower degrees x 3 n ( t ) = ( n i ) t i (1- t ) n - i B i x 0 = ( n - 1 ) t i (1- t ) n - i + ( n - 1 1 ) t i (1- t ) n - i i i - n -1 ( t ) + tB i n - 1 ( t ) = (1- t ) B i - 1 x 2

  9. p 1 Cubic Bezier Curves p 2 • Bernstein basis applied to points p ( t ) = S i ( 3 i ) t i (1- t ) 3- i p i • Bezier curve specified by four control p 0 points including two endpoints p 3 • Affine invariance: – Let M be a 4x4 transformation B 0 ( t ) B 3 ( t ) 1 – Then M p ( t ) = S i B i ( t ) M p i B 1 ( t ) B 2 ( t ) • Curve entirely contained in the convex hull of the control points 0 0 1/3 2/3 1

  10. p 1 Cubic Bezier Matrix p 2 p ( t ) = (1- t ) 3 p 0 + 3(1- t ) 2 t p 1 + 3(1- t ) t 2 p 2 + t 3 p 3 = (1 – 3 t + 3 t 2 – t 3 ) p 0 + (3 t – 6 t 2 + 3 t 3 ) p 1 + (3 t 2 – 3 t 3 ) p 2 + t 3 p 0 p 3 p 3       1 3 3 1 p 0      3 6 3 0 p B 0 ( t ) B 3 ( t )         3 2 1 p ( ) t t t t 1   1     3 3 0 0 p 2         1 0 0 0 p B 1 ( t ) B 2 ( t ) 3 0 0 1/3 2/3 1

  11. p ’ 3 Bezier v. Hermite p 3 p 2 p 1 = p 0 + 3 p ’ 0 p 2 = p 3 – 3 p ’ 3 • Bezier       1 1 3 1 p 0      2 6 3 0 p         3 2 1 p ( ) t t t t 1       p ’ 0 3 3 0 0 p p 1 p 0 2         1 0 0 0 p 3 • Hermite      2 2 1 1 p 0        3 3 2 1 p         3 2 3 p ( ) t t t t 1      0 0 1 0 p ' 0         1 0 0 0 p ' 3

  12. Building Bernsteins n ( t ) = (1- t ) B i n -1 ( t ) + tB i n - 1 ( t ) B i - 1 = 2 ( t ) = (1-t) B 0 1 ( t ) B 0 + = 2 ( t ) = (1- t ) B 1 1 ( t ) + t B 0 1 ( t ) B 1 = 2 ( t ) = t B 1 1 ( t ) B 2

  13. de Casteljau p 1 p 12 Algorithm p 2 p 012 1- t • Cascading lerps p 123 p 0123 p 01 = (1- t ) p 0 + t p 1 p 01 p 12 = (1- t ) p 1 + t p 2 t p 23 p 23 = (1- t ) p 2 + t p 3 p 0 p 012 = (1- t ) p 01 + t p 12 p 3 p 123 = (1- t ) p 12 + t p 23 p 0123 = (1- t ) p 012 + t p 123 • Subdivides curve at p 0123 – p 0 p 01 p 012 p 0123 – p 0123 p 123 p 23 p 3 • Repeated subdivision converges to curve

  14. p 1 B-Spline Segment p 2 t =0 p ( t ) = ( – 1/6 p 0 +1/2 p 1 – 1/2 p 2 +1/6 p 3 ) t 3 + t =1 ( 1/2 p 0 – p 1 +1/2 p 2 ) t 2 + ( – 1/2 p 0 + 1/2 p 2 ) t + p 0 1/6 p 0 +2/3 p 1 +1/6 p 2 p 3 but makes more sense as… p ( t ) = ( – 1/6 t 3 + 1/2 t 2 – 1/2 t + 1/6) p 0 + – t 2 + 2/3) p 1 + ( 1/2 t 3 ( – 1/2 t 3 + 1/2 t 2 + 1/2 t + 1/6) p 2 + ( 1/6 t 3 ) p 3

  15. B-Spline Basis ( t ) B 1 ( t ) B 2 2/3 p ( t ) = ( – 1/6 t 3 + 1/2 t 2 – 1/2 t + 1/6) p 0 + – t 2 + 2/3) p 1 + ( 1/2 t 3 1/6 ( t ) B 0 B 3 ( t ) ( – 1/2 t 3 + 1/2 t 2 + 1/2 t + 1/6) p 2 + ( 1/6 t 3 ) p 3 0 t 1 ( t ) p 1 + B 2 ( t ) p 2 + B 3 ( t ) p 3 = B 0 ( t ) p 0 + B 1 • Piecewise cubic approximation of a Gaussian bump function ( t ) B 2 B 1 ( t ) • Progressively weights ( t ) B 3 B 0 ( t ) points along spline p 3 p 2 p 1 p 0 0 1 0 1 0 1 0 1

  16. p 0 Uniform B-Splines p 1 t =0 t =1 p 2 • p 3 t =2 Notation p 4 – d = degree of polynomial t =3 – k = order of polynomal = d + 1 p 5 t =4 – E.g. cubic: d = 3, k = 4 p 6 t =5 Segment i  t < i +1 uses k = d + 1 control • points p i to p i + d p 7 p (t) = S j 3 = 0 B j ( t mod 1) p i + j n  •  Normalized basis function N i , d ( t ) p ( t ) N ( t ) p i , k i N i , d ( t ) = B floor( t - i ) ( t mod 1) if i  t < i + d +1 •  i 0 – Otherwise its zero p 1 p 2 p 3 p 4 p 5 p 6 • Knot vector – e.g. [0,1,2,3,4,5,6,7] – in general [ t 0 , t 1 ,…, t n + k ] t 0 1 2 3 4 5

  17. Non-Uniform knot vector: [0, .5, 1.3, 3.4, 4, 5.1, 6, 7] N =3 curve segments B-Splines d =3 (cubic) p 0 • Can specify an arbitrary parameter t i at each p 1 control point p i • Let N = # of polynomial curve segments p 2 t =1.3 • Parameters contained in a knot vector t =3.4 p 3 – Length ( N +1) + 2 d – 2 p 4 t =4 – [ t 0 , t 1 , t 2 , t 3 ,…, t N +2 d -2 ] p 5 – Cubic: [ t 0 , t 1 , t 2 , t 3 ,…, t N +4 ] t =5.1 p 6 • Domain of resulting curve is [ t d -1 , t N + d -1 ] – Cubic: domain = [ t 2 , t N+2 ] (segments [ t 0 , t 1 ], [ t 1 , t 2 ], [ t N +2 , t N +3 ] and [ t N +3 , t N +4 ] aren’t p 7 plotted) – Need d –1 “extra” knots at the beginning and end of the knot vector

  18. Knot Multiplicity • Knot multiplicity = # of times a given knot 2 nd derivative appears in the knot vector discontinuity • Continuity = d – multiplicity • Cubic example – All knots unique – 2 nd derivative continuity – Multiplicity two – 1 st derivative cont. 1 st derivative discontinuity – Multiplicity three – 0 th derivative cont. – Multiplicity four – discontinuous • Endpoint interpolation – Knots of multiplicity d +1 at beginning and (0 th derivative) end of knot vector discontinuity – e.g. [0, 0, 0, 0, 1, 2, 3, 3, 3, 3]

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend