bezier and spline curves and surfaces

Post on 11-Nov-2021

21 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Bezier and Spline Curves andSurfaces

Ed AngelProfessor of Computer Science,

Electrical and ComputerEngineering, and Media Arts

University of New Mexico

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

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

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

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

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

Bezier Matrix

!!!!

"

#

$$$$

%

&

''

'

'=

1331

0363

0033

0001

MB

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

blending functions

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)

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 !!

=!

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

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

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

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

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

Cubic B-spline

!!!!

"

#

$$$$

%

&

''

'

'=

1331

0363

0303

0141

MS

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

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

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

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 )()( !=

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

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

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

top related