<<

Chapter 1

B ezier 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 , 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 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 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 .

v

Note that the order's one plus the degree's of the B ezier curves are allowed

to b e di erent for the u and v directions.

Other useful values for the rst parameter to glMap2f include

GL MAP2 VERTEX 4 for rational B ezier patches, GL MAP2 COLOR 4 to sp ecify

colors, and GL MAP2 TEXTURE COORD 2 to sp ecify texture co ordinates. Generally,

one wants the texture co ordinates s; t to just b e equal to u and v . This is

done by sp ecifying a degree one order =2B ezier curve, for instance, 4

float texpts[8]=f0,0, 0,1, 1,0, 1,1g;

glMap2fGL MAP2 TEXTURE COORD 2,0,1,4,2,0,1,2,2,texpts;

glEnableGL MAP2 TEXTURE COORD 2;

The normals to the patchmay b e sp eci ed bya B ezier formula using

GL MAP2 NORMAL as the rst parameter to glMap2f;however, this is rarely

useful since usually one wants the true normals to the B ezier surface. Op enGL

will calculate these true normals for you according to the formula XX, if you

give the command glEnableGL AUTO NORMAL.

To display the B ezier patch, or a p ortion of the B ezier surface, the following

Op enGL commands are available:

glEvalCoord2ffloat u , float v ;

glMapGrid2fint N , int u , int u ,

u star t end

int N , int v , int v ;

v star t end

glEvalMesh2GL FILL, int p , p , q , q ;

star t end star t end

glEvalPoint2int p , int q ;

LINE or GL POINTS. The rst parameter to glEvalMesh2 may b e also GL

1.4 B-splines

B-splines provide a metho d of sp ecifying a single curve with many control

p oints. They has many advantages over B ezier curves, esp ecially in allowing a

great deal of exibility in sp ecifying characteristics of the curve. In addition, it

is p ossible to translate B ezier curves into B-splines and vice-versa.

We shall rst treat the case of uniform B-splines, and then the more general

case of non-uniform B-splines and NURBS.

1.4.1 Uniform B-splines

Before intro ducing the general de nition of B-splines in the next section 1.4.2,

this section will intro duce one of the simplest and most useful cases of B-splines,

namely the uniform B-splines of degree3. Such a B-spline is de ned with a

sequence p ; p ;p ;:::;p of control points.Together with a set of blending

0 1 2 n

or  blending functions B u;:::;B u , this parametrically de nes a

1 n

curve Qu:

n

X

Qu= B u  p 3  u  n +1:

i i

i=0

We de ne these blending functions b elow: it is imp ortant to note that they

are not the same as the Bernstein p olynomials used in the de nition of B ezier

curves.

An imp ortant prop erty of the blending functions B is that B u will equal

i i

zero if either u  i or i +4  u. That is to say, the supp ort of B uis

i 5

XX TODO

Figure 1.1: A uniform B-spline curve with seven control p oints.

XX TODO

Figure 1.2: The blending functions for a uniform, degree 3 B-spline

the op en interval i; i + 4 . In particular, this means that we can rewrite the

formula for Quas

j

X

Qu= Bup provided u 2 [j; j +1], 3  j  n 1.1

i i

i=j3

since the terms omitted from the summation are all zero. This means that the

B-spline has local control; namely, if a single control p oint p is moved then,

i

then only the segments Q ; Q ; Q ; Q of the B-spline are changed. The

i i+1 i+2 i+3

rest of the B-spline remains xed.

Figure 1.4.1 shows an example of a B-spline curve Qu de ned with

seven control p oints and de ned for 3  u  7. The curve Q is split into

four sub curves Q ;:::Q where Q is the p ortion of Qu corresp onding

3 6 3

to 3  u  4, Q is the p ortion with 4  u  5 , etc. More generally,

4

Q u=Qu for i  u  i +1.

i

The intuition of how the curve Qu b ehaves is as follows. At the b eginning

of Q , the p oint on the curve Q where u = 3 is b eing pulled strongly towards

3

the p oint p and less strongly towards the p oints p and p . The other

1 0 2

p oints on Q are calculated as a weighted average of p ; p ; p ; p . The other

3 0 1 2 3

segments are similar: namely, the b eginning of Q is b eing pulled strongly

i

towards p , the end of Q is b eing pulled strongly towards p , and the

i2 i i1

