Bezier and Spline Curves and Surfaces

19
Bezier and Spline Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Transcript of Bezier and Spline Curves and Surfaces

Page 1: Bezier and Spline Curves and Surfaces

Bezier and Spline Curves andSurfaces

Ed AngelProfessor of Computer Science,

Electrical and ComputerEngineering, and Media Arts

University of New Mexico

Page 2: Bezier and Spline Curves and Surfaces

2Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Objectives

• Introduce the Bezier curves and surfaces•Derive the required matrices• Introduce the B-spline and compare it tothe standard cubic Bezier

Page 3: Bezier and Spline Curves and Surfaces

3Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Bezier’s Idea

• In graphics and CAD, we do not usuallyhave derivative data

•Bezier suggested using the same 4 datapoints as with the cubic interpolating curveto approximate the derivatives in theHermite form

Page 4: Bezier and Spline Curves and Surfaces

4Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Approximating Derivatives

p0

p1p2

p3

p1 located at u=1/3 p2 located at u=2/3

3/1

pp)0('p 01

!"

3/1

pp)1('p 23

!"

slope p’(0) slope p’(1)

u

Page 5: Bezier and Spline Curves and Surfaces

5Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Equations

p(0) = p0 = c0p(1) = p3 = c0+c1+c2+c3

p’(0) = 3(p1- p0) = c0p’(1) = 3(p3- p2) = c1+2c2+3c3

Interpolating conditions are the same

Approximating derivative conditions

Solve four linear equations for c=MBp

Page 6: Bezier and Spline Curves and Surfaces

6Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Bezier Matrix

!!!!

"

#

$$$$

%

&

''

'

'=

1331

0363

0033

0001

MB

p(u) = uTMBp = b(u)Tp

blending functions

Page 7: Bezier and Spline Curves and Surfaces

7Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Blending Functions

!!!!!

"

#

$$$$$

%

&

'

'

'

=

u

uu

uu

u

u

3

2

2

3

)1(2

)1(3

)1(

)(b

Note that all zeros are at 0 and 1 which forcesthe functions to be smooth over (0,1)

Page 8: Bezier and Spline Curves and Surfaces

8Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Bernstein Polynomials

•The blending functions are a special caseof the Bernstein polynomials

•These polynomials give the blendingpolynomials for any degree Bezier form

- All zeros at 0 and 1- For any degree they all sum to 1- They are all between 0 and 1 inside (0,1)

)1()!(!

!)(kd uu

kdk

dub

kdk !!

=!

Page 9: Bezier and Spline Curves and Surfaces

9Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Convex Hull Property

• The properties of the Bernstein polynomialsensure that all Bezier curves lie in the convexhull of their control points

• Hence, even though we do not interpolate all thedata, we cannot be too far away

p0

p1 p2

p3

convex hullBezier curve

Page 10: Bezier and Spline Curves and Surfaces

10Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Bezier Patches

Using same data array P=[pij] as with interpolating form

vupvbubvup TBB

T

ijj

i j

i MPM==!!= =

)()(),(3

0

3

0

Patch lies inconvex hull

Page 11: Bezier and Spline Curves and Surfaces

11Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Analysis

• Although the Bezier form is much better than theinterpolating form, we have the derivatives are notcontinuous at join points

• Can we do better?- Go to higher order Bezier

• More work• Derivative continuity still only approximate• Supported by OpenGL

- Apply different conditions• Tricky without letting order increase

Page 12: Bezier and Spline Curves and Surfaces

12Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

B-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 toeach segment

• For cubics, we can have continuity of function,first and second derivatives at join points

• 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

Page 13: Bezier and Spline Curves and Surfaces

13Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Cubic B-spline

!!!!

"

#

$$$$

%

&

''

'

'=

1331

0363

0303

0141

MS

p(u) = uTMSp = b(u)Tp

Page 14: Bezier and Spline Curves and Surfaces

14Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Blending Functions

!!!!!

"

#

$$$$$

%

&

'++

+'

'

=

u

uuu

uu

u

u

3

22

32

3

3331

364

)1(

6

1)(b

convex hull property

Page 15: Bezier and Spline Curves and Surfaces

15Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

B-Spline Patches

vupvbubvup TSS

T

ijj

i j

i MPM==!!= =

)()(),(3

0

3

0

defined over only 1/9 of region

Page 16: Bezier and Spline Curves and Surfaces

16Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Splines and Basis

• If we examine the cubic B-spline from theperspective of each control (data) point,each interior point contributes (through theblending functions) to four segments

•We can rewrite p(u) in terms of the datapoints as

defining the basis functions {Bi(u)}

puBupii )()( !=

Page 17: Bezier and Spline Curves and Surfaces

17Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Basis Functions

2

21

1

1

12

2

0

)1(

)(

)1(

)2(

0

)(

3

2

1

0

+!

+<"+

+<"<"#

#<"#

#<

$$$

%

$$$

&

'

#

+

+

=

iu

iui

iui

iui

iui

iu

ub

ub

ub

ub

uBi

In terms of the blending polynomials

Page 18: Bezier and Spline Curves and Surfaces

18Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

Generalizing Splines

•We can extend to splines of any degree•Data and conditions to not have to givenat equally spaced values (the knots)

- Nonuniform and uniform splines- Can have repeated knots

• Can force spline to interpolate points

•Cox-deBoor recursion gives method ofevaluation

Page 19: Bezier and Spline Curves and Surfaces

19Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

NURBS

•Nonuniform Rational B-Spline curves andsurfaces add a fourth variable w to x,y,z

- Can interpret as weight to give moreimportance to some control data

- Can also interpret as moving to homogeneouscoordinate

•Requires a perspective division- NURBS act correctly for perspective viewing

•Quadrics are a special case of NURBS