Parametric Curves & Surfaces
Total Page:16
File Type:pdf, Size:1020Kb
Parametric Curves & Surfaces Parametric / Implicit Parametric Curves (Splines) Parametric Surfaces Subdivision Marc Neveu ± LE2I ± Université de Bourgogne 1 2 ways to define a circle Parametric Implicit F>0 F=0 u F<0 xu=r.cosu F x ,y= x2 y2−r 2 {yu=r.sinu 2 - Representations of a curve (2D) Explicit : y = y(x) y=mx+b y=x2 must be a function (x->y) : important limitation Parametric : (x,y)=x(u),y(u)) (x,y) = (cos u, sin u) + easy to specify - hidden additional variable u : the parameter Implicit : f(x,y) = 0 x2+y2-r2=0 + y can be a multivalued function of x - difficult to specify, modify, control 3 - Representations of curves and surfaces (3D) x2+y2+z2-1=0 · Implicit Representation x-y=0 · Curves : f(x,y,z) = 0 and g(x,y,z) =0 · Surfaces : f(x,y,z) =0 · Parametric Representation · Curves : x = f(t), y = g(t), z = h(t) · Surfaces : x = f(u,v), y = g(u,v), z = h(u,v) · Cubic Curve : 3 2 · x= axt + bxt + cxt + dx 3 2 · y = ayt + byt + cyt + dy 3 2 · z = azt + bzt + czt + dz 4 xt =x R.cos2.t 0 Helicoid : yt =y R.sin2 .t 0 u∈ℝ ,v∈ℝ = {z t z0 p.t x=v.cosu y=v.sinu Helix passing by (x ,y ,z ), radius R, 0 0 0 {z=u pitch p 5 Representation of Surfaces Parametric Surface ± (x(u,v),y(u,v),z(u,v)) Ex : plane, sphere, cylinder, torus, bicubic surface, sweeping surface parametric functions allow moving onto the surface modifying u and v (eg in nested loops) Easy for polygonal meshes, etc Terrific for intersections (ray/surface), testing points inside/border, etc Implicit Surface F(x,y,z)=0 Ex : plane, sphere, cylinder, torus, blobs Terrific for visualization Easy for intersections, morphing Subdivision Surface Defined by a control mesh and a recursive subdivision Easy for interactive conception 6 Visualization of Parametric Curves View of functions x(t), y(t), z(t) Parametric 3D curve, without t Parameterization of a curve: infinite number of solutions (with (un-)constant speed, (dis-)continuous, by arc length,...) 7 Parametric Curves : summary Why piecewise polynomials, why cubics ? Principal Curves : Hermite splines, Bezier splines, Catmull-Rom splines, natural cubic splines, B-Splines, NURBS Surfaces 8 Building Curves Representing is not building Goals for building curves : Smooth, ªthin plateº curve Use control points Like ship builders : Weights or joints to handle a flexible latte (spline) The latte passes by the joints and has a ªsmoothº shape Mathematically ? 9 2 types of curves Interpolation Approximation The curve passes by the control pointsThe curve is attracted by control points 10 Before we start... A few mathematical bases.... 11 Let E3 be an Euclidian space Parametric curve : 2 n Qt =[ xt , y t, zt ]= X 0X1 t X2 t ... Xn t eg : Qt =X 0 X1 t barycentric combination BC of E3 : point of E3 / n BC=∑ i Pi i=0 n ∑ i=1 {i=0 convex combination BC / ≥ ∀ i 0 i 12 Barycentric Coordinates area p, b, c areaa , p ,c areaa, b, p u= v= w= p=u av bw c areaa ,b ,c areaa ,b ,c areaa ,b ,c b uvw=1 a b c 1 x x c areaa , b, c= a b c 2 y y y ∣1 1 1 ∣ b p c u : v : w pa pc a p c u + v : w u : w a 13 Convex Hull The set of all the convex combinations of a set G of points of E3 is the convex hull of G A particular case of a convex combination : the linear interpolation of 2 distinct points a and b : Q(t) = (1 t) a + t b 14 Parameterization Segment [a, b] is defined by the affine application [0,1] → E3 ∀ t ∈ ℝ x ∈ E3 We can change the parametric space without altering [a, b] in E3 u−u ℝ t= a ub−ua u u u a b ℝ E3 0 t 1 a b u −u u−u15 x t=1 t at b xu= b a a b ub−ua ub ua Polynomial Interpolation Let P0, ..., Pn and t0, ..., tn the corresponding parameter values. ± Interpolation consists in finding a curve P(t) passing by all the points ± Compute a polynomial satisfying the interpolation constraints : P(ti) = Pi (i=0..n) · Theorem : ± There exists a unique polynomial P of degree ≤ n such that P(ti) = Pi (i=0..n) with fixed Pi and ti 16 Polynomial Interpolation A polynomial of degree n interpolates a curve in (n+1) points Ex : 2nd degree curve to interpolate 3 points 2 x(t) = at +bt+c in (t1,x1), (t2,x2), (t3,x3) 3 linear equations with 3 unknowns to find out a,b,c Lagrange interpolation curve « sinuous », global, unstable => low degree polynomials and smooth curve simulate an elastic thread (thin plate) 17 Lagrange Interpolation Data : n + 1 points (with x distinct by 2). i x0 , y0 ,x1 ,y1 .... xn ,yn Lagrange polynomials n x− x j x−x0 x−x j 1 x− xn L j x= ∏ = ... x−x j −1 iver x j −x j −1 ... i= 0, i≠ j x j −xi x j− x0 x j −x j 1 x j −x n Two properties : ∀ j degreeL j = n L j xi = j ,i ie L j x j =1 ∧ L j xi =0 if j≠i n th 18 L x = ∑ y j L j x Is the unique n degree polynomial verifying L xi = yi ∀ i j=0 Aitken's Algorithm P1 P3 2 P0 1 P 1 P0 1 1 P2 3 P0 P0 2 19 P1 P2 Aitken's Algorithm 1 ti 1−t t−ti Recursive Proof : r=1 Pi t = Pi Pi1 i=0,..., n−1 t i1−t i t i1−ti -1 r-1 Suppose proposition true for r-1 : P0r interpolates Pi, i=0,...,r-1 and P1 interpolates Pi, i=1,...,r r tr −t r−1 t−t 0 r −1 P0 t = P0 t P1 t t r −t 0 t r −t 0 n = ∗ n−1 ∗ n−1 = It interpolates all data points : for t=t0 P0 t 0 1 P0 t 0 0 P1 t 0 P0 Same for t=tn r−1 r −1 Under assumption P0 t i =P1 ti =Pi i=1,...,r−1 r Since weights sum to 1 P0 t i =Pi ∀ i Generalization r ti r −t r −1 t−t i r −1 Pi t = Pi t Pi1 t i=0,... ,n−1 ∧ r=1,20... ,n t ir −ti t ir −ti Splines : piecewise polynomial curves An elastic thread under constraints minimizes its flexion energy ~ integral of the squared curvature ~ second derivative => distribute curvature «in the best way as possible» Spline = piecewise polynomial (several low degree polynomials) The more frequent : cubics Minimize the second derivative 21 Piecewise Polynomials Spline : several combined pieces « correct » combination Position, tangency and curvature continuity Position continuityPosition and tangency continuity 22 - 9 Piecewise linear polynomials Linear Interpolation p0 p1 pt=1 −t p0 t p1 2 basis functions 1 1 −1 1 t = 1 p0 = p t t ∑ Bi t pi 0 1 0 1 i =O p1 23 Bézier Curve 1 −2 1 P 0 0 0 P1 Pt= t 2 t 1 0 −2 2 0 P1 1 0 0 0 P 2 0 2 0 2 −2 1 P B t P t t 0 0 0 P0 P t = −2 2 2 0 = 2 0 0 t t P1 B1 t P1 P0 2 2 t P 0 B2 t P0 2 2 2 n n 0 Bernstein polynomials Pt = ∑ Bi t Pi i =O 24 Degree n=2 Bézier Curve 1 0 0 P0 t = 1−t P0t P1 1 0 0 P1 t = 1−t P1 tP2 0 P1 2 1 1 P0 t = 1−t P 0t P1 2 P t 1 1 0 ( ) P1( t ) 2 0 0 P0( t ) P0 t = 1−t 1−tP 0 tP1 − 0 0 t 1 t P 1 tP2 P0 0 0 P2 2 2 0 0 2 0 P0 t = 1−t P0 2t 1−t P1t P2 n 2 0 2 0 2 0 n 0 = B0 P0B1 P1 B 2 P 2 = ∑ Bi Pi = i 0 degree n = 2 25 Bézier Blending functions Degree 1 Degree 2 1,2 (1-t)2 t2 1 0,8 1 1 0,6 B1 B 0 2t(1-t) 0,4 t 0,2 0 1 0 1 2 3 4 5 6 7 8 9 10 11 26 Bézier Curve P0 0 1 P1 2 1 2 1 1 P ( t ) P ( t ) P ( t ) P t P ( t ) 0 1 1 0 1( ) 0 P0( t ) 0 0 P0 P P0 0 0 2 P2 27 Subdivision of Bézier curves Each half is a Bézier curve General de Casteljau algorithm 28 - 26 Bézier Curve 29 Cubic Bézier Curve 0 −1 3 −3 1 P0 0 3 2 3 −6 3 0 P Pt = t t t 1 1 −3 3 0 0 0 P2 1 0 0 0 0 P3 3 0 3 0 1−t P 0 B0 t P0 − 2 P 0 B 3t P0 Pt = 3t 1 t 1 = 1 1 2 − 0 3 0 3t 1 t P 2 B2 t P2 3 t P 0 B 3t P0 3 3 3 30 Bézier Blending Functions 3 B0 ( t) 3 B3 (t) B3 t 1 ( ) 3 B2 ( t) 31 Bézier Curve 32 Bezier General form n n Bn t =∑ B i tPi i=0 with B nt= n 1−t n−i t i i i 1 1 1 B.