p oints interior to Q are computed as a weighted average of the four control

i

p oints p ; p ; p ; p . Finally, the segments Q are degree 2 p olynomials;

i3 i2 i1 i i

thus, Q is piecewise a degree 3 p olynomial. Furthermore, Q has continuous

second derivatives everywhere is it de ned.

These prop erties of the curve Q all dep end on prop erties of the blending

functions B . Figure 1.4.1 shows the graphs of the functions B u | the

i i

functions are de ned to equal zero outside their domain shown with their

graphs. It is immediate from the graphs of the blending functions that

equation 1.1 is correct. Also, it is now clear that a control p oint p a ects

i

only the four segments Q ; Q ; Q ; Q .

i i+1 i+2 i+3

The blending functions should have the following prop erties:

a The blending functions are translates of each other, i.e.,

B u=Bui:

i 0

b The functions B u are piecewise degree 3 p olynomials. The breaks

i

between the pieces o ccur only at integer values of i . 6

2

c The functions B uhave continuous second-derivatives, i.e., are C -

i

continuous.

d The blending functions are a partition of unity, i.e.,

X

B u= 1:

i

i

for 3  u  7 . Or for 3  u  n when there are n control p oints. This

prop erty is necessary for p oints on the B-spline curve to b e de ned as

weighted averages of the control p oints.

e B u  0 for all i and u . Therefore, B u  1 for all u .

i i

f  B u = 0 for u  i and for i +4  u.

i

Because of conditions a and f , the blending functions will b e fully

sp eci ed once we sp ecify the function B u on the domain [0; 4] . For this

0

purp ose, we will de ne four functions R , R , R , R for 0  u  1by

0 1 2 3

R u = B u Ru = B u+2

0 0 2 0

R u = B u+1 R u = B u+3

1 0 3 0

Thus the function R are the translates of the four segments of B to the

i 0

interval [0; 1] . These functions are degree 3 p olynomialsby condition b. In

fact, we claim that the following choices for the R functions work and this is

i

the unique way to de ne these functions:

3

1

u R u =

0

6

2 2

1

3u +3u +3u+1 R u =

1

6

1 3 2

R u = 3u 6u +4

2

6

3

1

R u = 1 u

3

6

We claim that if the functions R ;R ;R ;R are used to de ne the blending

0 1 2 3

functions, then the blending functions have continuous second derivatives and

condition c holds. To prove this, we need to know that the curves also are

continuous and have continuous rst-derivaties, so that the second-derivatives of

the curves are de ned. All these facts are proved by noticing that when the R

i

functions are pieced together, their values and their rst- and second-derivatives

match up. Namely,

0 00

R 0 = 0 R 0=0 R 0=0

0

0 0

0 0 00 00

R 1 = R 0 R 1 = R 0 R 1 = R 0

0 1

0 1 0 1

0 0 00 00

R 1 = R 0 R 1 = R 0 R 1 = R 0

1 2

1 2 1 2

0 0 00 00

R 1 = R 0 R 1 = R 0 R 1 = R 0

2 3

2 3 2 3

0 00

R 1 = 0 R 1=0 R 1=0

3

3 3

Exercise: Graph the four functions R on the interval [0; 1] .

i 7

Exercise: Give formulas for the rst and second derivatives of the R

i

2

functions. Verify the 15 conditions needed for the C -continuity of the blending

function B .

0

P

Exercise: Verify that R u=1. Prove that R u > 0 for i =0;1;2;3

i i

i

and for all u 2 0; 1 .

Exercise: Verify that R u=R 1 u and that R u= R 1 u . Show

0 3 1 2

that this means that uniform B-splines have left-right symmetry, in that if the

order of the control p oints is reversed, then the curve Q is unchanged except

for b eing tranversed in the opp osite direction.

Exercise: Describ e the e ect of rep eating control p oints in degree 3 uniform

B-splines. Qualitatively describ e the curve obtained if a control p ointis

rep eated, for instance, if p = p .

3 4

Secondly, supp ose p = p = p . Show that the curve Q interp olated the

3 4 5

p oint p with Q6 . Further show that the segments Q and Q are straight

3 5 6

lines.

1.4.2 Non-uniform B-splines

The uniform B-splines of the previous section were de ned so that curve Q

was a ected by the control p oints so that Qi is close to or at least, strongly

a ected by the control p oint P . These splines are called \uniform" since

