Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Parametric Curves CS 318 Interactive Computer Graphics John C. Hart."— Presentation transcript:

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

2 Linear Interpolation Need to get from point p 0 to point p 1 Define a parametric function p(t) p(0) = p 0, p(1) = p 1 Separate into coordinate functions p(t) = (x(t), y(t)) x(0) = x 0, x(1) = x 1 y(0) = y 0, y(1) = y 1 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 y(t) = y 0 + t(y 1 – y 0 ) = (1-t)y 0 + t y 1 p 0 =(x 0,y 0 ) p 1 =(x 1,y 1 ) x y t x t y

3 Hermite Interpolation From point p 0 along p’ 0 to point p 1 toward p’ 1 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 x’(0) = x’ 0, x’(1) = x’ 1 Need cubic function x(t) = At 3 + Bt 2 + Ct + D x’(t) = 3At 2 + 2Bt + C Solve A = 2x 0 – 2x 1 + x’ 0 + x’ 1 B = -3x 0 + 3x 1 – 2x’ 0 – x’ 1 C = x’ 0, D = x 0 x y x(0) = D = x 0, x’(0) = C = x’ 0 x(1) = A + B + C + D = x 1 A + B = x 1 – x 0 – x’ 0 x’(1) = 3A + 2B + C = x’ 1 3A + 2B = x’ 1 – x’ 0 A= x’ 1 – x’ 0 – 2x 1 + 2x 0 + 2x’ 0 = x’ 1 + x’ 0 – 2x 1 + 2x 0 B= x 1 – x 0 – x’ 0 – x’ 1 – x’ 0 + 2x 1 – 2x 0 = 3x 1 – 3x 0 – x’ 1 – 2x’ 0 p 0 =(x 0,y 0 ) p 1 =(x 1,y 1 ) p’ 0 =(x’ 0,y’ 0 ) p’ 1 =(x’ 1,y’ 1 )

4 Hermite Interpolation From point p 0 along p’ 0 to point p 1 toward p’ 1 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 x’(0) = x’ 0, x’(1) = x’ 1 Need cubic function x(t) = At 3 + Bt 2 + Ct + D x’(t) = 3At 2 + 2Bt + C Solve A = 2x 0 – 2x 1 + x’ 0 + x’ 1 B = -3x 0 + 3x 1 – 2x’ 0 – x’ 1 C = x’ 0, D = x 0 p 0 =(x 0,y 0 ) p 1 =(x 1,y 1 ) x y p’ 0 =(x’ 0,y’ 0 ) p’ 1 =(x’ 1,y’ 1 ) t x t y

5 Hermite Matrix p(t) = (2p 0 – 2p 1 + p’ 0 + p’ 1 )t 3 + (-3p 0 + 3p 1 – 2p’ 0 – p’ 1 )t 2 + p’ 0 t + p 0 (1) p(t) =(2t 3 – 3t 2 + 1)p 0 + (-2t 3 + 3t 2 )p 1 + (t 3 – 2t 2 + 1)p’ 0 + (t 3 – t 2 )p’ 1 p 0 =(x 0,y 0 ) p 1 =(x 1,y 1 ) x y d 0 =(x’ 0,y’ 0 ) d 1 =(x’ 1,y’ 1 ) t p0p0 t p1p1 t p’ 0 t p’ 1 00 0 1 0 1

6 Linear Interpolation Need to get from point p 0 to point p 1 Define a parametric function p(t) p(0) = p 0, p(1) = p 1 Separate into coordinate functions p(t) = (x(t), y(t)) x(0) = x 0, x(1) = x 1 y(0) = y 0, y(1) = y 1 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 y(t) = y 0 + t(y 1 – y 0 ) = (1-t)y 0 + t y 1 p 0 =(x 0,y 0 ) p 1 =(x 1,y 1 ) x y t x t y

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

8 Bernstein Polynomials Defined for any degree B i n (t) = ( n i ) t i (1-t) n-i n choose i ( n i ) = n!/(i!(n – i)!) = ( n i - 1 ) + ( n i - - 1 1 ) Partition of unity –Sum to one for any t in [0,1]  i=0..n B i n (t) = 1 Higher degrees lerps of lower degrees B i n (t) = ( n i ) t i (1-t) n-i = ( n i - 1 ) t i (1-t) n-i + ( n i - - 1 1 ) t i (1-t) n-i = (1-t)B i n-1 (t) + tB i n - - 1 1 (t) B03(t)B03(t) B13(t)B13(t)B23(t)B23(t) B33(t)B33(t) 01/32/31 0 1 x0x0 x1x1 x2x2 x3x3 x(t)=aB 0 3 (t)+bB 1 3 (t)+cB 2 3 (t)+dB 3 3 (t) x(t)x(t)

9 Cubic Bezier Curves Bernstein basis applied to points p(t) =  i ( 3 i ) t i (1-t) 3-i p i Bezier curve specified by four control points including two endpoints Affine invariance: –Let M be a 4x4 transformation –Then M p(t) =  i B i (t) Mp i Curve entirely contained in the convex hull of the control points p0p0 p1p1 p3p3 p2p2 B0(t)B0(t) B1(t)B1(t)B2(t)B2(t) B3(t)B3(t) 01/32/31 0 1

