
Chapter 1 B ezier curves and Splines This a very incomplete and rough draft, so please read it with caution. Many topics are just skipped, and thereare no pictures at al l. My suggestion is that you skim it quickly and read any sections that appear both relevant and accessible. To study the midterm, you arebetter o concentrating on notes from lectures. A spline curve, or spline surface, is a smo oth curve or surface whichis sp eci ed compactly in terms of a few p oints. Both asp ects of splines of curves are imp ortant. First, the ability to sp ecify a curve with only a few p oints reduces storage requirements and greatly facilitates computer-aided design of curves and surfaces. Second, the commonly used splines gives curves with go o d smo othness prop erties and without undesired oscillations; and, conversely, these splines also allow for isolated p oints where the curve is not smo oth, suchas p oints where the spline has a `corner'. Finally, splines provide us with simple algorithms for nding p oints on the spline curve or surface, and simple criteria for deciding how nely a spline should b e approximated by at patches to get a suciently faithful representation of the spline. Historically, splines were exible strips of wo o d or medal, that were tied into p osition to record a desired curve. Nowadays, a mathematical description is much more useful and more p ermanent, not to mention more amenable to computerization. Nonetheless, some of the terminology of splines p ersists, such as the use of `knots' in B-spline curves. This chapter discusses rst B ezier curves and then uniform and non-uniform B-splines, including NURBS. 1.1 Be zier curves B ezier curves were rst develop ed by automobile designers for the purp ose of describing the shap e of exterior car panels. The original develop er of B ezier curves was P.B ezier of Renault in the 1960's [?]. Slightly earlier, P. de Casteljau at Citroen had indep endently develop ed mathematically equivalent metho ds of de ning spline curves [?]. 1 XX TODO The most common typ e of B ezier curves is the degree3p olynomial curves which are sp eci ed by four p oints, called control points. This is illustrated in Figure 1.1, where a parametric curve Q = Qu is de ned by four control p oints p ; p ; p ; p . The curve starts from p initially in the direction of p , 0 1 2 3 0 1 then curves generally towards p , and ends up at p coming from the direction 2 3 of p . Only the rst and last p oints, p and p , are lie on Q . The other 2 0 3 two control p oints, p and p , in uence the curve: the intuition is that these 1 2 two middle control p oints \pull" on the curve. One can think of Q as b eing a exible, strechable curve that is contrained to start at p , end at p , and in 0 2 the middle is pulled by the two middle control p oints. XX LOTS MORE TO BE WRITTEN HERE XX 1.2 B ezier surfaces XX TO BE WRITTEN XX 1.3 B ezier curves and surfaces in Op enGL 1.3.1 B ezier curves Op enGL has several routines for automatic generation of B ezier curves of any degree. Unfortunately, Op enGL do es not have generic B ezier curve supp ort; instead Op enGL has B ezier curve linked directly to drawing routines, so that the the Op enGL B ezier curve routines can b e used only for drawing. So if you wish to use B ezier curves for other applications such as animation, you cannot use the built-in Op enGL routines. Rather than having a single command for generating B ezier curves, Op enGL has instead separate commands for sp ecifying a B ezier curve from its control p oints and for displaying part of all of the B ezier curve. De ning B ezier curves. To de ne and enable i.e., activate a B ezier curve, the following two Op enGL commands are used: MAP1 VERTEX 3, float u , float u , glMap1fGL min max int stride, int order, float* controlpoints glEnableGL MAP1 VERTEX 3 The values of u and u give the range of u values over which the min max curve is de ned. There are typically set to 0 and 1 . The last parameter p oints to an array of oats which contain the control p oints. Atypical usage would de ne controlpoints as an arrayof x; y ; z values: 2 float controlpoint[ N ][3]; The stride value is the distance in oats from one control p oint to the next; i.e., the i -th control p ointispointed to by controlpoints+ i *stride.For the ab ove de nition of controlpoints, str ide equals 3. The value of order is equal to one plus the degree of the B ezier curve: thus it also equals the numb er of control p oints. Thus, for the usual degree 3 B ezier curves, order equals 4. As we mentioned ab ove, B ezier curves can b e used only for drawing purp oses. In fact, several B ezier curves can b e active at one time to a ect di erent asp ects of the drawn curve, such as its lo cation and color, etc. The rst parameter to glMap1f describ es how the B ezier curve is used when the curve is drawn. GL MAP1 VERTEX VERTEX 3 means that the Bezi er curve is de ning the x; y ; z values of p oint in 3-space, as a function of u . There are several other useful constants that can b e used for the rst parameter. These include GL MAP1 VERTEX 4, which means that we are x; y ; z ; w values of a curve, i.e., a rational B ezier curve. Also, one can use GL MAP1 COLOR 4 as the rst parameter: this means that as the B ezier curve is b eing drawn by the commands describ ed b elow, that color values will b e sp eci ed as a B ezier function of u . The option GL MAP1 TEXTURE COORD 1 works similarly to sp ecify one-dimensional texture co ordinates. See the Op enGL do cumentation for other p ermitted values for this rst parameter. Drawing with B ezier curves. Once the B ezier curve has b een sp eci ed with glMap1f, the curve can b e drawn with the following commands. The most basic way to sp ecify a p oint on the curve is with the command: glEvalCoord1f float u whichmust b e given b etween a glBegin and glEnd. The e ect of the this command is similar to sp ecifying a p oint with glVertex* and, if the appropriate curves are enabled, with glNormal* and glTexCoord* commands. However, the currently active normal and texture co ordinates are not changed by a call to glEvalCoord1. If you use glEvalCoord1f, then you explicitly draw all the p oints on the curve. However, frequently you wanttodraw p oints at equally spaced intervals along the curve and Op enGL has also several commands for drawing an entire curve or a p ortion of curve at once. First, you must tell Op enGL the \grid" or \mesh" of p oints on the curve to b e drawn. This is done with the following command: glMapGrid1fint N , float u , float u ; star t end which tells Op enGL that you wanttodraw N + 1 p oints on the curve equally spaced starting with the value u = u and ending with u = u . It is star t end required that u u u u . min star t end max 3 A call to glMapGrid1f only sets a grid of u values. In order to actually draw the curve, you should call glEvalMesh1GL LINE, int p , int p star t end This causes Op enGL to draw the curve at grid values, letting p range from p to p , and drawing the p oints on the B ezier curve with co ordinates star t end u =Npu + p u =N: star t end The rst parameter, GL LINE tells Op enGL to draw the curve as sequence of straight lines, this the same functionality drawing p oints after a call to glBeginGL LINE STRIP.To draw only the p oints on the curve with- out the connecting lines, use GL POINT instead similar in functionalityto using glBeginGL POINTS. The values of p and p should satisfy star t end 0 p p N . star t end You can also use glEvalPoint1 int p to draw a single p oint from the grid. glEvalPoint1 and glEvalMesh1 are not called from inside glBegin and glEnd. 1.3.2 B ezier patches B ezier patches, or B ezier surfaces, can b e drawn using Op enGL commands analogous to the commands describ e ab ove for B ezier curves. Since the commands are very similar, only very brief descriptions are given of the Op enGL routines for B ezier patches. To sp ecify a B ezier patch, one uses the glMap2f routine: glMap2fGL MAP2 VERTEX 3, float u , float u , int ustride, int uorder, min max float v , float v , int vstride, int vorder, min max float* controlpoints glEnableGL MAP2 VERTEX 3; The controlpoints arrayisnoauorder vorder array and would usually b e sp eci ed by: float controlpointsarray[ N ][ N ][3]; u v In this case, the value vstride would equal 3, and ustride should equal 3N .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages18 Page
-
File Size-