i2

the values u = i , where the curve p oint Qi are most strongly a ected bya

i

control p oint, are evenly spaced at integer values. A non-uniform spline is one

where the are values u where Qu is most strongly a ected by some control

i

p oint are not uniformly spaced. Of course, the uniform B-splines are just the

sp ecial case of non-uniform B-splines where u = i .

i

We de ne a knot vector to b e a sequence u s  u  u    u 

0 1 2 m+k1

u of real numb ers, called knots. A knot vector is used with a sequence of

m+k

m + 1 control p oints, p ; p ;:::;p to de ne a non-uniform B-spline curve.

0 1 m

The b est way to get a qualitative understanding of how knots work is to consider

a few examples. You should think of the spline curve as b eing a exible and

streachable curve: the exibility of the curve is limited and thus the curve

resists b eing sharply b ent. he curve is parameterized by u values and we think

of u as measuring the time sp ent traversing the length of the curve. The control

p oints are tied to the curve with a knots b eing placed at the p ositions u = u

i

along the curve; you should mentally think of the knot b eing a strechy string

attached to the curveat u and tied also to the control p oint p . These knots

i i

pull on the spline and the spline settles down into a smo oth curve.

It is p ossible for knots to b e rep eated as u = u . If a knot p osition

i i+1

o ccurs twice, i.e., if u

i1 i i+1

a ected extra strongly by the corresp onding control p oint, p and the

i+1

control p oint p will just b e ignored. If a knot p osition o ccurs three times,

i

with u

i1 i i+1 i+2 i+3

will interp olate the p oint p and will generally have a \corner" at p and

i+2 i+2 8

XX TODO

thus not b e G -continuous. If a knot p osition o ccurs four times in a degree 3

1

curve, then the curve will actually b ecome discontinuous! Thus knots which

rep eat four times are usually used only at the b eginning or end of the knot

vector.

All these b ehaviors are exhibited in the examples in Figure 1.4.2.

Next, we give the Cox-de Bo or mathematical de nition of non-uniform

B-spline blending functions. So far, all of examples have b een for degree 3

splines, but it now convenient to generalize to degree k 1 splines, which are

also called order k splines. Assume the knot vector u  u    u has

0 1 n

b een xed. The blending functions B for order k splines are de ned by

i;k

induction on k  1 as follows. First, let



1 if u  u< u

i i+1

B u=

i;1

0 otherwise.

There is one minor exception to the ab ove de nition to include the very last

p oint u = u in the domain of the functions: namely,we let B u = 1 for

n n1;1

u  u  u . In this way, the theorems stated b elow hold also for u = u .

n1 n n

Second, for k  1,

uu u u

i i+k+1

B u= B u+ B u:

i;k +1 i;k i+1;k

u u u u

i+k i i+k +1 i+1

When multiple knots o ccur, some of the denominators ab ovemay b e zero: we

adopt the convention that 0=0 = 0 and a=00 = 0 . Since B u will b e

i;k

identically zero when u = u see the next paragraph, this means that any

i+k k

term with denominator equal to zero may b e ignored.

The form of the Cox-de Bo or recursive formulas for the blending functions

immediately implies that the functions B are piecewise degree k 1

i;k

p olynomials and that the breaks b etween pieces o ccur at the knots u . Secondly,

i

it is easy to prove, by induction on k  2 , that the function B have supp ort

i;k

in [u ;u ] , i.e., B u=0 for u< u and for From these considerations, it

i i+k i;k i

follows that the de nition of the blending function B dep ends only on the

i;k

knots u ;u ;:::;u .

i i+1 i+k

TO DO: AN EXAMPLE OR TWO

Theorem 1 Let u  u    u be a knot vector. Then the blending

0 1 n

functions B , for 0  i  n k , satisfy the fol lowing properties.

i;k

1 B has support in [u ;u ] for al l k  2:

i;k i i+k

2 B u  0 for al l u .

i;k

P

nk

3 B u=1, for al l u such that u  u  u .

i;k k 1 nk +1

i=0 9

Pro of As discussed ab ove, conditions 1 and 2 are readily proved by

induction on k . Condition 3 is also proved by induction on k ,by the

following argument. The base case, with k = 1 is obviously true. For the

induction step, assume u  u  u :

k nk

nk 1

X

B u=

i;k +1

i=0

nk1

X

u u u u

