Download presentation
Presentation is loading. Please wait.
1
Introduction to Computer Graphics with WebGL
Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
2
Bezier and Spline Curves and Surfaces
Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
3
Objectives Introduce the Bezier curves and surfaces
Derive the required matrices Introduce the B-spline and compare it to the standard cubic Bezier Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
4
Bezier’s Idea (http://fr.wikipedia.org/wiki/Courbe_de_Bézier)
In graphics and CAD, we do not usually have derivative data Bezier suggested using the same 4 data points as with the cubic interpolating curve to approximate the derivatives in the Hermite form Bezier worked for Renault as an engineer (from 1933 to 1975) ; He developed UNISURF in 1971. Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
5
Approximating Derivatives
p2 located at u=2/3 p1 located at u=1/3 slope p’(1) slope p’(0) p3 p0 u Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
6
Equations Interpolating conditions are the same p(0) = p0 = c0
p(1) = p3 = c0+c1+c2+c3 Approximating derivative conditions p’(0) = 3(p1- p0) = c0 p’(1) = 3(p3- p2) = c1+2c2+3c3 Solve four linear equations for c and we obtain c=MBp Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
7
Bezier Matrix p(u) = uT c = uT MBp = b(u)T p blending functions
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
8
Blending Functions Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
9
Bernstein Polynomials
The blending functions are a special case of the Bernstein polynomials These polynomials give the blending polynomials for any degree Bezier form All zeros of the functions are at 0 and 1 For any degree they all sum to 1 They are all between 0 and 1 inside (0,1) Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
10
Convex Hull Property The properties of the Bernstein polynomials ensure that all Bezier curves lie in the convex hull of their control points Hence, even though we do not interpolate all the data, we cannot be too far away p1 p2 convex hull Bezier curve p3 p0 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
11
Bezier Patches Using same data array P=[pij] as with interpolating form Patch lies in convex hull Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
12
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Analysis Although the Bezier form is much better than the interpolating form, we STILL have that the derivatives are not continuous at join points Need to align controls points to achieve continuity (see 3rd example in Can we do better? Go to higher order Bezier More work Derivative continuity still only approximate Apply different conditions Tricky without letting order increase Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
13
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
B-Splines Splines : Basis splines: use the data at p=[pi-2 pi-1 pi pi+1]T to define curve only between pi-1 and pi Allows us to apply more continuity conditions to each segment For derivation, see pages of reference manual Cost is 3 times as much work for curves Add one new point each time rather than three For surfaces, we do 9 times as much work Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
14
Cubic B-spline p(u) = uTMSp = b(u)Tp
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
15
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Cubic B-spline Example : (select B-spline and create 5 points…) Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
16
Blending Functions p(u) = uTMSp = b(u)Tp convex hull property
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
17
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Joining B-Splines Move the knots to see the effects Middle knots can change the shape of 4 segments End knots affects 1, 2 or 3 segments Superimposing the first three knots forces the curve to begin at that position Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
18
B-Spline Patches defined over only 1/9 of region
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
19
Splines and Basis If we examine the cubic B-spline from the perspective of each control (data) point, each interior point contributes (through the blending functions) to four segments We can rewrite p(u) in terms of the data points as defining the basis functions {Bi(u)} Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
20
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Splines and Basis Let us study the 4th point of the curve shown in For the leftmost segment, b3(u) multiplies that point. For the next segment, b2(u) multiplies that point. For the 3rd, it is b2(u). For the 4th, it is b0(u). Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
21
Basis Functions In terms of the blending polynomials (see link on slide 16) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
22
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
To start a B-spline: We can repeat the first node 3 times We can use a phantom control point (see Figure 5.4 in - move P1 or P5 to see the effect) We do similarly, at the end of a B-spline. (try repeating last node in Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
23
Generalizing Splines We can extend to splines of any degree
Data and conditions do not have to be given at equally spaced values (the knots) Nonuniform and uniform splines Can have repeated knots Can force spline to interpolate points Cox-deBoor recursion gives method of evaluation Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
24
NURBS Nonuniform Rational B-Spline curves and surfaces add a fourth variable w to x,y,z Can interpret as weight to give more importance to some control data Can also interpret as moving to homogeneous coordinate Requires a perspective division NURBS act correctly for perspective viewing Quadrics are a special case of NURBS Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
25
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
NURBS First, we note that B-spline basis functions can be computed using recurrence relations : (t0, t1, …ti, tn+k) are called the “knots” and can be selected to fit particular needs Equal spacing of the knots generates “regular” B-spline functions Uneven spacing generates NURBS (in the “second to last” figure of the link above, try moving knots above the basis functions). Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
26
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
NURBS Figure 7 : uniform basis functions Figure 10 : non-uniform basis functions (obtained by modifying uniform basis functions – using the knots…) In NURBS, repeating 3 times the first and the last three knots brings the curve right on the first and last control points (see slides 18 and 39 in Try it using a java applet in Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.