reading
play

Reading Required: Angel 10.1-10.3, 10.5.2, 10.6-10.7 Optional - PDF document

Reading Required: Angel 10.1-10.3, 10.5.2, 10.6-10.7 Optional Bartels, Beatty, and Barsky. An Introduction to Splines for use in Computer Graphics and Parametric curves Geometric Modeling , 1987. Farin. Curves and Surfaces for CAGD:


  1. Reading Required: � Angel 10.1-10.3, 10.5.2, 10.6-10.7 Optional � Bartels, Beatty, and Barsky. An Introduction to Splines for use in Computer Graphics and Parametric curves Geometric Modeling , 1987. � Farin. Curves and Surfaces for CAGD: A Practical Guide , 4th ed., 1997. cse457-15-curves 1 cse457-15-curves 2 Mathematical curve Curves before computers representation The “loftsman’s spline”: � Explicit y = f ( x ) • what if the curve isn’t a function, e.g., a circle? � long, narrow strip of wood or metal � shaped by lead weights called “ducks” � gives curves with second-order continuity, usually Used for designing cars, ships, airplanes, etc. � Implicit g ( x , y ) = 0 But curves based on physical artifacts can’t be replicated well, since there’s no exact definition of what the curve is. Around 1960, a lot of industrial designers were working on this problem. � Parametric ( x ( u ), y ( u )) Today, curves are easy to manipulate on a computer and are used for CAD, art, animation, • For the circle: x( u ) = r ⋅ cos 2 π u … y( u ) = r ⋅ sin 2 π u cse457-15-curves 3 cse457-15-curves 4

  2. Parametric polynomial curves de Casteljau’s algorithm We’ll use parametric curves, Q(u)= ( x(u),y(u) ) , Recursive interpolation: where the functions are all polynomials in the parameter. n = k x ( u ) a u ∑ k = k 0 n = k y ( u ) b u ∑ k = k 0 Advantages: � easy (and efficient) to compute � infinitely differentiable We’ll also assume that u varies from 0 to 1. What if u =0? What if u =1? cse457-15-curves 5 cse457-15-curves 6 de Casteljau’s algorithm, cont’d Finding Q(u) Let’s solve for Q (u): Recursive notation: = + 1 V (1- ) u V uV 0 0 1 = + 1 V (1- ) u V uV 1 1 2 = + 1 V (1- ) u V uV 2 2 3 = + 2 1 1 V (1- ) u V uV 0 0 1 = + 2 1 1 V (1- ) u V uV 1 1 2 = + 2 2 Q u ( ) (1- ) u V uV 0 1 = + + + 1 1 1 1 (1- )[(1- ) u u V uV ] u [(1- ) u V uV ] 0 1 1 2 = + + + + (1- )[(1- ){(1- ) u u u V uV } u {(1- ) u V uV }] ... 0 1 1 2 = + + + 3 2 2 3 1 (1- ) u V 3 (1- ) u u V 3 u (1- ) u V u V What is the equation for ? V 0 1 2 3 0 cse457-15-curves 7 cse457-15-curves 8

  3. Finding Q(u) (cont’d) Bernstein polynomials The coefficients of the control points are a set of In general, functions called the Bernstein polynomials: n n   n = − − i n i Q u ( ) u (1 u ) V = ∑ Q u ( ) b u V ( ) ∑   i i i i = i 0   = i 0 where “ n choose i ” is: For degree 3, we have:   = n n ! −   i ( n i i )! ! = −   3 b u ( ) (1 u ) 0 = − 2 b u ( ) 3 (1 u u ) 1 This defines a class of curves called Bézier = − 2 b u ( ) 3 u (1 u ) curves . 2 = 3 b u ( ) u 3 What’s the relationship between the number of control points and the degree of the polynomials? Useful properties on the interval [0,1]: � each is between 0 and 1 � sum of all four is exactly 1 (a.k.a., a “partition of unity”) These together imply that the curve lies within the convex hull of its control points. cse457-15-curves 9 Displaying Bézier curves Subdivide and conquer How could we draw one of these things? It would be nice if we had an adaptive algorithm, that would take into account flatness. DisplayBezier( V0, V1, V2, V3 ) begin DisplayBezier( V0, V1, V2, V3 ) if ( FlatEnough( V0, V1, V2, V3 ) ) begin Line( V0, V3 ); if ( FlatEnough( V0, V1, V2, V3 ) ) else Line( V0, V3 ); Subdivide(V[]) ⇒ L[], R[] else DisplayBezier( L0, L1, L2, L3 ); something; DisplayBezier( R0, R1, R2, R3 ); end; end; cse457-15-curves 11 cse457-15-curves 12

  4. Testing for flatness Curve desiderata Bézier curves offer a fairly simple way to model parametric curves. But, let’s consider some general properties we would like curves to have… Compare total length of control polygon to length of line connecting endpoints: − + − + − V V V V V V < + ε 0 1 1 2 2 3 1 − V V 0 3 cse457-15-curves 13 cse457-15-curves 14 Local control Interpolation One problem with Béziers is that every control Bézier curves are approximating . The curve point affects every point on the curve (except the does not (necessarily) pass through all the control endpoints). points. Each point pulls the curve toward it, but other points are pulling as well. Moving a single control point affects the whole curve! We’d like to have a curve that is interpolating , that is, that always passes through every control point. We’d like to have local control , that is, have each control point affect some well-defined neighborhood around that point. cse457-15-curves 15 cse457-15-curves 16

  5. Continuity Bézier curves � � splines � � We want our curve to have continuity : there Bézier curves have C-infinity continuity on their shouldn’t be any abrupt changes as we move interiors, but we saw that they do not exhibit local along the curve. control or interpolate their control points. There are nested degrees of continuity: It is possible to define points that we want to interpolate, and then solve for the Bézier control C -1 : C 0 : points that will do the job. But, you will need as many control points as interpolated points -> high order polynomials -> wiggly curves. (And you still won’t have local control.) Instead, we’ll splice together a curve from individual Béziers segments, in particular, cubic Béziers. C 1 , C 2 : C 3 , C 4 , …: We call these curves splines . When splicing Béziers together, the first thing we need to worry about is continuity where one curve segment meets the next… cse457-15-curves 17 cse457-15-curves 18 Ensuring C 0 continuity The C 0 Bezier spline Suppose we have a cubic Bézier defined by How then could we construct a curve passing ( V 0 , V 1 , V 2 , V 3 ), and we want to attach another through a set of points P 1 … P n ? curve ( W 0 , W 1 , W 2 , W 3 ) to it, so that there is C 0 continuity at the joint. 0 : = C Q (1 ) Q (0) V W What constraint(s) does this place on ( W 0 , W 1 , W 2 , W 3 )? We call this curve a spline . The endpoints of the Bezier segments are called joints . In the animator project, you will construct such a curve by specifying all the Bezier control points directly. cse457-15-curves 19 cse457-15-curves 20

  6. 1 st derivatives at the endpoints Ensuring C 1 continuity For degree 3 (cubic) curves, we have already Suppose we have a cubic Bézier defined by shown that we get: ( V 0 , V 1 , V 2 , V 3 ), and we want to attach another curve ( W 0 , W 1 , W 2 , W 3 ) to it, so that there is C 1 = + + + 3 2 2 3 Q u ( ) (1- ) u V 3 (1- ) u u V 3 u (1- ) u V u V continuity at the joint. 0 1 2 3 = 0 C : Q (1 ) Q (0) We can expand the terms in u and rearrange to V W get: = 1 ' ' C Q : (1 ) Q (0) V W = − + − + + 3 Q u ( ) ( V 3 V 3 V V u ) 0 1 2 3 − + + − + + 2 (3 V 6 V 3 ) V u ( 3 V 3 ) V u V What constraint(s) does this place on 0 1 2 0 1 0 ( W 0 , W 1 , W 2 , W 3 )? What then is the first derivative when evaluated at each endpoint, u =0 and u =1? ′ = Q (0) ′ = Q (1 ) cse457-15-curves 21 cse457-15-curves 22 The C 1 Bezier spline Catmull-Rom splines How then could we construct a curve passing If we set each derivative to be one half of the through a set of points P 1 … P n ? vector between the previous and next controls, we get a Catmull-Rom spline . This leads to: = V P 0 1 = + 1 V P ( P P - ) 1 1 6 2 0 = 1 V P - ( P P - ) 2 2 6 3 1 = V P 3 2 We can specify the Bezier control points directly, or we can devise a scheme for placing them automatically… cse457-15-curves 23 cse457-15-curves 24

  7. 2 nd derivatives at the endpoints Tension control Finally, we’ll want to develop C 2 splines. To do We can give more control by exposing the derivative scale factor as a parameter: this, we’ll need second derivatives of Bezier curves. = V P 0 1 τ = + V P ( P P - ) Taking the second derivative of Q ( u ) yields: 1 1 3 2 0 ′′ τ = + = Q (0) 6( V -2 V V ) V P - ( P P - ) 0 1 2 2 2 3 3 1 = + -6[( V V - ) ( V V - )] = V P 1 0 1 2 3 2 ′′ = + Q (1 ) 6( V -2 V V ) 1 2 3 The parameter τ controls the tension. Catmull- = + -6[( V V - ) ( V V - )] 2 3 2 1 Rom uses τ = 1/2. Here’s an example with τ =3/2. cse457-15-curves 25 cse457-15-curves 26 Ensuring C 2 continuity Building a complex spline Suppose we have a cubic Bézier defined by Instead of specifying the Bézier control points ( V 0 , V 1 , V 2 , V 3 ), and we want to attach another themselves, let’s specify the corners of the A- curve ( W 0 , W 1 , W 2 , W 3 ) to it, so that there is C 2 frames in order to build a C 2 continuous spline. continuity at the joint. = 0 C : Q (1 ) Q (0) V W = 1 ' ' C Q : (1 ) Q (0) V W = 2 '' '' C : Q (1 ) Q (0) V W What constraint(s) does this place on ( W 0 , W 1 , W 2 , W 3 )? These are called B-splines . The starting set of points are called de Boor points . cse457-15-curves 27 cse457-15-curves 28

Recommend


More recommend