i+k+1 i

= B u+ B u

i;k i+1;k

u u u u

i+k i i+k +1 i+1

i=0

nk2

X

u u u u +u u

0 i i+k

= B u+ B u

0;k i;k

u u u u

k 0 i+k i

i=1

u u

n

+ B u

nk 1;k

u u

n n

nk1

X

= 0+ 1  B u+0

i;k

i=1

= 0:

The rst zero in the next to last line ab ove is just ed by the fact that u  u

k

and by 1. 2

The imp ortance of conditions 2 and 3 is that they allow the blending

functions to b e used as co ecients of control p oints to givea weighted average

of control p oints. To de ne an order k degree k 1  B-spline curve, one needs

n = m + k knot p ositions and m control p oints p ;:::;p . Then the B-spline

0 m

curve equals

m

X

Qu= B up

i;k i

i=0

for u  u  u . The b ounded interval of supp ort given in condition 1

k 1 nk +1

means that

j

X

Qu= B up

i;k i

i=jk+1

provided u  u  u and u

j j +1 j j+1

local control over the B-spline curve, as changing a control p oint only a ects

k segments of the B-spline curve.

We next discuss the smo othness prop erties of a B-spline curve. Since a

B-spline consists of pieces which are degree k 1 p olynomials, it is certainly

1

continuous and C -continuous everywhere, except p ossible at knot p ositions.

If there are no rep eated knots and if k>1 , then the curve is in fact continuous

k2

everywhere in its domain and, even more, the curveis C -continuous

everywhere in its domain. For instance, a degree 3 B-spline has its second

derivatives de ned and continuous everywhere in its domain. 10

Nowwe consider the case of rep eated knots. Wesay that a knot has

multiplicity p if it o ccurs p times in the knot vector. Since the knots are

ordered, these p o ccurences must b e b e consecutivevalues in the knot vector,

i.e., wehave

u

i1 i i+1 i+p1 p

In this case, the curve will have its k p 1 -th derivative de ned and continuous

at u = u .For instance, a degree 3 B-spline will have continuous rst derivative

i

at a twice rep eated knot p osition, but will b e only continuous at a knot p osition

of multiplicity 3. In the latter case, the curve will generally have a \corner" or

\b end" at that knot p osition. A B-spline curve of degree 3 can ne discontinuous

at a knot p osition of multiplicity four.

The ability to rep eat knots and make the curvehave fewer continuous

derivatives is imp ortant for the usefulness of B-splines since it allows a single

curve to include b oth smo oth p ortions and sharply b ending p ortions.

We combine the ab ove assertions ab out the smo othness of B-splines into the

next theorem.

Theorem 2 Let the knot u have multiplicity p . Then the curve Qu has

i

continuous k p 1 -th derivative at u = u .

i

We shall prove this theorem from the next two lemmas. The rst lemma,

whichisinteresting in its own right, gives formulas for the rst derivatives of

the blending functions.

Lemma 3 Fix a knot vector and let l  1 .IfB has a rst derivative at

i;k +1

u , then

k k

0

B u= B u B u:

i;k i+1;k

i;k +1

u u u u

i+k i i+k +1 i+1

Pro of of Lemma 3. It will suce to prove the lemma for the case where u is

not one of the knot p ositions. This is b ecause the functions B and B have

i;k i+1;k

+

well-b ehaved limits at knot p ositions. In particular, b oth lim ! u B u

u i;k

j

and lim ! u B u b oth exist, and similarly for B . This is enough to

u i;k i+1;k

j

imply that if the lemma holds for all values of u which are not knot p ositions

and if B has a rst derivativeat u=u , then the derivativeof B is

i;k +1 j i;k +1



continuous at u = u .

j

So supp ose u is not a knot p osition. We prove the lemma by induction

on k . The base case, k = 1 , is immediate from the de nition of B , since

i;2

B u and B are either zero or the constant one in a neighb orho o d of

i;k i+1;k

u . It remains to prove the induction step where k>1 . By taking the rst

derivative of the Cos-de Bo or de nition of the B-spline basis functions, wehave

B u

i;k

0 0

u = u B + u u u u B

i i+k i

i;k +1 i;k

u u

i+k i



This uses the following fact from real analysis: If a function f has a derivativeata

0 0

p oint u , and if the limit L = lim f v  exists, then L = f u.

+

v !u 11

B u u u