10 Cubic Bezier Matrix p(t)= (1-t) 3 p 0 + 3(1-t) 2 tp 1 + 3(1-t)t 2 p 2 + t 3 p 3 = (1 – 3t + 3t 2 – t 3 )p 0 + (3t – 6t 2 + 3t 3 )p 1 + (3t 2 – 3t 3 )p 2 + t 3 p 3 p0p0 p1p1 p3p3 p2p2 B0(t)B0(t) B1(t)B1(t)B2(t)B2(t) B3(t)B3(t) 01/32/31 0 1

11 Bezier v. Hermite p 1 = p 0 + 3 p’ 0 p 2 = p 3 – 3 p’ 3 Bezier Hermite p0p0 p3p3 p’0p’0 p’3p’3 p2p2 p1p1

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

13 de Casteljau Algorithm Cascading lerps p 01 = (1-t) p 0 + t p 1 p 12 = (1-t) p 1 + t p 2 p 23 = (1-t) p 2 + t p 3 p 012 = (1-t) p 01 + t p 12 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 p0p0 p1p1 p3p3 p2p2 p 01 p 12 p 23 p 012 p 123 p 0123 t 1-t

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

15 B-Spline Basis p(t) = (–1/6t 3 + 1/2t 2 – 1/2t + 1/6)p 0 + ( 1/2t 3 – t 2 + 2/3)p 1 + (–1/2t 3 + 1/2t 2 + 1/2t + 1/6)p 2 + ( 1/6t 3 )p 3 = B 0 (t)p 0 +B 1 (t)p 1 +B 2 (t)p 2 +B 3 (t)p 3 Piecewise cubic approximation of a Gaussian bump function Progressively weights points along spline B0 (t)B0 (t) B1(t)B1(t)B2 (t)B2 (t) B3(t)B3(t) B0(t)B0(t) B1(t)B1(t)B2 (t)B2 (t) B3 (t)B3 (t) p3p3 p2p2 p1p1 p0p0 01010101 t01 2/3 1/6

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

17 Non-Uniform B-Splines Can specify an arbitrary parameter t i at each control point p i Let N = # of polynomial curve segments Parameters contained in a knot vector –Length (N+1) + 2d – 2 –[t 0,t 1,t 2,t 3,…,t N+2d-2 ] –Cubic: [t 0,t 1,t 2,t 3,…,t N+4 ] 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 plotted) –Need d–1 “extra” knots at the beginning and end of the knot vector p1p1 p2p2 p4p4 p6p6 p7p7 p5p5 p3p3 t=1.3 t=4 t=3.4 p0p0 knot vector: [0,.5, 1.3, 3.4, 4, 5.1, 6, 7] N=3 curve segments d=3 (cubic) t=5.1

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

19 N i,0 (t) N i+1,0 (t) N i+2,0 (t) N i+3,0 (t) N i,1 (t) N i+1,1 (t) N i+2,1 (t) N i,2 (t) N i+1,2 (t) N i,3 (t) Recursion Higher degree basis can be constructed from lower degree bases N i,0 (t) = 1 if t i  t < t i+1 0 otherwise Non-uniform B-splines constructed using a systolic array knot vector: [0,.5, 1.3, 3.4, 4, 5.1, 6, 7] N=3 curve segments d=3 (cubic)

20 Example knot vector: [0,.5, 1.3, 3.4, 4, 5.1, 6, 7] 01234567 N i,0 (t) = 1 when t i  t < t i+1 else 0 N0N0 N1N1 N2N2 N3N3 N4N4 N5N5 N6N6 d=0 t d=1 d=2 d=3

21 de Boor Algorithm Evaluate at t = 2 p 4,3 = 1/3 p 4,2 + 2/3 p 3,2 p 4,2 = 1/4 p 4,1 + 3/4 p 3,1 p 3,2 = 2/4 p 3,1 + 2/4 p 2,1 p 4,1 = 1/4 p 4,0 + 3/4 p 3,0 p 3,1 = 2/5 p 3,0 + 3/5 p 2,0 p 2,1 = 2/4 p 2,0 + 2/4 p 1,0 knot vector: [0 0 0 0 1 4 5 5 5 5] Cubic (d = 3, k = 4) p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p 2,1 p 3,1 p 4,1 p 3,2 p 4,2 p 4,3

22 Rational B-Splines Quotient of B-splines p(t) = (  w i p i N i (t))/(  w i N i (t)) B-spline in 4-D homogenous space Projected back into 3-D via homogenous division Weight values affect “tension” near control points Weights can also define control points at infinity from Tom Sederberg’s notes on Computer Aided Geometric Design

23 Conic Sections Circles, ellipses, arcs Only approximated by polynomial parametrics Modeled precisely by rational parametrics Can be rational Bezier, rational B- spline, etc. p 2 = (0,1) w 2 = 1 p 1 = (1,1) w 1 = 0 p 0 = (1,0) w 0 = 1 x = (cos  t/2, sin  t/2)


Download ppt "Parametric Curves CS 318 Interactive Computer Graphics John C. Hart."

Similar presentations


Ads by Google