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 =N pu + 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 basis 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=j 3
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
i 2 i i 1
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;
i 3 i 2 i 1 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=Bu i:
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
i 2
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+k 1
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
i 1 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
i 1 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 n 1;1
u u u . In this way, the theorems stated b elow hold also for u = u .
n 1 n n
Second, for k 1,
u u 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
n k
3 B u=1, for al l u such that u u u .
i;k k 1 n k +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 n k
n k 1
X
B u=
i;k +1
i=0
n k 1
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
n k 2
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
n k 1;k
u u
n n
n k 1
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 n k +1
means that
j
X
Qu= B up
i;k i
i=j k+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
k 2
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
i 1 i i+1 i+p 1 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