i+1;k i+k +1

0

+ B u:

i+1;k

u u u u

i+k +1 i+1 i+k +1 i+1

0 0

Expanding B and B u with the induction hyp othesis yields that

i;k i+1;k

0

B u equals

i;k +1

B u

uu i;k

k 1 k 1

i

+ B u B u

i;k1 i+1;k1

u u u u u u u u

i+k i i+k i i+k1 i i+k i+1

u u B u

i+k+1 i+1;k

k 1 k 1

+ B u B u :

i;k1 i+2;k1

u u u u u u u u

i+k+1 i+1 i+k+1 i+1 i+k i+1 i+k+1 i+2

Using the identity

u u u u u u u u

i+k +1 i i+1 i;k

= + ;

u u u u u u u u

i+k +1 i+1 i+k i i+k +1 i+1 i+k i

which is easily proved noting that the two fractions on the right are each

obtained by subtracting the corresp onding terms on the left from one, and

0

some algebra, we get that B u equals

i;k +1

h i

B u

u u

uu i;k

i+k k 1

i

+ B u + B u

i;k1 i+1;k1

u u u u u u u u

i+k i i+k i i+k1 i i+k i+1

h i

B u

uu u u

i+1;k

i+1 i+k+1 k 1

+ B u B u :

i;k1 i+2;k1

u u u u u u u +u

i+k+1 i+1 i+k+1 i+1 i+k i+1 i+k+1 i+2

Now the Cox-de Bo or formulas de ning B and B are identical to the

i;k i+1;k

expressions in the square brackets, and from this, we get

k k

0

B B u B u: u=

i;k i+1;k

i;k +1

u u u u

i+k i i+k +1 i+1

which proves Lemma 3. 2

We wish to use Lemma 3 to prove Theorem 2 by induction on k . The next

lemma contains what is needed for the base case of the induction pro of.

Lemma 4 Let k  1 . Suppose that u = u

i i+k 1 i+k

B u= 1: lim

i;k

+

u!u

i

Dual ly, suppose u

i i+1 i+k

lim B u=B =1:

i;k i;k

u!u

i+1

Pro of The lemma is proved by induction on k . It is immediate from the

Cox-de Bo or de nition in the base case k =1. For the induction step, the

recursive case of the Cox-de Bo or de nition of B is

i;k

uu u u

i i+k

B u= B u+ B u:

i;k i;k 1 i+1;k 1

u u u u

i+k1 i i+k i+1

From u u = 0 and the conventions ab out 0=0 , the lemma follows

i+k 1 i

immediately from the induction hyp othesis applied to B u.

i+1;k 1

The argument for the dual case is completely similar. 2 12

We are now ready to prove Theorem 2. It is certainly enough to prove the

following statement: If u has multiplicity p , then B has continuous

i j;p+s+1

s -th derivativeat u=u for all j  0 and s  0 . This statement is proven

i

by holding u and its multiplicity xed and using induction on s . The base

i

case, s = 0 , is a direct consquence of Lemma 4. The induction step is a simple

application of Lemma 3. Q.E.D. Theorem 2

1.4.3 Knot insertion

An imp ortant to ol for the practical interactive use of B ezier curves is the

technique of knot insertion, which allows one to add a new knot to a B-spline

curve without changing the curve, or its degree. For instance, when editting a

B-spline curve with a CAD program, one may wish to insert additional knots in

order to b e able to make further adjustments to a curve. Adding the additional

knots in the area of the curve that needs adjustment allows more exibilityin

editting the curve. Knot insertion also allows the multiplicity of a knot to b e

increased, which a ects the smo othness of the curve at that p oint. A second

use of knot insertion is to convert a B-spline curveinto a series of B ezier curves,

as we shall see in the next section.

There are commonly used two metho ds for knot insertion. The Bohm

metho d allows a single knot a time to b e inserted into a curve[?,?], and the

Oslo metho d allows multiple knots to b e inserted at once [?, ?]. We discuss only

the Bohm metho d here: of course, multiple knots may b e inserted by iterating

the Bohm metho d.

Supp ose Qu is an degree k B-spline curve, de ned with knot vector

[u ;:::;u + k + 1] and with control p oints P ;:::;P . We wish to insert

0 m 0 m

0 0

a new knot p osition u where u  u  u , and then cho ose new control

s s+1

p oints so that the curve Qu remains unchanged.

0 0

The new knot vector is denoted [u ;:::;u ] where, of course,

0

m+k+2

8

u if i  s

<

i

0

0

u = u if i = s +1

i

:

0

u if i>s+1.

i1

The metho d of cho ose the new control p oints is less obvious, since wemust b e

sure not to change the curve. The Bohm algorithm gives the following de nition

of the control p oints:

8

P if i  s k +1

>

i

>

<

0 0

u u u u

i+k i

0

P =

P + P if s k +1

i i+1

i

>

u u u u

i+k i i+k i

>

:

P if i>s

i1

0

Theorem 5 Suppose k  1 and let Q u be the degree k B-spline curve de ned

0 0 0 0

with the knot vector [u ;:::;u ] and control points P ;:::P +1. Then

0 0 m

m+k+1

0

Qu=Qu for al l u .

Pro of XXXX PROOF TO BE WRITTEN 13

1.4.4 B ezier and B-spline curves

Wenow discuss metho ds for translating B ezier curves b etween B-spline curves.

These metho ds are degree p erserving in that they will preserve the a degree k

B ezier curveinto a degree k B-spline, and vice-versa. Of course, there is a bit

of a mismatch: a B ezier curve consists of a single degree k curve, sp eci ed by

k + 1 control p oints. A B-spline curve consists of series of pieces, each piece

a degree k p olynomial. Accordingly, the translation b etween B-spline curves

and B ezier curves will transform a series of degree k pieces that join together

to make a single curve. Such a series of curve pieces can b e viewed as either a

single B-spline curve or as a collection of B ezier curves.

First, we consider the problem of converting a single B ezier curveinto a

B-spline curve. Supp ose wehave a degree 3 B ezier curve Qu de ned with

control p oints p ; p ; p ; p , de ned over the range 0  u  1 . In order to

0 1 2 3

construct a de nition of this curve as a B-spline curve with the same control

p oints we let [0; 0; 0; 0; 1; 1; 1; 1] b e the knot vector and keep control p oints

as p ; p ; p ; p . It can b e veri ed by direct computation that the B-spline

0 1 2 3

curve is in fact the same curve Qu as the B ezier curve. In fact, wehave the

following general theorem.

Theorem 6 Let k  1 and Qu beadegree k B ezier curve de nedbycontrol

points p ;:::;p . Then Qu is identical to the degree k B-spline curve

0 k1

de ned with the same control points over the knot vector consisting of the knot 0

with multiplicity k +1 fol lowed by the knot 1 also with multiplicity k +1.

In order to prove this theorem, let B b e the basis functions for the

i;k +1

B-spline with the knot vector [0; ;0;1;;1] . Then we claim that

k

i k 1

B = 1 u u : 1.2

i;k +1

i

The righthand side of this equation is just the same as the Bernstein

p olynomials used to de ne B ezier curves, so the theorem follows immediately

from equation 1.2. Equation 1.2 is easy to proveby induction on k , and we

leave the pro of to the reader. 2

The most useful cases of the previous theorem are when k = 2 and k =3.

The k = 2 case is frequently used for de ning conic sections, including circles

via B ezier curves or B-splines. In the k = 2 case, a degree 2 B ezier curve with

the three control p ; p ; p is equivalent to the degree 2 B-spline curve with

0 1 2

knot vector [0; 0; 0; 1; 1; 1] and with the same three control p oints.

Often one wants to combine two or more B ezier curves into a single B-spline

curve. For instance, supp ose one has a degree 2 B ezier curves Q u and

0

0 0 0

Q u de ned with control p oints p ; p ; p and p ; p ; p . By Theorem ??,

1 0 1 2

0 1 2

these two curves are equivalent to the degree 2 B-spline curve with knot vector

0

[0; 0; 0; 1; 1; 1; 2; 2; 2] and with the eight control p oints p ;:::;p . However,

0

3

0

usually the twoB ezier curves form a single continuous curve, i.e., p = p .

3

0

In this case, the twoB ezier curves are the same as the B-spline curve with

0 0

; p . Note knot vector [0; 0; 0; 1; 1; 2; 2; 2] and with control p oints p ; p ; p ; p

0 1 2

1 2 14

tXXTODO

Figure 1.3: Twoways to de ne circular arcs with rational B ezier curves without

control p oints at in nity.

that one knot p osition and the duplicate control p ointhave b een omitted. The

fact that this construction works is proved by the calculation in the two next

exercises.

Exercise: Calculate the degree 2 blending functions for the knot vector

[0; 0; 0; 1; 1; 2; 2; 2] . Show that the results are the degree 2 Bernstein p olynomials

and the degree 2 Bernstein p olynomials translated to the interval [1; 2] .

Exercise: Let Qu, 0  u  2 , b e the B-spline curve de ned with knot

vector [0; 0; 0; 1; 1; 2; 2; 2] and control p oints P ;:::;P . Let Q u, 0  u  1,

0 4 1

b e de ned with knot vector [0; 0; 0; 1; 1; 1] and control p oints P ;P ;P . Let

0 1 2

Q u, 1  u  2 , b e de ned with knot vector [1; 1; 1; 2; 2; 2] and control p oints

2

P ;P ;P . Prove that the curve Qu is the union of the curves Q u and

2 3 4 1

Q u.

2

The construction in these exercises can b e generalized in several ways.

First, if one has three degree 2 B ezier curves which form a single continuous

curve, then they are equivalent to a degree 2 B-spline curve with knot vector

[0; 0; 0; 1; 1; 2; 2; 3; 3; 3]. This generalizes to allow expressing any continuous

curve which consists of anynumberofB ezier as a single B-spline curve. Second,

the construction generalizes to other degrees: for instance, a continuous curve

which consists of two degree 3 B ezier curves is the same as the degree 3 B-spline

curve that has knot vector [0; 0; 0; 0; 1; 1; 1; 2; 2; 2; 2] and has the same seven

p oints as its control p oints. We will leave the pro ofs of these statements to the

reader.

Any B-spline curve can b e split into a sequence of B ezier curves. XXX

a General principles. XXX

b Knot insertion. XXX

1.4.5 Rational splines and NURBS

XXX

Preserved under p ersp ective transformations to o.

Rational curves - equivalenttoweighting for p oints not at in nity.

Conic sections, esp ecially circles.

Exercise: Prove that the following rational degree 2 B ezier curve de nes



the 90 arc of the unit circle in the plane from the p oint1;0 to 0; 1 .

The knot vector is [0; 0; 0; 1; 1; 1] and the control p oints are P =1;0;1 ,

0

p p p

P =1= 2;1= 2;1= 2 and P =0;1;1 . See gure 1.4.5 for this and the

1 2

next exercise. 15

XX TODO

Figure 1.4: De ning the Catmull-Rom spline segment from p to p .

i i+1

Exercise: Prove that the following rational degree 2 B ezier curve de nes the

p p



3=2; 1=2 to  3=2; 1=2 . The 120 arc of the unit circle in the plane from 

p

knot vector is [0; 0; 0; 1; 1; 1] and the control p oints are P = 3=2;1=2;1 ,

0

p

P =0;2;1=2 and P = 3=2;1=2;1 . See gure 1.4.5.

1 2

Exercise: Prove that there is no non-rational degree 3 B ezier or B-spline curve

which traces out a non-trivial part of a circle.

Exercise: Prove that there is no non-rational B ezier or B-spline curveofany

degree which traces out a non-trivial part of a circle.

1.5 Interp olating with spline curves

Frequently one wishes to de ne a smo oth curve that interp olate i.e., `pass

though' a given set of p oints. However, the B-spline curves that have b een

de ned so far are not particularly convenient for this purp ose: they have

b een de ned from control p oints, and the control p oints merely in uence the

curve but are usually not interp olated. When control p oints are interp olated

it is generally b ecause of rep eated knot values and then curve loses its go o d

smo othness prop erties and mayhave discontinuous rst derivatives.

However, there are a numb er of go o d metho ds to de ne interp olating spline

curves. Supp ose that wehave a set of interp olation p oints p ;:::;p and a

0 m

set of knot values u ;:::;u . The problem is to de ne a piecewise degree 3

0 m

p olynomial curve so that Qu =p for all i .

i i

We describ e two general solutions to this problem. The rst is Catmull-Rom

splines which use a B ezier curve construction to de ne degree 3 splines. The

second is based on solving a system of linear equations to nd control p oints

that de ne the desired curve. The linear equations are `upp er diagonal' and

thus are easily solved. Both approaches b ene t from the use of chord-length

parameterization techniques.

Catmull-Rom Splines Catmull-Rom splines are sp eci ed by a list of control

p oints p ;:::p and are piece-wise degree 3 p olynomial curves that interp olate

0 m

all the p oints except the endp oints p and p . They are de ned by making

0 m

an estimate for the slop e of the curve passing through p , using this to de ne

i

additional control p oints for B ezier curves so that the i -th B ezier curve has

b eginning p oint p and ending p oint p .

i i+1

Figure 1.5 illustrates the de nition of a Catmull-Rom spline segment. Let

+

1 1 1

v = p p  and de ne p v and p v . Then let = p + = p

i i+1 i1 i i i i

i i

2 3 3

Q u b e the B ezier curve, translated to have domain i  u  i + 1 , whichis

i 16

XX TODO

Figure 1.5: Examples of uniform and chord-length Catmull-Rom splines

+

de ned with control p oints p ; p ; p ; p . De ne Quby piecing together

i i+1

i i+1

these curves, namely, Qu= Q uifiui+1.

i

Since B ezier curves interp olate their end p oints, the curve Q is continuous

and Qi=p for all integer i such that 1  i  m 1 . In addition, Q has

i

0

continuous second derivatives, with Q i=p p =2.

i+1 i1

Figure 1.5, parts a and b, shows two examples of Catmull-Rom splines.

The Figure 1.5b shows that bad e ects can o ccur when the interp olated

p oints are not more-or-less equally spaced. One way to x this problem is

to use chord-length parameterization: what this means is that we assign the

knot p ositions so that u u is equal to jjp p jj . The idea is that the

i+1 i i+1 i

arclength of the curvebetween p and p will b e approximately prop ortional

i i+1

to the distance from p to p and therefore approximately prop ortional to

i i+1

u u . Therefore, if one views the u -parameter as time, then, as u varies,

i+1 i

the curve will traversed at approximately a constant rate of sp eed.

Of course, in order to use chord-length parameterization, we need to

mo dify the formalization of Catmull-Rom splines to allow for non-uniform

knot p ositions. For this purp ose, we assume that all knot p ositions are distinct

and de ne

p p

i+1 i

1

= : v

i+

2

u u

i+1 i

1

is the mean velo city at which the interp olating spline The idea is that v

i+

2

is traversed from p to p . Of course, if wehave de ned the knot p ositions

i i+1

1

using a chord-length interp olation, then the velo cities v will b e unit vectors.

i+

2

Then we de ne a further velo city

1 1

u u v +u u v

i+1 i i i1

i i+

2 2

v = ;

i

u u

i+1 i1

whichisaweighted average of the twovelo cities of the curve segments just

b efore and and just after the interp olated p oint p . Finally de ne

i

1 1

+

v and p v : p = p + = p

i i i i

i i

3 3

These p oints are then used to de ne B ezier curves exactly as in the manner

used for the uniform Catmull-Rom curves.

An example of chord-length parameterization is given in Figure 1.5c:

clearly this represents a qualitative improvementover the uniform Catmull-Rom

interp olating curve shown in Figure ??c.

Exercise: Investigate the chord-length parameterization Catmull-Rom curve

from p to p when p ; p ; p are colinear. What is the velo cityat p ?

1 2 0 1 2 1

Consider separately the cases where p is and is not b etween p and p .

1 0 2 17

Interp olating with B-splines XXX

1.5.1 B-splines and NURBS in Op enGL

Op enGL provides routines for drawing non-uniform B-spline surfaces in the

glu library. By sp ecifying the control p oints in homogeneous co ordinates,

this includes the ability to render NURBS surfaces. The B-spline routines

include gluNewNurbsRenderer and gluDeleteNurbsRenderer to allo cate and

deallo cate a B-spline renderer: these routines are misnamed as they can also b e

used to render non-rational B-splines. The routines gluBeginSurface and

gluEndSurface are used to bracket one or more calls to gluNurbsSurface.

The latter routine allows sp eci cation of an array of knots and control p oints.

Since it renders a surface, it uses two knot arrays and a two dimensional array

of control p oints. A routine gluNurbsProperty allows you to control the

level of detail at which the B-spline surface is rendered.

These B-spline routines work similarly to, but somewhat less complicatedly

than, the Op enGL routines for B ezier curves discussed in section 1.3. The

interested reader should refer to the Op enGL do cumentation for more details

on how to use the B-spline rendering routines. 18