Piegl1997-The NURBS Book 2nd Edition
Piegl1997-The NURBS Book 2nd Edition
Piegl1997-The NURBS Book 2nd Edition
Springer
Prof. Dr. Les Piegl
University of South Florida
Department of Computer Science and Engineering
Fowler Avenue,ENG1l8
Tampa,FL3362o-5399, USA
ISBN 978-3-540-61545-3
This work is subject to copyright. AII rights are reserved, whether the whole or part of
the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilm or in other ways,
and storage in data banks. Duplication ofthis publication or parts thereofis permitted
only under the provisions of the German Copyright Law of September 9, 196.5, in its
current version, and permission for use must always be obtained Crom Springer-
Verlag. Violations are liable for prosecution act under German Copyright Law.
The use of general descriptive names, registered names, trademarks, etc. in this
publication does not imply, even in the absence of a specific statement, that such
names are exempt Crom the relevant protective laws and regulations and therefore Cree
for general use.
Until recently B-spline curves and surfaces (NURBS) were principally of interest to the
computer aided design community, where they have become the standard for curve and
surface description. Today we are seeing expanded use of NURBS in modeling objects
for the visual arts, including the film and entertainment industries, art, and sculpture.
NURBS are now also being used for modeling scenes for virtual reality applications.
These applications are expected to increase. Consequently, it is quite appropriate for
The.N'URBS Book to be part of the Monographs in Visual Communication Series.
B-spline curves and surfaces have been an enduring element throughout my pro-
fessional life. The first edition of Mathematical Elements for Computer Graphics,
published in 1972, was the first computer aided design/interactive computer graph-
ics textbook to contain material on B-splines. That material was obtained through the
good graces of Bill Gordon and Louie Knapp while they were at Syracuse University.
A paper of mine, presented during the Summer of 1977 at a Society of Naval Architects
and Marine Engineers meeting on computer aided ship surface design, was arguably
the first to examine the use of B-spline curves for ship design.
For many, B-splines, rational B-splines, and NURBS have been a bit mysterious.
Consequently, for the last several years a thorough, detailed, clearly written, and easily
understood book on B-splines and rational B-splines has been needed. Thus, it was with
considerable anticipation that I awaited Les Piegl and Wayne Tiller's book. I was not
disappointed: They have elegantly and fully satisfied that need with The.N'URBS Book.
In developing the material for the book, they draw from their considerable academic
and industrial experience with NURBS to present this rather complex subject in a
straightforward manner: Their presentation style is clear and detailed. The necessary
mathematics is presented with considerable attention to detail and more than adequate
rigor. The algorithms (many of which are in C-like pseudocode) are well thought out
and meticulously prepared. In the interests of accuracy, each and every illustration in
the book was computer generated - a monumental task. They have created a book of
lasting value.
B-spline curves and surfaces grew out of the pioneering work of Pierre Bezier in the
early 1970s. Perhaps one can consider B-spline curves and surfaces the children of
Bezier curves and surfaces, and nonuniform rational B-splines, or NURBS, the grand-
children. The timing is about right; they have certainly come of age.
Finally, it is only appropriate to acknowledge my pleasure in working with both Les
Piegl and Wayne Tiller to bring this project to fruition.
David F. Rogers
Series Editor
Monographs in Visual Communication
PREFACE
• tested every single formula and algorithm, and presented graphical illustrations
precisely computed using the routines of Nlib. This book does not contain
any hand-drawn figures; each figure is precisely computed and hence
is accurate.
We are pleased to present all of the accomplishments to the reader: (1) the book as
a comprehensive reference, (2) Nlib source code (to order please see page 639 of this
volume), and (3) the illustrations to instructors who adopt the book to teach a course on
NURBS. In order for the reader to appreciate the enormous amount of work that went
into this reference book, we present some data. To generate the graphical illustrations
and to build Nlib, we wrote exactly (not counting the hundreds of test programs)
• 1,524 programs, that required
• 15,001,600 bytes of storage, which is roughly equivalent to
• 350,000 lines of code.
It was no picnic!
Some years ago a few researchers joked about NURBS, saying that the acronym really
stands for Nobody Understands Rational B-Splines. We admit that our colleagues
were right. In the last four years, we were largely influenced by this interpretation
and tried to present the material in the book in an intuitive manner. We hope that
this helps change the acronym NURBS to EURBS, that is, Everybody Understands
Rational B-Splines. We welcome the reader's opinion on our job and suggestions on
possible improvements.
It is our pleasure to acknowledge the help and support of many people and organi-
zations. First and foremost, we are grateful to our spouses, Karen Piegl and LaVella
Tiller, for their patience, support, and love. We owe special thanks to Nancy Rogers of
NAR Associates for the beautiful typesetting job, and David Rogers for the editorial
and technical discussions that led to many improvements in the manuscript. We also
thank Jim Oliver and Tim Strotman for the many suggestions and technical corre-
spondence that helped shape this book into its current form. Tiller also thanks the
many past and present colleagues in industry who over the years contributed inspiring
discussions, valuable insights, support, and collegial companionship: They know who
they are. Piegl's research was supported in part by the National Science Foundation
under grant CCR-9217768 awarded to the University of South Florida, and by various
grants from the Florida High Technology and Industry Council.
It is less than a year since the first printing of The NURBS Book. Due to its popularity,
Springer-Verlag decided to publish a soft cover edition of the book. Apart from being
significantly more affordable, the second printing corrects a number of errors; redesigns
Algorithm A3. S to elilllinate the use of a local array; and fixes minor bugs in the
knot insertion algorithms, AS. 1 and AS. 3, as well the degree elevation algorithm, AS. 9.
Apart from these corrections, this printing is identical to the first printing.
References 629
Index . . 641
CHAPTER
ONE
Curve and Surface Basics
x(U) = cos(u)
11"
y(u) = sin(u) O<u<
- - -2 (1.1)
1- t 2
x(t) = 1+t2
2t
y(t) = 1+t2 0~t~1 (1.2)
Radius =1
y C'(t = 0)
C'(u = 1) = C'(t = 1)
C'(u = 0)
Notice that two parameters are required to define a surface. Holding u fixed
and varying v generates the latitudinal lines of the sphere; holding v fixed and
varying u generates the longitudinal lines.
Radius =1
x y
Denote the partial derivatives of S (u, v) by Su (u, v) = (Xu (u, v), Yu (u, v),
zu( u, v)) and Sv( u, v) = (xv( u, v), Yv( u, v), zv( u, v)), i.e., the velocities along
latitudinal and longitudinal lines. At any point on the surface where the vector
cross product Su x Sv does not vanish, the unit normal vector, N, is given by
(Figure 1.4)
(1.4)
S"
Figure 1.4. Partial derivative and unit normal vectors of S(u, v).
Power Basis Form of a Curve 5
C(u)=[ao al 1
... an] [ ~n
u
1= [~] T'
[u'] (1.6)
Examples
(a)
Figure 1.7. at and a2 parallel. (a) Same direction; (b) opposite directions.
Bezier Curves 9
(b)
Figure 1. 7. (Continued.)
Twisted cubic
x y
(a)
y c' (u)IIC"(u)
or
C"(u) =0
Inflection point
./ x
(b)
Figure 1.8. Cubic curves. (a) Three-dimensional twisted; (b) inflection point; (c) cusp;
(d) loop.
The basis (blending) functions, {Bi,n(u)}, are the classical nth-degree Bernstein
polynomials ([Bern12j Lore86]) given by
n! i n-i
.)' U (1- u)
Bi,n(U) = z..'( n _ z. (1.8)
The geometric coefficients of this form, {Pd, are called control points. Notice
that the definition, Eq. (1.7), requires that U E [0,1].
Examples
Cusp
\.
C'(u) =0
(c)
(d)
PI = C(1)
Po = C(O)
Figure 1.9. A first-degree Bezier curve.
Po = C(O)
Po P3
(a)
Figure 1.11. Cubic Bezier curves.
word 'plane'). This expresses the property that a Bezier curve follows
its control polygon rather closely and does not wiggle more than its
control polygon (Figure 1.11f);
• initially (at u = 0) the curve is turning in the same direction as
Po PI P 2 • At u = 1 it is turning in the direction PI P 2 P 3 ;
• a loop in the control polygon mayor may not imply a loop in the
curve. The transition between Figure 1.11e and Figure 1.11f is a
curve with a cusp.
Po
(b)
Figure 1.11. (Continued.)
14 Curve and Surface Basics
P3
Po
(c)
Po = P3
(d)
Figure 1.11. (Continued.)
Exl.7 n = 6. Figure 1.12 shows a sixth-degree, closed Bezier curve. The curve
is smooth at C(O) ( = C(1)) because Pi - Po is parallel to P 6 - P 5 .
By smooth we mean that the tangent vectors at u = 0 and u = 1 have
the same direction.
In addition to the previously mentioned properties, Bezier curves are invariant
under the usual transformations such as rotations, translations, and scalingsj
Bezier Curves 15
Pa
Po
(e)
Po Pa
(f)
Figure 1.11. (Continued.)
that is, one applies the transformation to the curve by applying it to the control
polygon. We present this concept more rigorously in Chapter 3 for B-spline
curves (of which Bezier curves are a special case).
In any curve (or surface) representation scheme, the choice of basis functions
determines the geometric characteristics of the scheme. Figures 1.13a-d show the
basis functions {Bi,n(U)} for n = 1,2,3,9. These functions have these properties:
P5
BO,l
(a)
Figure 1.13. The Bernstein polynomials for (a) n = 1; (b) n = 2; (c) n = 3; (d) n = 9.
Bezier Curves 17
BO,2
(b)
Figure 1.13. (Continued.)
with
Figure 1.I5a shows the definition of B~,5' and Figure 1.I5b illustrates all
the cubic derivative functions.
B O,3 B 3 ,3
B 1,3
(c)
Figure 1.13. (Continued.)
18 Curve and Surface Basics
(d)
Figure 1.13. (Continued.)
From Eq. (1.8) we have Bo,o(u) = 1. Using property Plo6, the linear and
quadratic Bernstein polynomials are
(1 - u) u
B O,2
B~,5
(a)
B~,3
BL3
B~,3
Bb,3
(b)
Figure 1.15. Derivatives. (a) The derivative B~,5(U) in terms of Bl,4(U) and B 2 ,4(U);
(b) the derivatives of the four cubic Bernstein polynomials, Bb,3(U); B~,3(U); Bb(u);
Bb(u).
ALGORITHM A1. 2
Bernstein(i,n,u,B)
{ /* Compute the value of a Bernstein polynomial. */
/* Input: i,n,u */
/* Output: B */
for (j=O; j<=n; j++) /* compute the columns */
temp[j] = 0.0; /* of Table 1.1 */
temp[n-i] = 1.0; /* in a temporary array */
u1 = 1.0-u;
for (k=1; k<=n; k++)
for (j=n; j>=k; j--)
temp[j] = u1*temp[j] + u*temp[j-1];
B = temp[n];
}
BO.3
/
0= B_ l .O BO.2
'" BO.l
/
/ /
1 = Bo.o
'" B l •l
/
/
0= Bl.O
Bezier Curves 21
/'
B-l,O Bo,2
/' '\,
BO,l Bl ,3
Bl,l B2,3
'\, /'
B 3 ,3
ALGORITHM Ai.4
PointOnBezierCurve(P,n,u,C)
{ /* Compute point on Bezier curve. */
/* Input: P,n,u */
/* Output: C (a point) */
AllBernstein(n,u,B) /* B is a local array */
C = 0.0;
for (k=O; k<=n; k++) C = C + B[k]*P[k];
}
Using property Pi. 7, it is easy to derive the general expression for the deriva-
tive of a Bezier curve
d (tBi,n(U)Pi) n
C'(u) = i=O = "B' (u) p.
du L...J t,n t
i=O
n
= L n(Bi-l,n-I(U) - Bi,n-I(U)) Pi
i=O
n-I
From Eq. (1.9) we easily obtain formulas for the end derivatives of a Bezier
curve, e.g.
linear linear
Thus, C(u) is obtained as the linear interpolation of two first-degree Bezier
curves; in particular, any point on C(u) is obtained by three linear interpolations.
Bezier Curves 23
Po
Figure 1.16. Obtaining a point on a quadratic Bezier curve by repeated linear inter-
polation at Uo = %.
Po P3
This follows from the recursive definition of the basis functions (see Pl. 6). Fixing
u = Uo and denoting Pi by PO,i, Eq. (1.11) yields a recursive algorithm for
computing the point C(uo) = Pn,o(uo) on an nth-degree Bezier curve, i.e.
Pk,i( uo) = (1 - uo) Pk-l,i( uo) + Uo Pk-1,i+l (uo) for { ~ ::01, ... ,n _ k (1 12)
Z- , ... ,n .
Pn-1,o
Pn,o C(uo)
Pn-1,1
Pn - 2
Pn - 1
Rational Bezier Curves 25
Bezier curves more suitable for interactive curve design. The control points give
the designer a more intuitive handle on curve shape than do the power basis
coefficients. Furthermore, the deCasteljau algorithm is less prone to round-off
error than Horner's algorithm. This is intuitively clear when one considers that
the deCasteljau algorithm is simply repeated linear interpolation between points,
all of which lie in the vicinity of the curve. The only disadvantage of the Bezier
form is that point evaluation is less efficient (see Algorithms A1.i, A1.4, and
A1.5, and Exercise 1.13 later in the chapter).
This equation must hold for all u, which implies that all coefficients are zero.
Starting with the highest degree and working down, we show in n steps that all
ai = 0 and bi = 0 for 1 ~ i ~ n.
Step
1. a;' + b;, = 0 implies an = bn = O.
2. a;_l +2an-2an +b;'_l +2bn- 2bn = 0 and Step 1 imply that a;'_l +b;'_l = 0
which implies that an-l = bn- l = O.
26 Curve and Surface Basics
where X(u), Y(u), and W(u) are polynomials, that is, each of the coordinate
functions has the same denominator.
Examples
Ex1.9 Ellipse, centered at the origin; the y-axis is the major axis, the x-axis is
the minor axis, and the major and minor radii are 2 and 1, respectively
1- u 2 4u
x(u) = - 12 y(u) = 1+u2
+u
1-v'3 1+v'3)
(-
uE -2-'-2-
Ex1. 11 Parabola, vertex at the origin; the y-axis is the axis of symmetry
x(u) = u y(u) = u 2
Notice that the parabola does not require rational functions. The reader
should sketch these functions. For the circle equations it is easy to see that
for any u, (x( u), y( u)) lies on the unit circle centered at the origin
2 2 ( 1 - u2 ) 2 ( 2u ) 2
(x(u)) + (y(u)) = 1 + u2 + 1 + u2
1 - 2u2 + u 4 + 4u 2
(1 + u 2)2
Rational Bezier Curves 27
Define an nth-degree rational Bezier curve by (see [Forr68; Pieg86; Fari83, 89])
n
LBi,n(U)WiPi
C( u) = -'-i=.....::~_ _ __ (1.14)
LBi,n(U)Wi
i=O
The Pi = (Xi, Yi, Zi) and Bi,n (u) are as before; the Wi are scalars, called the
weights. Thus, W (u) = E~=o Bi,n (u )Wi is the common denominator function.
Except where explicitly stated otherwise, we assume that Wi > 0 for all i. This
ensures that W(u) > 0 for all U E [0,1]. We write
n
C(u) = LRi,n(U)Pi (1.15)
i=O
where ~,n(u) = nBi,n(U)Wi
LBj,n(U)Wj
j=O
The Ri,n(u) are the rational basis functions for this curve form. Figure 1.18a
shows an example of cubic basis functions, and Figure 1.18b a corresponding
cubic rational Bezier curve.
The ~,n(u) have properties which can be easily derived from Eq. (1.15) and
the corresponding properties of the Bi,n(U):
RO,3
(a)
Wo =1
(b)
Figure 1.18. Rational cubic. (a) Basis functions; (b) Bezier curve.
Example
(0,1)
x
(1,0)
(a)
Wo =1
x
Po
(b)
Figure 1.19. Representation of the unit circle. (a) x(u) = (1-u 2 )/(1+u2 ) and
y(u) = (2u)/(1 + u 2 ) for one quadrant; (b) the Bezier representation corresponding
to Figure 1.19a (wo = 1, WI = 1, W2 = 2).
w
(X,Y, W)
W= 1
n n
Z(u) = L Bi,n(U)WiZi W(u) = LBi,n(U)Wi
i=O i=O
n
LBi,n(U)WiPi
i=O
n (1.18)
LBi,n(U)Wi
i=O
32 Curve and Surface Basics
w
pw1
pw2
For algorithms in this book we primarily use the form given by Eq. (1.17),
and an analogous form for rational B-spline curves. Thus, nonrational forms
are processed in four-dimensional space, and the results are located in three-
dimensional space using the map H. We refer interchangeably to either CW(u)
or C(u) as the rational Bezier (or B-spline) curve, although strictly speaking,
C W (u) is not a rational curve.
Examples
Exl.13 Let us return to the circular arc of Figure 1.19b. We have Po = (1,0),
PI = (1,1), P 2 = (0,1), and Wo = 1, WI = 1, W2 = 2. Hence, for
Eq. (1.17) the three-dimensional control points are P~ = (1,0,1), = pr
(1,1,1), and P~ = (0,2,2). Then CW(u) = (l-u)2 P~ +2u(1-u) + pr
u 2 P~ is a parabolic arc (nonrational), which projects onto a circular
arc on the W = 1 plane (see Figure 1.22).
Let Uo be fixed. Since CW (u) is a polynomial Bezier curve, we use
the deCasteljau algorithm to compute CW(uo); subsequently, C(uo) =
H{CW(uo)}. Thus, we apply Eq. (1.12) to the Pi
k = 1, ... ,n
Pk',i(UO) = (1- uo) Pk-I,i + Uo Pk'-I,i+1 for {
i = 0, ... ,n - k
(1.19)
Rational Bezier Curves 33
w
pw2
Po =Pii'
x
y
Ex1.14 Let us apply Eq. (1.19) to compute the point at u = 1/2 on the rational
Bezier circular arc of Example 1.13. The arc is given by CW (u) =
(1 - u)2 p~ + 2u(1 - u) pr + u 2 p~, where p~ = (1,0,1), pr =
(1,1, 1), p~ = (0,2,2). The triangular set of generated points is shown
in Table 1.4. Then C(1/2) = H{C W (1/2)} = H{(3/4, 1, 5/4)} = (3/5,4/5).
Now let us compute the point using the other representations we have
developed. Let
( (1 - u )
2 (2U»)
C(u)= (1+u2)' (1+u2)
(1,1,1)
( 1 3 3)
2'2'2
(0,2,2)
34 Curve and Surface Basics
Then
C(!) _
2 -
(1-l+GY'l+GY
GY 2G)) _(~ ~)
- 5'5
+ (~ y
(0,2,2)
1
= 4 (1,0,1)
(3 5)
+"21 (1,1,1) + 41 (0,2,2) = 4,1'4
Projecting yields (3/5,4/5). Equations (1.18) and (1.15) yield the same
result.
Finally, we note that C(lh) = (3/5,4/5) is not the midpoint of the circular
arc in the first quadrant; i.e., the parameterization is not uniform (see
Section 1.1). The point (3/5,4/5) is more than half the arc length from
the starting point. This is intuitively correct, since by differentiating
C(u) one can see that the starting speed is twice the end speed.
(1.21)
i=O j=O - , -
We have Ii(u) = ui and gj(v) = vj, and the basis functions are the products,
{uiv j }. If we fix u = Uo, then
(1.22)
n
where bj(uo) = L ai,j u~
i=O
is a power basis curve lying on the surface, S(u,v). Similarly, Cvo(u) is a power
basis curve lying on S(u,v); and the curves Cuo(v) and Cvo(u) intersect at
the surface point, S(uo,vo). These curves are called isoparametric curves (or
isocurves). Cuo(v) is called a v curve, Cvo(u) a u curve (see Figure 1.23).
Equation (1.21) can be written as
S(u, v) = {ao,o
, + ao,lV + ao,2v2 + ... + ao,mvm},
...
bo
b2
+ un{an,o
, + an,lv + an,2V2 + ... + an,m vm,}
...
bn
8(0,1)
8(1,1)
x 8(1,0)
------=- u
The terms in the braces are simple polynomials that can be evaluated by the
Horner Algorithm (A1.1), yielding b o, bl, ... ,bn . Using the bs and reapplying
the algorithm, we obtain the point on the surface. Thus we have Algorithm A1. 6.
ALGORITHM Ai. 6
Horner2(a,n,m,uO,vO,S)
{ 1* Compute point on a power basis surface. *1
1* Input: a,n,m,uO,vO *1
1* Output: S *1
for (i=O; i<=n; i++)
Horner1(a[i) [),m,vO,b[i)); 1* a[i) [) is the ith row *1
Horner1(b,n,uO,S);
}
Algorithm A1. 6 is typical of the algorithms for tensor product surfaces. They
can usually be obtained by extending from the curve algorithms, often by process-
ing the n (or m) rows of coefficients (as curves) in one direction, then processing
one or more rows in the other direction.
Differentiating Eq. (1.21), we obtain
n m n m
Su(u,v) = L L ia.;"jUi-1V j ~ Sv(u,v) = L Ljai,jUiV j - 1
i=l j=O i=O j=l
Notice that for fixed (uo,vo), Su(uo,vo) = C~o(uo) and Sv(uo,vo) = C~o(vo).
The normal vector, N, is computed using Eq. (1.4).
Tensor Product Surfaces 37
(1.24)
j=O
n
where Qj(uo) = L Bi,n(uO)Pi,j j=O, ... ,m
i=O
is a Bezier curve lying on the surface. Analogously, C vo (u) = L~o Bi,n (u) Qi (vo)
is a Bezier u isocurve lying on the surface.
(a)
Figure 1.24. (a) The Bezier tensor product basis function, B O,2(U)B1,3(V);
(b) a quadratic x cubic Bezier surface.
38 Curve and Surface Basics
As is the case for curves, because of their excellent properties Bezier surfaces
are better suited for geometric modeling applications than power basis surfaces.
In particular,
• nonnegativity: Bi,n(u)Bj,m(v):2: 0 for all i,j,u,v;
• partition of unity: E~=o Ej=o Bi,n(u)Bj,m(v) = 1 for all u and v;
• S( u, v) is contained in the convex hull of its control points;
• transformation invariance;
• the surface interpolates the four corner control points;
• when triangulated, the control net forms a planar polyhedral approximation
to the surface.
It is interesting to note that there is no known variation diminishing property
for Bezier surfaces (see [Prau92]).
The deCasteljau algorithm (A1. 5) is also easily extended to compute points on
a Bezier surface. Refer to Eq. (1.24) and Figure 1.25. Let (uo, vo) be fixed. For
fixed jo, Qjo(uo) = E~=oBi,n(UO)Pi,jo is the point obtained by applying the
deCasteljau algorithm to the jo row of control points, i.e., to {Pi,jo}, i = 0, ... , n.
Therefore, applying the deCasteljau Algorithm (m + 1) times yields Cuo (v); and
applying it once more to Cuo (v) at v = Vo yields Cuo (vo) = S(Uo, vo). This
process requires
n(n + 1)(m + 1) m(m + 1)
(1.25)
2 + 2
PO,l ,~::.:..~?.,;....
,// "'.
PO,O
y
x
P2,O
(b)
Figure 1.24. (Continued.)
Tensor Product Surfaces 39
linear interpolations. Thus, if n > m compute Cvo(u) first, then Cvo(uo); oth-
erwise, compute Cuo(v) first, then Cuo(vo).
ALGORITHM Al.7
deCasteljau2(P,n,m,uO,vO,S)
{ 1* Compute a point on a Bezier surface *1
1* by the deCasteljau. *1
1* Input: P,n,m,uO,vO *1
1* Output: S
if (n <= m)
{
for (j=O; j<=m; j++) 1* P[j] [] is jth row *1
deCastelj au1(P [j] [] ,n, uO, Q[j] ) ;
deCasteljaul(Q,m,vO,S);
}
else
{
for (i=O; i<=n; i++)
Po,o
y
x
deCasteljaul(P[] [i],m,vO,Q[i]);
deCasteljaul(Q,n,uO,S);
}
}
n m
L LBi,n(u)Bj,m(V)Wi,jPi,j
and S(u, v) = H {SW (u, v)} = _i=_O-=nJ:-o=-::.=--_ _ _ _ _ __
L L Bi,n(u)Bj,m(V)Wi,j
i=O j=O
n m
= L LRi,j(u,V)Pi,j (1.28)
i=O j=O
Bi,n(u)Bj,m(V)Wi,j
where ~,j ( )
U, V = -n=---=m::-'--'--'---"-'---'--'--"'---
L LBr,n (u)Bs,m (v)wr,s
r=Os=O
Notice that the Ri,j (u, v) are rational functions, but they are not products
of other basis functions. Hence, S (u, v) is not a tensor product surface, but
SW (u, v) is. As with curves, we generally work with Eq. (1.27) and project
the results. Figure 1.26a shows a rational basis function, and Figure 1.26b de-
picts a quadratic x cubic rational Bezier surface. Compare these figures with
°
Figures 1.24a and 1. 24b.
Assuming Wi,j > for all i and j, the properties listed previously for nonra-
tional Bezier surfaces (and the product functions Bi,n (u )Bj,m (v)) extend natu-
rally to rational Bezier surfaces. Furthermore, if Wi,j = 1 for all i and j, then
~,j (u, v) = Bi,n (U ) B j, m ( V), and the corresponding surface is nonrational.
Example
Exl. 15 Let us construct a cylindrical surface patch. From Section 1.4 we know
that 2
for {Pi} = {(O, 1,0,1), (0, 1, 1, 1), (0,0,2, 2)}, is a circular arc in the yz
plane. Using translation (Pl.14, Section 1.4)
Tensor Product Surfaces 41
1 v
(a)
Figure 1.26. (a) The rational basis function Ro,l(U,V) (with WO,l = 5 and all other
weights equal to one); (b) a quadratic x cubic rational Bezier surface.
2 2
C~(u) = LBi,2(U)P~0 and Cf(u) = LBi,2(U)P~1
i=O i=O
where , = {(1,1,0,1),(1,1,1,1),(2,0,2,2)}
{pro}
and {pr1}
, = {(-1,1,0,1),(-1,1,1,1),(-2,0,2,2)}
are circular arcs in the x = 1 and x = -1 planes, respectively (see
Figure 1.27). A linear interpolation between C~ and Cr yields a cylin-
drical surface, i.e.
2 1
SW(u,v) = LLBi,2(U)Bj,l(V)prj
i=O j=O
PO,l
WO,l =5
Po,o
(b)
Figure 1.26. (b) (Continued.)
(1,1,1,1)
(-1,1,1,1)
(2,0,2,2)
(0,0,2,2) = Q~(vo)
(-2,0,2,2)
(0,1,1,1) (. ~ 1 ~) - Sw (~ ~)
,0, 4' , 4 - 2' 2
(0,0,2,2)
And projecting yields
-------------
Po, 1
x PO,o
EXERCISES
1.1. Consider the two parametric representations of the circular arc given by Eqs. (1.1)
and (1.2). Using Eq. (1.1), compute the curve point at u = 'If/ 4 and, using Eq. (1.2),
the point at t = 1/2. Explain the results.
1.2. Compute the acceleration vector, C"(u), for Eq. (1.1). Explain the result.
1.3. Using trigonometric functions, give a parametric definition of the bounded sur-
face of
• a right circular cone, with apex at the origin and axis of symmetry along the z-axis;
• the cone is opening upward, and is bounded above at z = 2 by the circle with
radius = 1.
Modify Eq. (1.2) to get another representation of the same cone. Compute the first
partial derivatives, Su and Sv, of the trigonometric representation. What are the values
of these derivatives at the apex of the cone?
1.4. Consider the parabolic arc C(u) = (x(u),y(u)) = (-1-u+2u 2 ,-2u+u2 ),
o :::; u
:::; 1. Sketch this curve. The curve is rotated and translated by applying the
transformations to the functions x(u) and y(u). Apply the two transformations
(1) 90° rotation about the origin. The rotation matrix (applied from the left) is
u E [0,1]
i=O
Let v E [a,b]. Then u = (v - a)/(b - a). Substitute this equation into Eq. (1.8) and
derive this expression for the reparameterized curve
Exercises 45
It is interesting to note that the control points do not change, only the basis functions.
Reparameterization of the power basis form changes the geometric coefficients but not
the basis functions.
1.16. Consider the circle
( ) --(~~)
Cu 1 + u2 ' 1 + u2
Determine which ranges of the parameter u yield which quadrants of the circle. Do
these equations yield the entire circle? What can you say about the parameterization?
1.17. Consider the following rational cubic Bezier curve in the xy plane: Po = (0,6),
PI = (3,6), P 2 = (6,3), P3 = (6,0), Wo = 4, WI = 1, W2 = 1, W3 = 4. Compute the
point C(%) by expanding the deCasteljau table.
1.18. What characteristic is it of the rational functions we are using that allows
us to use the homogeneous coordinate representation? Why is this representation
advantageous?
1.19. Find the rational Bezier representation of the circular arc in the second quad-
rant, i.e., determine the Pi and Wi. Hint: use symmetry and check your result by
showing that (X(U))2 + (Y(U))2 = 1 for all u E [0,1].
1.20. The circular arc in the first quadrant is also given by the equation
(
1+(v'2-2)U+(1-v'2)U2 ~U((v'2-2)U+2))
C(u) = 1 + (v'2 - 2)u+ (2 - v'2)u 2 ' 1 + (v'2 - 2)u+ (2 - v'2)u2
1.22. For the cylindrical surface example (Exl.l5) compute the control points Qj(uo)
for the isocurve C:o= 1/3 (v).
1.23. Let n = 3 and m = 2. Consider the nonrational Bezier surface defined by the
control net
{Pi,O} = {(O, 0, 0), (3,0,3), (6,0,3), (9, 0, On
{Pi,I} = {(O, 2, 2), (3,2,5), (6,2,5), (9, 2, 2n
{P i ,2} = {(O, 4, 0), (3,4,3), (6,4,3), (9,4, on
a. sketch this surface;
b. use the deCasteljau algorithm to compute the surface point S(1/a, 1M;
c. fix Uo = 1/2 and extract the Bezier representation (control points) of the curve
C uo = 112(v).
46 Curve and Surface Basics
1.24. Let n m
and assume that Po,o = P 1,0 = ... = Pn,o. How does this affect 8(u, v), the derivatives
8.,(u, v) and 8 v(u, v), and the curves Cvo(u)? Assume that P;,o = (1,0,0) for i = 0, 1,2
in Example Exl.15, with Wo,O = 1, W1,0 = 1, and W2,0 = 2. What type of surface do
you get?
1.25. The prerequisite for this problem is Exercise 1.14. The rational Bezier surface
(Eq. [1.27]) has a matrix form
where [u;]T and [v j ] are vectors, Mn is an (n+ 1) x (n+ 1) matrix, M;;' is a (m+ 1) x
(m + 1) matrix, and [Pi,'j] is an (n + 1) x (m + 1) matrix of four-dimensional points.
Write this form down explicitly for the cylindrical surface example, Exl.15. Using
this matrix form, compute the point 8 w (1/2, 1/2), and then project to obtain 8(1/2, 1/2).
There is no direct matrix form for 8(u, v)j why not?
CHAPTER
TWO
2.1 Introduction
Curves consisting of just one polynomial or rational segment are often inade-
quate. Their shortcomings are:
• a high degree is required in order to satisfy a large number of constraints;
e.g., (n - I)-degree is needed to pass a polynomial Bezier curve through
n data points. However, high degree curves are inefficient to process and
are numerically unstable;
• a high degree is required to accurately fit some complex shapes;
• single-segment curves (surfaces) are not well-suited to interactive shape
design; although Bezier curves can be shaped by means of their control
points (and weights), the control is not sufficiently local.
The solution is to use curves (surfaces) which are piecewise polynomial, or
piecewise rational. Figure 2.1 shows a curve, C(u), consisting of m (= 3) nth-
degree polynomial segments. C(u) is defined on u E [0,1]. The parameter values
Uo = 0 < Ul < U2 < U3 = 1 are called breakpoints. They map into the endpoints
of the three polynomial segments. We denote the segments by Ci(u), 1 ~ i ~ m.
The segments are constructed so that they join with some level of continuity (not
necessarily the same at every breakpoint). Let c~j) denote the jth derivative of
C i . C(u) is said to be C k continuous at the breakpoint Ui if C~j)(Ui) = C~~l (Ui)
for all 0 ~ j ~ k.
Any of the standard polynomial forms can be used to represent C i (u). Figure
2.2 shows the curve of Figure 2.1 with the three segments in cubic Bezier form.
pi denotes the ith control point of the jth segment.
If the degree equals three and the breakpoints U .= {uo, Ub U2, U3} remain
fixed, and if we allow the twelve control points, Pi, to vary arbitrarily, we
obtain the vector space, V, consisting of all piecewise cubic polynomial curves
48 B-Spline Basis Functions
C 3(U)
\
~----------~--------.-----+----.---------+--~=-
Uo =0 U3 =1
Figure 2.1. A piecewise cubic polynomial curve with three segments.
be local parameters on the intervals [uo, UI] and rUb U2], respectively. Then
o :S v, w:S 1.
C I continuity at UI implies
Thus (2.1)
Equation (2.1) says that P~ and P~ can be written in terms of P~, P~ and
P~, P~ , respectively. Hence, VI, the vector space of all C I continuous piecewise
cubic polynomial curves on U, has dimension eight, and VI C VO C V.
This makes it clear that storing and manipulating the individual polynomial
segments of a piecewise polynomial curve is not the ideal method for handling
Introduction 49
p33
pl
o
\ Pr p~
Uo =0 U3 =1
Figure 2.2. The curve of Figure 2.1 shown with the polynomial segments represented
in Bezier form.
such curves. First, redundant data must be stored: twelve coefficients, where
only eight are required for C l continuous cubic curves, and only six for C 2
continuous cubic curves. Second, for the Bezier form the continuity of C(u)
depends on the positions of the control points, hence there is little flexibility in
positioning control points while maintaining continuity. If a designer wants C l
continuity and is satisfied with the segments Cl(u) and C 3 (u), but wants to
modify the shape of C 2 (u), he is out of luck: none of C 2 (u)'s control points can
be modified. Third, determining the continuity of a curve requires computation
(such as Eq. [2.1]).
We want a curve representation of the form
n
C(u) = L fi(U) Pi (2.2)
i=O
where the Pi are control points, and the {Ii (U), i = 0, ... , n} are piecewise poly-
nomial functions forming a basis for the vector space of all piecewise polynomial
functions of the desired degree and continuity (for a fixed breakpoint sequence,
U = {Ui}, 0 ::; i ::; m). Note that continuity is determined by the basis functions,
hence the control points can be modified without altering the curve's continuity.
Furthermore, the {fi} should have the 'usual' nice analytic properties, e.g. those
listed in Section 1.3. This ensures that the curves defined by Eq. (2.2) have nice
geometric properties similar to Bezier curves, e.g., convex hull, variation dimin-
ishing, transformation invariance. Another important property that we seek in
our basis functions is that of local support; this implies that each fi(U) is nonzero
only on a limited number of subintervals, not the entire domain, [uo, urn]. Since
Pi is multiplied by fi(U), moving Pi affects curve shape only on the subintervals
where fi (u) is nonzero.
50 B-Spline Basis Functions
n m
SW(u,v) = L Lfi(U)gj(v)P~j (2.4)
i=O j=O
For the remainder of this chapter we study the so-called B-spline basis func-
tions. In Chapters 3 and 4 we combine these functions with three-dimensional
and four-dimensional control points to obtain nonrational and rational curves
and surfaces, respectively.
Note that
• Ni,o (u) is a step function, equal to zero everywhere except on the half-open
interval u E lUi, Ui+1);
• for p > 0, Ni,p(u) is a linear combination of two (p - I)-degree basis
functions (Figure 2.3);
Definition and Properties of B-spline Basis Functions 51
UiH-U
Ui+4 - Ui+1
value (breakpoint) in the set U, and an element of the set U (there can exist
additional knots in U having the same value). It should be clear from the context
which meaning is intended.
Examples
N 2,0 = {~ O::;u<1
otherwise
N 3,0 = N 4,0 = 0 -00 < U < 00
+ 0 _ 0 N 1,0- o
N, - u-0N, O-u _
0,1 - 0_ 0 0,0 -00 < u < 00
u- 0 1- u {u 2 O::;u<1
N 2 ,2 = 1 _ 0 N 2 ,1 + 1 _ 1 N 3 ,1 = 0 otherwise
Note that the N i ,2, restricted to the interval u E [0, IJ, are the quadratic
Bernstein polynomials (Section 1.3 and Figure 1.13b). For this reason,
the B-spline representation with a knot vector of the form
Ex2.2 Let U = {uo = 0,U1 = 0,U2 = 0,U3 = l,u4 = 2,us = 3,U6 = 4,U7 =
4, Us = 5, U9 = 5, U10 = 5} and p = 2. The zeroth-, first-, and second-
degree basis functions are computed here. The ones not identically zero
Definition and Properties of B-spline Basis Functions 53
u-o O-u
N O,1 = O_ONo,o+ O_ONl ,o =0 -oo<u<oo
N 2,1 =
u-O
I _ 0 N2,0 + 2_
2-u
I Ns,o =
{U - u
~
O::;u<1
l::;u<2
otherwise
U-I l::;u<2
u-l 3-u
N S ,1 = 2_ I Ns,o + 3 _ 2 N 4,0 {
= ~ - u 2~u<3
otherwise
2~u<3
3::;u<4
otherwise
3~u<4
otherwise
N, - u-4N, 5-u N _{5-U 4::;u<5
6,1 - 4 _ 4 6,0 + 5 - 4 7,0 - 0 otherwise
,e" 0 1 2
I I
3 4
III
5
,]
0 1 2
N3 ,o
I
3 4
III
5
,j
I
N4 ,o
II III c=
,] N",o
II III <="
0 1 2 3 4 5 0 1 2 3 4 5
,1 N7 ,o
III
0 1 2 3 4 5
Figure 2.4. The nonzero zeroth-degree basis functions, U = {O, 0, 0,1,2,3,4,4,5,5, 5}.
u-O l-u 2
No,2 = 0 _ 0 No,1 + 1 _ 0 NI,I = (1 - u) O:::;u<1
N 3,l N 7 ,l
1
o 1 2 3 4 5
Figure 2.5. The nonzero first-degree basis functions, U = {O, 0, 0,1,2,3,4,4,5,5, 5}.
Definition and Properties of B-spline Basis Functions 55
1/2u2 O::;u<l
u-O 3-u
N22 = --N21 + --N31 = { _3/:2+ 3u - 2
u 1::;u<2
, 2-0 ' 3-1 '
1/2(3 - U)2 2::;u<3
u-4 5-u 2
N 7 ,2 = 5 _ 4 N 7 ,1 + 5 _ 5 N S ,1 = (u - 4)
P2. 1 N i ,p (u) = 0 if u is outside the interval [Ui, Ui+p+1) (local support prop-
erty). This is illustrated by the triangular scheme shown here. Notice
o 1 2 3 4 5
that N 1,3 is a combination of N1,o, N 2 ,o, N 3 ,o, and N 4 ,o. Thus, N 1,3 is
nonzero only for U E [u 1, U5)
N1,o N O,2
'\
N1,1 N O,3
,/ '\
N 2 ,o N 1,2
'\ ,/ '\
N 2 ,1 N 1,3
,/ '\ ,/
N 3 ,o N 2 ,2
'\ ,/
N 3,1 N 2,3
,/
N 4 ,o N 3,2
P2.2 In any given knot span, [Uj, Uj+1), at most P + 1 of the Ni,p are nonzero,
namely the functions Nj_p,p,"" Nj,p' On [U3, U4) the only nonzero
zeroth-degree function is N 3 ,o. Hence, the only cubic functions not zero
on [U3, U4) are N O,3, . .. ,N3 ,3. This property is illustrated here
N1,1 N O,3
/'
N 2 ,o N 1,2
/' \.
N 2,l N 1,3
/' \. /'
N 3 ,o N 2,2
\. /' \.
N 3,1 N 2 ,3
\. /'
N 4 ,o N 3 ,2
\.
N 4,1 N 3 ,3
L Nj,p(u) = L
i i
u-u'
J Nj,p_l(U)
j=i-p j=i-p J P -u'J
U·+
i
+ '"
L....J uj+p+1 - U Nj+1,p-l (U )
..
J=t-p uj+p+1 - Uj+1
Changing the summation variable in the second sum from i-p to i-p+l,
and considering that Ni-p,p-l(U) = Ni+l,p-l(U) = 0, we have
j=i-p+l
P2.5 All derivatives of Ni,p(U) exist in the interior of a knot span (where it is a
polynomial, see Figure 2.7). At a knot Ni,p(U) isp-k times continuously
differentiable, where k is the multiplicity of the knot. Hence, increasing
58 B-Spline Basis Functions
\
\
\
\
\
\
\ /
\ /
'z ,
1 /
/
'
/
~(4-U)2
/ 2
.-- --
/
/
o
/
1 / 2 3 \
\ 4
I
I
I
\
I
11
I
I
--2
+ 5u-u
2 \
1 1
or
(see Figure 2.5). Now assume that Eq. (2.7) is true for p - 1, P > 1. Using the
product rule, (lg)' = /,g + fg', to differentiate the basis function
yields (2.8)
Ui
Substituting Eq. (2.7) into Eq. (2.8) for N:,p_l and N:+1,p-l yields
p-l U-Ui
+ ui+p - Ui Ui+p-l - Ui
N i ,p-2
Noting that
Ui+p+l - U U - Ui
= --1 + +1-
Ui+p+ 1 - Ui+ 1
+ U·+
•p - U-
.
U - U.•
Ui+p - Ui Ui+p - Ui
Ui+p - U U - Ui+l
we obtain
1 1
N' = ----Ni,p-l - Ni+l,p-l
Z,p Ui+p - Ui Ui+p+l - Ui+l
Derivatives of B-spline Basis Functions 61
By the Cox-deBoor formula (Eq. [2.5]), the expressions in the parentheses can
be replaced by Ni,p-l and Ni+l,p-b respectively. It follows that
N(k-l) )
i+l,p-l
(2.9)
(2.10)
with ao,o = 1
ak-l j - ak-l j - l
ak,j = ' , j = 1, ... ,k-l
Ui+p+j-k+1 - ui+j
ak k = -ak-l,k-l
, Ui+p+l - Ui+k
1 1
alO = ---- all=------
, Ui+p - Ui , Ui+p+l - Ui+l
and
62 B-Spline Basis Functions
Comparing this with Eq. (2.7) proves the case for k = 1; now let k = 2. Differ-
entiating Eq. (2.7) yields
= P
--=---- ( ---=----
p-l N i ,p-2 - p-l N Hl ,p-2 )
uHp - Ui uHp-l - Ui uHp - UiH
it follows that
Equation (2.11) gives the kth derivative of Ni,p(u) in terms of the kth derivative
of Ni,p-l and NHl,p-l.
Figures 2.9b and 2.1Ob show the derivatives corresponding to the basis func-
tions in Figures 2.9a and 2.1Oa. Figure 2.11 shows all the nonzero derivatives of
N i ,3. Note the effect of multiple knots in Figure 2.1Ob; N~,3 has a jump at the
triple knot.
Further Properties of the Basis Functions 63
o 2 4 6 8
(a)
N~,3
N~,3
(b)
Figure 2.9. (a) Cubic basis functions; (b) derivatives corresponding to the basis func-
tions in Figure 2.9a.
k
dim(V) = k(p + 1) - L (rj + 1) (2.12)
j=O
64 B-Spline Basis Functions
o 2 4 6 8
(a)
N~,3
(b)
Figure 2.10. (a) Cubic basis functions showing single, double, and triple knots; (b)
derivatives of the functions in Figure 2.lOa.
Now set
Further Properties of the Basis Functions 65
1
NII/
i,3
Nil
i,3
Then clearly, there are m zeroth-degree functions, Ni,o, m - 1 first degree func-
tions, N i,1, and in general, m - p pth-degree functions, Ni,p, which have the
desired continuity, Tj = P - Sj. Hence the Ni,p are contained in V. Substituting
Sj = P - Tj into Eq. (2.12) yields
k
dim(V) = k(p + 1) - L (p - Sj + 1)
j=O
k
=k(p+1)-(k+1)p+ LSj-(k+1)
j=O
k
= -p-1+ LSj
j=O
=m-p
which implies Qi - Qi-1 = 0 for all i (by assumption), which in turn implies
Qi = 0 for all i. This completes the proof.
We turn our attention now to knot vectors. Clearly, once the degree is fixed
the knot vector completely determines the functions N i , p (u). There are several
types of knot vectors, and unfortunately terminology varies in the literature. In
this book we consider only nonperiodic (or clamped or open) knot vectors, which
have the form
-----
U = {a, ... ,a,up+b ... ,Urn-p-1, b, ... ,b}
p+1 ~
p+1
(2.13)
that is, the first and last knots have multiplicity p + 1. For nonperiodic knot
vectors we have two additional properties of the basis functions:
p-i-1 p+1
N O,3(U)
1 j N ,3(U)
1
N2,3(U)
° 1 5 6 8
Figure 2.12. Nonuniform cubic basis functions defined on U = {O, 0, 0, 0,1, 5, 6,8, 8, 8, 8}.
68 B-Spline Basis Functions
search. Since we are using intervals of the form U E lUi, Ui+1), a subtle problem
in the evaluation of the basis functions is the special case U = Urn. It is best
to handle this at the lowest level by setting the span index to n (= m - p - 1).
Hence, in this case U E (Urn-p-b urn-pl. FindSpan is an integer function which
returns the span index.
ALGORITHM A2.1
int FindSpan(n,p,u,U)
{/* Determine the knot span index */
/* Input: n,p,u,U */
/* Return: the knot span index */
if (u == U[n+l]) return(n); /* Special case */
low = p; high = n+l; /* Do binary search */
mid =(low+high)/2;
while (u < U[mid] I I u >= U[mid+l])
{
if (u < U[mid]) high = mid;
else low = mid;
mid = (low+high)/2;
{
return(mid);
}
Now we tackle the second algorithm. Assuming U is in the ith span, compu-
tation of the nonzero functions results in an inverted triangular scheme
Example
Ex2.3 Let p = 2, U = {O, 0, 0,1,2,3,4,4,5,5, 5}, and U = 5/2 (see Figure 2.6).
Then i = 4, since U E [U4' U5). Thus, we compute
N 3,1(5/2)
N 3 ,2(5/2)
N 4,1(5/2)
N 4,2(5/2)
Computational Algorithms 69
Substituting U = 5/2 into Eq. (2.5) (the reader should do this) yields
It will be clear to the reader who carried out the substitutions in this example
that there is a great deal of redundant computation inherent in Eq. (2.5). For
example, writing out the second-degree functions in general terms, we have
Note that
• the first term of Eq. (2.14) and the last term of Eq. (2.16) are not com-
puted, since N i - 2,1(U) = Ni+l,l(U) = 0;
• the expression
which appears in the second term of Eq. (2.14) appears in the first term
of Eq. (2.15); a similar statement holds for the second term of Eq. (2.15)
and the first term of Eq. (2.16).
We introduce the notation
ALGORITHM A2.2
BasisFuns(i,u,p,U,N)
{/* Compute the nonvanishing basis functions */
/* Input: i,u,p,U */
/* Output: N */
N[0]=1.0;
for (j=1; j<=p; j++)
{
left[j] = u-U[i+1-j];
right[j] = U[i+j]-u;
saved = 0.0;
for (r=O; r<j; r++)
{
temp = N[r]/(right[r+1]+left[j-r]);
N[r] = saved+right[r+1]*temp;
saved = left[j-r]*temp;
}
N[j] = saved;
}
}
We remark that Algorithm A2. 2 is not only efficient, but it also guarantees that
there will be no division by zero, which can occur with a direct application of
Eq. (2.5).
Now to the third algorithm; in particular, we want to compute all NA~(u), for
i - p :::; r :::; i and 0 :::; k :::; n, where n :::; p. Inspection of Eq. (2.10) reveals that
the basic ingredients are:
• the inverted triangle of nonzero basis functions computed in Algorithm
A2.2;
• differences of knots (the sums: right [r+1] +left [j-r]), also computed
in Algorithm A2. 2;
• differences of the ak,j; note that the ak,j depend on the ak-l,j but not the
as,j, for 8 < k - 1.
Example
1
-
2
1
all = - =-1
, U7 - U5
1
2
1
-1- -
2 3
4-3 2
a2 2 = _ al,l
, U7 - U6
1
4- 4 °
1
N 6 ,o(5/2), which are also not in the array. These terms are defined to be
zero, and we are left with
(1)
N4,2 = 2al,oN4,1 (5)
2" = 2"1
N 4(2)
,2 = 2a2,oN4,o (5)
2" = 1
To check these values, recall from Section 2.2 that N 4,2(U) = l/2(U - 2)2
on u E [2,3). The computation of N~lJ (5/2), N~2J (5/2), NJ1J (5/2), and
NJ~J (5/2) is analogous. " ,
Based on these observations (and Ex2.4), it is not difficult to develop Algo-
rithm A2. 3, which computes the nonzero basis functions and their derivatives,
up to and including the nth derivative (n ::; p). Output is in the two-dimensional
array, ders. ders [k] [j] is the kth derivative of the function Ni-p+j,p, where
o::; k ::; n and 0 ::; j ::; p. Two local arrays are used:
• ndu[p+1] [p+1] , to store the basis functions and knot differences;
• a[2] [p+1] , to store (in an alternating fashion) the two most recently
computed rows ak,j and ak-l,j.
The algorithm avoids division by zero and/or the use of terms not in the array
ndu[] [].
ALGORITHM A2.3
DersBasisFuns(i,u,p,n,U,ders)
{/* Compute nonzero basis functions and their *1
1* derivatives. First section is A2.2 modified *1
1* to store functions and knot differences. *1
1* Input: i,u,p,n,U *1
/* Output: ders */
ndu[O] [0]=1.0;
for (j=l; j<=p; j++)
{
left[j] = u-U[i+1-j];
right[j] = U[i+j]-u;
saved = 0.0;
for (r=O; r<j; r++)
{ /* Lower triangle */
ndu[j] [r] = right [r+1]+left [j-r] ;
temp = ndu[r] [j-1]/ndu[j] [r];
/* Upper triangle */
ndu[r] [j] = saved+right[r+1]*temp;
saved = left[j-r]*temp;
}
ndu[j] [j] = saved;
Computational Algorithms 73
}
for (j=O; j<=p; j++) /* Load the basis functions */
ders [0] [j] = ndu [j] [p] ;
/* This section computes the derivatives (Eq. [2.9]) */
for (r=O; r<=p; r++) /* Loop over function index */
{
s1=0; s2=1; /* Alternate rows in array a */
a[O] [0] = 1.0;
/* Loop to compute kth derivative */
for (k=1; k<=n; k++)
{
d = 0.0;
rk = r-k; pk = p-k;
if (r >= k)
{
a[s2] [0] = a[s1] [0]/ndu[pk+1] [rk];
d = a[s2] [O]*ndu[rk] [pk];
}
if (rk >= -1) j1 = 1;
else j1 = -rk;
if (r-1 <= pk) j2 = k-1;
else j2 = p-r;
for (j=j1; j<=j2; j++)
{
a[s2] [j] = (a[s1] [j]-a[s1] [j-1])/ndu[pk+1] [rk+j];
d += a[s2] [j]*ndu[rk+j] [pk];
}
if (r <= pk)
{
a[s2] [k] = -a[s1] [k-1]/ndu[pk+1] [r];
d += a[s2] [k]*ndu[r] [pk];
}
ders [k] [r] = d;
j=s1; s1=s2; s2=j; /* Switch rows */
}
}
/* Multiply through by the correct factors */
/* (Eq. [2.9]) */
r = p;
for (k=1; k<=n; k++)
{
for (j=O; j<=p; j++) ders[k] [j] *= r;
r *= (p-k);
}
}
74 B-Spline Basis Functions
We turn our attention now to the last two algorithms, namely computing
a single basis function, N i ,p(u), or the derivatives, Ni~~ (u), of a single basis
function. The solutions to these problems result in triangular tables of the form
Example
N 3,o(5/2) =0
N 3,1(5/2) = 21
6
N 4,o(5/2) =1 N 3,2(5/2) =8
N 4,1(5/2) = 21
N 5,o(5/2) =0
N 4,2(5/2) is obtained from
N 4,o(5/2) =1
N 4,1(5h) = 21
N 5,o(5/2) =0 N 4,2(5/2) = 81
N 5,1 (5/2) =0
N 6,o(5/2) =0
Notice that the position and relative number of nonzero entries in the table
depend on p and on the position of the 1 in the first column. Algorithm A2. 4
computes only the nonzero entries. The value Ni,p(u) is returned in Nip; m is
the high index of U (m + 1 knots). The algorithm is similar to Algorithm A2. 2
in its use of the variables temp and saved.
ALGORITHM A2.4
OneBasisFun(p,m,U,i,u,Nip)
{/* Compute the basis function Nip *1
1* Input: p,m,U,i,u *1
1* Output: Nip *1
Computational Algorithms 75
k = 1:
N i ,2
N(1)
i,3
N H1 ,2
k=2:
N i,1
N(1)
i,2
N(2)
NiH, 1 i,3
(1)
N H1 ,2
N H2,1
k=3:
N(l)
i,1
N (1)
i+2,1
N H3,Q
In words, the algorithm is:
1. compute and store the entire triangular table corresponding to k = OJ
2. to get the kth derivative, load the column of the table which contains
the functions of degree p - k, and compute the remaining portion of the
triangle.
Algorithm A2. 5 computes Ni~~ (u) for k = 0, ... ,n, n ~ p. The kth derivative
is returned in ders [k] .
ALGORITHM A2.5
DersOneBasisFun(p,m,U,i,u,n,ders)
{/* Compute derivatives of basis function Nip *1
Computational Algorithms 77
/* Input: p,m,U,i,u,n */
/* Output: ders */
if (u < U[i] I I u >= U[i+p+1]) /* Local property */
{
for (k=O; k<=n; k++) ders[k] = 0.0;
return;
}
for (j=O; j<=p; j++) /* Initialize zeroth-degree functs */
if (u >= U[i+j] && u < U[i+j+1]) N[j][O] = 1.0;
else N[j] [0] = 0.0;
for (k=1; k<=p; k++) / * Compute full triangular table */
{
if (N[O] [k-1] == 0.0) saved = 0.0;
else saved = «u-U[i])*N[O] [k-1])/(U[i+k]-U[i]);
for (j=O; j<p-k+1; j++)
{
Uleft = U[i+j+1];
Uright = U[i+j+k+1];
if (N[j+1] [k-1] == 0.0)
{
N[j] [k] = saved; saved = 0.0;
}
else
{
temp = N[j+1] [k-1]/(Uright-Uleft);
N[j][k] = saved+(Uright-u)*temp;
saved = (u-Uleft)*temp;
}
}
}
ders[O] = N[O] [p]; /* The function value */
for (k=1; k<=n; k++) /* Compute the derivatives */
{
for (j=O; j<=k; j++) 1* Load appropriate column */
ND [j] = N[j] [p-k] ;
for (jj=1; jj<=k; jj++) 1* Compute table of width k *1
{
i f (ND[O] == 0.0) saved = 0.0;
else saved = ND[O]/(U[i+p-k+jj]-U[i]);
for (j=O; j<k-jj+1; j++)
{
Uleft = U[i+j+1];
Uright = U[i+j+p+jj+1];
if (ND[j+1] == 0.0)
{
78 B-Spline Basis Functions
EXERCISES
2.1. Consider the linear and quadratic functions computed earlier and shown in Fig-
ures 2.5 and 2.6. Substitute u = 5/2 into the polynomial equations to obtain N3,1 (5/2),
N4,1(5/2), N2,2(5/2), N 3 ,2(5/2), and N4,2(5/2). What do you notice about the sum of the
two linear, and the sum of the three quadratic functions?
2.2. Consider the quadratic functions of Figure 2.6. Using the polynomial expressions
for N 3 ,2(U), evaluate the function and its first and second derivatives at u = 2 from
both the left and right. Observe the continuity. Does Property P2. 5 hold? Do the
same with N4,2(U) at u = 4.
2.3. Let U = {O, 0, 0, 0,1,2,3,4,4,5,5,5, 5}. How does this change the degree 0, 1,
and 2 functions of Figures 2.4-2.6? Compute and sketch the nine cubic basis functions
associated with U.
2.4. Consider the function N2,2(U) of Figure 2.5, N2,2(U) = 1/2u2 on [0,1), _3/2 +
3u - u 2 on [1,2) and 1/2(3 - u? on [2,3). Use Eq. (2.10) to obtain the expressions for
the first and second derivatives of N2,2(U).
2.5. Again consider N2,2(U) of Figure 2.5. Obtain the first derivatives of N2,1 and
N 3 ,1 by differentiating the polynomial expressions directly. Then use these, together
with Eq. (2.11), to obtain Nb.
2.6. Again let p = 2, u = 5/2,
and U = {O, 0, 0,1,2,3,4,4,5,5, 5}. Trace through
Algorithm A2. 2 by hand to find the values of the three nonzero basis functions. Trace
through Algorithm A2. 3 to find the first and second derivatives of the basis functions.
Exercises 79
2.7. Use the same p and U as in Exercise 2.6, with u = 2. Trace through Algorithm
12.3 with n = 1, once with i = 3, and once with i = 4. Then differentiate the
appropriate polynomial expressions for the N j ,2 given in Section 2.2, and evaluate the
derivatives from the left and right at u = 2. Compare the results with what you
obtained from Algorithm 12.3.
2.S. Using the same p and U as in Exercise 2.6, let u = 4. Trace through Algorithms
12 . 2 and 12. 3 to convince yourself there are no problems with double knots.
2.9. With the same p and U as in Exercise 2.6, let u =5/2. Trace through Algorithm
12.5 and compute the derivatives N~~J (5/2) for k = 0,1,2.
CHAPTER
THREE
3.1 Introduction
In this chapter we define nonrational B-spline curves and surfaces, study their
properties, and derive expressions for their derivatives. For brevity we drop
the word nonrational for the remainder of this chapter. The primary goal is to
acquire an intuitive understanding of B-spline curves and surfaces, and to that
end the reader should carefully study the many examples and figures given in
this chapter. We also give algorithms for computing points and derivatives on B-
spline curves and surfaces. The use of B-splines to define curves and surfaces for
computer-aided geometric design was first proposed by Gordon and Riesenfeld
[Gord74bj Ries73]. B-spline techniques are now covered in many books on curves
and surfaces - see [DeBo78j Mort85j Bart87j Fari93j Yama88j Hosc93j Su89j
Roge90j Beac91].
where the {Pi} are the control points, and the {Ni,p(u)} are the pth-degree B-
spline basis functions (Eq. [2.5]) defined on the nonperiodic (and nonuniform)
knot vector
U = {a, ... ,a, up+l! ... , Um-p-l! b, ... , b}
............... '--v--"
pH pH
82 B-spline Curves and Surfaces
N32(~)
, 2 = ~
8
C ( -5) =-P
1 2 +-P
6 3 +-P
1 4
2 8 8 8
The algorithm follows.
ALGORITHM A3.1:
CurvePoint(n,p,U,P,u,C)
{/* Compute curve point *1
1* Input: n,p,U,P,u *1
1* Output: C *1
span = FindSpan(n,p,u,U);
BasisFuns(span,u,p,U,N);
C = 0.0;
for (i=O; i<=p; i++)
C = C + N[i]*P[span-p+i];
}
We now list a number of properties of B-spline curves. These properties follow
from those given in Chapter 2 for the functions Ni,p(u). Let C(u) be defined by
Eq. (3.1).
P3.1 If n = p and U = {D, ... ,D,l, ... ,I}, then C(u) is a Bezier curve
(Figure 3.1);
P3 . 2 C (u) is a piecewise polynomial curve (since the N i , p ( u) are piecewise
polynomials); the degree, p, number of control points, n+ 1, and number
of knots, m + 1, are related by
m=n+p+1 (3.2)
The Definition and Properties of B-spline Curves 83
Figure 3.1. A cubic B-spline curve on U = {O, 0, 0, 0,1,1,1,1}, i.e., a cubic Bezier curve.
(see Section 2.4). Figures 3.2 and 3.3 show basis functions and sections of
the B-spline curves corresponding to the individual knot spans; in both
figures the alternating solid/dashed segments correspond to the different
polynomials (knot spans) defining the curve.
P3.3 Endpoint interpolation: C(O) = Po and C(l) = Pn ;
P3 . 4 Affine invariance: an affine transformation is applied to the curve by ap-
plying it to the control points. Let r be a point in £3 (three-dimensional
Euclidean space). An affine tmnsformation, denoted by <1>, maps £3 into
£3 and has the form
<I>(r) = Ar + v
where A is a 3 x 3 matrix and v is a vector. Affine transformations
include translations, rotations, scalings, and shears. The affine invariance
property for B-spline curves follows from the partition of unity property
of the N i , p (u). Thus, let r = L CtiPi, where Pi E £3 and L Cti = 1. Then
P3 . 5 Strong convex hull property: the curve is contained in the convex hull
of its control polygon; in fact, if U E lUi, Ui+1), P ~ i < m - p - 1, then
C(u) is in the convex hull of the control points P i- p , '" , Pi (Figures 3.4,
3.5, and 3.6). This follows from the nonnegativity and partition of unity
properties of the Ni,p(u) (Properties P2.3 and P2.4), and the property
that Nj,p(u) = 0 for j < i - p and j > i when u E lUi, Ui+1) (Property
P2.2). Figure 3.6 shows how to construct a quadratic curve containing
a straight line segment. Since P 2 , P 3 , and P 4 are colinear, the strong
84 B-spline Curves and Surfaces
N o,3 N 6 ,3
1
N s,3
I \
° 1/2 3/4 1
(a)
P2
-----
/
/
Po
/
/
(b)
Figure 3.2. (a) Cubic basis functions U = {O,O,O,O, 1/4 , 1/2,3/4,1,1,1,1}; (b) a cubic
curve using the basis functions of Figure 3.2a.
convex hull property forces the curve to be a straight line segment from
C(2/5) to C(%);
P3.6 Local modification scheme: moving Pi changes C(u) only in the interval
[ui,Ui+p+d (Figure 3.7). This follows from the fact that Ni,p(u) = 0 for
U ~ [Ui' Ui+P+1) (Property P2. 1).
P3 . 7 The control polygon represents a piecewise linear approximation to the
curve; this approximation is improved by knot insertion or degree eleva-
tion (see Chapter 5). As a general rule, the lower the degree, the closer a
B-spline curve follows its control polygon (see Figures 3.8 and 3.9). The
curves of Figure 3.9 are defined using the same six control points, and
the knot vectors
The Definition and Properties of B-spline Curves 85
N O,2
N e,2
1
N 2 ,2 N 3 ,2 N 4 ,2
,, ,,
,, , ,, ,
" ,"
(a)
P2
P1
,,
\
\
\
Pe
I P5
I
Po
(b)
Figure 3.3. (a) Quadratic basis functions on U = {O, 0, 0,1/5, 2/s, 3js, 4/5 ,1,1, 1}; (b) a
quadratic curve using the basis functions of Figure 3.3a.
1234 }
p=1:U= { 0,0'5'5'5'5,1,1
113
p=2:U= { 0,0,0'4'2'4,1,1,1 }
p = 3 : U = {O, 0, 0, O,~,~, 1, 1, 1, 1}
p = 4 : U = {O, 0, 0, 0, O,~, 1, 1, 1, 1, 1}
p = 5 : U = {O, 0, 0, 0, 0, 0,1,1,1,1,1,1}
The reason for this phenomenon is intuitive: the lower the degree, the
fewer the control points that are contributing to the computation of
86 B-spline Curves and Surfaces
,, ,,
, ,
\ ,
I
',I " Ps
f/
, I
I
I
I
Po
Figure 3.4. The strong convex hull property for a quadratic B-spline curve; for
U E [Ui,Ui+l), C(u) is in the triangle Pi-2Pi-lPi.
C(uo) for any given Uo. The extreme case is p = 1, for which every point
C(u) is just a linear interpolation between two control points. In this
case, the curve is the control polygon;
a-~-~--~-~--~-~--~-~--~-~--~-~--~-~--~-~--~-~--~-~--~-~- ,,
'-, ,,
,,
Po
Figure 3.5. The strong convex hull property for a cubic B-spline curve; for U E lUi, Ui+1),
C(u) is in the quadrilateral Pi-3Pi-2Pi-lPi.
The Definition and Properties of B-spline Curves 87
Po
Figure 3.6. A quadratic B-spline curve on U = {O, 0, 0, 1/5 , 2/s, 3/5 , 4/5, 1, 1, 1}. The curve
is a straight line between C(2/s) and C(%).
P3.9 Variation diminishing property: no plane has more intersections with the
curve than with the control polygon (replace the word plane with line,
for two-dimensional curves) - see [Lane83] for proof;
P3
, ,
~" "
)'
"
,: ''
"
Po ," :,
P~ ~ ~
\ '. ~,
\ ,
\~
/"
" \,
, \'.\
~------~~~=---------~~ P5
Figure 3.7. A cubic curve on U = {O, 0, 0, 0, 1/4 , 1/2,3/4,1,1,1,1}; moving P4 (to P~)
changes the curve in the interval (1/4,1).
88 B-spline Curves and Surfaces
Ps
(a)
Ps
P5
(b)
Figure 3.8. B-spline curves. (a) A ninth-degree Bezier curve on the knot vector U =
{O, 0, 0, 0, 0, 0, 0, 0, 0, 0,1,1,1,1,1,1,1,1,1, 1}j (b) a quadratic curve using the same con-
trol polygon defined on U = {O, 0, 0, l/S, 2/s, 3/8, 4/S, 5/s, 6/s, 7fs, 1, 1, 1}.
P3.10 The continuity and differentiability of C(u) follow from that of the
Ni,p(U) (since C(u) is just a linear combination of the Ni,p(U)). Thus,
C (u) is infinitely differentiable in the interior of knot intervals, and it is
at least p-k times continuously differentiable at a knot of multiplicity k.
Figure 3.10 shows a quadratic curve (p = 2). The curve is C 1 continuous
(the first derivative is continuous but the second is not) at all interior
knots of multiplicity 1. At the double knot, u = 4/5, C(u) is only CO con-
tinuous, thus there is a cusp (a visual discontinuity). Figure 3.11 shows a
The Definition and Properties of B-spline Curves 89
Ps
P3
Figure 3.9. B-spline curves of different degree, using the same control polygon.
quadratic curve defined on the same knot vector. Hence, the two curves
use the same basis functions, Ni,p(u), for their definitions. But the curve
of Figure 3.11 is C 1 continuous at U = 4/5; this is not obvious but can be
seen using the derivative expression given in Section 3.3. This is simply
a consequence of the fact that discontinuous functions can sometimes be
combined in such a way that the result is continuous. Notice that P4,
P 5 , and P 6 are colinear, and length(P4P 5 ) = length(P5 P6)' Figure 3.12
shows a cubic curve which is C 2 continuous at u = 1/4 and u = 1/2, but
only C 1 continuous at the double knot u = 3/4. The eye detects discon-
tinuities in the second derivative but probably not in third and higher
derivatives. Thus, cubics are generally adequate for visual purposes.
Po
Figure 3.10. A quadratic curve on U = {O, 0, 0, lis, 2/s, 3/s, 4/s, 4/s, 1, 1, 1} with a cusp at
u = 4/S.
90 B-spline Curves and Surfaces
P3
Po
Figure 3.11. A quadratic curve on U = {O, 0, 0, l/S, 2/s, 3/s, 4/S, 4/S, 1, 1, I}; the first
derivative is continuous at u = 4/S.
Po
Po
(3.3)
i=O
N'
4,
2 (~)
2
= _2_1:
4 - 22
- 0 = 1:
2
It follows that
92 B-spline Curves and Surfaces
Po
(a)
(b)
Figure 3.14. Cubic curves with double control point P 2 = P3. (a) U = {O, 0, 0, 0, 1/4, 3/4,
I,I,I,I}; (b) U={O,O,O,O,l/2,l/2,I,I,I,I}.
where (3.4)
Now let U' be the knot vector obtained by dropping the first and last knots
from U, i.e.
U' = {O, ... ,0,Up+l,'" ,um - p- ! , 1, ... , I} (3.5)
~ ~
p p
(U' has m - 1 knots). Then it is easy to check that the function N i + l,p-l ( u),
computed on U, is equal to Ni,p-l(U) computed on U'. Thus
n-l
where the Qi are defined by Eq. (3.4), and the Ni,p-l(U) are computed on U'.
Hence, C' (u) is a (p - 1)th-degree B-spline curve.
Examples
U = {a, 0, 0,2/5,3/5,1,1,1}
Then U' = {O,O, 2/5, 3/5,1, I} and C'(u) = ~~=o Ni,l(U) Qi' where
The Derivatives of a B-spline Curve 95
C(u) and C'(u) are shown in Figures 3.15a and 3.15b, respectively.
Q3 = 3(P4 - P 3) = !!(P4 - P 3)
1- ! 2
3
Q4 = 3(P5 - P 4) = 9(P5 - P 4)
1- ~
3
Q 5 = 3(P6 - P 5) = 9(P6 - P 5)
1- ~
3
C(u) and C'(u) are shown in Figures 3.16a and 3.16b, respectively. No-
tice that C' (u) is a quadratic curve with a cusp at the double knot
u= 3/5.
Ex3 . 3 Recalling that a pth-degree Bezier curve is a B-spline curve on
°
U = {0, ... ,0,1, ... ,1} (no interior knots), Eq. (3.4) reduces to Qi =
P(PH1 - Pi) for :$ i :$ n -1. Since n = p and Ni,p-l(U) = Bi,n-l(U),
the Bernstein polynomials, Eq. (3.6) is equivalent to Eq. (1.9).
96 B-spline Curves and Surfaces
C'(O)
C'(1/5)
/' C'(l)
Y
/
/
C' (2/5)
P4
Po
L-------------------------r---------~=- x
(a)
(b)
Figure 3.15. (a) A quadratic curve on U = {O, 0, 0, 2js, 3js, 1, 1, l}j (b) the derivative of
the curve is a first-degree B-spline curve on U' = {O, 0, 2/5, 3/5, 1, I}.
The Derivatives of a B-spline Curve 97
C'(O)
C'(I)
C'(3/5)
(a)
Figure 3.16. (a) A cubic curve on U = {O, 0, 0, 0, 2js, 3/5, 3/5,1,1,1, I}; (b) the quadratic
derivative curve on U' = {O, 0, 0, 2/5, 3/5, 3/5,1,1,1}.
(see Examples Ex3.1 and Ex3.2, and Figures 3.15(a) and (b) and Figures 3.16
(a) and (b)). Note that in Figures 3.15b and 3.16b the derivative vectors and
control point differences are scaled down for better visualization, by 1/2 and by
1/3, respectively.
Since C'(u) is a B-spline curve, we apply Eqs. (3.4) through (3.6) recursively
to obtain higher derivatives. Letting p~O) = Pi, we write
n
C(u) = C(O)(u) = LNi,P(U)P~O)
i=O
n-k
Then C(k)(u) = LNi'P_k(U)p~k) (3.8)
i=O
k=O
with
k>O
98 B-spline Curves and Surfaces
(b)
ALGORITHM A3.3
CurveDerivCpts(n,p,U,P,d,rl,r2,PK)
{/* Compute control points of curve derivatives *1
1* Input: n,p,U,P,d,rl,r2 *1
1* Output: PK *1
r = r2-rl;
for (i=O; i<=r; i++)
PK[O] [i] = P[rl+i];
for (k=l; k<=d; k++)
{
tmp = p-k+l;
The Derivatives of a B-spline Curve 99
Analogously,
C(2)(I) = p(p - 1) x
1 - Um-p-l
Notice that for Bezier curves these equations reduce to the corresponding ex-
pressions of Eq. (1.10). Figure 3.17 shows the quadratic curve of Figure 3.15a
with the vectors C(2)(O) and C(2)(I). C(2)(u) is a piecewise zeroth-degree curve,
i.e., it is a constant (but different) vector on each of the three intervals [0,2/5),
[2/5,3/5), and [3/5, IJ.
We close this section with another algorithm to compute the point on a B-
spline curve and all derivatives up to and including the dth derivative at a fixed
U value (compare with Algorithm A3.2). The algorithm is based on Eq. (3.8)
and Algorithm A3. 3. We assume a routine, AllBasisFuns, which is a simple
modification of BasisFuns (Algorithm A2. 2), to return all nonzero basis func-
tions of all degrees from 0 up to p. In particular, N [j] [i] is the value of the
ith-degree basis function, Nspan-i+j,i(U), where 0 :::; i :::; p and 0 :::; j :::; i.
ALGORITHM A3. 4
CurveDerivsAlg2(n,p,U,P,u,d,CK)
{/* Compute curve derivatives */
/* Input: n,p,U,P,u,d */
/* Output: CK */
du = min(d,p);
100 B-spline Curves and Surfaces
Po
Figure 3.17. The second derivatives at the endpoints of the curve of Figure 3.15a.
Po P5
Figure 3.18. A cubic curve on U = {O, 0, 0, 0, 1/4,3/4,1,1,1,1} with first, second, and
third derivatives computed at u = 2/5.
with l!= {0, ... ,0,Up+1, ... ,Ur - p-1,1, ... ,1}
--------
p+1
--------
p+1
v = {O, ... ,0,Vq+1, ... ,V s- q-1, 1, ... , I}
--------
q+1
--------
q+1
r = n + p + 1 and s = m + q + 1 (3.12)
Let l! and {Ni ,3 (u)} be the knot vector and cubic basis functions of Figure 3.2a,
and {Nj ,2(V)} the quadratic basis functions defined on V = {O,O,O, 1/5,2/5,3/5,
3/5,4/5,1,1,1}. Figures 3.19a and 3.19b show the tensor product basis functions
N4,3(U)N4,2(V) and N4,3(U)N2,2(V), respectively. Figures 3.20-3.25 show exam-
ples of B-spline surfaces.
Five steps are required to compute a point on a B-spline surface at fixed (u, v)
parameter values:
1. find the knot span in which u lies, say u E lUi, Ui+1) (Algorithm A2.1);
2. compute the nonzero basis functions Ni-p,p(u), ... , Ni,p(u) (A2.2);
3. find the knot span in which v lies, say v E [vj,vj+d (A2.1);
4. compute the nonzero basis functions Nj_q,q(v), ... , Nj,q(v) (A2.2);
102 B-spline Curves and Surfaces
(a)
(b)
Figure 3.19. Cubic x quadratic basis functions. (a) N4,3(U)N4,2(V); (b) N4,3(U)N2,2(V);
U = {O, 0, 0, 0, 1/4, 1/2,3/4,1,1,1,1} and V = {O, 0, 0, 1/5, 2/s, 3fs, 3fs, 4/5, 1, 1, I}.
5. multiply the values of the nonzero basis functions with the corresponding
control points.
The last step takes the form
i - p '5, k '5, i, j - q '5, l '5, j (3.13)
Definition and Properties of B-spline Surfaces 103
f
Note that [Nk,p( u) is a 1 x (p+ 1) row vector of scalars, [Pk,l] is a (p+ 1) x (q+ 1)
matrix of control points, and [Nl,q (v)] is a (q + 1) x 1 column vector of scalars.
Example
Ex3.4 Let p = q = 2 and 2::=0 2:~=ONi,2(U)Nj,2(V)Pi,j, with
U = {O, 0, 0, 2/5, 3/5,1,1, I}
V = {O, 0, 0, 1/5, 1/2, 4/5, 1, 1, I}
Compute S(1/5, 3/5). Then 1/5 E [U2' U3) and 3/5 E [V4' V5), and
N2'2(~)
[PO.,
P 1,2
P O,3
P 1,3
po.•
P 1,4
1 N3,2 (~)
P 2,2 P 2,3 P 2,4
N4,2 (~)
Algorithm A3. 5 computes the point on a B-spline surface at fixed (u, v) values.
For efficiency, it uses a local array, temp [] , to store the vector/matrix product,
f
[Nk,p(U) [P k,!]. The resulting vector of points (in temp []) is then multiplied
with the vector [Nl,q(v)].
ALGORITHM A3.5
SurfacePoint(n,p,U,m,q,V,P,u,v,S)
{/* Compute surface point *1
1* Input: n,p,U,m,q,V,P,u,v *1
1* Output: S *1
uspan = FindSpan(n,p,u,U);
BasisFuns(uspan,u,p,U,Nu);
vspan = FindSpan(m,q,v,V);
BasisFuns(vspan,v,q,V,Nv);
uind = uspan-p;
S = 0.0;
for (1=0; l<=q; 1++)
{
temp = 0.0;
vind = vspan-q+l;
for (k=O; k<=p; k++)
temp = temp + Nu[k] *P [uind+k] [vind];
S = S + Nv[l]*temp;
}
}
104 B-spline Curves and Surfaces
P O,3
,'.-:...
, \
/ ~
PO,! /
............ ,
....... ~
,
",'" \
(a)
Figure 3.20. A B-spline surface. (a) The control net; (b) the surface.
The properties of the tensor product basis functions follow from the corre-
sponding properties of the univariate basis functions listed in Chapter 2.
(b)
Figure 3.20. (Continued.)
P3.19 If n = p, m = q, U = {O, ... , 0,1, ... ,I}, and V = {O, ... , 0, 1, ... ,I},
then S( u, v) is a Bezier surface; this follows from P3. 14;
P3.20 The surface interpolates the four corner control points: S(O,O) = Po,o,
S(I,O) = Pn,o, S(O,I) = PO,m, and S(I,I) = Pn,m (see Figures 3.20
through 3.25); this follows from P3 .13 and the identity
(a)
//---------
.~~-----.-.:--------.: '"
y
,,
x ,
,
, ,
•
(b)
Figure 3.21. (a) A cubic x quadratic B-spline surface; (b) the strong convex hull property.
(a)
(b)
Figure 3.22. (a) A biquadratic surface; (b) a biquartic surface (p q 4) using the
same control points as in Figure 3.22a.
108 B-spline Curves and Surfaces
z
(a)
(b)
Figure 3.23. (a) A planar quadratic x cubic surface, U = {O, 0, 0, 1/4, 1/2, 3/4,1,1,1} and
V = {O, 0, 0, 0, 1/s, 2/s, 3/5, 4/s, 1, 1, 1, 1}; (b) P3,S is moved, affecting surface shape only
in the rectangle [1/4,1) x [2/s, 1).
P3.24 Local modification scheme: if Pi,j is moved it affects the surface only in
the rectangle [ui,ui+p+d x [Vj,vj+q+1); this follows from P3.15. Now
consider Figures 3.23a and 3.23b: the initial surface is flat because all the
control points lie in a common plane (P3. 22); the control net is offset
Definition and Properties of B-spline Surfaces 109
Figure 3.24. A quadratic x cubic surface with crease, U = {O, 0, 0, 1/2, 1/2,1,1,1} and
V = {O, 0, 0, 0,1/2,1,1,1, 1}.
110 B-spline Curves and Surfaces
Po,o
Algorithm A3 . 6 computes the point on a B-spline surface and all partial deriva-
tives up to and including order d (d > p, q is allowed). Analogous to Algorithm
A3.5, this is a five-step process, with the last step being vector/matrix/vector
multiplications of the form
8 k +1
8ku8Iv S (u,v) = [N$~(u)([Pr,s] [N~I~(v)]
o ::; k + l ::; d uspan - p ::; r ::; uspan
vspan - q ::; s ::; vspan (3.18)
Output is the array SKL [] [], where SKL [k] [1] is the derivative of S( u, v) with
respect to u k times, and v l times. For fixed k, 0 ::; k ::; d, local array temp []
stores the vector/matrix product, [Nr,p (k)(u)]T [Pr,s], while it is being multi-
plied with the [Ns,q (I) (v) ], for 0 ::; l ::; d - k. Arrays Nu [] [] and Nv [] [] are
used to store the derivatives of the basis functions.
ALGORITHM A3.6
SurfaceDerivsA1g1(n,p,U,m,q,V,P,u,v,d,SKL)
{/* Compute surface derivatives *1
1* Input: n,p,U,m,q,V,P,u,v,d *1
1* Output: SKL *1
du = min(d,p);
for (k=p+l; k<=d; k++)
for (1=0; 1<=d-k; 1++) SKL[k] [1] = 0.0;
dv = min(d,q);
for (1=q+l; 1<=d; 1++)
for (k=O; k<=d-1; k++) SKL[k] [1] = 0.0;
uspan = FindSpan(n,p,u,U);
DersBasisFuns(uspan,u,p,du,U,Nu);
vspan = FindSpan(m,q,v,V);
DersBasisFuns(vspan,v,q,dv,V,Nv);
for (k=O; k<=du; k++)
{
for (s=O; s<=q; s++)
{
temp[s] = 0.0;
for (r=O; r<=p; r++)
temp[s] = temp[s] + Nu[k] [r]*P[uspan-p+r] [vspan-q+s];
}
112 B-spline Curves and Surfaces
dd = min(d-k,dv);
for (1=0; l<=dd; 1++)
{
SKL[k] [1] = 0.0;
for (s=O; s<=q; s++)
SKL[k] [1] = SKL[k] [1] + Nv[l] [s]*temp[s];
}
}
}
Figure 3.26 shows a bicubic surface and its first and second partial derivatives.
Note that the derivatives are scaled down by 1/2 for better visualization.
Let us formally differentiate S (u, v). With respect to u we have
Su(u,v) = 8
8u S (u,v)
m
= t;Nj,q(V) (8
n
8u~Ni'P(U)Pi,j
)
(3.19)
n
where Cj(u) = LNi,p(U)Pi,j j=O, ... ,m
i=O
Figure 3.26. A bicubic surface defined on U = V = {O, 0, 0, 0, 1/2,1,1,1,1} and its first
and second partial derivatives computed at u = 3/4 and v = 2/5.
Derivatives of a B-spline Surface 113
are B-spline curves. Applying Eq. (3.6) to each of the Cj(u) and substituting
into Eq. (3.19), we obtain
n-1 m
S .. (U,v) = LLNi,p-1(U)Nj,q(V)Pi~~'0) (3.20)
i=Oj=O
(1 ,0) _
P .. ',). -
P'+1 p ',)
..
where -p (see Eq. [3.4])
.,) Ui+p+1 - Ui+1
n m-1
Analogously Sv(u,v) = L LNi'P(u)Nj,q-1(V)Pi~~,1) (3.21)
i=O j=O
(0 ,1) _
P .. ',) -
P"+1 p ',)
..
where -q
I,) Vj+qH - VjH
n-1m-1
S ..v(U,v) = LLNi'P-1(U)Nj,q-1(V)Pi~~,1) (3.22)
i=O j=O
p(1,0) _ p(1,O)
where (1,1)
P .. i,jH i,j
=q
I,) Vj+qH - VjH
p(k,I-1) _ p(k,I-1)
where p?,l) = (q -l + 1) i,jH i,j
,) vj+qH - Vj+l
114 B-spline Curves and Surfaces
Using Eqs. (3.20)-(3.23), we derive useful formulas for corner derivatives. For
example, at the corner (u,v) = (0,0), we have
(1,0) P
Su ( )
0,0 = Po,o =:--u (Pl,o - Po,o)
pH
(0,1) q ( )
Sv ( )
0,0 = Po,o = -:--u PO,l - Po,o (3.24)
q+l
Now let Uo = 0 and Vo = o. From the properties of the basis functions, it is easy
to see that the isocurves C uo (v) and C vo (u) are given by
m n
Cuo(v) = LNj,q(v)PO,j Cvo(u) = L Ni,p(U)Pi,o
j=O i=O
Algorithm A3. 7 computes all (or optionally some) of the control points,
Pi~~,l), of the derivative surfaces up to order d (0 ~ k + l ~ d). The algorithm
is based on Eq. (3.23) and Algorithm A3. 3. Output is the array, PKL [] [] [] [] ,
where PKL[k] [1] [i] [j] is the i,jth control point of the surface, differentiated
k times with respect to u and l times with respect to v.
ALGORITHM A3.7
SurfaceDerivCpts(n,p,U,m,q,V,P,d,r1,r2,s1,s2,PKL)
{/* Compute control points of derivative surfaces *1
1* Input: n,p,U,m,q,V,P,d,r1,r2,s1,s2 *1
1* Output: PKL *1
du = min(d,p); dv = min(d,q);
r = r2-r1; s = s2-s1;
for (j=s1; j<=s2; j+:)
{
CurveDerivCpts(n,p,U,&P[] [j],du,r1,r2,temp);
for (k=O; k<=du; k++)
for (i=O; i<=r-k; i++)
PKL[k] [0] [i] [j -s 1] = temp [k] [i] ;
}
for (k=O; k<du; k++)
for (i=O; i<=r-k; i++)
{
Derivatives of a B-spline Surface 115
dd = min(d-k,dv);
CurveDerivCpts(m,q,&V[s1],&PKL[k] [0] [i] [] ,dd,O,s,temp);
for (1=1; l<=dd; 1++)
for (j=O; j<=s-l; j++)
PKL[k] [1] [i] [j] = temp [1] [j] ;
}
}
Algorithm A3. 8 computes the point on a B-spline surface and all partial deriva-
tives up to and including order d, at fixed parameters (u, v) (compare with Al-
gorithm A3. 6). d > p, q is allowed. On output, SKL [k] [1] is the derivative of
S(u,v) k times with respect to u and l times with respect to v.
ALGORITHM A3.8:
SurfaceDerivsAlg2(n,p,U,m,q,V,P,u,v,d,SKL)
{/* Compute surface derivatives */
/* Input: n,p,U,m,q,V,P,u,v,d */
/* Output: SKL */
du = min(d,p);
for (k=p+1; k<=d; k++)
for (1=0; l<=d-k; 1++) SKL[k] [1] = 0.0;
dv = min(d,q);
for (1=q+1; l<=d; 1++)
for (k=O; k<=d-l; k++) SKL[k] [1] = 0.0;
uspan = FindSpan(n,p,u,U);
AIIBasisFuns(uspan,u,p,U,Nu);
vspan = FindSpan(m,q,v,V);
A11BasisFuns(vspan,v,q,V,Nv);
SurfaceDerivCpts(n,p,U,m,q,V,P,d,uspan-p,uspan,
vspan-q,vspan,PKL);
for (k=O; k<=du; k++)
{
dd = min(d-k,dv);
for (1=0; l<=dd; 1++)
{
SKL[k] [1] = 0.0;
for (i=O; i<=q-1; i++)
{
tmp = 0.0;
for (j=O; j<=p-k; j++)
tmp = tmp + Nu[j] [p-k]*PKL[k] [1] [j] [i];
SKL[k] [1] = SKL[k] [1] + Nv[i] [q-l]*tmp;
}
}
}
}
116 B-spline Curves and Surfaces
EXERCISES
Compute S(3/1O , 6/10 ) by evaluating the nonzero B-spline basis functions and multiply-
ing these by the appropriate control points.
3.9. Derive the expressions for S,,(u, v), Sv(u, v), and S"v(u, v) at the three corners,
(u,v) = (0,1), (1,0), and (1,1) (see Eq. [3.24]).
3.10. Let S(u, v) be as in Exercise 3.8. Sketch this surface. Using Eqs. (3.20) and
(3.21), compute the surfaces S,,(u,v) and Sv(u,v). Sketch these two surfaces. Using
Eq. (3.22) and the expressions derived in Exercise 3.9, compute the mixed partial
derivative, S"v (u, v), at each of the four corners of the surface. What is the geometric
significance of these four vectors?
CHAPTER
FOUR
4.1 Introduction
In this chapter we combine the concepts of Sections 1.4 and 1.5 of Chapter 1 and
those of Chapter 3 to obtain NonUniform Rational B-Spline (NURBS) curves
and surfaces. We present definitions and general properties and derive formulas
and algorithms for the derivatives of NURBS curves and surfaces in terms of
their nonrational counterparts. The earliest published works on NURBS are
[Vers75; Till83J. A more recent survey can be found in [Pieg91aJ.
where the {Pi} are the control points (forming a control polygon), the {Wi} are
the weights, and the {Ni , p ( u)} are the pth-degree B-spline basis functions defined
on the nonperiodic (and nonuniform) knot vector
The {~,p{u)} are the rational basis junctions; they are piecewise rational func-
tions on U E [0, I].
The ~,p{u) have the following properties derived from Eq. (4.2) and the cor-
responding properties of the N i , p ( u):
Po
(a)
R O,3 Re,3
1 R 3,3
/
/
R 2,3
/
R 4,3
(b)
Figure 4.1. U = {O, 0, 0, 0, 1/4 , 1/2,3/4,1,1,1,1} and {wo, ... , W6} = {I, 1, 1,3,1,1,1}.
(a) A cubic NURBS curve; (b) associated basis functions.
of {Pi> P2 , P3 , P4 }, the dashed area)j this follows from P4. 1, P4. 2, and
P4.5j
P4. 11 C( u) is infinitely differentiable on the interior of knot spans and is p - k
times differentiable at a knot of multiplicity kj
P4.12 Variation diminishing property: no plane has more intersections with the
curve than with the control polygon (replace the word 'plane', with 'line'
for two-dimensional curves) j
P4. 13 A NURBS curve with no interior knots is a rational Bezier curve, since
the Ni,p(u) reduce to the Bi,n(U)j compare Eqs. (4.2) and (4.3) with
Eq. (1.15). This, together with P4. 7, implies that NURBS curves con-
tain nonrational B-spline and rational and nonrational Bezier curves as
special cases;
120 Rational B-spline Curves and Surfaces
P6
Ro,3 Re,,3
1
(a)
RO,3 R6 ,3
1
(b)
Ro,3
Re,,3
1 R2,3 R4,3
(c)
Figure 4.3. The cubic basis functions for the curves of Figure 4.2. (a) W3 = 1; (b)
W3 = 3/10; (c) W3 = o.
Po
i=O
Example
Ex4.1 Let U = {O,O,O, 1,2,3,3,3}, {wo, ... ,W4} = {1,4, 1, 1, I}, {Po, ... , P 4 }
= {(O,O),(1,1),(3,2),(4,1), (5,-1)}. We compute the point on the
rational B-spline curve at u = 1. Now u is in the knot span [U3, U4), and
N 3 ,o(1) = 1
2 -1 1
N 12 (1) =: - - N2 1(1) = -
, 2 - 0' 2
Definition and Properties of NURBS Curves 123
RO,2
1
o
(a)
RO,2
1
R3,2
o 1
(b)
RO,2
1
R3 ,2
o 1
(c)
Figure 4.5. The quadratic basis functions for the curves of Figure 4.4. (a) Wi = 4;
(b) Wi = 3/10; (c) Wi = O.
1-0 1
N 2,2(1) = 2 _ 0 N 2,1(1) = 2"
N 3,2(1) =0
Hence
C W (l) = !pw
2 1
+ !pw
2 2
= !2 (444)
"
(3 2 1) =
+!2" (1 3
2' '2
Q)
124 Rational B-spline Curves and Surfaces
Po
Ps
Projecting yields
= w(u)A'(u) -
~~~~~~~~~~
w'(u)w(u)C(u) A'(u) - w'(u)C(u)
(4.7)
W(U)2 w(u)
Since A(u) and w(u) represent the coordinates of CW(u), we obtain their first
derivatives using Eqs. (3.4)-(3.6). We compute higher order derivatives by dif-
ferentiating A(u) using Leibnitz' rule
.A<k)(u) = (w(u)C(u))(k) = t.(~)ll/i)(U)C(k-i)(U)
(4.8)
Equation (4.8) gives the kth derivative of C(u) in terms of the kth derivative
of A(u), and the first through (k - 1)th derivatives of C(u) and w(u). The
derivatives .A<k)(u) and w(i)(u) are obtained using either Eq. (3.3) and Algorithm
A3.2 or Eq. (3.8) and Algorithm A3.4.
Let us derive expressions for the first derivatives of a NURBS curve at its
endpoints (u = O,u = 1). From Eq. (3.7) we have
126 Rational B-spline Curves and Surfaces
Example
Ex4.2 Consider the quadratic rational Bezier circular arc given in Section 1.4
(Figure 1.19b). This is a NURBS curve on the knot vector U = {O, 0, 0,
1,1, I}, with {Pi} = {(I, 0), (1, 1), (0, I)} and {Wi} = {I, 1, 2}. From
Eqs. (4.9) and (4.10) we have
and
Now assume that u is fixed, and that the zeroth through the dth derivatives of
A(u) and w(u) have been computed and loaded into the arrays Aders and wders,
respectively, i.e., CW (u) has been differentiated and its coordinates separated
off into Aders and wders. Algorithm A4.2 computes the point, C(u), and the
derivatives, C(k)(U), 1 ~ k ~ d. The curve point is returned in CK[O) and the kth
derivative is returned in CK [k). The array Bin [] [] contains the precomputed
binomial coefficients (Bin [k) [i) is (~)).
ALGORITHM A4.2
RatCurveDerivs(Aders,wders,d,CK)
{/* Compute C(u) derivatives from Cw(u) derivatives *1
1* Input: Aders,wders,d *1
1* Output: CK *1
for (k=Oj k<=dj k++)
{
v = Aders[k)j
for (i=lj i<=kj i++)
v = v - Bin[k) [i) *wders[i) *CK[k-i) j
CK[k) = v/wders[O)j
}
}
Figure 4.7 shows the first, second, and third derivatives of a cubic NURBS
curve. The derivative vectors are scaled down by 0.4, 0.08, and 0.03, respectively.
P3
Po G----""=--------e>
Figure 4.7. First, second, and third derivatives of a cubic NURBS curve computed at
u = 1/2, with W3 = 1/2 and Wi = 1, i i- 3.
128 Rational B-spline Curves and Surfaces
The {Pi,j} form a bidirectional control net, the {Wi,j} are the weights, and the
{Ni,p(U)} and {Nj,q(v)} are the nonrational B-spline basis functions defined on
the knot vectors
U = {O, ... ,0, Up+l, ... , ur-p-l, 1, ... , I}
------
p+l
V = {O, ... ,0, vq+l, . .. ,vs-q-l, 1, ... ,I}
------
p+l
where r = n + p + 1 and s = m q 1.
------+ +
q+1
------
q+1
L LNk'P(u)NI,q(V)Wk,1
k=OI=O
the surface Eq. (4.11) can be written as
n m
S(u, v) = LL~,j(u,V)Pi,j (4.13)
i=O j=O
z
P O,4
Po,o or_
--~
P 10
, \\
y
/
/
/ /
/
/
x \
i(
/
!
!
!
/ ",Ii P
-- ! ,/
. . . '#1.. " 40
,
(a)
(b)
Figure 4.8, Control net and biquadratic NURBS surface, Wl,1 = Wl,2 = W2,1 = W2,2 =
10, with the rest of the weights L U = V = {O, 0, 0, 1/3,2/3,1,1,1}, (a) Control net;
(b) biquadratic NURBS surface.
130 Rational B-spline Curves and Surfaces
Figure 4.9. Bicubic NURBS surface defined by the control net in Figure 4.8a, with
U = V = {O, 0, 0, 0, 1/2,1,1,1,1} and with the same weights as in Figures 4.8.
S = S(U,VjW2,2 = 0)
M = S(u, Vj W2,2 = 1) (4.14)
Then the straight line defined by S and M passes through P2 ,2, and for arbitrary
W2,2, 0 < W2,2 < 00, S2,2 = S(u, Vj W2,2) lies on this line segment between S
and P 2 ,2.
(a)
Figure 4.10. The basis function R4 ,2,(U,V), with U = {O,O,O,O, 1/4, 1/2, 3/4,1,1,1, I} and
V = {O,O,O, 1/5, 2/5,3/5,3/5,4/5,1,1, I}. Wi,j = 1 for all (i,j) f= (4,2). (a) W4,2 = 2/5j
(b) W4,2 = 6.
132 Rational B-spline Curves and Surfaces
W4,2 = 6
(b)
Figure 4.10. (Continued.)
Example
l!= {O,O,O,1,2,3,4,4,5,5,5}
(a)
Figure 4.11. Cubic x quadratic surfaces corresponding to Figure 4.10, with the control
net offset for better visualization. (a) W4,2 = 2/5; (b) W4,2 = 6.
and
Then
SW(~,l) = [~ ~ ~] x
(b)
Figure 4.11. (Continued.)
,,
,
m
= LNj,q(v)Qj(uo)
j=o
n
where Qj(uo) = LNi,p(uo)Ptj
i=O
n
Analogously C~o(u) = L Ni,p(U) QY'(vo) (4.17)
i=O
m
where QY'(vo) = L Nj,q(vo)Ptj
j=O
136 Rational B-spline Curves and Surfaces
C~o(v) (C~o(u)) is a qth- (pth)-degree NURBS curve on the knot vector V (U).
The point SW(uo,vo) lies at the intersection of C~o(v) and C~o(u). Project-
ing yields
Cuo(v) = H{C~o(v)} = H{SW(uo,v)} = S(uo,v)
Cvo(u) = H{C~o(u)} = H{SW(u,vo)} = S(u,vo) (4.18)
t. G)
In general
= t(~)t(I.)w(i,j)S(k-i'l-j)
,=0 3=0 J
k I
+ L(~)L(I.)W(i,j)S(k-i'l-j)
.=1 3=1 J
(4.22)
(4.23)
P W10
Su(O, 0) = - - ' (P1 ,0 - Po,o) (4.24)
Up +1 Wo,o
q W01
Sv(O,O) = - - ' (PO,l - Po,o) (4.25)
Vq +1 Wo,o
+ (
2W1,OWO,1
- W11
) n
roo ) (4.26)
W 0,0 "
Figure 4.13 shows the first- and second-order partial derivatives of a NURBS
surface. The first partials are scaled down by 1/2, and the second partials are
scaled down by 113-
Now assume that (u, v) is fixed, and that all derivatives A(k,l), W(k,l) for k, l 2:
and 0 ~ k + l ~ d, have been computed and loaded into the arrays Aders and
°
wders, respectively. Algorithm A4. 4 computes the point S(u, v) and the deriva-
tives S(k,l)(u,v), 0 ~ k + l ~ d. Bin[] [] contains the precomputed binomial
coefficients.
ALGORITHM A4.4
RatSurfaceDerivs(Aders,wders,d,SKL)
{ 1* Compute S(u,v) derivatives *1
1* from Sw(u,v) derivatives *1
1* Input: Aders,wders,d *1
1* Output: SKL *1
for (k=O; k<=d; k++)
for (1=0; 1<=d-k; 1++)
{
v = Aders [k] [1] ;
for (j=l; j<=1; j++)
v = v - Bin[1] [j]*wders[O] [j]*SKL[k] [1-j];
138 Rational B-spline Curves and Surfaces
Figure 4.13. The first- and second-order partial derivatives of a bicubic NURBS surface
computed at u = % and v = 1/4.
EXERCISES
4.1. Let U = {O, 0, 0, 1/3, %, 1, 1, 1} and {wo, ... , w4}={1, 4,1,1,1}. Using the Cox-
deBoor recurrence formula (Eq. [2.5]) and Eq. (4.2), compute the five quadratic rational
functions, ~,2(U), 0 :S i :S 4. The graphs of these functions are shown in Figure 4.5a.
Assume {Po, ... , P 4 } = {(O, 0), (1, 1), (3,2), (4, 1), (5, -I)} are control points in the xy
plane. Compute the rational coordinate functions x(u) and y(u) representing C(u) in
the interval u E [1/3, %).
Exercises 139
4.2. Refer to Example Ex4. 2 for a quadratic rational Bezier circular arc; compute
C"(l).
4.3. Let C W(u) = E!=o Ni, 1(u) P!" be a line segment in the xy plane, where Po =
(0,1), PI = (2,0), Wo = 1, WI = 3, and U = {0,0,1,1}. Derive the rational functions
representing the x and y coordinates of this line segment, i.e., x(u) and y(u), where
C(u) = (x(u),y(u)). Compute C'(O) using Eq. (4.9) and C"(O) using Eqs. (4.8) and
(3.9). Then set WI = 1 and recompute x(u), y(u), C'(O), and C"(O).
4.4. Let SW(u,v) = E!=o E~=oNi,l(U)Nj,l(V)P~j, where {Po,o, P1,o, PO,l, P1,1} =
{(O, 0,1), (0,1,3),(2,1,1),(2,0, 3)}, {wo,o, W1,O, WO,l, W1,1} = {2, 1, 1, 1}, and U = V =
{O, 0,1, 1}. Derive the four rational basis functions, Ro,j(u, v), 0 $ i,j $ 1, and the
rational coordinate functions x(u, v), y(u, v), and z(u, v) of the surface S(u, v).
4.5. From SW (u, v) in Exercise 4.4 derive the two rational isoparametric curves C:!'o (v)
and C::'o(u), for Uo = 1/a and Vo = 1/2. Then evaluate the curves Cuo(v) and C"o(u) at
v = 1/2 and u = 1/3 , respectively. Check your results by substituting (u, v) = (1/a, 1/2)
into the rational coordinate functions obtained in Exercise 4.4.
4.6. Let SW(u,v) = E;=oE~=oNi,l(U)Nj,l(V)P~j be the surface given in Exercise
4.4. Since N O,l(1/2) = N 1,1(1/2) = 1/2, it follows that
5.1 Introduction
In this chapter we present five tools which are fundamental in the implementation
of B-spline curves and surfaces; these are knot insertion, knot refinement, knot
removal, degree elevation, and degree reduction. We devote a section to each
topic, and the layout of each section is roughly:
• a statement of the problem (for curves);
• a list of applications;
• clarification of the problem and solution approaches (curves);
• a list of references where more rigorous derivations and proofs can be
found;
• the solution formulas (curves);
• worked examples (curves);
• computer algorithms;
• examples of applications;
• the solution for surfaces, and outlines of the surface algorithms.
where the {Ni,p(u)} are the pth-degree basis functions on U. The term knot
insertion generally refers to the process of determining the {Qi"} in Eq. (5.1).
It is important to note that knot insertion is really just a change of vector space
basis; the curve is not changed, either geometrically or parametrically.
Although not immediately obvious, knot insertion is one of the most important
of all B-spline algorithms. Some of its uses are:
• evaluating points and derivatives on curves and surfaces;
• subdividing curves and surfaces;
• adding control points in order to increase flexibility in shape control (in-
teractive design).
Now the {Qi"} in Eq. (5.1) can be obtained by setting up and solving a system
of linear equations. If we set
n n+l
LNi,p(u)Pi = LNi,p(u)Qi (5.2)
i=O i=O
Equations (5.3) and (5.4), together with the linear independence of the basis
functions (Section 2.4), imply that
Pi= Qi i = 0, ... , k - p - 1
Pi = Qi+1 i = k + 1, ... ,n (5.5)
Now consider the Ni,p(U) for i = k - p, ... , k. They can be expressed in terms
of the Ni,p(U) when i = k - p, ... , k + 1, by
(5.6)
Equation (5.6) is proven by induction on p (and using Eq. [2.5]), but we omit
the proof here as it is quite messy. Proofs using divided differences are found in
[DeBo78; Boeh80; Lee83].
Knot Insertion 143
For brevity we now write Ni for Ni,p(U). Substituting Eq. (5.6) into Eq. (5.3)
yields
pw
( _
U - Uk-p
_
N
k-p + Uk+2 - U N )
k-p+1 k-p
Uk+1 - Uk-p Uk+2 - Uk-p+1
U - Uk-p+1 - Uk+3 - U - )
+ ( Uk+2
- - Uk-p+l
- + Uk+3
_ - Uk-p+2
_
W
Nk-p+1 Nk-p+2 P k- +1
P
o= Nk - p ( Q~_p - P~_p )
+ N- k (Qwk - U - Uk
Uk+p - Uk
pw
k -
Uk+p - U
Uk+p - Uk
pW) + N- (QW
k-l k+1 k+1 -
pW) k
(5.7)
Using the linear independence of the basis functions, and substituting Eqs. (5.8)
and (5.9) into Eq. (5.7), yields
Q~-p = P~-p
Q~+1 = p~ (5.10)
Finally, by combining Eqs. (5.5) and (5.10) we obtain the formula for computing
all the new control points, Qr', of Eq. (5.1), that is
(5.11)
144 Fundamental Geometric Algorithms
where i5,k-p
k-p+l5,i5,k
i2:k+1
Equation (5.11) says that only p new control points must be computed. For
brevity we use P instead of pw in examples Ex5. 1 - Ex5. 4.
Examples
5
2- 0
0:3 = 3 _ ° ==
5
6" ==}
5 1
Q3 = 6" P 3 + 6" P 2
Figure 5.1a shows the control polygon before and after the insertion,
and Figure 5.1b shows the basis functions before and after the insertion.
The bottom part of Figure 5.1a shows the ratios used to subdivide the
polygon legs.
Ex5.2 Use the same curve as in Ex5 .1, that is, p = 3, U = {O, 0, 0, 0,1,2,3,4,5,
5,5,5}, and Po, ... , P 7 . This time we insert a knot which is already in
the knot vector, namely u = 2. Then u E [U5' U6), k = 5, and again we
compute Q3' Q4' and Q 5
The control polygons and basis functions, before and after knot inser-
tion, are shown in Figures 5.2a and 5.2b. From Eq. (5.6) one can verify
Knot Insertion 145
~------------~ PS=Q6
IIII IIII
(a)
No = No
1
(b)
Figure 5.1. Knot insertion into a cubic curve. (a) The control polygon after inserting
u = s/2 into the knot vector {O, 0, 0, 0,1,2,3,4,5,5,5, 5}j (b) the original (solid) and
the new (dashed) basis functions before and after knot insertion.
Clearly, knot insertion is similar to the deCasteljau algorithm for Bezier curves,
and in fact they are equivalent for a curve with no interior knots, i.e., a Bezier
curve. However, a glance at Example Ex5. 1 and Figure 5.la shows that the
linear interpolation is not the same on each of the p legs of the control polygon.
Indeed, in the example, a3 = 5/6, a4 = 1/2, and a5 = 1/6. Based on the previous
146 Fundamental Geometric Algorithms
P2 = Q2 P3
Q3
U
1111 ~ 1111
• .----I
"'- -------.J
(a)
No = No N7 = Ns
1
N3 N4
N5 = N6
u=2
(b)
Figure 5.2. Inserting an existing knot into a cubic curve. (a) The control polygon after
inserting u = 2 into {O, 0, 0, 0,1,2,3,4,5,5,5, 5}; (b) the original (solid) and the new
(dashed) basis functions before and after knot insertion.
examples, we arrive at the general result: For i = 1, ... , n let Li denote the
ith-Ieg of the control polygon
With each leg L i , we associate the knots UHj, j = 0, ... ,po Refer to Figures 5.3a
and 5.3b and Figures 5.1a and 5.2a. For fixed i let A{, j = 0, ... ,p - 1, denote
the length of the knot span [UHj, UHj+l) relative to lUi, UHp)
Aj = uHj+l - UHj
j = 0, ... ,p-l (5.12)
• uHp - Ui
(5.13)
respectively. Notice that A{, and hence dl, can be zero. For example, df = df =
and dl = d1 in Example Ex5 .1; thus, there is only one segment on the first leg.
°
Now Figures 5.3a and 5.3b and Eq. (5.13) show how the polygon legs are
subdivided, and Figures 5.1a and 5.2a show how polygon corners are cut in the
knot insertion process. In particular, if u E [Uk, uk+d is a knot of multiplicity s,
° ~ s ~ p-l, then the corners with control points P k - pH , ... , P k - s - 1 are cut,
and the following p- s new control points are generated on the indicated segments
Qk' . E L{ .
-) -)
j =p-l, ... ,s (5.14)
P3
PlO
P9
P4
Pi
P5 Ps
Po
Pa P7
IIII I I I II I I IIII
° 1 2 3 4 5 6 7
(a)
Figure 5.3. The control polygon and its partitioning by its knot vector. (a) Parti-
tioning of the entire polygon by the knot vector {O, 0, 0, 0,1,2,3,4,4,5,6,7,7,7, 7};
(b) partitioning of the polygon side P2 P 3 by the knot span [U3, ua].
148 Fundamental Geometric Algorithms
Us
I
I-=~~~~- ~---=-l
(b)
Figure 5.3. (Continued.)
Examples
Furthermore
A~ = U6 - U5 = 3 - 2 = .!
U6 - U3 3- 0 3
A! = U6 - U5 = 3- 2 = .!
U7 - U4 4 -1 3
A~ = ~6 - U5 = 3- 2 = .!
U8 - U5 5- 2 3
(This is not surprising, since the knots are equally spaced). Recalling
that 03 = 5/6, 04 = 1/2, and 05 = 1/6, we see that Q3' Q4' and Q5 are
located at the midpoints of their segments, L5, Lg.
L!, and This follows
from the fact that u = 5/2 is halfway between U5 = 2 and U6 = 3.
Ex5.4 For Example Ex5.2, k = 5 and s = 1. By Eq. (5.14)
and Li, respectively. This follows from the fact that u= 2 lies at the
start of the knot span, [U5, U6).
Figure 5.4 shows the partitioning of the same control polygon as in Figure 5.3a
but with the nonuniform knot vector U = {O, 0, 0, 0,1,1.5,2.3,3.9,4.3,5,6.5,
7,7,7,7}.
As we shall see later, it is often necessary to insert a knot multiple times.
Equation (5.11) can be generalized to handle this. Suppose u E [Uk,Uk+t} ini-
tially has multiplicity s, and suppose it is to be inserted r times, where r + s :S P
(it generally makes no practical sense to have interior knot multiplicities greater
than p). Denote the ith new control point in the rth insertion step by QY'r (with
Qro = Pr). Then Qrr is '
(5.15)
where i:Sk-p+r-1
i2:k-s+1
°
If s = and r = p, then Eq. (5.15) generates a triangular table of control points
(see Table 5.1, and see Figure 5.5 with p = 3). The outer control points
Figure 5.4. Nonuniform partitioning of the control polygon in Figure 5.3a defined by
the knot vector {O, 0, 0, 0,1,1.5,2.3,3.9,4.3,5,6.5,7,7,7, 7}.
150 Fundamental Geometric Algorithms
are kept, and the inner ones are discarded. In general, the table is less than full
if s > 0 and/or r + s < p. But in any case, the final control points are obtained
by traversing the resulting table in a clockwise fashion, starting at the top of the
first column generated. The number of new control points in the last column is
p - (s + r) + 1. In all other columns, two new points are kept (top and bottom) j
thus, the total number of new (keeper) control points is
p-s+r-1 (5.16)
These new control points replace
p-s-1 (5.17)
PI
QI,I
Po
U
IIII ~ IIII
8
8 r=l
9
9 r=2
9
9 r=3
Figure 5.5. Knot insertion into a cubic curve three times. The curve is defined on
{0,0,0,0,2,3,3,3,3}.
Knot Insertion 151
We now consider three applications of knot insertion, curve splitting (or subdi-
vision), the evaluation of points and derivatives, and insertion in order to obtain
an additional control point for interactive shape design. Refer to Figure 5.5.
The original curve, C{u), is a cubic defined by U = {O,O,O,O,2,3,3,3,3} and
Po, ... , P 4 • 'it = 1 is now inserted three times. Figures 5.6a and 5.6b show the
basis functions before and after insertion. The process splits the curve. The
sets of control points {PO,Ql,1,Q2,2,Q3,3} and {Q3,3,Q3,2,Q3,1,P3,P4} define
cubic B-spline curves, CI{U) and Cr{u), on the knot vectors UI = {O,O,O,O,1, 1,
152 Fundamental Geometric Algorithms
o 2 3
(a)
(b)
Figure 5.6. Basis functions corresponding to Figure 5.5. (a) Before knot insertion;
(b) after knot insertion.
Knot Insertion 153
Figure 5.7. Splitting a cubic curve defined on {O, 0, 0, 0,1/4 ,1/2,3/4,1,1,1, I}.
ALGORITIIM A5.2
CurvePntByCornerCut(n,p,U,Pw,u,C)
{ /* Compute point on rational B-spline curve */
/* Input: n,p,U,Pw,u */
/* Output: C */
if (u == U[O]) /* Endpoints are special cases */
{
C = Pw[O]/w; return;
}
if (u == U[n+p+l])
{
C = Pw[n]/w; return;
}
FindSpanMult(n,p,u,U,&k,&s); /* General case */
r = p-s;
for (i=O; i<=r; i++) Rw[i] = Pw[k-p+i];
for (j=l; j<=r; j++)
for (i=O; i<=r-j; i++)
{
alfa = (u-U[k-p+j+i])/(U[i+k+l]-U[k-p+j+i]);
Rw[i] = alfa*Rw[i+l] + (1.0-alfa)*Rw[i];
154 FUndamental Geometric Algorithms
}
C Rw[O]/w;
}
The third application is interactive shape design. As we saw in Chapter 4,
curves and surfaces can be shaped by moving control points and/or modifying
weights. For modification purposes, a designer might like to have a control
point somewhere on the control polygon where one currently does not exist.
For example, suppose he picks the point Q on the three-dimensional polygon
leg, P i - 1 Pi (see Figure 5.8). Denote the corresponding four-dimensional point
on the leg, Li = Pf'-lPf', by Q W • Then there exists au E [Ui,UHp) such
that a single insertion of u causes QW to become a new control point and Q
its projection. This process of determining u is called inverse knot insertion
[Pieg89cJ. Now there exists a value s, 0::; s ::; 1, such that
(5.19)
It follows that
(5.20)
and thus
(5.21)
Knots are inserted into surfaces by simply applying the previous formulas and
algorithms to the rows and/or columns of control points. In particular, let prj'
Q Pi
Figure 5.8. Inverse knot insertion for cubic curves; the point Q lies on the leg Pi- 1 Pi
partitioned by the knots Ui, Ui+l, UiH, and Ui+3.
Knot Insertion 155
° °
~ i ~ n, ~ j ~ m, be the control points of a NURBS surface; call i the row
index and j the column index. Then u is added to the knot vector U by doing a
u knot insertion on each of the m + 1 columns of control points. The resulting
° °
control net is Qri' ~ i ~ n + 1, ~ j ~ m. Analogously, v must be inserted
° ~ i ~ n, °
on each of the n + 1 rows of control points. The resulting control net is Qri'
~ j ~ m + 1. Figure 5.9 shows a cubic x quadratic surface on
U = {a, 0, 0, 0,1,1,1,1} and V = {a, 0, 0, 1/2,1, 1, I}. Figures 5.lOa and 5.lOb
show insertion of the knots u = 4/10 and v = 7/10, respectively, and Figure 5.lOc
shows the insertion of both knots. We point out that a surface knot insertion
algorithm should not merely consist of a loop in which Algorithm A5. 1 is called
m + 1 (or n + 1) times. The computation of the alphas (alpha in A5. 1) does
not depend on the control points. Hence, they should be computed only once
and stored in a local array before entering the loop which executes the m + 1 or
n + 1 knot insertions. Algorithm A5. 3 is such an algorithm.
ALGORITHM A5.3
SurfaceKnotIns(np,p,UP,mp,q,VP,Pw,dir,uv,k,s,r,nq,UQ,mq,VQ,Qw)
{ /* Surface knot insertion */
/* Input: np,p,UP,mp,q,VP,Pw,dir,uv,k,s,r */
/* Output: nq,UQ,mq,VQ,Qw */
if (dir == UJDIRECTION)
PO,3
",
, ;
,, ,,
Po,o _--:
".
,,
y
, /
,,
x , /
"',/ P3 ,o
Figure 5.9. The control net of a (cubic x quadratic) surface defined on the knot vectors
U = {O,O,O,O, 1, 1,1, I} and V = {O,O,o, 1/2,1,1, I}.
156 Fundamental Geometric Algorithms
,
"'';,,
...........
y
(a)
x .,
, /
"
"
--"', I
' ........... / Q3 0
(b)
Figure 5.10. Knot insertion into the surface in Figure 5.9. (a) Inserting u = 2/s one
time in the u direction; (b) inserting v = 7/10 one time in the v direction; (c) inserting
both knots at the same time.
Knot Insertion 157
"",s' Q
4,0
(c)
Figure 5,10. (Continued.)
{
load u-vector as in A5.1
copy v-vector into VQ
/* Save the alphas */
for (j=l; j<=r; j++)
{
L = k-p+j;
for (i=O; i<=p-j-s; i++)
alpha[i] [j] = (uv-UP[L+i])/(UP[i+k+l]-UP[L+i]);
}
for (row=O; row<=mp; row++) /* For each row do */
{
/* Save unaltered control points */
for (i=O; i<=k-p; i++) Qw[i] [row] = Pw[i] [row] ;
for (i=k-s; i<=np; i++) Qw[i+r] [row] = Pw[i] [row] ;
/* Load auxiliary control points. */
for (i=O; i<=p-s; i++) Rw[i] = Pw[k-p+i] [row] ;
for (j=l; j<=r; j++) /* Insert the knot r times */
{
L = k-p+j;
for (i=O; i<=p-j-s; i++)
158 Fundamental Geometric Algorithms
y
x ,,
" " ,
'.. ,,
\.,:", ,
,,/
,
,
" -,_ I '
'II
(a)
/'
"
...... _-.
y
" ";'
,
x
-,
,, /
/
(a)
. Figure(b) . atv =
5.1 m the u directIOn 7/10 . (a) The
Figure 5net f the splitt hsur
.13 .0 Splitting e sfurface . surl'
ace,. (b)m the split face.
control
Knot Insertion 161
x ", /
'-:
'. /
'fi_
(a)
Figure 5.14. Splitting the surface in Figure 5.11 in both u and v directions at u = 2/5
and v = 7/10. (a) The control net of the split surface; (b) the split surface .
(b)
Figure 5.14. (Continued.)
IIII IIII
(a)
IIII IIII
(b)
Figure 5.16. Curve refinement. (a) Cubic curve defined on {O,O,O,O, 3/10, 7/10 ,1,1,1, I};
(b) the first midpoint knot refinement; (c) the second midpoint knot refinement.
1111 1111
(c)
Figure 5.16. (Continued.)
1* Output: Ubar,Qw *1
m = n+p+1;
a = FindSpan(n,p,X[O],U); 1* Algorithm A2.1 *1
b = FindSpan(n,p,X[r],U);
b = b+1;
for (j=O; j<=a-p; j++) Qw [j ] = Pw [j] ;
for (j=b-1; j<=n; j++) Qw[j+r+1] = Pw[j]j
for (j=O; j<=a; j++) Ubar[j] = U[j];
for (j=b+p; j<=m; j++) Ubar[j+r+1] = U[j];
i = b+p-1; k = b+p+r;
for (j=rj j>=Oj j--)
{
while (X[j] <= U[i] && i > a)
{
Qw[k-p-1] = PW[i-p-1] j
Ubar [k] = U[i] j
k = k-1; i = i-1j
}
Qw[k-p-1] = Qw[k-p]j
for (1=1; l<=pj 1++)
{
ind = k-p+l;
alfa = Ubar[k+l]-X[j]j
if (abs(alfa) == 0.0)
Qw[ind-1] = Qw[ind];
else
166 Fundamental Geometric Algorithms
(a)
. ,
\ .-
,
--,,
\,
\
,
)t,
\
-'/ I
/
\
"
I Y
Y,
X \ I
Ir: I
'yl
I
'",
(b)
Figure 5.17. Refining the surface in Figure 5.9. (a) The third midpoint refinement in
the u direction; (b) the second midpoint refinement in the v direction; (c) the third
refinement in the u direction and second in the v direction.
Knot Refinement 167
z
(c)
Figure 5.17. (Continued.)
{
alfa = alfa/(Ubar[k+l]-U[i-p+l])j
Qw[ind-l] = alfa*Qw[ind-l] + (1.0-alfa)*Qw[ind]j
}
}
Ubar[k] X[j] j
k = k-lj
}
}
Let SW(u, v) = 2:~=0 2:;:0 Ni,p(u)Nj,q(v)P'tj be a NURBS surface on U and
V. A U knot vector refinement is accomplished by simply applying Algorithm
A5 . 4 to the m + 1 columns of control points. A V refinement requires n + 1
applications of Algorithm A5. 3. The algorithm can be organized so that redun-
dant operations are eliminated (e.g., the values of the alfas in the last for-loop
are the same for each of the m + 1 columns of control points). A sketch of the
algorithm is:
ALGORITHM A5.5
RefineKnotVectSurface(n,p,U,m,q,V,Pw,X,r,dir,Ubar,Vbar,Qw)
{ /* Refine surface knot vector */
/* Input: n,p,U,m,q,V,Pw,X,r,dir */
/* Output: Ubar, Vbar, Qw */
168 Fundamental Geometric Algorithms
if (dir == UJDlRECTION)
{
find indexes a and b;
initialize Ubar;
copy V into Vbar;
/* Save unaltered ctrl pts */
for (row=O; row<=m; row++)
{
for (k=O; k<=a-p; k++) Qw[k] [row] = Pw[k] [row];
for (k=b-1; k<=n; k++) Qw[k+r+1] [row] = Pw[k] [row] ;
}
for (j=r; j>=O; j--)
{
while (X[j]<=U[i] && i>a)
{
compute Ubar;
for ( row Qw[k-p-1] [row] = PW[i-p-1] [row] ;
k = k-1; i i-1;
}
for ( row ... ) Qw[k-p-1] [row] = Qw[k-p] [row];
for (1=1; l<=p; 1++)
{
ind = k-p+l;
compute alia;
if (abs(alfa) == 0.0)
for ( row ... ) Qw[ind-1] [row] = Qw[ind] [row];
else
{
compute alia;
for ( row '" )
Qw[ind-1] [row]
alfa*Qw[ind-1] [row]+(1.0-alfa)*Qw[ind] [row];
}
}
Ubar[k] = X[j]; k = k-1;
}
}
if (dir == VJDlRECTION)
{
/* Similar code as above with u and v directional
parameters switched */
}
}
An important application of knot refinement is the problem of decomposing a
NURBS curve into its constituent (four-dimensional) polynomial segments. This
Knot Refinement 169
is required when converting a NURBS curve to another spline form, e.g., to the
IGES Parametric Spline Curve, Entity type 112 [IGE93]. In such a conversion,
the first step is to decompose the curv.e into its piecewise Bezier form. The Bezier
control points of the segments are obtained by inserting each interior knot until
it has multiplicity p. This is done in two steps:
1. pass through U and build the refinement vector X;
2. call Algorithm A5. 4.
Figures 5.18a and 5.18b show a cubic curve and its corresponding basis func-
tions; Figures 5.19a and 5.19b show the same curve and its basis functions after
decomposition. The control points in Figure 5.19a are the Bezier control points
of the curve's segments. Figures 5.20a, 5.20b, 5.21a, and 5.21b show the decom-
position of a surface.
(a)
° 1 2
(b)
3 4
Figure 5.18. A cubic curve. (a) The curve and its control polygon; (b) basis functions
defined over {O,O,O,O,1,2,3,4,4,4,4}.
170 Fundamental Geometric Algorithms
(a)
o 1 2 3 4
(b)
Figure 5.19. Decomposition of the curve in Figure 5.18 into a piecewise Bezier curve via
knot refinement. (a) The decomposed curve and its control polygon; (b) basis functions
after inserting knots 1, 2, and 3 two times each.
We now give an algorithm which extracts all the Bezier segments of a curve,
working from left to right, in an efficient manner. For convenience we drop the
w superscipts from control points. Figures 5.22a through 5.22d best explain
the algorithm. Let C(u) = 2:;=0 N i ,3(U) Pi be a cubic curve with two distinct
interior knots, and let Q{ be the kth control point of the jth Bezier segment,
k = 0, ... ,p and j = 0,1,2. Notice in Figures 5.22b and 5.22c that while the
rightmost Bezier control points of the zeroth segment, Qg and Qg, are being
computed (via knot insertion), the leftmost Bezier points of the first segment,
Q6 and Q~, are also being computed and stored.
Another major reduction in computation, as compared with using general
knot refinement, is achieved by examining the computation of the knot insertion
alphas (Eq. [5.15]). Assume [u a , Ub] is the current segment being processed,
where a and b are the indices of the rightmost occurrences of knots U a and Ub.
Knot Refinement 171
.... -----:-..-::\",
r~:'-T
\ ....
/'. .,
\'"
_: '>\ ;i<;:~::>'
-- ....... ..... - --
~\
,
y
(a)
(b)
Figure 5.20. A (cubic x quadratic) surface to be decomposed. (a) The control net;
(b) the surface defined over U = {O, 0, 0, 0, 3js, 1, 1, 1, I} and V = {O, 0, 0, 2/s, 1, 1, I}.
Then, when we start to insert Ub the knot vector has the form (locally)
••• ,Ua - p +l
,
= ... = Ua, Ub-s+l = ... = Ub
? ' , :y .,
(5.22)
p 8
172 Fundamental Geometric Algorithms
--............
... ~~
\
\
.~./
\ .. ",. y
(a)
Figure 5.21. Piecewise Bezier patch decomposition via knot refinement. (a) The control
nets; (b) Bezier surface patches.
O!b-s,p-s
O!b-s-1,1
O!b-s,2
ab-s,l
(b)
Figure 5.21. (Continued.)
Notice that the as along southeasterly diagonals are 0.2/0 .4 , 0.2/0 .6 , and 0.2/0 .S,
respectively, and that the numerator remains 0.2.
Algorithm A5 . 6 decomposes a NURBS curve and returns nb Bezier segments.
Qw [j] [k] is the kth control point of the j th segment. The local array alphas []
contains the alphas, with their indices shifted to start at O.
ALGORITHM A5.6
DecomposeCurve(n,p,U,Pw,nb,Qw)
{ /* Decompose curve into Bezier segments */
174 Fundamental Geometric Algorithms
Ps
IIII IIII
(a)
Po= Qg
IIII ~I IIII
(b)
Figure 5.22. On-the-fly curve decomposition. (a) The original cubic curve; (b) first
knot inserted; (c) second knot inserted; (d) preparation for the second segment.
1* Input: n,p,U,Pw *1
1* Output: nb,Qw *1
m = n+p+l;
a = Pi
b = p+l;
nb = 0;
for (i=Oi i<=Pi i++) Qw[nb] [i] = Pw[i]i
Knot Refinement 175
Po= Qg
IIII IIII
(c)
Q~ = P3
while (b < m)
{
i = b;
while (b < m && U[b+l] == U[b]) b++;
mult = b-i+l;
if (mult < p)
{
numer = U[b]-U[a]; /* Numerator of alpha */
176 Fundamental Geometric Algorithms
r=l
r=2
r=3
Figure 5.23. Ratios for the alphas used to compute the second Bezier segment of a
quartic curve.
ALGORITHM A5.7
DecomposeSurface(n,p,U,m,q,V,Pw,dir,nb,Qw)
{ 1* Decompose surface into Bezier patches *1
1* Input: n,p,U,m,q,V,Pw,dir *1
1* Output: nb,Qw *1
if (dir == UJDIRECTION)
(a)
Figure 5.24. On-the-fly decomposition of a quartic curve. (a) The first Bezier segment;
(b) the second Bezier segment; (c) the third Bezier segment.
178 Fundamental Geometric Algorithms
(b)
(c)
Figure 5.24. (Continued.)
{
a=p; b=p+1;
nb=O;
for (i=O; i<=p; i++)
for (row=O; row<=m; row++)
Qw[nb] [i] [row] = Pw[i] [row];
while (b<m)
{
get multi
if ( mult<p )
{
get the numerator and the alfas;
for (j=l; j<=p-mult; j++)
{
save= ... ;
s = ... ;
Knot Removal 179
Figure 5.25. Surface decomposition on the fly; three Bezier patches are shown.
where Ni,p(U) are the basis functions on Ut , that is, Eqs. (5.23) and (5.24)
geometrically and parametrically represent the same curve.
From earlier chapters we know that the basis functions Ni,p(U) which are
nonzero at U r are only Cp-s continuous there. Furthermore, although one does
not generally expect more than Cp-s continuity of the curve, the control points
Pi" can lie in positions such that the (p - s + 1)th (or even higher) derivative
is continuous. Hence, the knot U r is t times removable if and only if the curve
CW (u) is Cp-sH continuous at U = U r . It is important to note that the continuity
must be with respect to CW(u), not its projection C(u) which can be continuous
even though CW(u) is not.
A knot removal algorithm must do two things:
• determine if a knot is removable and how many times;
• compute the new control points, Qr.
Details can be found in [Till92].
Knot removal is an important utility in several applications:
• The standard method to convert a spline curve or surface represented in
power basis form to B-spline form is:
convert the segments (patches) to Bezier form;
obtain a B-spline representation by piecing the Bezier segments to-
gether and using knot vectors in which all interior knots have multi-
plicity equal to the degree;
Knot Removal 181
We describe the knot removal process with an example. As usual, the al-
gorithm operates on the four coordinates of the control points, but we drop
the w superscript for the sake of notational convenience. Consider the cubic
curve of Figure 5.26. Assume the original curve is defined by {Pg, ... ,Pg} and
U = {uo, ... , UlO}, where the superscript on the control points denotes the step
number in the knot removal process, and the knots are Uo = ... = U3 = 0,
U4 = U5 = U6 = 1, and U7 = ... = UlO = 2. Consider removing U = 1(= U6).
p32
p~
----~---
--------1
p~ cr - - - - / '
,
" , p~ = P5
'., pI2 -_ pO2.t¥. ~_:::=:,,"_>-=::::::--"- ,
, I
\
, pO I
,, 3
p~ = p~ = p~
P~ = P~
U7 = Us = Ug = UIO
Figure 5.26. Knot removal from a cubic curve with a triple knot.
182 Fundamental Geometric Algorithms
U-U3
(5.25)
Equation (5.25) is just the equation for inserting U = 1 into the knot vector
having 1 as a double knot (U7 is U6 in that knot vector). Furthermore, the second
derivative at U = 1 is continuous if and only if the knot U = 1 can be removed a
second time. It can be removed when
P~ = Q2P~ + (1 - (2)P~
P~ = QIP~ + (1 - Ql)P~
P~ = Q2P~ + (1 - (2)P~
P~ = Q3P~ + (1 - (3)P~ (5.27)
U -Ui
with Qi=---- i = 1,2,3
uHp+3 - Ui
2 _ p~ - a3P~
P2 -
1- a3
If these two values for P~ are within tolerance, then the knot can be removed
and P~ and P~ are replaced by P~.
Solving the first and third equations of Eq. (5.27), we obtain
Then substitute P~ and P~ into the right side of the second of Eqs. (5.27), and
check to see if it is within tolerance of P~. If it is, remove the knot and replace
P~, P~, and P~ with P~ and P~.
In general, to solve the system of equations start with the first and last equa-
tions and work inward, computing the new control points. If the number of
equations is even (as in Eq. [5.26]), then the final new control point is computed
twice. The knot can be removed if the two values of the control point are within
tolerance. If the number of equations is odd (as in Eqs. [5.25] and [5.27]), then
all new control points are computed once, and the last two computed are substi-
tuted into the middle equation. If the result is within tolerance of the old control
point on the left side of the middle equation, then the knot is removable.
We now give general formulas. Let U = U r =I Ur+l be a knot of multiplicity s,
where 1 ~ s ~ p. The equations for computing the new control points for one
removal of U are
r - p~i ~ ~ (2r - p - s - 1)
1 .
2" (2r - p - s + 2) ~ J ~ r - s (5.28)
U-Uk
with ak = ----'-'- k = i,j
Uk+v+1 - Uk
while (j - i > 0)
ai = ...
aj = .. .
P} = .. .
P~ = .. .
J
i = i + Ij j = j - Ij
184 Fundamental Geometric Algorithms
Now suppose we want to remove U = U r multiple times. Each time the knot
is removed, sand r are decremented (in Eq. [5.28]) and the superscripts on the
control points are incremented. Thus, the equations for removing U = U r the tth
time are
1 .
"2 (2r - p - s + t + 1) ::; J ~ r - s + t - 1
(5.29)
U - Ui U - u"-t+1
3
with Qi = -----'- n." _
'-'3 -
uHp+t - Ui uj+p+1 - Uj-t+1
first = r - p + 1; last = r - s - 1;
for t = 1, ... ,k
first = first - 1; last = last + 1;
i = first; j = last;
while (j - i > t - 1)
Qi = ...
Qj =
p~ = .. .
p~ = .. .
3
i = i + 1; j = j - 1;
• if the curve is nonrational (all Wi = 1), then one knot removal results in
a curve whose deviation from the original curve is less than TOL, on the
entire parameter domain;
• if the curve is rational, then the deviation is everywhere less than
TOL(l+ IPlmax)
Wmin
where Wmin is the minimum weight on the original curve, and IP Imax is the
maximum distance of any three-dimensional point on the original curve
from the origin. The convex hull property of B-splines is used to compute
bounds for Wmin and IP Imax . If the desired bound on deviation is d, then
TOL should be set to
dWmin
TOL= 1 + IPI max (5.30)
ALGORITHM A5.8
RemoveCurveKnot(n,p,U,Pw,u,r,s,num,t)
{ /* Remove knot u (index r) num times. */
/* Input: n,p,U,Pw,u,r,s,num */
/* Output: t, new knots t ctrl pts in U t Pw */
m = n+p+lj
ord = p+1j
fout = (2*r-s-p)/2j /* First control point out */
last = r-Sj
first = r-pj
for (t=Oj t<numj t++)
{ /* This loop is Eq.(5.28) */
off = first-lj /* Diff in index between temp and P */
temp[O] = Pw[off]j temp[last+l-off] = Pw[last+l]j
i = firstj j=lastj
ii = lj jj = last-offj
remflag = OJ
while (j-i > t)
{ /* Compute new control points for one removal step */
alfi = (u-U[i])/(U[i+ord+t]-U[i])j
alfj = (u-U[j-t])/(U[j+ord]-U[j-t])j
temp [ii] (Pw[i]-(1.0-alfi)*temp[ii-l])/alfij
temp[jj] (Pw[j]-alfj*temp[jj+l])/(1.0-alfj)j
i = i+lj i i = ii+lj
j = j-lj jj = jj-lj
} /* End of while-loop */
i f (j-i < t) /* Check if knot removable */
{
if (Distance4D(temp[ii-l],temp[jj+l]) <= TOL)
remflag = lj
186 Fundamental Geometric Algorithms
}
else
{
alfi = (u-U[i])/(U[i+ord+t]-U[i]);
if (Distance4D(Pv[i],alfi*temp[ii+t+1]
+(1.0-alfi)*temp[ii-1]) <= TOL)
remflag = 1;
}
if (remflag == 0) 1* Cannot remove any more knots *1
break; 1* Get out of for-loop *1
else
{ 1* Successful removal. Save new cont.pts. *1
i = first; j = last;
while (j-i > t)
{
Pw[i] = temp[i-off]; Pv[j] = temp[j-off];
i = i+1; j = j-1;
}
}
first = first-1; last = last+1;
} 1* End of for-loop *1
if (t == 0) return;
for (k=r+1; k<=m; k++) U[k-t] = U[k]; 1* Shift knots *1
j = fout; 1=J; 1* Pj thru Pi will be overwritten *1
for (k=1; k<t; k++)
if (Mod(k,2) == 1) 1* k modulo 2 *1
i = i+l; else j = j-1;
for (k=i+1; k<=n; k++) 1* Shift *1
{ Pv[j] = Pw[k]; j = j+1; }
return;
}
Table 5.2 shows how the control point array changes for the cubic curve ex-
ample given in Figure 5.26. The first row shows the contents before entering
the for-loop (0 ~ t < num). Rows 2-4 show the array (changes only) at the
bottom of the for-loop for t = 0, t = 1, and t = 2. An 'X' denotes an unused
array element.
We remark that Algorithm A5. 8 can create negative or zero weights. Theo-
retically this is correct, but it may be undesirable for software reasons. It can
be avoided by simply inserting a check after the distance computation, before
setting remflag to 1.
Let SW(u, v) = E~=o E.i=o Ni,p(u)Nj,q(v) prj be a NURBS surface. A u knot
(v knot) is removed from SW (u, v) by applying the knot removal algorithm (Al-
gorithm A5. 8) to the m + 1 columns (n + 1 rows) of control points. But the knot
can be removed only if the removal is successful for all m+l columns (n+l rows).
Two additional algorithms for knot removal are given in [Till92]. These are:
• given a curve, remove as many knots as possible;
Knot Removal 187
Table 5.2. The control point array for the cubic curve
of Figure 5.15.
Pg P~ Pg Pg P~ Pg Pg before loop
X t=O
P~ X P~ t=l
P~ X X X P~ t=2
,,
,,
I
, ,
,
I (j)
Cil
(9----------,-~~
ml+I--------~------+IHII------~II--------~I~111
(a)
Figure 5.27. Curve knot removal example. (a) The original cubic curve defined over the
knot vector {O, 0, 0, 0, 3/10, 1/2, 1/2, 1/2, 7/10, 7/1O ,1,1,1,1}; (b) removal of 3/10, one time;
(c) removal of 1/2 one time; (d) removal of 1/2 two times; (e) removal of 1/2 three times.
188 Fundamental Geometric Algorithms
(b)
H - + + - - - - - - + - - - - - t + - - - - t l - f - - - !- - - - - - j I f - H I I - 1
(c)
Figure 5.27. (Continued.)
points; and what is the deviation between the original and the knot removed
curve. Similar examples are shown for the surfaces in Figures 5.30a and 5.30b
through Figures 5.34a and 5.34b. The control net for the original surface is seen
in Figure 5.30a. The original surface is shown in Figure 5.30b. Knot removed
surfaces are illustrated in Figures 5.31a and 5.31b through Figures 5.34a and
5.34b, using the tolerances 0.05, 0.1, 0.3, and 0.5, respectively.
j
\
I+H II IIII
(d)
/
/~
/
H-II-----+++-\
(e)
Figure 5.27. (Continued.)
From a vector space point of view, e n+1 (u) is simply en (u) embedded in a
higher dimensional space.
Now let e;(u) = E~=o Ni,p(u) Pi be a pth-degree NURBS curve on the knot
vector U. Since e;(u) is a piecewise polynomial curve, it should be possible to
elevate its degree to p+ 1, that is, there must exist control points Qi and a knot
vector U such that
n
e;(u) = e;+1(u) = L N i,P+1(U) Qi (5.31)
i=O
e;+1 (u) and e; (u) are the same curve, both geometrically and parametrically.
e;+1 (u) is simply e; (u) embedded in a higher dimensional space. Degree el-
evation refers to the process (the algorithm) for computing the unknown Qi
and U.
The applications of degree elevation include:
190 Fundamental Geometric Algorithms
y
I
x \ ". ''JI.. I
-.: , / .~
, /
""
"....,/
/ /
(a)
(b)
Figure 5.28. Surface knot removal example. (a) The original (cubic x quadratic) surface
defined over U = {O, 0, 0, 0,3/10,3/10,3/10 ,7/10,1,1,1, I} and V = {O, 0, 0,1/4,1/2,3/4,
1,1,I}j (b) removal of u = 3/10 three times in the u direction.
Degree Elevation 191
(c)
(d)
Figure 5.28. Continued. (c) removal of v = 1/4one time in the v direction; (d) removal
of the knots in both directions.
192 Fundamental Geometric Algorithms
0----<·:-·.-.:---0-
I - ! + f - - - - - t - - - - j - - - - - t - - - - t - - - r - - r - - + - - - - + - I·i-HII
(a)
1-+-1 +-----------+---I---f----!----€j-----+----4-t-!-i
(b)
Figure 5.29. Remove all removable knots from a cubic curve. (a) The original curve de-
fined over {O, 0, 0, 0, 0.16, 0.31, 0.45, 0.5501, 0.702,0.8,0.901,1,1,1,1}; (b) knot removed
curve using the tolerance 0.007; (c) tolerance is 0.025; (d) tolerance is 0.07; (e) tolerance
is 0.6; (f) tolerance is 1.2.
H+'-----l--I- - + - -
o =
(d)
Figure 5_29. (Continued.)
where mI. ... ,ms denote the multiplicities of the interior knots. Now Cp(u) is
a polynomial curve on each nondegenerate knot span, hence its degree can be
elevated to p + 1 on each such knot span. At a knot of multiplicity mi, Cp(u)
is C p - rn ; continuous. Since the degree elevated curve, C p+1(u), must have the
194 Fundamental Geometric Algorithms
(e)
H++--{!)--~~----(f)--t+-l-l
(f)
Figure 5.29. (Continued.)
same continuity, it follows that the same knot must have multiplicity mi + 1 for
C p +1 (U ). This yields
n=n+s+l (5.32)
and (; = {uo, ... ,Urn} = {a, .. . ,a, Ul, . .. ,Ul, . .. , Us, . .. , Us, b, . .. ,b} (5.33)
'---""" '----.,.----' '----.,.----' '---v-'
p+2 m,
+1 ms+, p+2
where m= m + s + 2.
Degree Elevation 195
,,
,
\
,
\
y
,,
x
,
.,~,
-"'--
/
.. '
/
(a)
I
I
, /
/
,):\
//
I "" ' __ ,
,,
,
,, I
, , ,I
v- ,
I'
\
I
I
,
, / ,,
I
I
A-
/
I Y
/
/
x ,
'/ I
't
I
/
'J
(b)
Figure 5.30. A (cubic x quadratic) surface for knot removal. (a) The control net;
(b) the surface defined over U = {0,0,0,0,0.22,0.3,0.52,0.7,0.79,1,1,1,1} and V
{a, 0, 0, 0.2, 0.42, 0.5, 0.81,0.9, 1, 1, I}.
196 Fundamental Geometric Algorithms
(a)
(b)
Figure 5.31. Remove all removable knots in both directions using the tolerance 0.05.
(a) The control net of both the original (dashed) and the knot removed surface (solid);
(b) isoparametric lines of both surfaces.
Degree Elevation 197
(a)
(b)
Figure 5.32. Remove all removable knots in both directions using the tolerance O.l.
(a) The control net of both the original (dashed) and the knot removed surface (solid);
(b) isoparametric lines of both surfaces.
198 Fundamental Geometric Algorithms
(a)
(b)
Figure 5.33. Remove all removable knots in both directions using the tolerance 0.3.
(a) The control net of both the original (dashed) and the knot removed surface (solid);
(b) isoparametric lines of both surfaces.
Degree Elevation 199
\-
(a)
(b)
Figure 5.34. Remove all removable knots in both directions using the tolerance 0.5.
(a) The control net of both the original (dashed) and the knot removed surface (solid);
(b) isoparametric lines of both surfaces.
200 Fundamental Geometric Algorithms
(a)
(b)
Figure 5.35. Degree elevation of a cubic curve defined over {O, 0, 0, 0, 3/10, 7/10, 1, 1, 1, I}.
(a) The original curve; (b) the first Bezier segment obtained via knot insertion.
The only remaining problem is to compute the {Qi}' An obvious but very
inefficient method to do this is to solve a system of linear equations. Setting
ii n
i=O i=O
n
and evaluating the N i , p (u) and N i ,p+1 (u) at appropriate + 1 values yields a
n
banded system of + 1 linear equations in the unknowns, Qi'
More efficient but mathematically more complicated methods are given by
Prautzsch [Prau84]' by Cohen et al. [Cohe85], and by Prautzsch and Piper
[Prau91]. The algorithm due to Prautzsch and Piper is the most efficient for
the general case, but Cohen et al. also give simple and efficient algorithms for
low-degree special cases, such as linear to quadratic, and quadratic to cubic. All
these algorithms raise the degree by 1 (p ----t p + 1).
Degree Elevation 201
/~~----B.
(c)
J
(d)
Figure 5.35. Continued. (c) the first Bezier segment is degree elevated, (d) the second
Bezier segment is computed.
(e)
(f)
Figure 5.35. Continued. (e) the second Bezier segment is degree elevated; (f) two
occurrences of the knot u = 3/10 are removed.
c. The Bezier segment on [0, u a ] is degree elevated; this replaces the first four
control points with five new ones (see subsequent text);
d. Ub is inserted twice to obtain the Bezier segment on [u a , Ub];
e. the Bezier segment on [u a , Ub] is degree elevated;
f. two occurrences of the knot U a are removed;
g. the last segment [Ub, 1] is degree elevated;
h. two occurrences of Ub are removed, yielding the final fourth-degree, C 2
continuous curve.
Step 1 is a straightforward application of Algorithm A5. 6. It is modified to
not return the Bezier segments, but rather to process them on-the-fly.
Step 2 degree elevates a Bezier segment. We present two formulas to do this.
The first is the well-known formula (due to Forrest [Forr72]) to elevate from
degree p to degree p + 1. Let
Degree Elevation 203
~-
(g)
(h)
Figure 5.35. Continued. (g) the third Bezier segment is degree elevated; (h) two occur-
rences of the knot u = 7/10 are removed.
Cp(u) = LBi,P(U) Pi
i=O
be a pth-degree Bezier curve. Its representation as a (p + 1) th-degree curve is
pH
CpH(U) = LBi,PH(U)Qi (5.34)
i=O
Setting these equal and multiplying Cp(u) by (u + (1- u)) (= 1) yields
p+l p
= L((1-u)Bi,p+uBi,p)Pi
i=O
204 Fundamental Geometric Algorithms
From
( p)/(p + 1) = p!i!(P + 1 - i)! = p+1 - i = 1 __i_
i i i!(P-i)!(p+1)! p+1 p+1
and
( p )/(p +
i- 1 i
1) = p!i!(P + 1-
i)!
(i - 1)!(P + 1 - i)!(p + 1)!
i
= p+1
it follows that
(5.35)
where i = 0, ... ,p + 1
Notice that Eq. (5.35) represents a corner cutting process (see Figures 5.35c,
5.35e, and 5.35g). Regarding Eq. (5.35):
• it can be applied recursively to elevate the degree t times (t 2: 1);
• its growth rate is O(t 2 ); ift > 1, recursive application ofEq. (5.35) involves
some redundant computations;
• the (tiS depend only on the degree, not on the particular Bezier segment
to which they are applied, thus they can be computed one time and stored
in a local array before processing of the segments begins;
• it is a convex combination scheme.
Degree Elevation 205
min(p,i)
where P~ denotes the degree elevated control points after t-degree elevations. As
an example, consider the case of p = 2 and t = 4, that is
Pt=~PO+~PI
6 6
4 4 12 4
P g = 20 Po + 20 PI + 20 P2
Pt=~PI+~P2
6 6
As an example of this, Figure 5.36 shows a curve whose degree is being raised
from 4 to 5 (p = 4). Let u c , Ud, U e be the three parameter values defining the two
segments shown. Assuming the original multiplicity of Ud is 1, then three knot
insertions are required to form the two Bezier segments (note that C(Ud) = P~),
and three removals are now necessary. However, we can skip the first two and
compute pL 1 and p~ directly. This requires computing only two points in the
form of Eq. (5.29), and no checking for equality of points is necessary. This
compares to the six point computations and the three point equality checks
required in the general case. Locally the knot vector has the form
ALGORITHM A5.9
DegreeElevateCurve(n,p,U,Pw,t,nh,Uh,Qw)
{ /* Degree elevate a curve t times. */
/* Input: n,p,U,Pw,t */
/* Output: nh,Uh,Qw */
m = n+p+l;
ph = p+t; ph2 = ph/2;
/* Compute B6zier degree elevation coefficients */
bezalfs[O] [0] = bezalfs[ph] [p] = 1.0;
for (i=l; i<=ph2; i++)
{
inv = 1.0/Bin(ph,i);
mpi = Min(p,i);
Degree Elevation 207
,,
1
1
,
I
1 ,
p2 1 pi
10-1,1 ______ 10 "
/1
Pi-I /1
I
1
1
1
,, 1
1
\
{
else
{
ebpts[kj] = bet*ebpts[kj]+(1.0-bet)*ebpts[kj+l];
{
}
i i+l; j j-l; kj = kj-l;
}
first = first-l; last = last+l;
}
} 1* End of removing knot, u=U[a] *1
if (a != p) 1* Load the knot ua *1
for (i=O; i<ph-oldr; i++)
{ Uh[kind] = ua; kind = kind+l; }
for (j=lbz; j<=rbz; j++) 1* Load ctrl pts into Qw *1
{ Qw[cind] = ebpts[j]; cind = cind+l; }
if (b < m)
{ 1* Set up for next pass thru loop *1
for (j=O; j<r; j++) bpts[j] = Nextbpts[j];
for (j=r; j<=p; j++) bpts[j] = Pw[b-p+j];
a = b; b = b+l; ua = ub;
}
else
1* End knot *1
for (i=O; i<=ph; i++) Uh[kind+i] = ub;
} 1* End of while-loop (b < m) *1
nh = mh-ph-l;
}
Several curve degree elevation examples are shown in Figures 5.37a-5.37d.
The original third-degree curve (Figure 5.37a) is raised to fourth-, fifth-, and
seventh-degrees in Figures 5.37b, 5.37c, and 5.37d, respectively. Note that the
control polygon converges to the curve as the degree is raised.
Let SW(u,v) = L:~=oL:7=oNi'P(u)Nj,q(v)Pf,'j be a NURBS surface. Degree
elevation is accomplished for surfaces by applying it to the rows/columns of
control points. In particular, we elevate the degree p (u direction) by applying
Algorithm A5. 9 to each of the m + 1 columns of control points. The v direction
degree q is elevated by applying Algorithm A5. 9 to each of the n + 1 rows of
control points. An efficient organization of a surface degree elevation algorithm
which requires storage of Bezier strips is Algorithm A5. 10.
ALGORITHM A5.10
DegreeElevateSurface(n,p,U,m,q,V,Pw,dir,t,nh,Uh,mh,Vh,Qw)
{ 1* Degree elevate a surface t times. *1
1* Input: n,p,U,m,q,V,Pw,dir,t *1
1* Output: nh,Uh,mh,Vh,Qw *1
210 Fundamental Geometric Algorithms
r
I
r~ 4
/
\ &-
_d
j
(a)
/
0
/;1
p-----
r~
J
f
~
(b)
Figure 5.37. Curve degree elevation example. (a) The original cubic curve defined over
{O, 0, 0, 0,4/10, 7/10, 1,1,1,1}j (b) the degree is elevated by onej (c) the degree is elevated
by tWOj (d) the degree is elevated by four.
if (dir == UJDlRECTION)
{
allocate memory for Bezier and NextBezier strips;
initialize knot vectors and first row of control points;
initialize Bezier strip;
set variables;
while (b<m)
{
get multiplicity;
get ub, r, oldr, etc;
save alias
Degree Elevation 211
(c)
(d)
Figure 5.37. (Continued.)
if (dir == VJDlRECTION)
{
1* Similar code as above with u- and v-directional
parameters switched *1
}
}
Surface degree elevation examples are shown in Figures 5.38a-5.38e. The orig-
inal (3,2)th-degree surface (Figure 5.38a) is raised to (4,3), (5,4), (6,6), and
(9,9)th-degrees in Figures 5.38b-5.38e, respectively; the original net is shown
dashed, and the degree elevated net is drawn solid.
As usual, C(u) can be rational or nonrational; we drop the w superscript for the
remainder of this section. C(u) is degree reducible if it has a precise representa-
tion of the form
for some user-specified tolerance, TOL. We consider only precise degree reduc-
tion in most of this section, i.e., we assume that TOL is very small. The main
application is to reverse the degree elevation process. For example, degree reduc-
tion should be applied to each constituent piece when decomposing a composite
Degree Reduction 213
(a)
z
(b)
Figure 5.38. Surface degree elevation example. (a) The original (cubic x quadratic) sur-
face net, the surface defined over U = {O, 0, 0, 0, 1, 1, 1, 1}, and V = {O, 0, 0, 1/2,1,1,1};
(b) the degree elevated by one in both directions; (c) the degree elevated by two in
both directions; (d) the degree elevated by three in the u direction, by four in the v
direction; (e) the degree elevated by six in the u direction, by seven in the v direction.
214 Fundamental Geometric Algorithms
z
(c)
z
(d)
Figure 5.38. (Continued.)
curve, because degree elevation may have been required in the composition pro-
cess. The material in this section is taken from [Pieg95j.
Degree reduction of Bezier curves is relatively well understood, and there exist
a number of algorithms (e.g., see references [Forr72; Dann85; Lach88; Watk88;
Degree Reduction 215
z
(e)
Figure 5.38. (Continued.)
Wein92; Eck93)). Following the strategy developed in the previous section for
degree elevation, we present a three-step algorithm for degree reduction of B-
spline curves:
repeat
extract the ith Bezier segment from the B-spline curve,
degree reduce the ith Bezier piece,
remove unnecessary knots between the (i - l)th and the
ith segments,
until done
Error is produced in both the Bezier degree reduction and the knot removal
steps, and our algorithm accumulates both types of error and exits immediately
if TOL is exceeded on any knot span. Figures 5.39a-5.39h show walk-through
examples explaining how the algorithm works. The details of each step are:
a. original fourth-degree B-spline curve defined over the knot vector
The coordinate system (u,E) is used to graph the error over each knot
span as a function of u as the algorithm sweeps out the entire knot vector;
b. the knot Ul is inserted twice, bringing the total multiplicity to four; the
first Bezier piece is obtained;
216 Fundamental Geometric Algorithms
~----------+-------------~--------~I =- u
(a)
E
1
~r---------+--------------r--------~I =- U
(b)
Figure 5.39. Degree reduction of a B-spline curve from fourth-degree to third-degree. (a)
Fourth-degree B-spline curve to be degree reduced; (b) first Bezier segment is extracted.
c. the first Bezier segment is degree reduced, which replaces the first five
control points by four new ones; this is the first time error is introduced
as graphed in the (u, E) system. The solid curve is the original curve,
whereas the dashed one is the approximation;
Degree Reduction 217
(c)
(d)
Figure 5.39. Continued. (c) first Bezier segment is degree reduced; (d) second Bezier
segment is extracted.
(e)
(f)
Figure 5.39. Continued. (e) second Bezier segment is degree reduced; (f) first interior
multiple knot is removed twice.
I~IC=U
(g)
C' U
(h)
Figure 5.39. Continued. (g) third Bezier segment is degree reduced; (h) second interior
multiple knot is removed twice.
C(u) = LBi,p(U)Qi
i=O
220 Fundamental Geometric Algorithms
be a pth degree Bezier curve, and denote its degree reduced counterpart by
p-l
C(u) = LBi,P-l(U)Pi
i=O
(we need coefficients for degree elevation from p - 1 to p). There are two cases to
consider, p is even, and p is odd. Assume first that p is even. Solving Eq. (5.35)
for the Pi, we obtain
i = 1, ... ,r
i = p - 2, ... , r +1
(5.41)
i = 1, ... ,r - 1
i = p - 2, ... , r + 1
where
pR = Qr+! - (1 - or+!) Pr +!
r
Degree Reduction 221
Note that the odd case differs from the even case only in that, for symmetry
reasons, the middle control point, Pn is computed as the average of two com-
ponents computed from the left and right, respectively. In general, the resulting
(p - 1)th degree curve, C(u), is an approximation to C(u); they coincide only
when C( u) is precisely degree reducible. Piegl and Tiller [Pieg95] derive the
error bounds for the approximation
p even:
(5.43)
p odd:
Figures 5.40a and 5.40b show examples of reducing the degree of a Bezier curve
from seven to six, and six to five, respectively. The error curves are graphed on
the bottom of the figures. We remark that:
• Equations (5.43) and (5.44) express the parametric error (distance between
points at corresponding parameter values); the maximums of geometric
and parametric errors are not necessarily at the same u value;
• even if C(u) is not degree reducible, Eqs. (5.41) and (5.42) produce p/2
precise control points from the left and p/2 precise ones from the right,
in the sense that if C(u) is degree elevated to yield C(u), then C(u) and
C(u) have the same first and last P/2 control points. Hence, C(u) and
C(u) have the same derivatives up to order P/2 - 1 at both ends. This is
an important property from the standpoint of B-spline degree reduction,
since it implies that up to C P/2-1 continuity is maintained in the Bezier
degree reduction steps, which in turn implies that the first P/2 - 1 knot
removal steps produce no error;
• for p even the maximum error occurs at u = 1/2 (see Figure 5.40b); for p
odd the error is zero at u = 1/2, and it has two peaks a bit to the left and
right of u = 1/2 (Figure 5.40a). The odd case is analyzed in more detail
elsewhere by Piegl and Tiller [Pieg95].
We now present an algorithm to degree reduce a B-spline curve, subject to
a maximum error tolerance, TOL. If the curve is rational, then TOL should be
adjusted as in Eq. (5.30). We maintain an error vector, ei, i = 0, ... ,m - 1,
which we use to accumulate error for each knot span. The ei are initialized to
zero. When the ith span is Bezier degree reduced, the incurred error is added to
ei. For simplicity we drop the scalar functions (which are bounded by 1) from
Eqs. (5.43) and (5.44) and use maximum error bounds
Ps
Qs --- --~
P4 ijI-----IV"'-'''-'------- - - - i l ' Q6
PI I
~-- Q2
QI ~1----="''9-_--1i1 P2
\
\
\
\
\ I
\ I
\ I
\ I
\ I
\ I
\ I
\I
I!J
P3
(a)
Q5
&---.,::----------6)- - - ~ P4
P2
- 61, I
I
I
-- - -'~ -- - ----,-"./ I
,
---~,,..--- I
,,
I
I
,, I
I
G---------'-'-----4> Q4
Q3 ,,
,, I
,, I
I
,,
'~
P3
1
(b)
Figure 5.40. Bezier degree reduction. (a) From degree seven to degree six; (b) from
degree six to degree five.
Degree Reduction 223
The algorithm in [Pieg95] computes tighter error bounds for both the Bezier
degree reduction and knot removal steps. When removing a knot, the maximum
knot removal error is added to each ei whose span is affected by the removal.
The local arrays used are:
bpts[p+1] Bezier control points of the current segment;
Nextbpts [p-1] leftmost control points of the next Bezier
segment;
rbpts[p] degree reduced Bezier control points;
alphas [p-1] knot insertion alphas;
e[m] error vector.
A supporting routine, BezDegreeReduce (bpts ,rbpts, MaxErr) , which imple-
ments Bezier degree reduction and computation of the maximum error, is used.
This routine uses Eqs. (5.41), (5.42), (5.45), and (5.46). A return code of 1
indicates the curve was not degree reducible; if the curve is reducible, ft, (;, and
the Pi are computed (nh, Uh, Pw) and a 0 code is returned.
ALGORITHM A5. 11
DegreeReduceCurve(n,p,U, Qw,nh,Uh,Pw)
{ 1* Degree reduce a curve from p to p-1. *1
1* Input: n,p,U,Qw *1
1* Output: nh,Uh,Pw *1
ph = p-1; mh = ph; 1* Initialize some variables *1
kind = ph+1; r = -1; a = p;
b = p+1; cind = 1; mult = p;
m = n+p+1; Pw[O] = Qw[O];
for (i=O; i<=ph; i++) 1* Compute left end of knot vector *1
Uh[i] = U[O] ;
for (i=O; i<=p; i++) 1* Initialize first Bezier segment *1
bpts [i] = Qw [i] ;
for (i=O; i<m; i++) 1* Initialize error vector *1
e[iJ = 0.0;
1* Loop through the knot vector *1
while (b < m)
{ 1* First compute knot multiplicity *1
i = b;
while (b < m && U[b] == U[b+1]) b = b+1;
mult = b-i+1; mh = mh+mult-1;
oldr = r; r = p-mult;
if (oldr > 0) Ibz = (oldr+2) 12; else Ibz = 1;
1* Insert knot U[b] r times *1
if (r > 0)
{
numer = U[b] -U [a] ;
for (k=p; k>=mult; k--)
224 Fundamental Geometric Algorithms
alphas[k-mult-l] = numer/{U[a+k]-U[a]);
for (j=l; j<=r; j++)
{
save = r-j; s = mult+j;
for (k=p; k>=s; k--)
bpts[k] = alphas[k-s]*bpts[k]
+ {1.0-alphas[k-s])*bpts[k-l];
Nextbpts[save] = bpts[p];
}
}
/* Degree reduce Bezier segment */
BezDegreeReduce{bpts,rbpts,MaxErr);
era] = e[a]+MaxErr;
if (e [a] > TOL)
return{l); /* Curve not degree reducible */
1* Remove knot ural oldr times */
if (oldr > 0)
{
first = kind; last = kind;
for (k=O; k<oldr: k++)
{
i = first: j = last: kj = j-kind:
while (j-i > k)
{
alfa = (U[a]-Uh[i-l])/{U[b]-Uh[i-l]):
beta = (U[a]-Uh[j-k-l])/{U[b]-Uh[j-k-l]);
Pw[i-l] = {Pw[i-l]-{1.0-alfa)*Pw[i-2])/alfa:
rbpts[kj] = (rbpts[kj]-beta*rbpts[kj+l])/{1.0-beta):
i = i+l: j = j-l: kj = kj-l:
}
/* Compute knot removal error bounds (Br) */
if (j-i < k) Br = Distance4D{Pw[i-2],rbpts[kj+l]):
else
{
delta = (U[a]-Uh[i-l])/{U[b]-Uh[i-l]);
A = delta*rbpts[kj+l]+{1.0-delta)*Pw[i-2]:
Br = Distance4D{Pw[i-l],A):
}
/* Update the error vector */
K = a+oldr-k; q = {2*p-k+l)/2:
L = K-q:
for (ii=L: ii<=a: ii++)
{ /* These knot spans were affected */
e[ii] = e[ii] + Br:
i f (e [ii] > TOL)
Degree Reduction 225
1.<1,
I
I
I
I
ID
I
rn \
\
-E1
\
IS -&--=--£l
Figure 5.41. Degree reduction of a B-spline curve from degree five to four.
226 Fundamental Geometric Algorithms
331177 }
U= { 0,0,0,0, 10' 10'2'2' 10' 10,1,1,1,1
(a)
(b)
Figure 5.42. A cubic curve. (a) The cubic curve is not degree reducible; (b) the curve
is degree reducible after knot refinement.
Exercises 227
u(r) = {O, 0, 0, 0, 0.15, 0.15, 0.3, 0.3, 004, 004, 0.5, 0.5, 0.5,
0.6,0.6,0.7,0.7,0.85,0.85,1,1,1,1 }
EXERCISES
13349 }
where U = { 0,0,0, 5' 10' 5' 5' 10,1,1,1
12174 }
and V= { 0,0,0,0, 10'5'2' 10'5,1,1,1,1
Suppose you want to modify the surface shape slightly in the region corresponding to
the rectangular area of parameter space given by 3/10 < u < 6/10 and 1/2 < V < 7/10,
You want to do this by adding knots (control points) until you have at least one control
point which you can freely move, without changing the continuity of the surface with
respect to u and v, and without changing the surface shape outside of this rectangular
area. What knots must you add to U and V? State clearly how many and what values.
5.4. Consider the B-spline surface
3 2
where U= {0,0,0,~,1,1,1}
228 Fundamental Geometric Algorithms
f(u) = C'(u).(C(u) - p)
The distance from P to C(u) is minimum when f(u) = 0, whether P is on the
curve or not (Figures 6.1a and 6.1b). Denote by Ui the parameter obtained at
the ith Newton iteration. Then
(a)
C(Ui)
p
(b)
Figure 6.1. (a) Point projection; (b) point inversion.
2. zero cosine:
I C'(Ui)·(C(Ui) - P) I
I C'(Ui) II C{Ui) _ P I ~ 102
If at least one of these conditions is not satisfied, a new value, UHb is computed
using Eq. (6.3). Then two more conditions are checked:
232 Advanced Geometric Algorithms
3. ensure that the parameter stays within the range (Ui+1 E [a, b])
if the curve is not closed:
if (Ui+l < a)
if (Ui+1 > b)
if the curve is closed:
if (Ui+1 < a) Ui+1 = b - (a - Ui+1)
4. the parameter does not change significantly, e.g., the point is off the end
of the curve
If any of conditions (1), (2), or (4) is satisfied, the iteration is halted. Figure 6.2
shows the projection of a set of points onto a NURBS curve.
Point inversion and projection for surfaces are analogous. Form the vector
function
r(u, v) = S(u, v) - P
and the two scalar equations
f(u, v) = r(u,v)·Su(u,v) = 0
g(u, v) = r(u,v).Sv(u,v) = 0 (6.5)
where all the functions in the matrix Ji are evaluated at (Ui,Vi). At the ith
iteration we must solve the 2 x 2 system of linear equations in the unknown Oi,
given by
(6.6)
From Oi we obtain
Ui+! = D.u + Ui
Vi+! = D.v + Vi (6.7)
(6.8)
Again, the conditions are checked by
1. point coincidence:
2. zero cosine:
If these conditions are not satisfied, a new value (Ui+b vi+d is computed using
Eq. (6.7). Then two more conditions are checked:
3. ensure that the parameters stay in range (Ui+! E [a, b] and Vi+! E [e, d]):
if the surface is not closed in the U direction:
Iteration is halted if any of conditions (1), (2), or (4) is satisfied. Figure 6.3 shows
the projection of a set of points from the control net onto a NURBS surface.
Figure 6.3. Projecting points of the control net onto a NURBS surface.
Surface Tangent Vector Inversion 235
:: 1[~:] [~~dz 1
XU
[ yu (6.10)
=
zu Zv
which we write as
MW=T
Equation (6.10) has a unique and exact solution (generally such a system does
not) which we obtain by multiplying through by MT (the transpose of M)
or I Su 12 SUOSV] [dU]
[ Su = [SuoT]
0 Sv 1Sv 12 dv Sv T
0
(6.11)
Solving this 2 x 2 system of equations yields the unknowns du and dv.
(6.12)
i=O
With the exception of perspective, all transformations and projections of C(u)
are performed by applying the operation to the three-dimensional control points,
Pi; the weights, Wi, do not change. This follows from the Affine Invariance
Property, P4.9 (which follows from the form of Eq. [6.12]). Let us consider
projections. Figure 6.5 shows a general parallel projection of the control point,
Pi, to a projection plane given by the reference point, Q, and the unit length
normal vector, N. Pi denotes the projection of Pi' If the direction of the
projection is given by the vector W, then
(6.13)
Transformations and Projections of Curves and Surfaces 237
x
N
and
and finally
P.=p.+(N.(Q-Pi))W (6.14)
• > N·W
The corresponding formula for surfaces is
p ..
>,3
= p ..
>,3
+ (N'(Q - Pi,j)) W
N.W (6.15)
Figure 6.6 shows a perspective projection. As before, let the projection plane
be defined by Q and N. Denote the eye position by E. Then
(6.16)
238 Advanced Geometric Algorithms
z
Q
N
x E
P2 P2
It follows that
we obtain
(6.17)
Equation (6.17) is the formula for computing the new control points of the pro-
jected curve.
We now derive the formula for the new weights. Let
n
P = C(u) = LRi,p(U)Pi
i=O
- N.(E - Q) N.(Q - P)
P = N .(E - P) P + N .(E _ P) E
Setting (6.18)
and recalling that
we obtain
l:Ni,p(U)WiPi
(6.19)
l: Ni,p(U)Wi
Equation (6.19) shows that the control points and weights given by Eqs. (6.17)
and (6.18) are those of the projected curve. The formulas for surfaces are
- N· (E - Q) N· (Q - Pi,i)
Pi,i = N .(E _ p .. ) Pi,i
~J
+ N .(E _ p .. ) E
~J
(6.20)
z
Q
A-- [BP T ]_
a3,3 -
(6.22)
Examples
Let Pi" = (WiXi, WiYi, WiZi, Wi), and denote a transformed homogeneous control
point by P~ = APi".
Ex6.1 Translate CW(u) by the vector V = (x,y,z). Then
1 0
p~ = [ 0 1
too
o 0
Reparameterization of NURBS Curves and Surfaces 241
Ex6.3 Perspective projection: Let E = (0,0, d) be the eye position lying on the
z-axis, a distance d from the origin. Let the xy plane be the projection
plane. Then
P~ = (6.23)
C(J(s))
U
IIII e IIII
a b
~ III e III
C S d
Examples
Ex6.4 Let
C(u) = (x(u), y(u)) = (u, -2u 2 + 2u) (6.24)
on u E [0,1], and assume we want a parameter 8 E [0,1] such that
u = 1/2 corresponds to 8 = 6/10 , that is
0= /(0) 1 = /(1)
u = / (8) = a82 + bs + c
The first constraint implies c = 0, and the last two yield the linear
equations
~ = ~a+ ~b
2 25 10
1=a+b (6.25)
Reparameterization of NURBS Curves and Surfaces 243
(6.27)
Note also that the derivatives have changed. For example, differentiating
Eqs. (6.24) and (6.27) directly yields
C'(u = 0)
y
C'(s = 0)
c u _ (l-u 2 ~) (6.28)
( )- 1 + u2 ' 1 + u2
on u E [0,1]. This arc is centered at the origin, has radius 1, and sweeps
an angle of 90° (see Chapter 1, Eq. [1.2], Figure 1.2, Example 1.8, and
Figure 1.19a). It is easy to check that
The condition given by Eq. (6.30) determines a. From Eq. (6.29) and
C'(s) = C'(u) I'(s), we require
/'(s) = a 2
((a-l)s+l)
(6.35)
The reader can verify that C(s) satisfies Eq. (6.30) and also the condition
(6.36)
The reparameterized curve C W (s) has degree pq and is defined on the knot vector
Example
6.10). The control points are {(a, 0),(1/2,1),(1, On, and the reparame-
terization function is
4
C(s) = LN ,4(S)Qi
i s= {0,0,0,0,0,1,1,1,1,1} (6.38)
i=O
1\
I \
I \
I \
I \
I \
\
Figure 6.10. The reparameterized B-spline curve of Example Ex6. 6; + shows the original
parameterization and 0 illustrates the new parameterization.
Reparameterization of NURBS Curves and Surfaces 247
/'(s=O)=.1. !,,(s=O)=~
12 6
we obtain
is due to Faa di Bruno (see [Knut73], page 50). Although this formula is elegant,
its implementation is not straightforward. The difficulty is in obtaining the
n-tuples that satisfy the conditions
kl+ k2 + ... + kn = j
kl + 2k2 + ... + nkn = n kb k2' ... ,kn 2: 0
To illustrate this we use Eq. (6.40) to derive the first four derivatives given in
Eq. (6.39):
n=l: kl = 1 must hold:
j = 0 : kl = 0 --+ no solution
j = 1 : kl = 1 --+ (1)
which yields
j = 0 : kl + k2 = 0 --+ no solution
j = 1 : kl + k2 = 1 --+ (0,1)
j = 2 : kl + k2 = 2 --+ (2,0)
j = 0 : kl + k2 + k3 = 0 --+ no solution
j = 1 : kl + k2 + k3 = 1 --+ (0,0,1)
j = 2 : kl + k2 + k3 = 2 --+ (1,1,0)
j = 3 : kl + k2 + k3 = 3 --+ (3,0,0)
Reparameterization of NURBS Curves and Surfaces 249
c w(3) (8) = c w(l) (U)I(3) (8) + 3cw(2) (u)I(1) (8 )1(2) (8) + c w(3) (u) (1(1) (8)) 3
j = °: kl + k2 + k3 + k4 = ° ---+ no solution
j = 1 : kl + k2 + k3 + k4 = 1 ---+ (0,0,0,1)
Given the derivatives of C W(8) in terms of those of CW (u) and 1(8), the general
formulas for Qf are
for i = 1,000, mro For example, the first five control points from the left are
QO'=PO'
Qr = !l8 C W (I)(8 = c) + QO'
pq
_ 3
c w(3) ( + QW0 - 3QW + 3Qw
Qw !l8
3 - pq(pq _ l)(pq _ 2) 8
_
- C
)
1 2
4 C w(4) ( _) + 4Qw
Q4w -_ pq(pq _ l)(Pq
!l8
_ 2)(pq _ 3) 8 - C -
QW
0 1 -
6Qw
2 +
4Qw
3
(6.43)
250 Advanced Geometric Algorithms
Qw _ As2 ew(2l ( _ d) QW QW
pq-2 - pq(pq _ 1) s- - pq + 2 pq-1
Then Qw _ As ew(1l ()
1-- S+
_ aAs (PW1 - PW)
QWO-~ pw
0+ 0 (6.47)
pq ~u
where the {Ii} are scalars. Denote the knot vector by 8j then CW(J(s)) is a
pqth-degree NURBS curve on s E [c, d], and its knots and control points can be
computed as follows:
1. let {Si} denote the set of distinct internal knots of 1(s), and let {Ui} =
{I (Si)} denote their imagesj use knot refinement to insert all Ui and all
original internal knots of U until they all have multiplicity p. CW(u) is
then in piecewise Bezier formj denote the refined knot vector by U' j
2. let
(6.51)
be the inverse function of I(s)j then form the new knot vector, 8', whose
distinct knots are the images Si = g(Ui) of the distinct knots of U'. All
internal knots in 8' appear with multiplicity pqj
3. use Eqs. (6.39)-(6.44) and the ~Si obtained from the new S knots in Step
2 to compute the new control points of CW(s), which is also in piecewise
Bezier formj
4. apply knot removal to C W (s) and 8' to obtain the minimal representation
of C W ( S ). The continuity of C W ( 8) and the multiplicities of its knots
are known, hence general knot removal (as in Algorithm A5. 5) is not
required. Let Si be a knot in 8', and let Ui = I(si)j denote by mi and
mi the multiplicities of Ui and Si in the original knot vectors U and 8,
respectively (mi, mi ~ 0). Then the multiplicity mi of Si in 8' is
mi =pq-p+mi
mi = pq - q + mi if mi = °
mi = max(pq - p+mi,pq - q+mi) if mi "# 0, mi"# ° (6.52)
(6.53)
For example, the knot vectors U = {O, 0, 0, 1ja, 1, 1, I} and 8' = {I, 1, 1, 3, 7, 7, 7}
are equivalent (define the same curve), since S = 6u + 1 maps U to 8'.
Figures 6.11a-6.11d show reparameterization examples. The curve is a cubic
B-spline curve defined on U = {O, 0, 0, 0, 1/2, 1, 1, 1, 1}. In Figure 6.11a the repa-
rameterization function (shown in the upper right corner) is defined by the scalars
F = {O, 2/5,1}, on the knot vector 8 = {O, 0, 0, 1,1,1}. Figure 6.11b shows repa-
rameterization defined by F = {O, 2/5, 9/10, I} and 8 = {O, 0, 0, 1/2, 1, 1, I}. In
Figure 6.11c the function is given by F = {O, 1/2,7/10, 9/10, I} and 8 = {O,O,O,
1/2,1/2, 1,1,1}. Reparameterization with a linear B-spline function, given by
F = {O, I} and 8 = {O, 0,1,1}, is depicted in Figure 6.11d.
We turn now to reparameterization with rational (or piecewise rational) func-
tions of the form
g(S)
U = I(s) = h(s) (6.54)
252 Advanced Geometric Algorithms
/(8)
-
I
....
(a)
/(8)
(b)
Figure 6.11. B-spline curve reparameterized with quadratic B-spline functions.
(a) F = {O, 2js, I}, S = {O,O,O, 1, 1, I}; (b) F = {O, 2js, 9/10, I}, S = {O,O,o, 1/2,1,1, I}.
f(s)
e--
(c)
u
f(s)
~--------I+-C~ S
(d)
Figure 6.11. (Continued.) (c) F {O, 1/2, 7/10, 9/10 , I}, S {O, 0, 0, 1/2, 1/2,1,1,1};
(d) F = {O, I}, S = {O,O, 1, I}.
Hence, we can assume that CW(u) and /(s) have no internal knots. Theoretically,
one can reparameterize with a rational function using a technique similar to that
used for polynomial functions. Let r(u) = L:f=o aiui be a pth-degree polynomial
function. Then _ (g(S)) _ P . (g(S))i
r(s) - r h(s) - ~a, h(s)
254 Advanced Geometric Algorithms
P
and 1'(8) = (h(8)Yr(8) = Lai(9(8))i(h(8))P-i
i=O
Example
Ex6.7 The circular arc given by Eq. (6.35) has a Bezier representation. Clearly,
the Euclidean control points, {Pi} ={(1, 0),(1,1), (0, I)}, remain the
same. The weights are determined by equating the power basis and
Bezier forms of the denominator function of Eq. (6.35)
(6.55)
= PO'
Po
---
x
y
Figure 6.12. Homogeneous representation of the circular arc using weights {1, V'i/2, 1}.
256 Advanced Geometric Algorithms
Wi
or Wi = --:p::-----=--- (6.57)
IIJ.t(Ui+j)
j=l
Si+j and ui+j are the new and old knots, respectively.
(U) = 2u + 1
9 3u+2
~ _ _- - g ( u )
.p
o
rn
o
~---+------r---~~ u
o
+
+
+
+
+ 0+
(a)
Figure 6.13. Rational reparameterization of NURBS curves; + shows the original
parameterization, and 0 illustrates the new parameterization. (a) g(u) = (2u+1)/(3u+2);
(b) g(u) = 2u/(3u+1) ; (c) g(u) = (2u-1)j(3uH).
Reparameterization of NURBS Curves and Surfaces 257
g(u)
0+ 0 +0
HI +0
o
a-
D
[!J
o
o
+
+
+ +
+
(b)
g(u)
o -;0 III
IT q.
o
+
o 0
+ +
o
o
+
o +
+
o
+
(c)
Figure 6.13. (Continued.)
U = {0.5, 0.5, 0.5, 0.5, 0.55, 0.58, 0.6, 0.6, 0.6, 0.6}
and weights
W = {0.125, 0.08, 0.04, 0.01, 0.009, 0.008}
258 Advanced Geometric Algorithms
+ shows the original parameterization, and D marks the new one. Figure 6.13b
applies
2u
g(u) = 3u + 1
The formulas for surfaces are similar. For example, Eq. (6.56) generalizes to
P
Wi,j = Wi,j II A(Si+k) j=O, ... ,m
k=l
1
U = {0,0,0,0,1,1,1,1} V= {0,0,0'2,1,1,1}
( ) _ 2u + 1 h(v) = 2v + 1
gu - 3u+2 3v+2
Figure 6.14a shows the original surface; note the even distribution of the param-
eter lines. In Figure 6.14b the surface was reparameterized in the u direction, in
Reparameterization of NURBS Curves and Surfaces 259
(a)
(b)
::;
(c)
Figure 6.14c in the v direction, and in Figure 6.14d in both directions. Note the
uneven distribution of parameter lines in Figures 6.14b-6.14d.
Now assume that the end weights of C(u) are not equal, i.e., Wo "I W n . Since
the linear rational function s = g(u) has three degrees of freedom, it should be
possible to determine g(u) satisfying the three conditions
c = g(a) d = g(b)
TIl(' )I('W illtl'rval ('hoSI'Il is [(0. II] = [1/111.1/:,]. Thl' fC'paramPil'rizatioll fUllctioll
COOJlIpllt('d hy Eq. ((j.ri~) is
1.2.1211 + 1l.12G
y( II) = - - - - , - - -
Il,.t!ill + 1.2{i
Reparameterization of NURBS Curves and Surfaces 261
(d)
Figure 6.14. (Continued.)
u' = {O.l, 0.1, 0.1, 0.1, 0.36, 0.63, 0.8, 0.8, 0.8, 0.8}
W' = {I, 3.61,1.08,1.06,0.43,1}
where the end weights were chosen to be one. Again, + marks the original
parameterization and 0 the new parameterization.
We gave examples in Chapter 4 which showed that arbitrary changes in weights
generally changed the shape of a rational NURBS curve (e.g., see Figures 4.2 and
4.4). In this section we changed weights without modifying the curve shape, the
only change being in the parameterization of the curve. This suggests that for a
given curve there must exist a relationship among the weights which determines
the curve shape, that is, weight changes which maintain this relationship result in
a reparameterization of the curve but not a change in shape. These relationships
are called shape invariants or shape factors. For rational Bezier curves they
depend only on the degree; for NURBS curves they depend on the degree and the
knots. In general, the derivation of these shape invariants is quite complicated
(see [Forr68; Vers75; Patt85; Lee87; Pieg9laJ). We give a few here for reference;
the Ci denote constants.
• Quadratic Bezier curve (conic):
(6.59)
262 Advanced Geometric Algorithms
g(u)
131 []I- 0+ 0+
10I 0
~ +
o 0
+
+ o
+
o
+
o
+
Consider the circular arc, defined by either {wd = {I, 1, 2} (Figure 1.1gb)
or {wd = {I, v'2/2, I} (Eq. [6.55])
(v:y
2 = (1)(2) = (1)(1) = 2
12
Assuming fixed control points, any three weights which when substituted
into Eq. (6.59) yield the value 2 produce the circular arc;
• Cubic Bezier curve:
(6.60)
(6.62)
for i = 1, ... , n - 1.
Curve and Surface Reversal 263
°
a reparameterization function on 8 E [c, d]. In Section 6.4 we assumed that
/,(8) > on 8 E [c,d]. This was implicitly used in Example Ex6.6 and in the
derivation of Eqs. (6.41) through (6.44) and Eq. (6.49).
°
The concepts of Section 6.4 still apply if we assume /' (8) < on 8 E [c, d]. In
particular, let
U=f(8)=-8+a+b s E [a,b] (6.63)
Observe that
b = f(a) a = f(b) (6.64)
and that /,(8) = -1 on 8 E [a,b]. The inverse of f(8) is
8 = g(u) = -u + a + b (6.65)
From Eq. (6.53), the knots of C W (8) are computed by
Sm-p-i = -Up+i + a + b i = 1, ... ,m - 2p-1 (6.66)
°
where Ui are the knots of CW (u), SiS m. For example, if U = {O, 0, 0, 1,3,6,
6,8,8,8}, then S= {0,0,0,2,2,5,7,8,8,8}.
The control points Qf of C W (s) are computed as
Q~ = CW(J(s = a)) = CW(u = b) = P~
Qf = 8p+1 - a c w(1)(8 = a) + Q~
p
= b- U m - p -1 P (PWn _ pw
n-1
)(-1) + pw
n
p b- U m - p -1
=P~-1
264 Advanced Geometric Algorithms
In general
Q1.w =pWn-'l,. (6.67)
The effect of Eqs. (6.63)-(6.67) is to reverse the direction of the curve. This is
shown in Figure 6.16; note that the parameterization does not change.
Let SW(u, v) = l:~=o l:j:o Ni,p(u)Nj,q(v)pr· be a NURBS surface with knot
vectors U = {uo, .. " ur } and V = {vo, ... , vs}. A surface's parameterization
can also be reversed. More specifically, u reversal produces
n m
SW(s, v) = L L Ni,p(s)Nj,q(v)Qrj (6.68)
i=O j=O
on S and V, where
Sr-p-i = -Up+i + Uo + Ur i = 1, ... , r - 2p - 1 (6.69)
Ell
P5 = Q o
Ell
III
C(s)
III
r III
j III
C(u) III
III
III
III
Po = Q5 Ell
iii Ell
III
P 3 = Q2 P 4 = Ql
At an arbitrary parameter point (u, v), the surface normal vector is given by
(6.77)
we obtain
(6.78)
266 Advanced Geometric Algorithms
(a)
/ ,
,,
(b)
Figure 6.17. Surface reversal. (a) Original surface showing partial derivatives and the
normal vector; (b) parameterization is reversed in the u direction; (c) parameterization
is reversed in the v direction.
Conversion Between B-spline and Piecewise Power Basis Forms 267
,
,,
,,
(c)
Figure 6.17. (Continued.)
which is the power basis form of the jth segment in the parameter 8.
We now derive the matrices Mp for arbitrary p. As a warm-up and for refer-
ence, we compute the first three matrices. From Eq. (6.76) it follows that
(6.79)
Now we derive the general formula. Let Mp(i,j) denote the element of Mp in
268 Advanced Geometric Algorithms
the ith row and the jth column. From Eq. (1.8) we have
From elementary algebra, expanding (1- s)P yields the binomial coefficients with
alternating signs; hence
i = O, ... ,p (6.81)
j = O, ... ,p - k
j = O, ... ,k-l
j =k, ... ,p (6.82)
(6.83)
Equation (6.83) says that Mp is symmetric about the diagonal which runs from
the bottom left element to the top right element.
Algorithm A6. 1 computes Mp efficiently. An array bin [i] [j], which contains
the precomputed binomial coefficients, is used.
ALGORITHM A6.1
BezierToPowerMatrix(p,M)
{ 1* Compute pth degree Bezier matrix *1
1* Input: p *1
1* Output: M *1
for (i=O; i<p; i++) 1* Set upper triangle to zero *1
for (j=i+l; j<=p; j++) M[i] [j] = 0.0;
M[O] [0] = M[p] [p] = 1.0; 1* Set corner elements *1
if (p mod 2) M[p] [0] = -1.0;
else M[p] [0] = 1.0;
sign = -1.0;
for (i=l; i<p; i++) 1* Compute first column, last row, *1
{ 1* and the diagonal *1
M[i] [i] = bin[p] [i];
M[i] [0] = M[p] [p-i] = sign*M [i] [i] ;
sign = -sign;
}
1* Compute remaining elements *1
kl = (p+l)/2; pk = p-l;
for (k=l; k<kl; k++)
{
sign = -1.0;
for (j=k+l; j<=pk; j++)
{
M[j] [k] = M[pk] [p-j] = sign*bin[p] [k]*bin[p-k] [j-k];
sign = -sign;
}
pk = pk-l;
}
}
(6.84)
the power basis segment in the original parameter, u. We work through the
details for p = 2, then give the general formula without proof. Solving Eq. (6.75)
for s yields
1 Uj
s= u- ---"-- =cu+d (6.85)
Uj+l - Uj Uj+1 - Uj
270 Advanced Geometric Algorithms
For p = 2, substituting s = cu + d into Eq. (6.78) and equating the result with
Eq. (6.84) yields
where
Rp = [ri,;]
j <i
where
ri,; = { mC~d;-i i 5, j i,j = 0, ... ,p (6.88)
(6.89)
for the power basis coefficients in terms of the Bezier control points. Figure 6.18
shows an example of B-spline to power basis conversion. A cubic NURBS curve
with three segments was converted to piecewise power basis form. Figure 6.18
illustrates the curve and marks its second segment. Note that the segment is
defined by the middle four control points. The middle curve segment is also
shown, as are the vector coefficients, b o, bl. b 2 , and b 3 , which are scaled by
l/to to make them fit into the figure. Note that the vector coefficients have
no geometric relationship with the curve. The polynomial piece is defined on
[3/to ,7/to ].
We complete the discussion of B-spline to power basis conversion with two
final remarks:
• the IGES parametric splines (Entities 112 and 114) [IGE93] assume a
parameterization for each segment starting at zero; this implies d = in
Eq. (6.85), and hence Rp reduces to a diagonal matrix with elements
°
r·· -
1,3 -
{ oci ii=j
i =j i = O, ... ,p (6.90)
Conversion Between B-spline and Piecewise Power Basis Forms 271
bo
x
Figure 6.18. Converting a NURBS curve into a piecewise polynomial curve represented
in power basis form .
(6.91)
3 3
u= {O,O,O,O, ;0' 170,1,1,1,1} V= { 0,0,0, 10'S,1,1,1}
Three polynomial patches are shown in Figure 6.19a: patch (0,2) defined on
[0,3/10] x [%,1]; patch (1,1) defined on [3/10,7/10] X [3/10 , %]; and patch (2,0)
defined on [7/10 ,1] x [0,3/10]. Figure 6.19b illustrates some of the vector coeffi-
cients defining the patch (1,1) in power basis form. The vectors are scaled by 1/2
for better visualization. Note the lack of any geometric relationship between the
patch geometry and the vector coefficients. Compare this figure with Figure 5.25
in Chapter 5.
We now discuss the conversion of a piecewise power basis curve or surface to
B-spline form. The steps are:
1. apply matrix multiplications to reparameterize the power basis segments
(patches) to the interval [0,1];
272 Advanced Gcomctric Algorithms
(a)
Figure 6.19. Converting a NURBS surface into a collection of polynomial patches rep-
resented in power basis form. (a) Patches with indexes (0,2), (1,1), and (2,0) are shown;
(b) some of the vector coefficients defining patch (1,1).
(6.92)
be the power basis form of the jth curve segment, with U E [Uj, Uj+lJ. We need
the corresponding Bezier form of the segment
= [ui(RpMp[Pd= [ui([ad=Cj(u)
Conversion Between B-spline and Piecewise Power Basis Forms 273
(b)
Figure 6.19. (Continued.)
and (6.93)
Figures 6.20a through 6.20c show examples of power basis to NURBS conversion.
Figure 6.20a illustrates a piecewise cubic power basis curve defined on 80 < 81 <
82 < 83. In Figure 6.20b each piece is converted to Bezier form, that is, it
is a B-spline curve with triple internal knots. Figure 6.20c shows the B-spline
curve after knot removal. Note that the original curve was C 2 continuous at
81, but only C 1 continuous at 82; thus, 82 is a double knot in the final knot
vector. It is easy to invert the matrices M 1 , M 2 , and M 3 , shown in Eq. (6.80),
to obtain
M-
1
1 --
[~ ~]
:]
0
1
M-
2
1 -- -
2
[: 1
274 Advanced Geometric Algorithms
So
(a)
Figure 6.20. Converting a piecewise polynomial curve into NURBS form. (a) Piecewise
polynomial defined over 80 < 81 < 82 < 83j (b) converting each piece into Bezier formj
(c) the NURBS representation after knot removal.
1 0 0 0
1
1 - 0 0
M- l -
3
3 -
2 1
1 - - 0
3 3
1 1 1 1 (6.94)
o j = 0, ... ,k-1
1
j=k
M- l
p (.), k) = j-l
- LMp(j,i)M;l(i,k)
i=k
j=k+1, ... ,p (6.95)
As was Mp, Mp-l is symmetric about the diagonal running from the bottom
left element to the top right element, hence
(6.96)
(b)
1111 II 1111
Uo -U3
(c)
Figure 6.20. (Continued.)
ALGORITHM A6.2
PowerToBezierMatrix(p,M,MI)
{ 1* Compute inverse of pth-degree Bezier matrix *1
1* Input: p,M *1
1* Output: MI *1
276 Advanced Geometric Algorithms
(6.97)
1 d
U = -s
c
- -
c
= (Uj+l - Uj)s + Uj = 1S + 6
From Eq. (6.97) we have
j<i
with
i '5. j i, j = 0, ... ,p (6.98)
where
Conversion Between B-spline and Piecewise Power Basis Forms 277
.. J = M-
[ p t,J 1 R- 1 [~ .J (R-l)T(M-l)T
P P ,J q q
(a)
Figure 6.21. Converting a piecewise polynomial surface into NURBS form. (a) Piece-
wise polynomial surface; (b) converting each patch into Bezier form; (c) the NURBS
representation after knot removal.
278 Advanced Geometric Algorithms
(b)
(c)
EXERCISES
6.1. Consider the perspective projection of Example Ex6.3. The Euclidean coordi-
nates of P:" are
Pi = (~, dYi ,0)
d-Zi d-zi
Carry out the projection using Eqs. (6.17) and (6.18); compare the results.
6.2. Use a quadratic function u = /(8) = a8 2 + b8 + c to reparameterize the Bezier
circular arc C(u) given by {Pi} = {(I, 0), (1, 1), (0, I)} and {Wi} = {I, 1, 2}, so that
P=C( =!)=(v'2
2 2 ' v'
8 22)
7.1 Introduction
The conic sections and circles play a fundamental role in CAD CAM applica-
tions. Undoubtedly one of the greatest advantages of NURBS is their capability
of precisely representing conic sections and circles, as well as free-form curves
and surfaces. We assume a knowledge of conics and circles; the purpose of this
chapter is to study them in the framework of their representation as NURBS
curves. In Section 7.2 we review various forms and properties of conics which
are required in subsequent sections. Section 7.3 covers the quadratic rational
Bezier representation of conic and circular arcs; Section 7.4 introduces infinite
control points. In Sections 7.5 and 7.6 we present algorithms for constructing
the NURBS representation of arbitrary circles and conics, respectively, includ-
ing full circles and ellipses. Section 7.7 covers conversions between the various
representation forms, and Section 7.8 gives examples of higher order circle rep-
resentations.
Conic = { P I :~ = e}
P(x, y)
D(O, y) ~----+--------=~--_
Figure 7.1. Conic definition via the focus and the directrix.
- I parabola
e= { < 1 ellipse
> 1 hyperbola
If the directrix is chosen to be the line x = 0 and the focus to be F = (k, 0), then
(7.1)
where 1x 1= PD and D = (0, y). Squaring and rearranging Eq. (7.1) yields
(7.2)
be the determinant of the 3 x 3 matrix formed from the coefficients of Eq. (7.3).
Using a and D, a complete classification of the conics is
a=O D=I=O parabola
D=O b=l=O g2 _ bc > 0 2 parallel real lines
g2-bc=0 2 parallel coincident lines
g2 _ be < 0 2 parallel imaginary lines
b=h=O p-ac>O 2 parallel real lines
P - ac = 0 2 parallel coincident lines
p-ac<O 2 parallel imaginary lines
a>O D=O point ellipse
D =1= 0 -bD > 0 real ellipse
-bD < 0 imaginary ellipse
a<O D =1= 0 hyperbola
D=O 2 intersecting lines
ke
where a = - -2
1- e
There are two cases:
• Ellipse (see Figure 7.2): e < 1 implies a, b > 0, and Eq. (7.4) becomes
x2 y2
a2 + b2 =1 a>b>O (7.5)
In this position the origin is the center of the ellipse. The x-axis is the ma-
jor axis, and the y-axis is the minor axis. The points (-a, 0), (a, 0), (0, -b),
(0, b) are the vertices. The distances a and b are the major and minor radii,
respectively. If a = b Eq. (7.5) represents a circle (this is the limiting case,
e-tO,k-too) .
• Hyperbola (Figure 7.3): e > 1 implies a < 0 and b2 < 0 (b is imaginary).
Setting b =1 b I, Eq. (7.4) yields
x
(-a,O) (a,O)
Figure 7.2. Ellipses defined by different parameters (a = 5/2, b = P/2,2, 3/2, 4/5}).
y
a=l
In this position the origin is the center of the hyperbola. The x-axis is the
transverse axis, and the y-axis is called the semiconjugate or imaginary
axis. The points (-a, 0) and (a, 0) are the vertices. The distances a and
b are called the major and minor (or imaginary) radii, respectively. Note
that the hyperbola has two branches separated by the imaginary axis.
Similarly, e = 1 and the transformations
, 1
x =x--k y' =y
2
yield the parabola
(7.7)
with focus F = (a,O) and directrix x+a = 0 (see Figure 7.4). The parabola has
no center. In standard position its axis is the x-axis, the origin is its vertex, and
a is its focal distance.
Two parametric representations of the conics are important in CAD CAM ap-
plications: rational and maximum inscribed area forms. We discuss the rational
form first. The equations
l-u2
x(u) = a-
1- -
+u2
2u
y(u) = 1b -2 -oo<u<oo (7.8)
+u
Figure 7.4. Parabolas defined by different parameters (a = {5, 3/2, 7/10, 3/1O})'
286 Conics and Circles
represent an ellipse in standard position (Figure 7.5 shows points on the segment
0::; u ::; 1). This can be seen by substituting Eq. (7.8) into Eq. (7.5)
1 - 2u + u + 4u
2 4 2
-----;:----;-- =1
1+ 2u 2 + u4
Note that (x(O),y(O)) = (a,O), (x(l),y(l)) = (O,b), and the vertex (-a,O) is
approached in the limit as u - t -00 or u - t 00. The equations
1 +u2
x(u) = a - -2
1-u
2u
y(u) = b- - 2
1 -u -oo<u<oo (7.9)
x(u) ~ au 2
y(u) = 2au -oo<u<oo (7.10)
parameterizes the parabola in standard position (see Figure 7.7). Let C(u) =
(x( u), y( u), 0) be a conic in standard position, embedded in three-dimensional
Euclidean space. By applying an arbitrary 3 x 3 rotation matrix and an arbitrary
++++++
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Lai
i=O
Ui
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
x
2
Lbiui
i=O
2
LWi Ui
i=O
2
LCiUi
i=O
2
-oo<u<oo (7.11)
LWi Ui
i=O
Setting
and
we obtain
(7.13)
2
yields CW(U) = LarUi (7.14)
i=O
the homogeneous form of the rational power basis conic. Furthermore, any equa-
tion in the form of Eq. (7.11) is a conic. This fact will follow from Sections 7.3
and 7.7.
The rational forms can represent rather poor parameterizations of a conic,
in the sense that evenly spaced parameter values can map into very unevenly
spaced points on the curve. Figures 7.5 to 7.7 show points on sections of the
conics given by Eqs. (7.8)-(7.10). The points are images of evenly spaced values
of u. From Chapter 6 we know that the parameterization of a rational curve
can be changed (and possibly improved) by a reparameterization with a linear
rational function.
Various Forms for Representing Conics 289
+ + +
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
x
•
+
+
+
+
+
+
+
x{u) = au 2
y{u) = 2au -oo<u<oo (7.17)
• Parabola: with 0 as the vertex and X as the axis, Y gives the tangent
direction of the parabola at its vertex. The equation of the parabola is
(7.20)
Equations (7.18)-(7.20) are the conic forms specified in the new Standard for
the Exchange of Product Model Data (STEP) [STEP94].
The Quadratic Rational Bezier Arc 291
Almost any book on analytic geometry covers the implicit equation form of
the conics in detail, including the classification of conic types, degenerate cases,
and the transformations into standard position (Eqs. [7.5]-[7.7]), for example
see [Salm79j Coxe80j Ilyi84]. A few modern CADCAM geometry books cover
the conics in some detail, particularly the rational and maximum inscribed area
parametric forms, e.g., see Rogers [Roge90] and Beach [Beac91]. The maximum
inscribed area property of Eqs. (7.15)-(7.17) was first given by [Smit71]. Liming's
two books ([Limi44, 79]) contain a wealth of information on conic constructions
and the use of conics in engineering design.
where . ( )_
R .,2 B i,2(U)Wi U E [0,1]
U - 2
L B j,2(U)Wj
j=O
292 Conics and Circles
To show that Eq. (7.21) is a conic, introduce a local, oblique coordinate system
(7.22)
with
(see Figure 7.11). For arbitrary u E [0,1] the point C(u) lies in the triangle
Po PI P 2 , hence can be written as
and Eq. (7.23), and denoting the denominator function in Eq. (7.21) by w(u),
we obtain
Setting (7.25)
a(u)S
T
S
Po
Figure 7.11. Local coordinate system for rational quadratic Bezier curve.
where k is the conic shape factor. Equation (7.25) says that any two weights can
be chosen arbitrarily; the conic is then determined by the third weight. It is cus-
tomary to choose Wo = W2 = 1; this is called the normal parameterization. Then
if Wl = 1, Eq. (7.21) is a parabola. Assuming Wl =/; 1, Eq. (7.28) implies that
• if k > 1, then Eq. (7.27) has no real solutions; there are no points at
infinity on the curve, hence it is an ellipse;
• if k = 1, Eq. (7.27) has one real solution; there is one point on the curve
at infinity, and the curve is a parabola;
• if k < 1, Eq. (7.27) has two roots; the curve has two points at infinity, and
it is a hyperbola.
Expressing these conditions in terms of Wl, we have:
• Wl 2 < 1 (-1 < Wl < 1) ==} ellipse;
• Wl 2 = 1 (Wl = 1 or -1) ==} parabola;
• Wl 2 > 1 (Wl > 1 or Wl < -1) ==} hyperbola.
(see Figure 7.12).
Notice that Wl can be zero or negative. Wl = 0 yields a straight line segment
from Po to P 2 , and Wl < 0 yields the complementary arc, traversed in the reverse
order (see [Lee87] for a simple proof). Notice also that the convex hull property
does not hold if Wl < O.
Varying Wl yields a family of conic arcs having Po and P 2 as endpoints and
end tangents parallel to Po P l and P l P 2 . However, specifying a weight is not a
294 Conics and Circles
convenient design tool. A more convenient way to select a conic from the family
is to specify a third point on the conic, which is attained at some parameter value,
say u = 1/2. This point is called the shoulder point of the conic, S = C(1/2) (see
Figure 7.12). Substitution of u = 1/2 into Eq. (7.21) yields
1 WI
S = - - M + - - Pl (7.29)
1 +Wl 1 +Wl
S=(I-s)M+sPl (7.30)
WI S
s=-- Wl=-- (7.31)
I+Wl l-s
The parameter s is a good shape design tool. The designer can move his shoulder
point (which determines the fullness of the curve) linearly from M to Pl' S = 0
yields a line segment, 0 < s < 1/2 yields an ellipse, s = 1/2 yields a parabola, and
1/2 < s < 1 yields a hyperbola.
~------------~------------~ Po
Figure 7.12. Various conic arcs defined by WI = {3, 1,3/10 ,0, _3/1O}.
Infinite Control Points 295
A circular arc of sweep angle less than 180 0 is also represented by Eq. (7.21).
For symmetry Po PI P 2 must be an isosceles triangle, with Po PI = PI P 2 . Be-
cause the circle is a special case of an ellipse, we expect that 0 < WI < l.
Consider Figure 7.13. From Eq. (7.31) it follows that
s MS
WI = - - = - - (7.32)
1- S SPI
Let 0 = L PI P 2 M. From symmetry the arc P 2 S is the same as SPo, hence the
angle LSP2 M bisects O. From the properties of bisectors it follows that
MS MP2 e
WI = SPI = P I P 2 = 7 = coso (7.33)
Much of the material in this section goes back to the work of Coons and Forrest
[Coon67j Ahuj68j Forr68]. It can also be found in [Lee87j Pieg87a].
W2 =1 Wo =1
P2 Po
e M
Figure 7.13. Quadratic rational Bezier representation of a circular arc sweeping less
than 180°.
296 Conics and Circles
(tjf.i=O
Ni,P(U)WiPi) + Nj,p(u)Pj
C(u) = -'------=n:---------''-----
L Ni,p(U)Wi
jf.i=O
LNi,p(U)WiPi ....
= jf.i + Nj,p(u)P j
w(u) w(u)
Hence, for fixed Uo, C(uo) is C(uo), which lies in the convex hull of the control
points Po, ... , Pj - b Pj+b"" Pn , plus a nonnegative scale factor of the vector
Pj (see Figure 7.14). Increasing the magnitude of Pj pulls the curve toward its
direction. Note in Figure 7.14 that the curve C(u) touches the control polygon
on the segments P 1 P 3 and P 3 P 4 . C(u) is a cubic curve with two distinct
internal knots (mUltiplicity 1). The points at which C(u) touches the control
polygon correspond to C(u) evaluated at these internal knot values.
We warn the reader at this point that in the projective geometry sense we
are not rigorously correct in stating that pw = (x, y, z, 0) is a point at infinity.
In projective geometry terminology, the points (x,y,z,w) and (ax,ay,az,aw),
a i= 0, are the same, that is, a point in projective space is what mathemati-
cians call an equivalence class. This means that Pj = (Xj,Yj,Zj,O) and i>; =
(axj, aYj, azj, 0) are two representations of the same point in projective space.
However, substituting Pj and i>;
into Eq. (7.34) clearly results in two different
curves. In this book we do not delve into projective geometry, thus we choose
to sacrifice mathematical rigor for clarity. Strictly speaking, our infinite control
point is just a representative of a projective point, whose last coordinate happens
to be zero.
Example
C(u)
Po
Figure 7.14. NURBS curve with an infinite control point Fai notice the stronger convex
hull property.
---------~---~~----------
----~--------------4_--------------~-----=- X
P2 = (-r,O) Po = (r,O)
The reader can verify that (x(u))2 + (y(u))2 = r2 for all u. Notice that
c(~) = (O,r)
is the point on the arc farthest from the chord P OP 2 , and the derivative
at this point, C' (1/2), is parallel to Po P 2, i.e., the shoulder point concept
of Section 7.3 also holds when Pf is an infinite control point.
Note that there is a difference between infinite control points and zero weights.
Figure 7.12 shows that WI = 0 yields a straight line from Po to P 2 • Substituting
WI = 0 into Eq. (7.21) and assuming the normal parameterization yields
that is, R l ,2(U) == 0, and C(u) is a straight line from Po to P 2 ; see also
Figures 4.2, 4.3c, 4.4, 4.5d, and 4.6. If we think of our NURBS curves in terms
of homogeneous control points
n
CW(u) = LNi,p(U)pr (7.35)
i=O
then we represent an infinite control point by Pj = (Xj, Yj, Zj, 0), and we set Wj
to zero by setting Pj = (0,0,0,0). Although one must be careful in dealing with
such points individually, they generally cause no problems in B-spline algorithms
derived from Eq. (7.35). For example, the point evaluation and knot insertion
algorithms of previous chapters (Algorithms A4. 1 and AS. 1) have no problem
with zero weights or infinite control points (assuming, of course, not all weights
are zero).
Examples
Ex7 • 2 A full circle using a nine-point square control polygon: Example Ex6. 7
and Figure 6.12 (and Section 7.3) show the 900 arc in the first quadrant
is obtained using {Pi} ={(1,0),(1, 1), (0, I)} and {Wi} = {I, ../2/2, I}.
By piecing four of these arcs together using double knots, we obtain the
full circle of Figures 7.16a and 7.16b. The knots, weights, and control
points are
I I 1 133 }
U = { 0,0,0, 4' 4' 2' 2' 4' 4,1,1,1
P3 P2 Pi
+ + + +
+ +
+ +
+ +
+ +
+ +
+ +
Po = Ps
+ +
+ +
+ +
+ +
+ +
+ +
+ + + +
Ps P6 P7
(a)
Figure 7.16. A nine-point square-based NURBS circle. (a) Control polygon and param-
eterization; (b) rational basis functions.
300 Conics and Circles
(b)
Figure 7.16. (Continued.)
{Pi} =
{(1,0), (1, 1),(0, 1), (-1,1), (-1,0), (-1, -1), (0, -1), (1, -1), (1,0)}
Clearly, the basis functions N 2,2(U) and R 2,2(U) are only CO continuous
at u = 1/4 (see Figure 7.16b). CW(u) is also only CO continuous, that is,
the four parabolic arcs in homogeneous space are linked together around
the cone, and where each pair meet there is a cusp. Analytically, this
can be seen by computing the first derivative of CW(u) at u = 1/4 from
the left and right. Applying Eq. (3.7) to just the w coordinate yields
w,(I) 2 ( \1'2)
-
4 left
= - - (W2
1:. _
4
° - wd = 8 1- -
2
and
Construction of Circles 301
C,(!)
4 left
= _2_
! _
4
° ..;2/2 (P 2
1
- Pi) = (- 4V2, 0)
and C,(!)
4 right
= _2-
! _!
..;2/2 (P3
1
- P 2 ) = ( - 4V2, 0)
2 4
With regard to the first three criteria, this is quite a good representation
of the full circle.
Ex7 . 3 A full circle using a seven-point triangular control polygon: From ele-
mentary geometry it is easy to see that an arc of 120° requires a control
triangle whose base angle, LP 1 P OP 2 , is equal to 60°. From Eq. (7.33),
Wi = cos 60° = 1/2. By piecing together three such arcs we obtain the
full circle of Figures 7.17a and 7.17b, with
1 122 }
u= { 0,0,0'3'3'3'3,1,1,1
+ + + + + +
+ +
P2 +
Po = P 6
+
X
+ +
+ +
+ +
+ +
+ +
+ +
+ +
P3 P4 P5
(a)
Figure 7.17. A seven-point triangle-based NURBS circle. (a) Control polygon and pa-
rameterization; (b) rational basis functions.
302 Conics and Circles
R 2,2 R4 ,2 R 6,2
1 R O,2
U
0 1/3 2/3 1
(b)
Figure 7.17. (Continued.)
{Pi} =
{(a, ~), (0,2),( - a,~), (-2a, -1), (0, -1), (2a, -1), (a,~)}
where a = cos 30° . Points on the circle are marked to show parame-
terization, which is not quite as good as in Figure 7.16a. The convex
hull is also looser. The reader can verify that C(u) is C 1 continuous at
u = 1/3 and u = 2/3, in spite of the fact that the basis functions are CO
continuous there (see Figure 7.17b ).
Ex7 . 4 An arc of 240 Setting W1 negative yields the complementary arc. Thus,
0 :
!-O !-O
2 1 2 1
01 = 1_ 0 =2 02 = 1- 0 = 2
Construction of Circles 303
Po
j ~
+ +
+
_ _ _ _ _ _ _ _L -_ _ _ _ _ _-+________
+ ________= _ X ~
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
(a)
Figure 7.18. Arc of 240 0 using a negative weight. (a) Control polygon and parameteri-
zation; (b) rational basis functions.
Q w _ 1 pw + 1 pw _
1 - 2 1 2 0 -
(a2' -4'1 41)
u= {0,0,0,~,1,1,1}
{Wi} = {1,~,~,1}
{Qi} = {(a, ~), (2a, -1), (-2a, -1), ( - a,~)}
~--~------------------~~~~--~~ u
o 1
(b)
Figure 7.18. (Continued.)
Ex7 . 5 A semicircle using four control points: Consider the semicircle of Exam-
ple Ex7.1 and Figure 7.15, with r = 1. Inserting the knot u = 1/2 one
time, we obtain (as in Example Ex7.4)
1
01 = 02 =-
2
Q!f = p~
Qw1 _ 1 pw 1 pw _ ( 1 1 1)
- 2 1 +2 0 - - 2' 2' 2
QW = .!pw + .!pw =
2 2 2 2 1
(.!2' .!2' .!)
2
Thus (see Figures 7.20a and 7.20b)
u= {0,0,0,~,1,1,1}
{Wi} = {1,~,~, I}
{Qi} = {(I, 0), (1, 1), (-1,1), (-1, On
Ex7 . 6 A full circle using a seven-point square control polygon: Two semicircles
such as in Example Ex7. 5 can be pieced together to form a seven-point
square circle (see Figures 7.21a and 7.21b)
U=
II2' 2'
{0,0,0, 4' 1 4,1,1,1
3 }
Construction of Circles 305
+ +
+ +
--------+-l---------~----------~+~---------c- X
+ +
+ +
+ +
+ +
+ +
+ +
+ +
(a)
R O,2
1
(b)
Figure 7.19. Arc of Figure 7.18 after inserting u = 1/2 one time. (a) Control polygon
and parameterization; (b) rational basis functions.
1 1 1 1 }
{Wi} = { 1, 2' 2' 1, 2' 2' 1
Q1
+ + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
x
Qo = Po
(a)
1 R O,2 R 3,2
(b)
Figure 7.20. Semicircle of Figure 7.15 after inserting u = 1/2 one time. (a) Control
polygon and parameterization; (b) rational basis functions.
angle dO, min(O,45°) < dO :::; 90°, using double knots, and weights computed by
Eq. (7.33). The resulting arc of angle 0 is C 1 continuous, has a tight convex hull,
and has a good parameterization.
Designers are offered many different interfaces to specify circular arcs, but no
matter what the interface is, the following data can be easily generated:
o : center of circle (origin of local coordinate system);
X : unit length vector lying in the plane of definition of the circle;
Y : unit length vector in the plane of definition of the circle, and orthogonal
to X;
r : radius.
Os,Oe : start and end angles, measured with respect to X.
Construction of Circles 307
P2 Pl
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
Po =
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+
P4 P5
(a)
R O,2 R 3,2
(b)
Figure 7.21. A seven-point square-based NURBS circle. (a) Control polygon and pa-
rameterization; (b) rational basis functions.
the parametric locations of PI along the lines [Po, Tol and [P 2 , T 2 ], respectively.
ao, a2, and the integer return value are not used in Algorithm A7 .1, but they
are used in Section 7.6. Pw=w*P denotes multiplication of a Euclidean point by a
weight (Pw=P if w = 1). The algorithm computes the knots and weighted control
points for the NURBS circular arc.
ALGORITHM A7. 1
MakeNurbsCircle(O,X,Y,r,ths,the,n,U,Pw)
{ /* Create arbitrary NURBS circular arc */
/* Input: O,X,Y,r,ths,the */
/* Output: n,U,Pw */
if (the < ths) the = 360.0 + the;
theta = the-ths;
if (theta <= 90.0) narcs = 1; /* get number of arcs */
else
if (theta <= 180.0) narcs 2;
else
if (theta <= 270.0) narcs 3;
else
narcs = 4;
dtheta = theta/narcs;
n = 2*narcs; /* n+l control points */
wl cos(dtheta/2.0); /* dtheta/2 is base angle */
PO = a + r*cos(ths)*X + r*sin(ths)*Y;
TO = -sin(ths)*X + cos(ths)*Y; /* Initialize start values */
Pw[O] = PO;
index = 0; angle = ths;
for (i=l; i<=narcs; i++) /* create narcs segments */
{
angle = angle + dtheta;
P2 = a + r*cos(angle)*X + r*sin(angle)*Y;
Pw[index+2] = P2;
T2 = -sin(angle)*X + cos(angle)*Y;
Intersect3DLines(PO,TO,P2,T2,dummy,dummy,Pl);
Pw[index+l] = wl*Pl;
index = index + 2;
if (i < narcs) { PO = P2; TO = T2; }
}
j 2*narcs+l; /* load the knot vector */
for (i=O; i<3; i++)
{ U[i] = 0.0; U[i+j] = 1.0; }
switch (narcs)
{
case 1: break;
case 2: U[3] = U[4] 0.5;
break;
Construction of Circles 309
---------------+----------------=-x
(a)
Figure 7.22. Circular arcs of different sweep angles. (a) (Js = 10°, (Je 100°;
(b) (Js = 30°, (Je = 170°; (c) (Js = 20°, (Je = 250°; (d) (Js = 40°, (Je = 330°,
310 Conics and Circles
----------------r---------------~- x
(b)
Figure 7.22. (Continued.)
--1------------+----------------=- x
(c)
--~-----------+----------------=- x
(d)
PI (Figure 7.23) is easily obtained by intersecting lines [Po, To] and [P 2, T2]'
Setting Wo = W2 = 1, the only missing item is WI. Allowing WI to be negative,
or PI to be infinite (temporarily), we can obtain any conic arc with one rational
Bezier curve. If necessary, we then split this Bezier arc at suitable locations to
obtain positive weights and multiple segments with good parameterization and
convex hull characteristics.
The additional point P determines the conic and hence WI. Substituting
P = C(u) into the left side of Eq. (7.21) yields three equations in the two
unknowns, u and WI (which can be solved). But geometric arguments yield a
more efficient algorithm (see Piegl [Pieg87b]). First assume that PI is finite. The
conic we seek can be considered as a perspective view of the parabola determined
by Po, PI, and P 2, with PI being the center of the perspective. Any pair of
conic segments lying in this triangle can be mapped onto one another, including
the line [Po, P 2] (degenerate conic) onto the conic we seek. Hence, P and Q
(Figure 7.23) are corresponding points under this transformation. Now the line
L(u) = [Po, P 2] is obtained by setting WI = 0 (not using an infinite control
point), yielding
(7.37)
a 1 PoQ 1
u=-- a= (7.38)
l+a 1 QP 2 1
(Compare Figure 7.23 and this argument with Figure 4.6 and Eq. [4.4]). Substi-
tuting u and Pinto Eq. (7.21), we easily obtain WI, i.e.
Wl = (1 - u)2(p - Po) ,(Pl - P) + u 2(P - P 2),(Pl - P) (7.39)
2u(1- u) 1 PI - P 12
Piegl [Pieg87b] derives Wl using techniques from projective geometry.
Now suppose P l CPI) is infinite (To and T2 are parallel). In this case, WI = 0
and P l is parallel to To. Only the magnitude of PI is unknown. Consider
Figure 7.24. The perspective center is now at infinity, and u is obtained exactly
as before: [P, To] (which is [P, PI]) is intersected with [Po, P 2] to yield Q, and
u is then computed from Eq. (7.38). For a rational quadratic Bezier curve with
Wo = W2 = 1, Eq. (7.34) reduces to
,,
,,
(l-~)~ __ ---------
Q
Po
Figure 7.23. A general conic segment defined by endpoints, end tangents, and one
additional point lying on the curve.
Based on Eqs. (7.38), (7.39), and (7.41), we now give an algorithm to con-
struct one rational Bezier conic arc. Since WI can be negative or PI infinite,
this algorithm handles any conic arc except a full ellipse. We make use of the
'P
u2 {1-u)2
---------e------------------- P2
Po Q
Figure 7.24. A 180 0 elliptical arc defined by endpoints, end tangents, and one addi-
tional point.
314 Conics and Circles
Algorithm A7. 2 is adequate for parabolic and hyperbolic arcs, and for ellipti-
cal arcs for which W1 > 0 and whose sweep angle is not too large. Splitting an
ellipse into segments is not as easy as was the case for circles. We do not know
the major and minor axes and radii, and an equation of the form of Eq. (7.36)
is not available with our input. A convenient point at which to split is the
shoulder point, S. To split the arc Po P 1 P 2 we make use of the rational de-
Casteljau algorithm, Eq. (1.19). There are two steps in splitting the ellipse (see
Figures 7.25a-7.25c):
1. Split at u = 1/2. Using the deCasteljau Algorithm to obtain
Construction of Conics 315
,, ,
,,
\
,
,, ,
\
, ,, \
,,
\
, ,
I \
,
\
(a)
I ,
I ,
I ,
I ,
I ,
\
I ,
I ,
I \
I ,
,,
,
I
I
,
(b)
Figure 7.25. Splitting a conic curve. (a) Arc sweeping less than 180°; (b) arc sweeping
more than 180°; (c) arc sweeping 180°.
(7.42)
and (7.43)
316 Conics and Circles
(c)
Figure 7.25. (Continued.)
(7.44)
and (7.45)
2. Reparameterize so that the end weights are 1 for both of the two new
segments. After splitting, the weights for the first segment are
WOWs WOWq2
w q2 w ql
2
(7.47)
Construction of Conics 317
Figures 7.25a and 7.25b illustrate ellipse splitting with positive and negative
weights. The preceding process also works for infinite control points (see Figure
7.25c); however, the resulting formulas
QI = Po + PI RI = P 2 + PI (7.48)
1
Ro = Q2 = S = "2 (QI + R I) (7.49)
y'2
w q1 = w r1 = 2 (7.50)
are even simpler. Equation (7.50) should not be surprising, as the semiellipse
of Figure 7.25c is obtained by applying an affine transformation (specifically,
a nonuniform scaling) to a semicircle. Such transformations do not change the
weights. We leave it as an exercise for the reader to write a routine Spli tArc (PO,
Pl,wl,P2,Ql,S,Rl,wqr) which implements Eqs. (7.42)-(7.50).
Making use of Algorithm A7.2 and Spli tArc 0, we now present an algorithm
which constructs an arbitrary open conic arc in three-dimensional space. The
resulting NURBS curve consists of either one, two, or four segments connected
with C I continuity. The output is the knots (U), the number of control points
less 1 (n), and the control points in homogeneous form (Pw). We assume a utility,
Angle (P , Q, R), which returns the angle L P QR.
ALGORITHM A7.3
MakeOpenConic(PO,TO,P2,T2,P,n,U,Pw)
{ 1* Construct open conic arc in 3D *1
1* Input: PO,TO,P2,T2,P *1
1* Output: n,U,Pw *1
MakeOneArc(PO,TO,P2,T2,P,Pl,wl);
if (wl <= -1.0) 1* parabola or hyperbola *1
return(error); /* outside convex hull */
if (wl >= 1.0) 1* classify type & number of segments *1
nsegs = 1; /* hyperbola or parabola, one segment */
else
{ 1* ellipse, determine number of segments */
if (wl > 0.0 && Angle(PO,Pl,P2) > 60.0) nsegs 1;
else
if (wl < 0.0 && angle(PO,Pl,P2) > 90.0) nsegs 4;
else nsegs = 2;
}
n = 2*nsegs;
j = 2*nsegs+l;
for (i=O; i<3; i++) 1* load end knots *1
{ U[i] = 0.0; U[i+j] = 1.0; }
Pw[O] = PO; Pw[n] = P2; 1* load end ctrl pts *1
if (nsegs == 1)
318 Conics and Circles
{
Pw[i] w1*Pij
returnj
}
SplitArc(PO,Pi,wi,P2,Qi,S,Ri,wqr)j
i f (nsegs 2)
{
Pw[2] = Sj
Pw[i] = wqr*Qij Pw[3] wqr*Rij
U[3] = U[4] = 0.5j
returnj
}
1*
nsegs 4 *1
Pw[4] = Sj
wi = wqrj
SplitArc(PO,Qi,wi,S,HQi,HS,HRi,wqr)j
Pw[2] = HSj
Pw[i] = wqr*HQij Pw[3] = wqr*HRij
SplitArc(S,Ri,wi,P2,HQi,HS,HRi,wqr)j
Pw[6] = HSj
Pw[5] = wqr*HQij Pw[7] = wqr*HRij
for (i=Oj i<2j i++) 1* load the remaining knots *1
{
U[i+3] = 0.25j U[i+5] = 0.5j U[i+7] = 0.75j
}
returnj
}
Figures 7.26a and 7.26b show examples using two and four segments, respectively.
Algorithm A7.3 produces ellipses which have good parameterization. For ap-
plications where parameterization is not considered important, a simpler algo-
rithm which produces C 2 continuous curves with equally good convex hulls (see
[Pieg90]) is:
1. call MakeOneArc (Algorithm A7 . 2) ;
2. insert knots at appropriate locations to cut the corners and to eliminate
negative weights or an infinite control point (e.g., at u = 1/2, or u = 1/3
and u = 2/3).
For comparison, Figure 7.26c shows an elliptic arc which was constructed using
• Algorithm A7.3 (points marked by D);
• MakeOneArc, with subsequent insertion of u = 1/2 one time (points marked
by +).
There remains the problem of full ellipses. If the major and minor axes and
radii are known, a rectangular control polygon is appropriate. The weights and
Construction of Conics 319
(a)
To
p
(b)
Figure 7.26. NURBS representation of conic segments. (a) Arc sweeping less than 180°;
(b) arc sweeping more than 180°; (c) comparison between representations obtained by
curve splitting (0) and knot insertion (+).
knots are the same as those of the circle in Example Ex7 . 2 (Figure 7.16a), or a
configuration analogous to Example Ex7. 6 (Figure 7.21a) can be used.
If input data is Po, To, P 2 , T 2 , P, together with the knowledge that the conic
is a full ellipse (starting and ending at Po), then an appropriate construction is:
1. call MakeOneArc to get the rational Bezier representation of one segment
of the ellipse (with positive weight WI);
320 Conics and Circles
Ql ..•
+
0
+
~
To
Q2
o o
(c)
Figure 7.26. (Continued.)
Q o = C +rIU (= Qs)
QI = Qo +r2V
Q2 = C+r2V
Q 3 = Q 2 -riU
Q4 = C-rIU
Q 5 = Q4 -r2V
Q6 = C-r2V
Q 7 = Q6 +rIU
The details of Steps 2 and 3 are given in the next section, and the results are
illustrated in Figure 7.28.
and (7.52)
P a 1 a
Wi = Wo + "2 Wi
W 2P = a+ Wia+ W2a
Wo (7.53)
When substituted into Eq. (7.25), these wf yield the conic type.
322 Conics and Circles
A quadratic NURBS curve with internal knots mayor may not represent a
unique conic (it is a conic, line, or point on each span). The classification of a
quadratic NURBS curve is a three-step process:
1. using Eq. (6.62), compute the conic shape factor of each nondegenerate
segment;
2. if all shape factors indicate a common type (all Ci < 1, = 1, or > 1),
decompose the curve into Bezier segments;
3. compute the geometric characteristics of each segment and compare them.
Notice that all shape factors can indicate a common type, and in fact may even
be equal, but the curve may still not be a unique conic. As an example, recall
that the weights of a circular arc depend only on the sweep angle (Eq. [7.33]);
hence one could piece together circular arcs of different radii, but with equal
sweep angles and shape factors.
Based on this discussion, for classification and conversion purposes the five
forms can be put into two groups:
1. implicit and maximum inscribed area forms;
2. quadratic rational power basis, Bezier, and NURBS forms.
Conic representations are easily obtained within a group if certain data is avail-
able, that is
• geometric characteristics (Group 1);
• start points and end points, together with their tangent directions and an
additional point, P O,TO,P2 ,T2 ,P (Group 2).
Using Algorithms A7 .1-A7 .3, conversion from a form in Group 1 to one in
Group 2 is easy because it involves only point and tangent computation from
Eqs. (7.3) and (7.5)-(7.7) or (7.15)-(7.17). Conversion from Group 2 to Group
1 requires more work. Beach [Beac91] derives the formulas for converting from
the rational power basis to implicit form (Eq. [7.3]). We show here how to
convert from rational Bezier form to Eq. (7.3), and how to compute the geometric
characteristics of a conic from its rational Bezier form.
Let C(u) be the rational Bezier conic given by Eq. (7.21). Recalling Eqs. (7.22)
through (7.26) and Figure 7.11
1 2
a(u)(3(u) = 4k(1- a(u) - (3 (u)) (7.54)
is the implicit equation of the conic in the oblique coordinate system given by
{PI, S, T}, where
a(u) = Ro,2(U)
In order to obtain Eq. (7.3) from Eq. (7.54) we need to express a and (3 in terms
of Cartesian coordinates x and y. Equation (7.20) says that a(u) and (3(u)
Conic Type Classification and Form Conversion 323
are the barycentric coordinates of the point C(u) in the triangle {Po, Pl, P 2}.
Fixing an arbitrary uo, let 0: = o:(uo), (3 = (3(uo), and P = C(uo) = (x, y). Then
Now let ho = Xo - Xl
h2 =Yo-Yl h3 =Y2-Yl
and
2 4
a=82+"kh2h3
2 4
b= 81 + "khoh1
2
h= 8 18 2 - k (hoh3 + h 1 h 2 )
f = -hYl - aXl + 91 82
9 = -hX1 - by1 + 91 81
C = by~ + 2hx1Y1 + ax~ - 291 (Y181 + X182) + 9~ (7.57)
s = Po - PI
€= 2(k-1)
324 Conics and Circles
o= O"f - /p = 1S X T 12
( = 0 + "f + 2,8 = 1S + T 12
'f/ = 0 + "f - 2,8 = 1S - T 12
For the parabola we have the formulas
Axis (7.58)
Focus (7.59)
Vertex: (7.60)
The roots of this equation are real. For an ellipse, A2 2: Al > 0 and € > O. For a
hyperbola, Al < 0 < A2 and € < o. The major and minor radii are
Hyperbola TI=ff T2 = R
A2 (7.63)
if ~
I - "fAll> I - OAII ~
k k
x= - -"fAI Y = ,8AI - - + 1
2 2
k k
else x = ,8AI - - +1 Y = - - OAI
2
2
and p = ox2 + 2,8xy + "fy2
Xo
X
= -p Yo
Y
= -p
Conic Type Classification and Form Conversion 325
(7.64)
lie on the major axis of the ellipse or on the transverse axis of the hyperbola.
The other orthogonal axis is easily obtained, and the vertices of the ellipse or
the hyperbola are computed from the center, the radii, and the axis directions.
Note that for the circle, which is a special case of the ellipse, Eq. (7.62) yields
rl = r2. An algorithm should check for this case, because it makes no sense to
apply Eq. (7.64) to a circle.
Figures 7.27a-7.27c illustrate these formulas. Figure 7.27a shows a parabolic
arc along with the vertex (V), focus (F), and axis vector (A). In Figure 7.27b an
elliptical arc is depicted, with center (C), negative major axis (-U), and minor
axis (V). Figure 7.27c shows the hyperbolic case. Again, center (C), major (U)
and minor (V) axes are computed. This figure also shows how to compute the
asymptotes of the arc, Al and A 2 , i.e., the lines that are tangential to the curve
at two points at infinity.
Finally, Figure 7.28 shows how to compute the NURBS representation of a
full ellipse, given an arc in Bezier form (see the four steps given at the end of
the previous section).
Po
(a)
Figure 7.27. Geometric data computed from the Bezier representation. (a) A parabola
with vertex (V), focus (F), and axis (A)j (b) an ellipse with center (C), negative major
axis ( - U), and minor axis (V) j (c) a hyperbola with center (C), major axis (U), minor
axis (V), and the two asymptotes (Ai and A2).
326 Conics and Circles
Po
(b)
- - '-,-
I
C
I ,
I
I
I
I
I
I...
(c)
,
,, ,,
, ,,
,, ,,
,,
---
Po
Figure 7.28. NURBS representation of a full ellipse given in Bezier form (dashed line).
Examples
with a = ,;3/2.
328 Conics and Circles
The following fourth- and fifth-degree full circle constructions are due to Chou
[Chou95] and Strotman [Stro91].
(7.66)
1- 2u h(u)= 2u(1-u)
g( u) = 1 _ 2u + 2u2 (7.67)
1- 2u + 2u 2
Substituting Eq. (7.67) into Eq. (7.66) and returning to the real xy
plane, we obtain
1 - 4u + 8u 3 - 4u4
x( u) = -1---4-u-+-8-u=-2-_-8-u"""3-+-4-u"""4
4u(1 - 3u + 2u2)
y( u) = 1 _ 4u + 8u2 - 8u3 + 4u4 (7.68)
-------r~----~--_,~----------~~ x
----~~----------~----~--~~--------=- x
Figure 7.31. Rational quartic representation of the full circle using two infinite con-
trol points.
330 Conics and Circles
R3
--+---~----~----------~r-~- X
R5 =Ro
Figure 7.32. Rational quintic representation of the full circle using only finite control
points.
EXERCISES
7.1. Prove the statement made in Section 7.3, "Due to our choice of Wo = W2 = 1,
it follows that the tangent to the conic at S = CUM is parallel to POP2'! Hint: Use
Eqs. (7.25) and (7.26) and the properties of similar triangles.
Exercises 331
7.2. Consider Figure 7.13 and Eq. (7.33). They imply that WI depends only on the
sweep angle (not radius). Consider what happens to WI in the two limiting cases:
• hold Po and P2 fixed and let PI go to infinity;
• fix a circle, and let Po and P 2 come together.
7.3. The two concepts of "setting a weight to zero" and "infinite coefficients" also
exist for the rational power basis representation. Is one of these concepts being used
to obtain Eqs. (7.8) and (7.9)? If so, which one?
7.4. Another representation ofthe full circle is obtained by using the nine-point square
control polygon and the knots of Example Ex7. 2 but with weights {Wi} = {1, 1,2,1,1,1,
2,1,1}. Investigate the continuity at u = 1/2. Use formulas from Chapter 5 to remove
the knot u = 1/2 as many times as possible. Compare this with Example Ex7 . 2 and
explain the results. Visualize the two circles lying on the cone in homogeneous space.
7.5. Use Eqs. (7.53) and (7.25) to verify that Eqs. (7.8) and (7.9) represent an ellipse
and a hyperbola, respectively.
7.6. A NURBS curve is defined by
u= { 0,0, 0, ~, 1, 1, 1}
Pi = {(1,0),(1,1),(-2,1),(-2,-1)}
Wi = {1, ~, ~, 1}
Is this curve a unique conic?
CHAPTER
EIGHT
8.1 Introduction
Sections 2 through 5 of this chapter cover the NURBS representation of the
four surface types: bilinear surfaces, general cylinders (extruded surfaces), ruled
surfaces, and surfaces of revolution. As the reader surely realizes by now, these
representations are not unique. Considerations such as parameterization, convex
hull, continuity, software design, application area, data exchange, and even per-
sonal taste can influence the choice of representation method. Our presentation
closely follows the constructions given by Piegl and Tiller [Pieg87aj. Section 6
uses nonuniform scaling to obtain additional surfaces such as the ellipsoid and
elliptic paraboloid. Section 7 presents a method for constructing a three-sided
patch on a sphere, whose boundary curves are circles whose radii are equal to
the radius of the sphere. This patch is useful as a corner fillet surface.
In order to clearly indicate the degree in this chapter, we use the notation
Ri,p;j,q(u, v) for the i,jth rational basis function of degree p x q (compare this
with Eq. [4.12]).
with u = V = {O,O, 1, I}
334 Construction of Common Surfaces
n 1
on knot vectors U and V, where V = {O, 0,1,1} and U is the knot vector of
C(u). The control points are given by Pi,o = Pi and P i,1 = Pi + dW, and the
weights are Wi,O = Wi,1 = Wi' A general cylinder is shown in Figure B.2.
A right circular cylinder is obtained by translating the NURBS circle a distance
d along a vector normal to the plane of the circle. Any of the circle representa-
tions given in Chapter 7 will do. Figure 8.3 shows a right circular cylinder whose
underlying circle is the quadratic, nine-point, square control polygon represen-
tation of Example Ex7.2 and Figure 7.16a. The cylinder is defined by
8 I
S(u,v) = LLRi,2;j,I(U,V)Pi,j (8.3)
i=O j=O
where V = {O,O, 1, 1} and U and the weights (Wi,O and Wi,l) are those given for
the circle in Example Ex7 . 2. Note that the control net forms the circumscribing
box of the cylinder.
Cylinders with circular and conic cross sections of sweep angle less than 360 0
are obtained by translating the control points computed by Algorithms A7.1 and
A7.3. Figure 8.4 shows an elliptic cylinder.
The General Cylinder 335
/\
\
PO,1
<::
PO,O
\
\ \
\
\
\
PI,I\
\
Y
X
\
\ PI,O
(a)
PO,O
y
x
(b)
Figure 8.1. Bilinear surfaces. (a) Straight line boundaries lying in the plane IIj (b)
nonplanar straight line boundaries (defined by diagonals of a cube) yielding a hyperbolic
paraboloid.
336 Construction of Common Surfaces
,~--_ u isocurve
v isocurve ' ------i ---____ _
;~C---~l - '" t -------
\_'::;;~ ~>~?r/
C(u) ~ "', I - ----~ --8
y
"7(
x C(u) +dW
"
.......................
'<:~i
y
n 1
2. if PI = P2, then set P = PI; otherwise, set P to the larger of PI,P2, and
raise the degree of the lower degree curve to P (Algorithm A5. 9);
3. if the knot vectors U I and U 2 are not identical, merge them to obtain the
knot vector U; more precisely, Uj is in U if it is in either U I or U 2 . The
maximum multiplicity of Uj in U I or U 2 is also carried over to U. For
example, if U I = {O, 0, 0,1,2,2,4,4, 4} and U 2 = {O, 0, 0,1,2,3,4,4, 4},
then U = {O, 0, 0,1,2,2,3,4,4, 4};
4. using U, apply knot refinement (Algorithm A5.4) to both curves, Ck(u);
this step yields the final values of n, Wi,j, and Pi,j'
Figures 8.5a-8.5e show the process of constructing a ruled surface between a
degree two and a degree three curve.
The general cone is also a ruled surface. Let P be the vertex point of the cone,
and let n
i=O
be its base curve. Define the curve
n
C 2 (U) = L Ri,p(U)P~
i=O
pI
4
p25
pI
°
pI
I
p2
3
x
y
(a)
Figure 8.5. Construction of a ruled surface between two NURBS curves. (a) In-
put degree two and degree three curves, U 1 = {O, 0, 0, 1/4, 1/2,3/4,1,1,1} and U 2 =
{O,O,O,O, 3/10, 7/10 ,1,1,1, I}.
The Ruled Surface 339
x
y
(b)
R~
x
y
(c)
Figure 8.5. (Continued.) (b) degree elevation of degree two curve; (c) knot refined
curves after merging the knot vectors; surface knot vector is U = {O, 0, 0, 0, 1/4, 1/4, 3/10,
1/2, 1/2, 7/10 , 3/4, 3/4,1,1,1,1}.
340 Construction of Common Surfaces
S8,0 ......
,,~, S11,O
' \.........
.', - ~-.., - ~
-- -- -
S11,1
--1'
S3,0 ...., ,
, ..
-:'~'-
x
y
'~ SO,l
(d)
Figure 8.5. (Continued.) (d) control net of ruled surface.
(e)
Figure 8.5. (Continued.) (e) ruled surface.
y
... ---
,I
(a)
(b)
Figure 8.7. Ruled surfaces defined by circles and lines. (a) Degree two ruled surface
(conoid); (b) degree three ruled surface.
The Surface of Revolution 343
(c)
Figure 8.7. (Continued.) (c) degree four ruled surface.
z
Ps
PS,2
S(u,1)) , ':,.
P3,2
• for fixed u, S(u,v) is the curve C(v) rotated some angle about the z-axis;
• for fixed v, S( u, v) is a full circle which lies in a plane perpendicular to
the z-axis, with its center on the z-axis.
Let us use the nine-point circle representation, with U = {O, 0, 0, 1/4, 1/4 , 1/2, 1/2,
3/4,3/4,1,1, 1} and weights Wi = {1, V2/2, 1, V2/2, 1, V2/2, 1, V2/2, 1}. Then the re-
quired surface has the form
S m
S(u,v) = LL R i,2;j,q(U,v)Pi,j (8.5)
i=O j=O
The knot vectors are U and V. The control points and weights are determined
But this says that Qj is just PO,j (= P j ) rotated about the z-axis through
some fixed angle, (), corresponding to u. Hence, from the rotational invariance
of NURBS curves, it follows that S(u,v) is just C(v) rotated about the z-axis
through (). This completes the proof.
Several common surfaces are surfaces of revolution. A torus is obtained by
revolving a full circle about the z-axis (Figure 8.10). A sphere is obtained by
revolving about the z-axis a half circle whose endpoints lie on the z-axis (see
Figure 8.11). Notice that the control points at the north and south poles of
the sphere are repeated nine times: Po,o = ... = Ps,o and P O,4 = ... = P S,4.
Hence, the partial derivatives at these poles with respect to u are identically
zero. However, the normal vectors clearly exist there.
We now present an algorithm which constructs a NURBS surface of revolution
through an arbitrary angle, theta, about an arbitrary axis (see Figure 8.12).
The axis is specified by a point, S, and a unit length vector, T. For conve-
nience, we separate weights and three-dimensional control points in this algo-
rithm; m,Pj [] ,wj [] define the generatrix curve, and n,U,Pij [] [] ,wij [] [] are
computed (see Eq. [8.5]). We assume four utility functions:
The Surface of Revolution 345
z
- - -/~ - --
(a)
(b)
Figure 8.9. (a.) A control net for a surface of revolution; (b) a surface of revolution.
ALGORITHM AB.l
MakeRevolvedSurf(S,T,theta,m,Pj,wj,n,U,Pij,wij)
{ 1* Create NURBS surface of revolution *1
1* Input: S,T,theta,m,Pj,wj *1
1* Output: n,U,Pij,wij *1
if (theta <= 90.0) narcs = 1;
else
if (theta <= lBO.O)
{ narcs = 2; U[3] = U[4] = 0.5; }
else
if (theta <= 270.0)
{
narcs = 3;
U[3] = U[4] 1.0/3.0;
U[5] = U[6] 2.0/3.0;
}
else
{
narcs = 4;
U[3] = U[4] = 0.25;
U[5] = U[6] = 0.5;
U[7] = U[B] = 0.75;
}
dtheta = theta/narcs;
j = 3 + 2*(narcs-l); 1* load end knots *1
for (i=O; i<3; j++,i++)
The Surface of Revolution 347
-----~~-::~~~
.-::~~~-: - - ~ - ;- - - -
y
x ~:-'- --
,, ''
,, ,'
""
"
,,,~,,,
S
y
Figure 8.12. A general surface of revolution through an arbitrary angle about an arbi-
traryaxis.
348 Construction of Common Surfaces
(8.7)
The scaling is called uniform if the three fi are equal; otherwise, it is nonuniform.
Several interesting surfaces can be obtained by applying a nonuniform scaling
to a surface of revolution. Figure 8.14 shows an ellipsoid, centered at the origin,
which has an implicit equation of the form
(8.8)
The three coordinate planes cut the surface in three ellipses. The ellipsoid is
constructed by first producing the unit radius sphere, centered at the origin, and
then scaling it about the origin with the factors F = (a, b, c).
Figure 8.15b shows an elliptic paraboloid. The xz and yz planes cut the surface
in parabolas; the xy plane cuts it in an ellipse. It has the implicit equation
(8.9)
The elliptic paraboloid of Figure 8.15b is obtained from the paraboloid of rev-
olution shown in Figure 8.15a by scaling about the origin with the factors F =
(a,b,l).
A nonuniform scaling is performed on a NURBS surface by applying the scale
factors to the three-dimensional control points. If the control points are stored in
Figure 8.13. A toroidal patch as a surface of revolution used to round a sharp corner.
350 Construction of Common Surfaces
x
,~_
'.-
'- I /
,
,
---i--
(a)
Figure 8.15. Paraboloids. (a) A paraboloid of revolution; (b) an elliptic paraboloid.
A Three-sided Spherical Surface 351
" ........
~ , ~ ~ I
,
/
/
I
I
(b)
Figure 8.15. (Continued.)
three-dimensional (unweighted) form, then Eq. (8.6) or Eq. (8.7) can be applied
directly. The weights do not change. If the control points are stored in four-
dimensional form
(8.11)
y
x
(a)
y
S5
x
(b)
Figure 8.16. Rounding edges and a corner. (a) Three edges and a corner formed by
three intersecting planes; (b) three edge fillet surfaces and one corner fillet surface
formed by rolling a marble; the rounded corner and the three edges are shown dashed.
354 Construction of Common Surfaces
that is, a (u, v) point maps into the (x, y, z) point which is at the intersection
of the sphere and the line segment from (u,v,O) to (0, 0, 2R) (see Figure 8.17).
Under this projection we have the following correspondences:
• straight lines passing through the origin of the xy plane map to longitu-
dinal circles on the sphere;
• all other circles on the sphere correspond to circles in the xy plane.
The three boundaries of the fillet surface are circular arcs of radius R, with
centers at (O,O,R). Denote these arcs by C 1 (t),C 2 (8),C 3 (t), with 0::; 8, t::; l.
Without loss of generality we assume that the patch boundaries are positioned
and oriented as (see Figure 8.18):
• C 1 (t) and C 3 (t) start at the origin: C 1 (0) = C 3 (0) = (0,0,0);
• C 1 (t) lies in the xz plane;
• C 1 (1) = C 2 (0) and C 2 (1) = C 3 (1).
Then the projection of the fillet patch yields a flat surface, 8 2(8, t) = (U(8, t),
° °
V(8, t), 0) in the xy plane. The 8 = and 8 = 1 boundaries of 8 2 (8, t) are straight
lines, the t = boundary is degenerate, and the t = 1 boundary is a circular arc.
Hence, 8 2 (8, t) has degree (2,1) and the composition mapping 8(8, t) = 8 1 08 2
yields a (4 x 2)-degree rational Bezier representation of the fillet surface.
Clearly, general formulas can be derived for computing the control points and
weights of 8(8, t). However, as most terms are zero anyway, we specifically derive
the formulas for each coordinate and weight separately. The computation is:
(0,0,2R)
(x,y,z)
y
(u,v)
x
(0,0,2R)
y
PO,l ~ ~ ~~-~- - - -
,,
x
Figure 8.18. The flat surface 8 2 obtained by projecting the fillet surface onto the
xy plane.
-2R
a=--- u = ax, v = ay (8.14)
z-2R
of two of the chords formed by the projections of the three points, C 2 (0),
C 2 (1/2), and C 2 (1);
3. then compute Pf,l by (see Figure 8.18):
- compute M = lh(PO,l + P 2,1);
Pl,l is the inverse of M with respect to the projected circular arc (see
[Coxe67]), hence OM· OPl,1 = r2; from this we get
Pl,l = (1- a)O +aM
where a=-----,.-
IOMI 2 '
from Eq. (7.33), Wl,l = cos LPl,lP2,1 PO,l.
Let [ai,j] denote the power basis coefficients of S~(s, t). From Eq. (6.91) it
follows that
[ a':".]
t,}
=M2[P':".]MlT
t,}
where M2 and Ml are the second- and first-order Bezier matrices, respectively
(Eq. [6.80]). Applying the matrix multiplications yields
ag:0 = PO,o
w _ pw pw
ao,l - 0,1 - 0,0
ato = 2( Pf,o - PO,o)
atl = 2(Pf,1 + PO,o - PO,l - Pf,o)
a~o = PO,o - 2Pf,0 + P~o
a~l = Pif,l + P~l - Pif,o - P~o + 2(Pr.o - Pr.l) (8.15)
Now let
(8.16)
(note that the Ui,j and Vi,j are weighted). The z coordinate is zero, and to avoid
a conflict later we use h instead of W for a weight. Denote the control points of
the circular arc by Pi"1 = (ai, (3i, 'Yi), 0 :.::; i :.::; 2 (ai and (3i weighted). Assuming
corner weights to be i, and considering the fact that Cl(t) lies in the xz plane
and Cl(O) = (0,0,0), it follows that the only nonzero Ui,j, Vi,j, and hi,j are
UO,l = ao
Ul,l = 2(al - ao)
U2,1 = a2 + ao - 2al
Vl,l = 2(31
V2,1 = (32 - 2f3l
ho,o = 1
hl,o = 2('Y1 - 1)
h 2,0 = 2(1 - 'I'd (8.17)
A Three-sided Spherical Surface 357
Using Eqs. (8.16) and (8.17) and the power basis form
and
V(s, t) = Vl,lSt + V2,lS2 t
H(s, t) = ho,o + h1,os + h2,oS2 (8.20)
Substituting Eqs. (8.19) and (8.20) into Eq. (8.13), we have
S(s, t) = (x(s, t), y(s, t), z(s, t)) (8.21)
(8.27)
the power basis representation of SW(s, t), and let brj = (Xi,j, Yi,j, Zi,j, Wi,j).
Most of the coordinates of the brj are zero. The only nonzero elements are
XO,1 = 4R2UO,lho,o
XI,1 = 4R 2(UI,lho,o + uO,lhl,o)
YI,1 = 4R2vI,lho,o
Y2,1 = 4R2(V2,lho,o + VI,lhl,o)
Y3,1 = 4R 2(VI,lh2,o + V2,lh l ,o)
Y4,1 = 4R2v2,lh2,O (8.29)
ZO,2 = 2Ru~,1
ZI,2 = 4Ruo,1 UI,1
Z2,2 = 2R(ui,1 + 2UO,IU2,1 +Vi,l)
Z3,2 = 4R(UI,IU2,1 + VI,IV2,1)
Z4,2 = 2R(u~,1 + V~,l) (8.30)
W2,2 = UI,1
2
+ 2UO,1 U2,1 + VI,1
2
Equations (8.27)-(8.31) give the power basis form of the fillet surface SW(s, t).
The Bezier (NURBS) representation is obtained by applying Eq. (6.100), that is
[ pw.]
',J
= M-
4
1 [b W ] (M-l)T
',J 2
Po,o = ... = P 4 ,O
Figure 8.19. A corner fillet surface - an arbitrary spherical patch whose boundaries are
great circles of the sphere.
We now summarize the complete algorithm. Input to the algorithm are three
boundary arcs, C l , C 2 , and C 3 , arbitrarily positioned and oriented in space but
joined at their endpoints. Output is a (4 x 2)-degree rational Bezier fillet patch.
ALGORITHM A8.2
MakeCornerFilletSurf(Cl,C2,C3,Pwij)
{ /* Create NURBS corner fillet surface */
/* Input: Cl,C2,C3 */
/* Output: Pwij */
1. Compute the common radius and center point of the three
boundary arcs.
2. Using translation, rotation and possibly curve reversal
(see Chapter 6), position and orient the boundary arcs
as in Figure 8.18. Note that, in fact, only C2 must
actually be positioned and oriented, as only it is
required in order to compute the three control points
Pi'l = (aiJ3i , "Ii).
3. Co~pute the (ai,f3i,"Ii) as described above.
4. Convert S~(s, t) from Bezier to power basis form
(Eq. [8.17]).
5. Compute the power basis form of the fillet patch
SW = Sf 0 S~ (Eqs. [8.27] - [8.31]).
360 Construction of Common Surfaces
9.1 Introduction
In Chapters 7 and 8 we showed how to construct NURBS representations of com-
mon and relatively simple curves and surfaces such as circles, conics, cylinders,
surfaces of revolution, etc. These entities can be specified with only a few data
items, e.g., center point, height, radius, axis of revolution, etc. Moreover, the few
data items uniquely specify the geometric entity. In this chapter we enter the
realm offree-form (or sculptured) curves and surfaces. We study fitting, i.e., the
construction of NURBS curves and surfaces which fit a rather arbitrary set of
geometric data, such as points and derivative vectors. We distinguish two types
of fitting, interpolation and approximation. In interpolation we construct a curve
or surface which satisfies the given data precisely, e.g., the curve passes through
the given points and assumes the given derivatives at the prescribed points. Fig-
ure 9.1 shows a curve interpolating five points and the first derivative vectors
at the endpoints. In approximation, we construct curves and surfaces which do
not necessarily satisfy the given data precisely, but only approximately. In some
applications - such as generation of point data by use of coordinate measuring
devices or digitizing tablets, or the computation of surface/surface intersection
points by marching methods - a large number of points can be generated, and
they can contain measurement or computational noise. In this case it is im-
portant for the curve or surface to capture the "shape" of the data, but not
to "wiggle" its way through every point. In approximation it is often desirable
to specify a maximum bound on the deviation of the curve or surface from the
given data, and to specify certain constraints, i.e., data which is to be satisfied
precisely. Figure 9.2 shows a curve approximating a set of m + 1 points. A
maximum deviation bound, E, was specified, and the perpendicular distance, ei,
is the approximation error obtained by projecting Qi on to the curve. The ei
of each point, Qi' is less than E. The endpoints Q o and Q m were specified as
constraints, with the result that eo = em = O.
362 Curve and Surface Fitting
Figure 9.1. A curve interpolating five points and two end derivatives.
There are many subtleties in fitting, and literally hundreds of papers have been
written on this topic. Many of the techniques are heuristic, and there are usually
no unique or clear-cut "right" answers. A fundamental problem is that the given
data never specifies a unique solution. There are infinitely many NURBS curves
which can interpolate the seven data items in Figure 9.1, or approximate the
m + 1 items in Figure 9.2. How often has the implementor of a fitting algorithm
been told by a designer using the software: "but that's not the curve I wanted!".
And the reply is often: "well, it's mathematically correct; it satisfies the data
you gave me!".
Input to a fitting problem generally consists of geometric data, such as points
and derivatives. Output is a NURBS curve or surface, i.e., control points, knots,
and weights. Furthermore, either the degree p (or (p, q) for surfaces) must be
input or the algorithm must select an appropriate degree. If CT continuity is
o
o o
o o
Figure 9.2. A curve approximating m+ 1 points; the curve is constrained to pass through
the endpoints, Qo and Qm·
Introduction 363
p~r+l (9.1)
Suppose we are given a set of points {Qk}, k = 0, ... ,n, and we want to in-
terpolate these points with a pth-degree nonrational B-spline curve. If we as-
sign a parameter value, Uk, to each Qk, and select an appropriate knot vector
U = {uo, ... , urn}, we can set up the (n + 1) x (n + 1) system of linear equations
n
Q k = C(Uk) = LNi,P(Uk)Pi (9.2)
i=O
The control points, Pi, are the n + 1 unknowns. Let r be the number of coordi-
nates in the Qk (typically 2,3, or 4). Note that this method is independent of rj
Eq. (9.2) has one coefficient matrix, with r right hand sides and, correspondingly,
r solution sets for the r coordinates of the Pi.
The problem of choosing the Uk and U remains, and their choice affects the
shape and parameterization of the curve. Throughout this section we assume
that the parameter lies in the range u E [O,lJ. Three common methods of
choosing the Uk are:
• equally spaced:
Then Uo = °
Global Interpolation 365
This is a newer method (see [Lee89]) which gives better results than the
chord length method when the data takes very sharp turns.
Knots can be equally spaced, that is,
UO="'=Up=O Um - p = ... = U m = 1
u· - j j = 1, ... ,n-p (9.7)
J+p - n - p+ 1
However, this method is not recommended; if used in conjunction with Eqs. (9.5)
or (9.6) it can result in a singular system of equations (Eq. [9.2]). We recommend
the following technique of averaging
Uo="'=Up=O Um - p = ... = U m = 1
1 j+p-l
uj+p =- L Ui j = 1, ... ,n-p (9.8)
P i=j
With this method the knots reflect the distribution of the Uk. Furthermore,
using Eq. (9.8) combined with Eq. (9.5) or (9.6) to compute the Uk leads to a
system (Eq. [9.2]) which is totally positive and banded with a semibandwidth
less than p (see [DeBo78]), that is, Ni,p(Uk) = 0 if I i - k I ~ p. Hence, it can be
solved by Gaussian elimination without pivoting.
Figure 9.3 shows control points, parameters, and the knot vector of a cubic
curve interpolating seven points. Parameters were chosen by the chord length
method, and the knots were obtained by averaging the parameters (Eq. [9.8]). In
Figure 9.4 a comparison of different parameterizations is illustrated. Figure 9.5
shows the same comparison using more "wildly" scattered data points. In both
cases a cubic curve is passed through seven points, using uniform parameters and
uniform knots (solid curve and top knot vector - see Eqs. [9.3] and [9.7]); chord
length parameters and knots obtained by averaging (dashed curve and middle
366 Curve and Surface Fitting
P2
r- __
I
--- P3
I
I
Q2 --"
I \
\
I
I
Q3 \
\ Ps
\
.- A ,,
PI
\
,,
QI \
\ Q4 Po
\ .-
.- .- Qs
\
\ Qo
.-
Po , .-
\
\
" P4
I~I e el Ie 19 9 I~I
Uo UI U2 U3 U4 Us Uo
Figure 9.3. A curve interpolation example using chord length parameterization and a
knot vector obtained by averaging parameters.
knot vector - see Eqs. [9.5] and [9.8]); and centripetal parameters and knots
obtained by averaging (dotted curve and bottom knot vector - see Eqs. [9.6] and
[9.8]). In Figure 9.5 notice how the chord length and centripetal parameterized
curves adapt to the changes in point spacing.
I~ I 9 9 9 9 I~ I
I ~I 9 91 Ie 19 e I~I
I~I 9 91 Ie 9 I~I
Figure 9.4. A curve interpolation example with different parameterizations and knot
vectors.
Global Interpolation 367
,'/
,/1
/ r
\, \
l\'jl o o o o l\'jl
1\'j 1 0 + 0 1 o l\'jl
l\'jl 8 1 e e 1 8 l\'jl
Figure 9.5. A curve interpolation example with different parameterizations and knot
vectors.
Figure 9.6 illustrates interpolation with different degrees; solid, dashed, and
dotted curves have degrees 2, 3, and 4, respectively. Figure 9.7 shows the inability
of the global interpolant to handle collinear point sets.
Once the Uk and the knots are computed, the (n+ 1) x (n+ 1) coefficient matrix
of the system (Eq. [9.2]) is set up by evaluating the nonzero basis functions at
each Uk, k = 0, ... , n; use Algorithms A2.1 and A2. 2.
Example
Ex9.1 Let {Qd = {(0,0),(3,4), (-1,4), (-4,0), (-4,-3)}, and assume that
we want to interpolate the Qk with a cubic curve. We use Eqs. (9.5)
and (9.8) to compute the Uk and Uj, and then set up the system of linear
equations, Eq. (9.2). The separate chord lengths are
Uo = ° _
Ul =
5
17
_
U2 = -
9
17
U3= -
14
17
Using Eq. (9.8)
1 ( 5 9 14) 28
U4 ="3 17 + 17 + 17 = 51
368 Curve and Surface Fitting
1$1 o o I 0 I 0 o 1$1
I t11 0 o 10 0 o 1t11
11$11 0 10 o 11$11
Figure 9.6. A curve interpolation with different degrees using chord length parameter-
ization and knots obtained by averaging.
1
5
°5 °5 °5 °
N (1 7) N (1 7) N (1 7) N (1 7)
O,3 1 ,3 2 ,3
° 3 ,3
Po
N C
PI
N (197)
O,3 1 ,3
97) N (197) N (197)
2 ,3
° 3 ,3 P2
P3
N1,3 C4)
17 N 2,3 C4)
17 N 3,3 C4)
17 4,3 C4)
17
P4
° N
1
° ° ° ° Qo
Ql
Q2
Q3
Q4
Global Interpolation 369
/
(
,,
/
/
/
/
/
/
,,
'N..=-=-'-'~- - - - - - - - - - - -=--&------fl
Figure 9.7. A global cubic curve interpolant to data containing collinear points (see the
dashed line).
LUDecomposition(A,n+1,p-1);
for (i=O; i<r; i++) /* r is the number of coordinates */
{
for Cj=O; j<=n; j++) rhs[j] = ith coordinate of Q[j];
ForwardBackward(A,n+1,p-1,rhs,sol);
for Cj=O; j<=n; j++) ith coordinate of P[j] = sol[j];
}
}
1 j+p-l
uj+p+l = - LUi j = 0, ... , n - p + 1 (9.9)
P i=j
Notice that Eq. (9.9) is analogous to Eq. (9.8) except that we pick up two addi-
tional knots by running j from 0 to n - p + 1. As before, Eq. (9.2) yields n + 1
equations
n+2
Qk = C(Uk) = LNi,P(Uk)Pi (9.10)
i=O
Global Interpolation 371
Inserting Eqs. (9.11) and (9.12) into Eq. (9.10) as the second and next to last
equations, respectively, yields an (n + 3) x (n + 3) banded linear system. Fig-
ure 9.8 shows cubic curve interpolants with end tangents specified. The small,
medium, and large magnitudes of the derivatives produce the solid, the dashed,
and the dotted curves, respectively. Figure 9.9 illustrates interpolants to the
same data points, but with different end tangent directions and magnitudes for
the derivatives.
The previous method (Eqs. [9.9]-[9.12]) is valid for any degree p > 1. If p = 3,
there is an algorithm which is more efficient and yields the traditional C 2 cubic
spline. The Uk are computed as previously. The knots are
Uo = ... = U3 = 0 U n +3 = ... = U n +6 = 1
Uj+3 = Uj j = 1, ... ,n-l (9.13)
In other words, the interpolation of the Qk occurs at the knots. The first two
and last two equations are, respectively
Po = Q o
U4
-Po + PI = 3Do (9.14)
Figure 9.8. Global cubic curve interpolants with varying end derivative magnitudes.
372 Curve and Surface Fitting
Figure 9.9. A global cubic curve interpolation with different end derivative directions.
1- U n +2
and -Pn +1 + Pn +2 = 3 Dn
Pn +2 = Qn (9.15)
These can be solved directly. Recalling that there are only three nonzero cubic
basis functions at an interior knot, the remaining n - 1 equations have the form
(9.16)
R2 Ql - alPl
R3 Q 2
R n- l Qn-2
Rn Qn-l - Cn-l Pn+1
bl Cl 0 0 0 0
a2 b2 C2 0 0 0
(9.17)
000 an -2 bn - 2 Cn -2
000 o an-l bn - 1
Global Interpolation 373
This system can be solved by a simple algorithm which computes the rows of
the matrix in Eq. (9.17) on-the-fly. It requires two local arrays, R [] and dd [],
of length n + 1, and an array abc [] of length 4, which stores ak, bk , Ck, O. It
assumes that Po, PI. Pn +l, Pn +2 are already computed and loaded into array P.
The algorithm can be adapted to handle points with any number of coordinates.
ALGORITHM A9.2
SolveTridiagonal(n,Q,U,P)
{ /* Solve tridiagonal system for C2 cubic spline */
/* Input: n,Q,U,P[0],P[1],P[n+1],P[n+2] */
/* Output: P */
for (i=3; i<n; i++) R[i] = Q[i-1];
BasisFuns(4,U[4],3,U,abc);
den = abc[1];
P [2] = (Q [1] -abc [0] *P [1]) /den;
for (i=3; i<n; i++)
{
dd[i] = abc[2]/den;
BasisFuns(i+2,U[i+2] ,3,U,abc);
den = abc[1]-abc[0]*dd[i];
P[i] = (R[i]-abc[0]*P[i-1])/den;
}
dd[n] = abc[2]/den;
BasisFuns(n+2,U[n+2],3,U,abc);
den = abc[1]-abc[0]*dd[n];
P[n] = (Q[n-1]-abc[2]*P[n+1]-abc[0]*P[n-1])/den;
for (i=n-1; i>=2; i--) P[i] = P[i]-dd[i+1]*P[i+1];
}
Figure 9.10 shows data interpolated with this cubic spline algorithm.
Often, only tangent directions but not magnitudes for derivative vectors are
specified. We denote unit length tangent vectors by To and Tn. In this case,
magnitudes 0:0 and O:n must be estimated. Set
Do = o:oTo (9.18)
and proceed as before. A reasonable choice is to set 0:0 and O:n equal to the total
chord length, d, as computed in Eq. (9.4). In an interactive environment, 0:0 and
O:n can be used as additional shape controls.
,,
,,
,,
Figure 9.10. A cubic spline interpolant (solid line) compared to a regular cubic in-
terpolant (dashed line) obtained by using chord length parameterization and knots
computed by averaging.
and from Eqs. (2.10) and (3.3), the n + 1 equations expressing the Dk are
2n+1
Dk = C'(Uk) = L N{,p(Uk) Pi (9.20)
i=O
The parameters Uk are computed using Eq. (9.5) or Eq. (9.6). The number of
knots is
2(n + 1) + p + 1 (9.21 )
and they should be chosen to reflect the distribution of the Uk. For p = 2 and
p = 3, satisfactory choices are
UI _ UI + U2 _ _ Un-l + 1 }
U= { 0,O,O'2,UI, 2 ,U2,···,Un -l, 2 ,1,1,1 (9.22)
Un-l + 1 }
2 ,1,1,1,1 (9.23)
Um-p-l =
Un-l +1
2
Global Interpolation 375
Po = Qo
_ U4
-Po + PI D
- 3 0
(9.24)
Figure 9.11. Quadratic (solid line) and cubic (dashed line) curve interpolants with
derivatives specified at each data point.
376 Curve and Surface Fitting
".
\
\
\ \
""
/
/
Figure 9.12. Cubic curve interpolants with varying tangent derivatives at each point.
the dashed curve has ak = 3/2d (large tangent); and the dotted curve was ob-
tained by ak = l/2d (small tangent). Figure 9.13 shows the control points of a
quadratic curve interpolant to specified points and first derivatives.
Again, the first order of business is to compute reasonable values for the (Uk, Vi)
and the knot vectors U and V. We show how to compute the Uk; the v£ are
analogous. A common method is to use Eq. (9.5) or Eq. (9.6) to compute pa-
rameters ub, ... ,u~ for each £, and then to obtain each Uk by averaging across
allu1, £ = 0, ... ,m, that is
-
Uk =
1
--1
,,-£
m
~uk k = O, ... ,n
m+ £=0
where for each fixed £, u1, k = 0, ... ,n, was computed by Eq. (9.5) or Eq. (9.6).
An efficient algorithm using Eq. (9.5) follows. It computes both the Uk and Vi.
It requires one local array, cds [], of length max(n + 1, m + 1), to store chordal
Global Interpolation 377
~---~---+---~~----~
,,
\
G-~-~--==--~---c-
Figure 9.13. Control points of a quadratic B-spline curve interpolant to data with
specified derivatives.
distances I Qk,t - Qk-l,tl, k = 1, ... , n (and similarly for the v direction). The
function Distance3D 0 computes the distance between two three-dimensional
points. This algorithm handles the case when the total chord length of a row is
equal to zero, a necessary condition if a three-sided surface is being constructed.
ALGORITHM A9.3
SurfMeshParams(n,m,Q,uk,vl)
{ 1* Compute parameters for *1
1* global surface interpolation */
1* Input: n,m,Q *1
1* Output: uk,vl *1
1* First get the uk *1
num = m+l; 1* number of nondegenerate rows *1
uk[O] = 0.0; uk[n] = 1.0;
for (k=l; k<n; k++) uk[k] = 0.0;
for (1=0; l<=m; 1++)
{
total = 0.0; 1* total chord length of row *1
for (k=l; k<=n; k++)
{
cds[k] = Distance3D(Q[k] [l],Q[k-l] [1]);
total = total + cds[k];
}
if (total == 0.0) num = num-l;
378 Curve and Surface Fitting
else
{
d = 0.0;
for (k=l; k<n; k++)
{
d = d + cds[k];
uk[k] = uk[k] + d/total;
}
}
}
if (num == 0) return(error);
for (k=l; k<n; k++) uk[k] = uk[k]/num;
/* Now do the same for vl */
}
Once the (Uk, Vl) are computed, the knot vectors U and V can be obtained by
Eq. (9.8).
Now to the computation of the control points. Clearly, Eq. (9.25) represents
(n + 1) x (m + 1) linear equations in the unknown Pi,j. However, since S(u,v)
is a tensor product surface, the Pi,j can be obtained more simply and efficiently
as a sequence of curve interpolations. For fixed £ write Eq. (9.25) as
(9.26)
m
where Ri,l = LNj,q(Vl)Pi,j (9.27)
j=O
Notice that Eq. (9.26) is just curve interpolation through the points Qk,l, k =
0, ... ,n. The Ri,l are the control points of the isoparametric curve on S( u, v)
at fixed v = Vl. Now fixing i and letting £ vary, Eq. (9.27) is curve interpolation
through the points Ri,o, ... , Ri,m, with Pi,o, ... , Pi,m as the computed control
points. Thus, the algorithm to obtain all the Pi,j is (see Figure 9.14a-9.14d):
1. using U and the Uk, do m + 1 curve interpolations through Qo,Jil· .. , Qn,£
(for £ = 0, ... , m); this yields the Ri,l (Figure 9.14b);
2. using V and the Vl, do n + 1 curve interpolations through Ri,o, ... ,Ri,m
(for i = 0, ... ,n); this yields the Pi,j (Figure 9.14c).
Figure 9.14d portrays the resulting surface. Clearly, the algorithm is symmetric;
the same surface is obtained by:
1. doing n+ 1 curve interpolations through the Qk 0, ... , Qk m to obtain the
Rk,j (control points of isoparametric curves S( ilk, v)); ,
2. then doing m+ 1 curve interpolations through the RO,j, ... ,Rn,j to obtain
the Pi,j.
Global Interpolation 379
..
QO,2
- \ --
,
~
QO,3
,
Qo,O/ \
,, ,,
,,
Ql,O ' \
,,
'- ,
'- , , ,
x
,,
,,
,, ," y
, '
e'Q3,O
(a)
z
Ro,2
RO,l Ro,3
Ro,o
(b)
Figure 9.14. Global surface interpolation. (a) The data points; (b) interpolating the
u-directional data points; (c) interpolating in the v direction through control points of
u-directional interpolants; (d) the surface interpolant showing control points.
380 Curve and Surface Fitting
PO,!
PO,2
(c)
Figure 9.14. (Continued.)
.--- z
I
I " ,
\
I ,
I \
(d)
Figure 9.14. (Continued.)
--
--,.1\
I
I
I
, I
I
-0
I
I
,
--
\
-- ,,
I
-----.,
\
\
\ y
/
/
/ /
x ,
\
/
8
,
/
knot vectors are illustrated in Figures 9.16a-9.16c. The degree is (2,3), and the
parameterizations and knot vectors are uniform (Figure 9.16a); chord length,
knots obtained by averaging (Figure 9.16b)j and centripetal, knots obtained
by averaging (Figure 9.16c). In Figure 9.17 surface interpolants with differ-
ent degrees are depicted. The degrees in each are: Figure 9.17a, degree (2,3);
Figure9.17b, degree (3,2); and Figure9.17c, degree (3,3). In Figure 9.18 the
inability to handle coplanar data is demonstrated.
Derivative constraints can also be incorporated into global surface interpola-
tion. Conceptually, the derivative formulas of Chapters 2 and 3 can be used
to define one additional linear equation for each derivative constraint specified.
Unfortunately, if the number of data constraints is not the same in every row
or column it becomes more difficult to solve for the unknown surface control
points using curve interpolations in two directions, as described previously. How-
ever, with clever use of curve knot insertion and surface knot removal, one can
adapt Algorithm A9 . 4 to handle partial derivative constraints at individual data
points. Finally, local surface interpolation methods (see Section 9.3) are well-
suited to handling derivative constraints, as they require derivatives at every
point anyway.
(a)
(b)
Figure 9.16. A surface interpolation with degree (2,3) surfaces obtained by using dif-
ferent parameterizations and knot vectors.
384 Curve and Surface Fitting
(c)
Figure 9.16. (Continued.)
are possible with cubics, higher degree must be used if a reasonable amount of
flexibility is to be maintained.
Obtaining the Bezier segments, Ci(u), requires computation of the inner
Bezier control points, one point for quadratics, two for cubics. These control
points lie on the lines which are tangent to the curve at the Qk; thus, we require
tangent vectors Tk at each Qk' In some cases they can be input along with the
Qk; e.g., they are easily obtained when computing points of intersection between
two surfaces. However, if not input then they must be computed as part of the
fitting algorithm. A number of methods exist; Boehm et al [Boeh84] gives a
survey of various methods. Let
Vk
or Tk = IV k I (9.29)
(see Figure 9.19). Notice that Eq. (9.28) assumes that values for the Uk have
been assigned. The vectors Dk can be viewed as estimates for the derivatives.
Local Interpolation 385
(a)
(b)
Figure 9.17. Surface interpolants using different degrees; the parameterization is chord
length and knot vector obtained by averaging.
386 Curve and Surface Fitting
(c)
Figure 9.17. (Continued.)
Equation (9.29) does not use parameters Uk, and the resulting vectors should
be viewed as tangent directions only. Assignment of magnitudes and parameters
must be done in conjunction with one another; they are not independent. Notice
also that we use the notation T strictly for unit length tangent vectors. Equations
(9.28) and (9.29) are linear interpolations. The various schemes differ in the way
they compute the interpolation parameter (tk; it typically depends on either
three or five neighboring points. For example, the Bessel method [DeBo78] is a
three-point method using
(a)
(b)
Figure 9.18. Global surface interpolation example. (a) Data containing coplanar points;
(b) interpolating surface.
388 Curve and Surface Fitting
Figure 9.19. Computation of tangent (V k) and derivative (Dk) vectors for local curve
interpolation .
(9.32)
(9.33)
to substitute into Eqs. (9.31) and (9.29) in order to obtain To, Tl and Tn-I, Tn.
We are now ready to present several local interpolation methods.
point of L k - 1 and L k . Assume for the moment that the intersection exists,
and that
'Yk-l >0 (9.34)
where
(we drop this restriction later). Then we choose as our control points
(9.35)
(9.36)
Uo = 0
_ _ + (_ _) I Rk - Qk-l I
Uk = Uk-1 Uk-1 - Uk-2 I Qk-l - R
k-l
I k = 2, ... ,n (9.37)
,
I \
\
I
I
\
ill
I
R5
I
L.
Figure 9.20. C 1 continuous quadratic curve interpolant.
390 Curve and Surface Fitting
The C 1 continuous curve interpolating the {Qk} is then defined by the con-
trol points
(9.38)
and the knots
ih
U = { 0,0,0, -=-, -=-,
U2
... , -_-,
Un -2 Un -1
-_-,1,1,1
}
(9.39)
Un Un Un Un
One must pay a price for the C1 continuity and the reduction in the number
of control points, namely in the parameterization; Figures 9.21a and 9.21b show
this. The curve in these figures is marked at equally spaced parameter values.
In Figure 9.21a the knots were computed using Eq. (9.37) and in Figure 9.21b
using the chord length parameterization (Eq. [9.5]). Note the spacing of the Qk'
We now drop the restriction given in Eq. (9.34) and detail two special cases
which arise when computing the Rk:
• Tk-l and Tk are parallel, hence Rk cannot be computed by intersection;
this can indicate collinear segments, an inflection point, or a 1800 turn in
the curve;
• Rk can be computed, but 'Yk-l and 'Yk do not satisfy Eq. (9.34); this
indicates either an inflection point or a turn of more than 1800 •
The collinear segments case applies if Tk-l and Tk are both parallel to the chord
Qk-l Qk' We handle this case simply by setting
\
+ \
/ I)) R5
/+ /
/
+ /
/
..
/
/
/
/
/
(a)
Figure 9.21. Parameterizations of the curve interpolant in Figure 9.20. (a) 0 1 parame-
terization (Eqs. [9.39]-[9.41]); (b) G 1 parameterization using chord length parameters.
Local Interpolation 391
,, I
'-1; f
(b)
Figure 9.21. (Continued.)
(9.40)
All other special cases are handled by creating two parabolic segments between
Qk-l and Qk' instead of one. Thus, we must compute three additional points,
R'k' Q~ and R'k+1 (see Figures 9.22a and 9.22b). Setting
(9.41)
and Q 'k-
_ 'YkR;.+1 + 'Yk+1R;. (9.42)
'Yk + 'Yk+1
it remains to determine reasonable choices for Ik and IHI. If Tk-I and Tk are
parallel (but not to Qk-l Qk), then set
1
'Yk = 'YHI = 2" I Qk-l Q k I (9.43)
This is illustrated in Figure 9.22a for the case of a 180° turn. Now consider
the case when Tk-l and Tk are not parallel, but Eq. (9.34) does not hold (see
Figure 9.22b). Intuitively, 'Yk and 'YHI should depend on the angles lh-l and (h
subtended by the chord Qk-l Qk and the tangents T k- 1 and Tk, respectively
(0 ::; lh-l' (h ::; 90°). Figure 9.22c shows a parabola defined by an isosceles
triangle. For this figure one can easily derive
1 I Qk-l Q k I
'Yk = 'Yk+1 = 4: cos (1
This suggests setting
392 Curve and Surface Fitting
Q~ R~+I
R'k - - - - - - - - - -c:.=-~-----w---=--=- - - - - - - - - - - ~
I
I
I I
I
I
I
I I
I I
I
I
I
I
I
I
I
I
--------------e-------------- Qk
Qk-l M
(a)
Figure 9.22. Computing piecewise parabolic arcs to tangents at neighboring data points.
(a) Parallel end tangents; (b) a turning point implied by tangents T k - 1 and Tk; (c)
parabola defined by an isosceles control triangle.
1 I Qk-l Qk I (9.44)
'Yk+l = 4" a cosfh-l + (1 - a) cos(h
where a is some constant between 0 and 1. Based on experimental observation,
we choose 0: = 2/3. The two curve segments of Figure 9.22b are obtained using
Eqs. (9.41), (9.42), and (9.44).
Figures 9.23-9.25 show several examples. In Figure 9.23a the tangents are
computed by Bessel's method [DeB078], while in Figure 9.23b Akima's method
[Akim70] is used. Note how collinearity is maintained in Figure 9.23b. In
Figure 9.24a the "no corner" option was selected, resulting in a (perhaps un-
wanted) smooth connection of each segment. Figure 9.24b shows the corner pre-
serving case, using the same algorithm with only a different flag setting. Figure
9.25 shows the profile of a shoe sole, obtained using this interpolation method.
(b)
R'k
()
(c)
Figure 9.22. (Continued.)
(a)
(b)
Figure 9.23. Local quadratic curve interpolants. (a) Tangents computed by Bessel's
method; (b) tangents computed by Akima's method.
Thus, we set
1 I Qk-1 Q k I (9.45)
rk+l = 2 1 + acos(h-1 + (1 - a) cos(h
where a is the same constant as in Eq. (9.44).
Local Interpolation 395
(a)
(b)
Figure 9.24. Local quadratic curve interpolants. (a) No corner is allowed; (b) the corner
is maintained.
Cubics easily handle three-dimensional data and inflection points without special
treatment. We begin by deriving a general fact about cubic Bezier curves, which
is of interest in its own right. Let Po and P a be two endpoints, and To and
Ta be the corresponding tangent directions with unit length. It is possible to
construct a cubic Bezier curve, C(u), u E [0, IJ, with these endpoints and tangent
directions, and satisfying
(see Figure 9.28), that is, the speed is equal at the start point, midpoint, and
endpoint of the curve. Equations (9.46) and (1.10) imply that
1
PI = Po + 3aTo (9.47)
Figure 9.26. Choosing the weight (shoulder point) for rational quadratic interpolation.
Local Interpolation 397
o
Figure 9.27. Rational quadratic curve interpolants; circles are precisely reproduced, and
corners are maintained.
Applying Eq. (1.10) and considering the bisection of the parameter range, it
follows that
c' ( ~) = 6 (P~ - P~) (9.49)
Setting the speed equal to a, substituting Eq. (9.48) into Eq. (9.49), and using
Eq. (9.47), we obtain
8
6a = 1P g + P2 - Pl - Po 1
which leads to
and finally
(9.50)
where
a = 16 -I To + Tgl2 b = 12(Pg - Po) • (To + Tg) C = -361 Pg - Po 12
Equation (9.50) has two real solutions for a, one positive and one negative.
Substituting the positive solution into Eq. (9.47) yields the desired P l and P 2 .
We now return to the cubic interpolation problem. Let {Qk}' k = 0, ... , n,
be a set of three-dimensional data points. If tangent vectors are not given,
compute them (Eqs. [9.29], [9.31], and [9.33]). We must construct a cubic Bezier
398 Curve and Surface Fitting
C'(O)
P2
PI ----------------------~
\
C'UM \
\
\
\
\
\
Po
C'(l)
Figure 9.28. A cubic Bezier curve with equal tangent magnitudes at parameters 0, 1/2,
and!.
curve segment, Ck{u), between each pair, Qk' Qk+1. Denote the Bezier control
points by
Pk,O = Q k Pk,l Pk,2 Pk,3 = Qk+1 (9.51)
We must determine suitable locations for P k ,1 arId P k ,2 along Tk arId Tk+l,
respectively. It is possible to obtain a C 1 continuous cubic arId to achieve a good
approximation to a uniform parameterization. The method is due to Renner
[Renn82]. True uniform parameterization means constarIt speed over the entire
parameter rarIge. We construct a curve with equal speed at each Qk arId at the
midpoint of each Bezier segment. Set Uo = O. Now, for k = 0, ... , n - 1, the
Uk+1 and the two inner control points of Ck{u) are computed as follows:
1. use Eq. (9.50) to compute a and Eq. (9.47) to compute P k ,l and Pk,2;
2. set
(9.52)
This algorithm yields n Bezier segments, each having speed equal to 1 at their
end- and midpoints with respect to their parameter ranges, [Uk, Uk+1]. Thus, a
C 1 continuous cubic B-spline curve interpolating the Qk is defined by the control
points (see Figure 9.29)
(9.53)
and the knots
U1 U1 U2 U2 Un-l Un-l }
U = { 0,0,0,0, -::-, -::-, -::-, -::-, ... , -_-, -_-,1,1,1,1 (9.54)
Un Un Un Un Un Un
Local Interpolation 399
PO,2
G- -_
,,
,,
PO,l (/)'
, /
IIII II II IIII
Uo Uu
Figure 9.30 shows an example of cubic curve interpolation using this method.
The curve is marked at points corresponding to equally spaced parameter values.
Figure 9.31 is another example of this interpolation, using the same data set as
in Figure 9.7. Notice how collinear points are fitted by straight cubic segments.
Figure 9.30. Parameterization of a local cubic curve interpolant; the points are com-
puted at equally spaced parameter values.
400 Curve and Surface Fitting
Figure 9.31. The cubic curve interpolant to data shown in Figure 9.7; note how collinear-
ity is preserved.
and l = 0, ... ,m, be a set of data points, and let {(Uk, Vi)} be the corresponding
parameter pairs, computed by chord length averaging (as in Algorithm A9.3).
The following method produces a bicubic surface, S(u,v), satisfying
2n+12m+l
S(Uk' Vi) = L L N i ,3(Uk)Nj ,3(Vl)Pi,j (9.55)
i=O j=O
(9.56)
A bicubic Bezier patch has 16 control points. The 12 boundary control points
are obtained by initially looping through the m + 1 rows and n + 1 columns
of data and using a cubic curve interpolation scheme. The scheme is slightly
different from the one detailed previously, because we already have the param-
eters {(Uk, Vi)}. Notice that these had to be computed up front, since all rows
(columns) must have the same parameterization in a tensor product surface.
Thus, we can still force C 1 continuity at the segment endpoints, but we cannot
force equal speed at the midpoint of the Bezier curve segments. More specifi-
cally, let l = lo be fixed, and consider the cubic curve interpolating the points
Local Interpolation 401
-- ............
,,///
,":............... ..
/, -.
,
" ....... 111
I I
,
-
I
~ ......
I
I
I
I
I
I ,
I
I
I
\ ,.,'""
,(..
I I
/c.,
I
I I
I I
I I
I I
I
I
I
I
I
I y
;*
I
/
/
/
(a)
(b)
Figure 9.32. C(1,1) local bicubic surface interpolation. (a) The data set; (b) the Bezier
net of the interpolant.
402 Curve and Surface Fitting
, I
*,
, I
"r I I
')-._ I I
-/~--/'
, , y
/
" fJ
x
(c)
(d)
Figure 9.32. (Continued.) (c) a B-spline net (large cubes mark data points, and the
small ones are the B-spline control points); (d) the surface interpolant.
Local Interpolation 403
Q o,i 0 , ... , Qn ,i 0 . Let rio denote the total chord length of the Roth row. At each
point, Qk , i 0 , compute the Tk , i 0 (the unit tangent in the u direction) as previ-
ously (Eqs. [9.29],[9.31], and [9.33]). Then the interior Bezier points on this row
are computed by
P k,io
1,0 =
Qk,io + a T k,io
U pkio
2;0 =
Qk+l,io - a
T Uk+l,io (9.57)
rio (Uk+l - Uk) rio~Uk+l
where a = 3 = ---"--3---'-
The resulting curve is C 1 continuous, with derivative magnitude equal to rio at
all Qk,i o. The same technique is applied to the n + 1 columns of data.
It remains to compute the four interior control points of each Bezier patch.
This requires estimates for the mixed partial derivative, Dk~£> at each Qk,i, as
well as Eq. (3.24) (and analogous formulas for the other three corners). We
derive a formula for D kvi based on the three-point Bessel method (Eqs. [9.28],
[9.30], and [9.32]). Let ~i and Sk denote the total chord length of the Rth row
(kth column). Then
(9.58)
Then set
and
with
Finally (9.59)
The appropriate end formulas (Eq. [9.32]) must be used on the boundaries.
The four interior control points of the (k, £)th patch are now computed using
Eqs. (9.59) and (3.24)
pk,e _ 'YDuV
1,1 - k,e
+ pk,e
0,1
+ pk,e
1,0
_ pk,e
0,0
pk,e __ DUV
2,1 - 'Y k+l,e
+ pk,e
3,1
_ pk,i
3,0
+ pk,i
2,0
pk,i _ _ DUV
1,2 - 'Y k,e+l
+ pk,i
1,3
_ pk,e
0,3
+ pk,£
0,2
k,e
P 2,2 = 'Y DUV
k+l,e+l
+ pk,e
2,3
+ pk,e
3,2 -
pk,e
3,3
where
404 Curve and Surface Fitting
We now summarize with an algorithm. For the sake of efficiency, the sequence
of events is slightly different than detailed here. The algorithm requires local
arrays: td [n+1] [m+1] [3], which contains the Tk II T% II and D kv£; ub [n+1]
and vb [m+1] , which contain the parameter valu~s; and r [m+1] ~nd s [n+1] ,
which store the total chord lengths of the rows and columns, respectively.
ALGORITHM A9.5
LocalSurfInterp(n,m,Q,U,V,P)
{ 1* Local surface interpolation *1
{ 1* through (n+1)(m+1) points *1
1* Input: n,m,Q *1
1* Output: U,V,P *1
total = 0.0; 1* get ub[] , r[] and u direction tangents *1
for (k=O; k<=n; k++) ub[k] = 0.0;
for (1=0; l<=m; 1++)
{
Compute and load T~,£ into td [0] [1] [0] ;
r[l] = 0.0;
for (k=l; k<=n; k++)
{
Compute and load T k,£ into td[k] [1] [0]
1* Eqs.(9.31) and (9.33) *1
d = I Qk,£- Qk-l,ll;
ub[k] = ub[k]+d;
r[I] = r[l]+d;
}
total = total + r[l];
}
for (k=l; k<n; k++) ub[k] = ub[k-1]+ub[k]/total;
ub[n] = 1.0;
total = 0.0; 1* get vb[] , s[] and v direction tangents *1
for (1=0; l<=m; 1++) vb[l] = 0.0;
for (k=O; k<=n; k++)
{
Compute and load T%,o into td [k] [0] [1] ;
s[k] = 0.0;
for (1=1; l<=m; 1++)
{
Compute and load T%, £ into td [k] [1] [1]
1* Eqs.(9.31) and (9.33) *1
d = I Qk, £ - Qk, £-1 I;
vb [1] = vb [1] +d;
s[k] = s[k]+d;
}
total = total + s[k];
}
Global Approximation 405
Figure 9.32 shows the surface construction process. In Figure 9.32a data points
are shown marked by small cubes. Figure 9.32b illustrates the control points of
the Bezier patches. Eliminating Bezier points along inner rows and columns
yields the NURBS surface control net depicted in Figure 9.32c. The surface is
shown in Figure 9.32d.
This interpolation scheme easily generates closed C(1,l) continuous surfaces.
Figures 9.33a and 9.33b show an example of a surface interpolation where the
data indicates a closed surface in one direction. In Figures 9.34a and 9.34b the
surface is closed in both directions (a toroidal-like interpolant). A nice property
of this method is that flat (planar) patches are generated where the data points
indicate planarity. An example of this is shown in Figures 9.35a and 9.35b.
Obtaining pleasing surfaces when the data is unevenly spaced is more difficult
for surfaces than for curves. Figures 9.36a and 9.36b show an interpolation to
very unevenly spaced data. Although the surface is not particularly pleasing, the
results using the global methods of the previous section are not much different.
. ~~:;i
,,
,,
,,,
,
--;.
-- --
.: y
x "'""",~", '
(a)
y
x
(b)
Figure 9.33. A surface interpolation example using a local bicubic surface interpolant.
(a) Data points; (b) an interpolating surface.
(a)
(b)
Figure 9.34. A surface interpolation example using a local bicubic surface interpolant.
(a) Data points; (b) interpolating surface.
408 Curve and Surface Fitting
I
I
--.-
I
I
I
I ,
/
/
I
/ y
/ I
: ../ - - - - - - -8/
x
/
/
'Ell
(a)
(b)
Figure 9.35. A surface interpolation example using a local bicubic surface interpolant.
(a) Data points; (b) an interpolating surface.
Global Approximation 409
"" ............
,,
I
I
.--- .. -
,,
,,
\
\
\
\
\
, \
\
\
\
,,
-., , y
\
\ I
,
I
I
I
x ,, I
, /
8.
(a)
(b)
Figure 9.36. A surface interpolation example using a local bicubic surface interpolant.
(a) Data points; (b) an interpolating surface.
410 Curve and Surface Fitting
2a. start with the maximum or "many" control points, enough that the first
approximation satisfies E;
b. fit a curve/surface to the data using a global method;
c. check if the deviation E is satisfied everywhere;
d. if E is nO longer satisfied return the previous curve or surface, else reduce
the number of control points and go back to Step 2 (b).
We return to these two methods in Section 9.4.4, and in particular we give an ex-
ample of the second type. Clearly, approximation is also more expensive than in-
terpolation. Multiple fits are required, and deviation checking can be expensive.
A central ingredient in both of these methods is that given a fixed number of
control points, say n, we fit an approximating curve (surface) to the data. There
are many ways to do this. For example, a nonlinear optimization problem can
be set up, with the control points, parameters (Uk)' knots, and even the weights
as unknowns. The objective function to be minimized must measure the error
in some way, e.g., least squares or maximum deviation (e.g., see [Laur93]). In
Sections 9.4.1-9.4.3, we present curve and surface fitting methods in which a
fixed number of control points are the only unknowns, and they are solved using
linear least squares techniques.
To avoid the nonlinear problem, we set the weights to 1, and precompute values
for the parameters and knots. We then set up and solve the (unique) linear least
squares problem for the unknown control points. We start with a simple curve
fit to point data. Assume that p ~ 1, n ~ p, and Qo, ... , Qm (m > n) are given.
We seek a pth degree nonrational curve
n
C(u) = LNi,p(U)Pi u E [0,1] (9.61)
i=O
satisfying that:
• Qo = C(O)and Qm = C(1);
• the remaining Qk are approximated in the least squares sense, i.e.
m-l
L I Qk - C(Uk) 12 (9.62)
k=l
is a minimum with respect to the n + 1 variables, Pi; the {ukl are the
precomputed parameter values.
Global Approximation 411
We emphasize that the resulting curve generally does not pass precisely through
Qk' and C(Uk) is not the closest point on C(u) to Qk' Let
- LN£,p(uk)Rk + L LN£,p(Uk)Ni,p(Uk)Pi = 0
k=l k=l i=l
It follows that
(NTN)P =R (9.65)
Nn-l,p(Ut} 1 (9.66)
::: Nn-l,p:(Um-l)
412 Curve and Surface Fitting
and P= [ PI
: 1
Pn- I
Note that Eq. (9.65) is one coefficient matrix, with three right hand sides and
three sets of unknowns (x, y, z coordinates). In order to set up Eqs. (9.66) and
(9.67), a knot vector U = {uo, ... ,ur } and parameters {ud are required. The
{ud can be computed using Eq. (9.5). The placement of the knots should reflect
the distribution of the {ud. If d is a positive real number, denote by i = int(d)
the largest integer such that i ~ d. We need a total of n + p + 2 knots; there are
n - p internal knots, and n - p + 1 internal knot spans. Let
d= m+l (9.68)
n-p+l
i = int(jd) 0: = jd - i
Equation (9.69) guarantees that every knot span contains at least one Uk, and
under this condition deBoor [DeBo78] shows that the matrix (NT N) in Eq. (9.65)
is positive definite and well-conditioned. It can be solved by Gaussian elimination
without pivoting. Furthermore, (NT N) has a semibandwidth less than p + 1 (if
Ni,j is the element in the ith row, jth column, then Ni,j = 0 if I i - j I > p).
Finally, concerning implementation, note that the matrix N (Eq. [9.66]) can
be very large, and most of its elements are zero; in some applications it is not
uncommon for m = 1000 and n = 100. Hence, the implementor may want to
develop a storage scheme that stores only the nonzero elements of N. Once
(NT N) and R (Eq. [9.67]) are computed, N can be deallocated. Similarly, only
the nonzero band of (NT N) should be stored.
Figures 9.37a-9.37c show examples of simple least squares curve fits. In Fig-
ure 9.37a seven control points were specified. Figure 9.37b shows a nine control
point fit, whereas Figure 9.37c depicts an eleven control point fit. Notice that,
in a distance sense, the approximation improves as the number of control points
increases. However, as the number of control points approaches the number
of data points, undesirable shapes can occur if the data exhibits noise or un-
wanted wiggles.
Global Approximation 413
1
1
o, '0
, 1
o
,
," 0
,, o
(
1
\
\ 10
\ 1
\ 1
'0 '-, 0
\
o \
\
01 0 0 00 I 0 0 0 0 10 0
(a)
Figure 9.37. Global curve fitting. (a) Seven control points; (b) nine control points;
(c) eleven control points.
I
I
(
I
I
I
, \
\
.J \
\
\
\----
list I 8 I 8 8 18 8 Ej 8 8 18 8 Ej 8 8 I 9 8 list I
(b)
r-----------,
,,
,0 0 01
~ ,-..;-~~-k,.-- , ,,
-----1
(c)
Figure 9.37. (Continued.)
data with a pth degree nonrational curve, C(u), with n + 1 control points. The
next algorithm requires that
be the vector of Lagrange multipliers; note that each Ak is a vector with the
same dimensionality as the {Qi} and {Di(j)}.
The unconstrained equations are
NP=S
and the constrained equations are
MP=T
The error in the unconstrained equations is S - N P, and we want to minimize
the sum of the weighted squares of this error, subject to MP = T. Hence, using
Lagrange multipliers we want to minimize the expression
(9.73)
We must solve Eq. (9.73) for A and P. There is a unique solution if NTWN
and M(NTWN)-l MT are both invertible. This is seen by solving Eq. (9.71)
for P, that is
(9.74)
Multiplying by M yields
Hence, we solve first for A and then for P by substituting A into Eq. (9.74).
Algorithm A9. 6 implements weighted and constrained least squares curve fit-
ting. The input is:
Q[r+1]: an array containing the points to be fit (constrained and uncon-
strained);
r: the upper index of Q[] ;
Wq[r+1]: Wq[i] > 0 means Qi is unconstrained, and Wq[i] is the weight
w;; Wq [i] < 0 means Qi is to be constrained;
D [s+l]: an array containing the derivatives; s = -1 means no derivatives
are specified;
s: there are s + 1 derivatives in D[] ;
I [s+ 1]: an integer array; I [j] gives the index into Q[] of the point corre-
sponding to the derivative in D[j] (i.e., D[j] = Di(j));
Wd[s+l]: Wd[j] > 0 means D[j] is unconstrained, and Wd[j] is the weight
wt(j); Wd [j] < 0 means D[j] is to be constrained;
n: a fit with n + 1 control points;
p: a fit with degree p curve.
Global Approximation 417
The knots U and control points P are output. The algorithm uses LUDecompo-
sitionO and ForwardBackwardO to invert the matrix (NTWN) and to solve
for the Lagrange multipliers, A. (NTW N) has a semibandwidth less than p + 1,
due to the way in which the algorithm constructs N. In general A can have full
bandwidth, but it is usually a small matrix. The appropriate algorithms from
Chapter 2 are used to determine knot spans and to compute basis functions and
their derivatives. The following local arrays are required:
ub [r+1] : the parameters;
N[mu+1] [n+1] ,M[mc+1] [n+1] ,S[mu+1] ,T[mc+1] ,A[mc+1]: the arrays cor-
responding to the matrices defined previously (except S [], which
is WS);
W[mu+1] : the weights; since the matrix W is diagonal, only a vector of length
mu + 1 is required;
funs [2] [p+1]: contains the basis functions, and their derivatives where
specified (see Algorithms A2. 2 and A2. 3).
Furthermore, several local arrays are required for temporary storage of matrices
computed in Eqs. (9.71)-(9.76).
ALGORITHM A9.6
WCLeastSquaresCurve(Q,r,Wq,D,s,I,Wd,n,p,U,P)
{ /* Weighted & constrained least squares curve fit */
/* Input: Q,r,Wq,D,s,I,Wd,n,p */
/* Output: U,P */
ru = -1; rc = -1;
for (i=O; i<=r; i++)
if (Wq[i] > 0.0) ru = ru+1;
else rc = rc+1;
su = -1; sc = -1;
for (j=O; j<=s; j++)
if (Wd[j] > 0.0) su = su+1;
else sc = sc+1;
mu = ru+su+1; mc = rc+sc+1;
if (mc >= n I I mc+n >= mu+1) return(error);
Compute and load parameters Uk into ub[] (Eq.[9.5]);
Compute and load the knots into un (Eqs. [9.68] , [9.69] ) ;
/* Now set up arrays N, W,S, T,M */
j = 0; /* current index into I[] */
mu2 = 0; mc2 = 0; /* counters up to mu and mc */
for (i=O; i<=r; i++)
{
span = FindSpan(n,p,ub[i],U);
dflag = 0;
if (j <= s)
if (i == I[j]) dflag = 1;
418 Curve and Surface Fitting
if (dflag == 0) BasisFuns(span,ub[i],p,U,funs);
else DersBasisFuns(span,ub[i],p,1,U,funs);
if (Wq[i] > 0.0)
{ 1* Unconstrained point *1
W[mu2] = Wq[i];
Load the mu2th row of N[] [] from funs [0] [];
S[mu2] = W[mu2]*Q[i];
mu2 = mu2+1;
}
else
{ 1* Constrained point *1
Load the mc2th row of M[] [] from funs [0] [];
T[mc2] = Q[i];
mc2 = mc2+1;
}
i f (dflag == 1)
{ 1* Derivative at this point *1
if (Wd[j] > 0.0)
{ 1* Unconstrained derivative *1
W[mu2] = Wd[j];
Load the mu2th row of N[] [] from funs [1] [];
S[mu2] = W[mu2]*D[j];
mu2 = mu2+1;
}
else
{ 1* Constrained derivative *1
Load the mc2th row of M[] [] from funs [1] [];
T[mc2] = D[j];
mc2 = mc2+1;
}
j = j+1;
}
} 1* End of for-loop i=O, ... ,r *1
Compute the matrices NTW N and NTWS;
LUDecomposition(NTWN,n+1,p);
if (mc < 0)
{ 1* No constraints *1
Use ForwardBackward() to solve for the control points P[].
Eq. (9.71) reduces to (NTWN)P = NTWS.
return;
}
Compute the inverse (NTWN)-l, using ForwardBackward().
Do matrix operations to get: M(NTWN)-lMT and
M(NTWNr\NTWS) - T;
Solve Eq.(9.75) for the Lagrange multipliers, load into A[];
Global Approximation 419
/
o
/
,, o
,,
Figure 9.38. Unconstrained fit with all weights equal to one; note that the curve does
not pass through the endpoints.
420 Curve and Surface Fitting
wl = ... = wi = 100
1"--
---.,
----
o
o I
I
I
o
o
\
I
\
o I
I
I 0
I
(
,, o \
0
)
,,
Figure 9.39. Unconstrained fit with weights wl = w~ = w~ = wi = 100; the curve does
not pass through the endpoints.
very simple, and is quite adequate for most applications. As was done for global
surface interpolation, we simply fit curves across the data in one direction, then
fit curves through the resulting control points across the other direction.
I
I
,,
I ,,
,
o 0
0/
/
o
/
I
I
( " 0
\
o /
I
\ 0 I
\
\ J
\ /
/
\ 0 /
/
o
,
\ /
\
\
\ /
V
Figure 9.40. A constrained curve fit; point constraints are marked by squares, tangent
constraints are shown by arrows, and all weights are one.
Global Approximation 421
,
,,
,,
,
,,
,,
,
o 0 ,,
,
, '\ ,,
wZ = 100 o ,
0',
/
0
op
/
o /
/
0
\
\
0
\ 0
Wi5 = 100 o
, ~ /
/
\
/ 0
/
/
/
/
,,
\ /
\
,
/
\
\ /
\I \ /
Figure 9.41. The curve from Figure 9.40, with weights w~ = Wi5 = 100.
Algorithm A9.7 interpolates the corner points Qo,o, Qr,O, QO,8' and Qr,s
precisely, and approximates the remaining {Qk,l}. It uses repeated least squares
curve fits given by Eqs. (9.63) and (9.65)-(9.67). It fits the s + 1 rows of data
o o
,r--_ o
,,, ,
0,
o }
o
,0
o
o
,
,, o
..J
,
,
L---
Figure 9.42. The curve from Figure 9.40, but using two new tangent constraints.
422 Curve and Surface Fitting
,
1
I' , w1 = 50
,
/
,
i
/ 1
1
/
/
0 0 I
/ I
/ I
, /
/
/
0 I
I
0 V
I
I
I
0
I o
0
0
o
0
0
----..1
Figure 9.43. The curve from Figure 9.42, but with weights w1 = 50 and Wi6 = 20.
first, storing the resulting control points in the local array, Temp [n+1] [s+1].
Then it fits across these control points to produce the (n + 1) x (m + 1) surface
control points. Notice that the matrices N and NT N only have to be computed
once for each direction, and the LU decomposition of NT N is only done once for
each direction. We require local arrays Nu[r-1] [n-1] and NTNu[n-1] [n-1] for
the u direction fits, and Nv [s-1] [m-1] and NTNv [m-1] [m-1] for the v direction
fits. The vector R of Eq. (9.68) is stored in Ru [n-1] and Rv [m-1].
ALGORITHM A9.7
GlobaISurfApproxFixednm(r,s,Q,p,q,n,m,U,V,P)
{ /* Global surface approx with fixed num of ctrl pts */
/* Input: r,s,Q,p,q,n,m */
/* Output: U,V,P */
SurfMeshParams(r,s,Q,ub,vb);
Compute knots U by Eqs.(9.68),(9.69);
Compute knots V by Eqs.(9.68),(9.69);
Compute Nu[] [] and NTNu[] [] using Eq.(9.66);
LUDecomposition(NTNu,n-1,p);
for (j=O; j<=s; j++)
{ /* u direction fits */
Temp [0] [j] = QO,j; Temp En] [j] = Qr,j;
Compute and load Ru[] (Eqs. [9.63], [9.67]);
Call ForwardBackward() to get the control points
Temp [1] [j] , ... ,Temp [n-1] [j] ;
}
Compute Nv[] [] and NTNv[] [] using Eq.(9.66);
LUDecomposition(NTNv,m-1,q);
Global Approximation 423
(a)
Figure 9.45. A least squares surface fit with a degree (2,3) surface using a (5 x 6) control
net. (a) Surface approximant; (b) error surface (error measured at data points).
curve fit, as in Algorithm A9. 6. Then, if Uko E lUi, Ui+1), the points Temp[i -
p][io], ... , Temp[i][io] must be constrained in the v direction fitting.
(9.77)
or as
or max (min
O<k<r O<u<l
I Qk,t - S(u,v) ~ (9.78)
O~t~8 O~v~l
Global Approximation 425
(b)
Figure 9.45. (Continued.)
(a)
Figure 9.46. A least squares surface fit with a degree (2,3) surface using an (8 x 8)
control net. (a) Surface approximant; (b) error surface (error measured at data points).
426 Curve and Surface Fitting
(b)
We call Eq. (9.78) the max norm deviation. It uses Eqs. (6.4)-(6.9) to compute
the minimum distance from each Qk (Qk,£) to C( u) (S (u, v) ). The Uk (Uk, V£)
serve as good start points for the Newton iterations. Obviously, Eq. (9.78) is
more expensive to apply than Eq. (9.77). However, it is usually what a user
wants measured, and it generally leads to curves and surfaces with fewer control
points, since
(9.79)
We emphasize that both Type 1 and Type 2 methods can fail to converge, and
this eventuality must be dealt with in a software implementation.
A Type 1 curve approximation method can proceed as follows. Start with
p + 1 control points (the minimum). Fit a curve using Eqs. (9.63) and (9.65)-
(9.67), or Algorithm A9. 6 if interior constraints are desired. After each fit, use
Eq. (9.78) to check if the curve deviation is less than E. A record is maintained
for each knot span, indicating whether or not it has converged; a span [Uj, uj+t}
has converged ifEq. (9.78) is satisfied for all k such that Uk E [Uj,Uj+1)' After
each fit and subsequent deviation check, a knot is added at the midpoint of each
nonconvergent span, thus adding control points. This algorithm must deal with
the case in which a span can become empty as knots are added (i.e., the span
contains no Uk), thus producing a singular system of equations in the fitting step.
A Type 1 surface approximation method can be implemented in a similar fash-
ion, with an efficiency improvement. During the deviation check, determine the
row fo and column ko which have the greatest numbers of points with deviations
greater than E. Then extract isoparametric curves C Uko (v) and C Vlo (u), and
independently approximate them to within E. This yields new (increased) knot
vectors, U and V, to use for the next surface fit. Using this method, usually
only a few surface fits and subsequent deviation checks are required.
We now develop a Type 2 curve approximation method, which combines least
squares fitting with the knot removal techniques of Chapter 5. First we need a few
more knot removal tools. Let U r be an interior knot of a pth degree nonrational
curve, C(u), Ur i:- Ur+1' and denote the multiplicity of Ur by s, i.e., ur-s+j = Ur
for j = 1, ... , s. Let C(u) denote the curve obtained by removing one occurrence
of u r . Recall that the new control points, PI and P}, are computed from the
left and the right, respectively, by Eq. (5.28). After removal, C(u) differs from
C(u); Tiller [Till92J derives error bounds for two cases:
• assume (p + s) mod 2 = 0; set k = (p + s)/2 and
(9.80)
Ur - Ur-k
where Ctr-k = - - - - - - -
Ur-k+p+l - Ur-k
Now let {Qk} be a set of points and {Uk} the associated set of parameters. De-
note by {ek} a set of errors associated with the points, and let E be a maximum
error bound. Given a curve C(u) with the property that the max norm devia-
tion of each Qk from C(u) is less than or equal to ek, Algorithm A9.9 removes
(roughly) as many knots as possible from C(u) while maintaining ek ::; E for all
k. It also updates the {ek}, i.e., it accumulates the error. Output is the new
curve, represented by ft, fl, and Pi. The algorithm maintains two lists, the knot
removal error, BTl for each distinct interior knot; and for each basis function,
Ni,p(u), the range of indices representing the parameters Uk which fall within
the domain of that function. Clearly, when a knot is removed these lists must be
updated; however, the effect is local. The bound, BTl of only a few neighboring
knots changes, and only a few neighboring basis functions (and their domains)
change. Suppose we remove u r , which has multiplicity s before removal. After
removal there is one less basis function, and in the new numbering scheme the
range of Uk indices for only the basis functions
i = r - p - 1, ... , r - s (9.84)
must be recomputed. Br values change for all knots whose old span index lies
in the range
max{r - p,p + I}, ... ,min{r + p - s + l,n} (9.85)
Example
Ex9.3 See Figure 9.48: Let the cubic curve be defined by Po, ... , PH and
U = {O, 0, 0, 0,1,2,3,4,4,5,6,7,8,8,8, 8}. Suppose we remove one oc-
currence of the knot Us = 4 (r = 8, s = 2). By Eq. (9.85) new Br values
must be computed for knots 2,3,4,5,6. By Eq. (9.84) new Uk ranges of
indices must be computed for N 4 ,3, N 5 ,3, and N 6 ,3.
Ex9.4 See Figure 9.49: Let the cubic curve be defined by Po, ... , P lO and U =
{O, 0, 0, 0,1,2,3,4,5,6,7,8,8,8, 8}. Suppose we remove the knot U7 = 4
(r = 7, s = 1). By Eq. (9.85) new Br values must be computed for
knots 1,2,3,5,6,7 (all remaining interior knots). By Eq. (9.84) new Uk
ranges of indices must be computed for N 3 ,3, N 4 ,3, N 5 ,3, and N 6 ,3.
ALGORITIIM A9.9
RemoveKnotsBoundCurve(n,p,U,P,ub,ek,E,nh,Uh,Ph)
{ 1* Remove knots from curve, bounded *1
1* Input: n,p,U,P,ub,ek,E *1
1* Output: ek,nh,Uh,Ph *1
Inf = 00; 1* Big number *1
Get the values Br for all distinct interior knots (A9.8).
For each basis function, get range of parameter indices.
while (1)
{
Find knot with the smallest Br bound. Set r and s.
430 Curve and Surface Fitting
P~ = P~
P1l
Po
Affected domain
1
o 1 2 3 4 5 6 7 8
p'4
, n l
/ 0 .£"6
Po
Affected domain
1
o 1 2 3 4 5 6 7 8
(a)
,,
,
,,
(b)
Figure 9.50. A cubic curve fit using algorithm A9. 10.
and let S(u, v) denote the surface obtained by removing one occurrence of U r .
Considering the tensor product structure of S(u, v), and using the techniques of
Tiller [Till92]' it can be shown that:
Figure 9.51. A cubic curve fit using algorithm A9. 10 and E = 8/100 .
m
Then I S(u, v) - S(u, v) I ~ Nr-k,p(u) L Nj,q(v)Bt
j=O
ur - Ur-k+1
with (lr-k+1 = - - - - - - ' - - -
Ur-k+p+2 - Ur-k+1
Analogous equations hold for v direction knot removal. Using these equations,
one can develop a knot removal stategy for surfaces similar to Algorithms A9. 8
and A9. 9. This, combined with the least squares based surface fitting algorithm
A9. 7, provides a method for approximating a set of points {Qk, R} to within an
E tolerance.
Figures 9.52a-9.52e show several examples of surface approximation. The data
set to be approximated is shown in Figure 9.52a. Figure 9.52b shows a degree
(2,2) surface that is an interpolant obtained by using E = O. Increasing E to
1/2 yields the surface in Figure 9.52c. Further increasing E to 1 produces the
surface of Figure 9.52d. Finally, a degree (3,3) approximation using E = 1 is
shown in Figure 9.52e.
Global Approximation 435
•
y
x
•
•
•
•
(a)
y
x
(b)
Figure 9.52. Various surface fitting examples using the extension of algorithm A9.10
to surfaces.
436 Curve and Surface Fitting
(c)
y
x
(d)
y
x
(e)
Figure 9.52. (Continued.)
Algorithm A9 .10 and the corresponding surface algorithm are, in fact, data
reduction algorithms, i.e., they work best on large data sets. They assume that
during the knot removal phase (Algorithm A9. 9) a significant number of knots
can be removed. If this is not the case the least squares approximation step can
fail, either because degree elevation requires more control points than there are
data points, or because the many multiple knots make the system of equations
singular. A simple fix is to restart the process with a higher degree curve.
such that Qk s "'" Qke can be fit to within the E tolerance by one pth degree
segment. Once found, set ks = ke and repeat the process to find the largest
ke :S m such that Qk s "'" Qke can be fit with one pth degree segment. This
continues until ks = m. Since m is usually rather large in approximation, a
binary search is much faster than a linear search. As a practical matter, it may
be desirable to bound the number of data points which can be approximated
by one segment. We denote this bound by K mru{) that is, the binary search
algorithm is modified to guarantee that
(9.90)
s
,,
Figure 9.53. A curve fit and scatter check for conic curve fitting.
1. interpolate each point Qi' i = ks + 1, ... ,ke - 1, with a conic, using Qk s '
R, and Qke as the control polygon, as in Algorithm A7. 2. This yields
the middle weight, Wi, and the corresponding shoulder point coordinate,
Si = Wi/(1 + Wi);
2. compute an approximating conic by averaging the Si, Le.
1 ke-l
s= k - k - l '~
" Si (9.92)
e s i=k.+l
FitWi thConic 0 returns the value 1 for a successful fit, or the value 0 for
no fit. In the case of a successful fit, the weighted middle control point, R~ is
also returned.
ALGORITHM A9.11
FitWithConic(ks,ke,Q,Ts,Te,E,Rw)
{ 1* Fit to tolerance E with conic segment *1
1* Input: ks,ke,Q,Ts,Te,E *1
1* Output: Rw *1
if (ke-ks == 1)
{ 1* No interior points to interpolate *1
Fit an interpolating segment as in Section 9.3.3.
return (1) ;
}
i = Intersect3DLines(Q[ks],Ts,Q[ke],Te,alf1,alf2,R);
i f (i != 0)
{ 1* No intersection *1
i f (Qks, ... ,Qke not collinear) return(O);
else
{
Rw = (Q[ks]+Q[ke])/2.0;
return (1) ;
}
}
if (alf1 <= 0.0 I I alf2 >= 0.0) return(O);
s = 0.0; V = Q[ke]-Q[ks];
for (i=ks+1; i<=ke-1; i++)
{ /* Get conic interpolating each interior point *1
V1 = Q[i] - R;
j = Intersect3DLines(Q[ks],V,R,V1,alf1,alf2,dummy);
if (j != 0 I I alf1 <= 0.0 I I alfl >= 1.0 I I alf2 <= 0.0)
return(O);
Compute the weight wi. 1* Algorithm A7.2 *1
s = s + wi/(1.0+wi);
}
s s/(ke-ks-l); w = s/(1.0-s);
if (w < WMIN I I w > WMAX) 1* system bounds on weights *1
return(O);
Create Bezier segment with Q[ks] ,R,Q[ke] and w.
for (i=ks+l; i<=ke-1; i++)
{
Project Q[i] onto the Bezier segment.
if (distance> E) return(O);
}
Rw = w*R;
return (1) ;
}
Local Approximation 441
Figures 9.54a-9.54e show local quadratic curve fitting examples. The loga-
rithmic spiral
r=.!e'l/5
2
was sampled and approximated. Input parameters for Figures 9.54a-9.54d were:
Figure 9.54a E = 1/100, Kmax = 50
Figure 9.54b E = 1/1000, Kmax = 50
Figure 9.54c E = 1/10, Kmax = 6
Figure 9.54d E = 1/10, Kmax = 10
Figure 9.54e shows the parameterization of the curve in Figure 9.54b.
we must determine values for 0 and (3 such that the cubic Bezier curve defined
by Po, PI, P 2 , P 3 passes within the E tolerance of all Qk' ks < k < k e . If
ke - ks = 1, then theoretically, any 0 and (3 will do; however, they should
be chosen so that the derivative magnitudes blend naturally with neighboring
magnitudes. Using Eq. (9.29) and Exercise 9.2, reasonable estimates for the
derivatives Dks and Dke at Qks and Qke are
if ks =0
D 3. -- Cj+1 - Cj V.
3 j#{O,m} j=ks or j=ke
Cj - Cj-l
ifke=m (9.93)
1 Dksl
0=--
(3 = _I Dke 1 (9.94)
3 3
Now assume ke - ks > 1. Our algorithm consists of three steps:
1. for each k, ks < k < ke, interpolate a cubic Bezier segment to the data
Po, T s , Qk, P 3 , T e , thus obtaining an Ok and a (3k; the Bezier segments,
Ck(U), are defined on the normalized interval U E [0,1];
442 Curve and Surface Fitting
/\
/
\
/ \
/ \
/ \
/
/
/ \
/ \
/ \
\
/ \
/ \
/
/
/
\
\
\
\
\
\
/ \
/ \
/ \
\
/ \
/
\
/
/ \
/ \
/ \
L / ______________ ~_~~~r_
(a)
(b)
Figure 9.54. Local quadratic curve fitting examples.
2. average the akS and f3ks to obtain a and f3; these define the candidate
Bezier segment, C(u);
3. check if all Qk' ks < k < ke, are within E distance of C(u).
Local Approximation 443
r - __
/
--,
/
/
/
\
\
\
)
/
/
(c)
,..,
I '
,
\
(d)
Figure 9.54. (Continued.)
+ + + + + +
+++ +++
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + +
+ +
+ + + +
+ + + +
+ +
+ +
+ +
+ +
+ + + + +
(e)
Figure 9.54. (Continued.)
and finally
(9.96)
where the point
(9.97)
Consider Figure 9.55. Equation (9.96) says that we obtain P by starting at Pc,
going along a direction parallel to Ts for some distance (to P d ), then continuing
from there in the opposite direction of Te for another distance. Since Ts and Te
have unit length, it follows that
(9.100)
Hence, we must compute Pc and P d, then a and b from Eq. (9.100), and finally
o and (3 from Eq. (9.99).
There are two cases to consider, coplanar and not coplanar. First assume the
vectors T s , T e , and P OP 3 are not coplanar. It turns out that there is a unique
cubic Bezier curve passing through P, and Pc and Pd can be constructed as
follows (see Figure 9.55):
Local Approximation 445
Te
z
,",
"
\,
\\
\',
\ ,
"\ " ,
\
,,\
\
\ '
\, "
I
I
-_ I
i--
,,
I
y
Po
..'IT'''
P
x
Figure 9.55. A unique cubic three-dimensional (twisted) Bezier curve specified byend-
points, end tangents, and one point on the curve.
where
,= II PoPs
PcPs I
I =Bo,s + BI,s (9.102)
any 'Y, a quick search in the table yields a start U. Finally, substituting U into
Eq. (9.99) yields a and {3.
If T s , T e, and P OP 3 are coplanar, then more than one cubic curve passing
through P can exist, and the previous geometric construction of Pc and Pd fails.
There are several special cases which complicate matters, hence we derive a set
of equations which always yields a and {3. We first assign a parameter, U, to P.
A good estimate is obtained using chord length parameterization, i.e.
Uks = 0
, , Ck - Ck-I
Uk = Uk-I + --"--------''----=- (9.103)
Cke - Cks
The Uk are, in fact, the normalized chord length parameters for the Qk on
Qk s "'" Qke' Now if P = Qk' ks < k < ke, then U = Uk.
Next we compute the tangent Tp at P (Eqs. [9.29] and [9.31]). Let
s=l-u t=u
By definition
(9.104)
and recalling the deCasteljau algorithm (Eq. [1.12], Algorithm A1. 5, and Figure
1.17) one can derive
P~ = s2p O + 2stP I + t 2 P 2
P~ = S2P I + 2stP 2 + t 2P 3 (9.105)
where P~ and P~ lie on the line defined by P and Tp (Figure 9.56). Thus
o= Tp x (P~ - P~)
Equation (9.107) involves the point constraint, P, and Eq. (9.108) the tangent
constraint, Tpo They each contribute three equations in two unknowns, for a
total of six equations (or four, when the data is xy planar). Some of the special
cases are:
• if Ts II T e, then Eq. (9.107) yields only one equation; Eq. (9.108) supplies
the necessary additional equation;
Local Approximation 447
~---------;~~---------~
I "... ,
I "" ... , \
\
\
\
\
P3
Figure 9.56. A planar cubic Bezier curve as specified by endpoints, end tangents, a
point on the curve, and a tangent direction at this point .
1 ke- 1 1 ke- I
The candidate cubic Bezier curve, C(u), is then defined by Po, PI = Po+o:Ts ,
P 2 = P 3 + (3Te, and P 3 •
We now must check if each Qk is within E distance from the curve C(u)
(k s < k < k e ). This requires Newton iterations, and the us computed previously
are good start values. Recall that Qk = Ck(Uk). Let ~O:k = O:k - 0: and
~{3k = {3k - (3. Then from Eq. (9.95) we have
ICk(Uk) - C(Uk) I
Equation (9.110) can be used as a fast acceptance test: if it is less than or equal
to E, then Newton iterations are not required. If iterations are required, the
technique given in Section 6.1 is appropriate.
The routine Fi tWi thCubic 0 follows. It returns the value 1 for a successful
fit, or the value 0 for no fit. We remark that the construction of Pc and Pd in the
noncoplanar case is unstable when Ts, Te, and Po P 3 are close to being coplanar.
Hence, this test should be made with a rather loose tolerance. The algorithm
uses local arrays uh[], alfak[], betakE] to store the Uk, ak, and 13k.
ALGORITHM A9.12
FitWithCubic(ks,ke,Q,Ts,Te,E,Pl,P2)
{ /* Fit to tolerance E with cubic segment */
/* Input: ks,ke,Q,Ts,Te,E */
/* Output: Pl,P2 */
if (ke-ks == 1)
{ /* No interior points to interpolate */
Compute a and 13 by Eqs.(9.93),(9.94).
Set PI = Qks + aTs
and P 2 = Qke + f3Te
return(1) ;
}
dk = ke-ks;
line = Collinear(dk+l,Q[ks]);
if (line == 1)
{ /* Collinear points case; create straight line */
Pi = (2.0*Q[ks]+Q[ke])/3.0;
P2 = (Q[ks]+2.0*Q[ke])/3.0;
return (1) ;
}
for (k=l; k<dk; k++)
{
Get plane ~ defined by Q[ks],Q[ke],Ts.
if (Line(Q[k+ks],Te) lies in~)
{ /* Coplanar case */
Compute Uk by Eq.(9.103) and load into uh[k].
Set up Eqs.(9.107) and (9.108) and solve for ak and 13k
(by least squares).
if (ak > 0 && 13k < 0)
{
alfak[k] = ak; betak[k] = 13k;
}
else
return(O);
}
else
Local Approximation 449
{ /* Noncoplanar case */
Pd = Intersection of n with Line(Q[k+ks] ,Te);
Pc = Intersection of Line(Q[ks],Q[ke]-Q[ks]) with
Line(Pd,Ts);
gamma = Distance3D(Pc,Q[ke])/Distance3D(Q[ks],Q[ke]);
if (gamma < 0.0 I I gamma> 1.0) return(O);
Use Newton iteration to solve Eq.(9.102) for uh[k].
if (uh[k] < 0.0 I I uh[k] > 1.0) return(O);
else
{
a = Distance3D(Pc,Pd); b = -Distance3D(Pd,Q[k+ks]);
Evaluate Bernstein polynomials and use Eq.(9.99)
to get alfak[k] and betak[k] .
}
}
} /* End of for-loop: k=l, ... ,dk-l */
/* Step 2: average the aks and ~kS */
alpha = beta = 0.0;
for (k=l; k<dk; k++)
{ alpha = alpha+alfak[k]; beta = beta+betak[k]; }
alpha = alpha/(dk-l); beta = beta/(dk-l);
Pl = Q[ks]+alpha*Ts; P2 = Q[ke]+beta*Te;
/* Step 3: check deviations */
for (k=l; k<dk; k++)
{
u = uh[k];
if (Eq. [9.110] less than E) continue;
else
{ /* Must do Newton iterations. u is start value */
Project Q[k+ks] to curve to get error ek.
if (ek > E) break;
}
}
if (k == dk) return(l); /* segment within tolerance */
else return(O); /* not within tolerance */
}
Figures 9.57 and 9.58 show examples of planar and nonplanar fits, respectively.
The input data for Figure 9.57 was
Figure 9.57a E= 1/10 , Kmax = 11
Figure 9.57b E = 1/10, Kmax = 8
Figure 9.57c E= 1/100 , Kmax = 11
Notice the change in the quality of the approximation from Figure 9.57a to
Figure 9.57b. For the same tolerance, allowing a maximum of eight points per
450 Curve and Surface Fitting
,,
/
,
,,
I
, I
,,
)
,
/
/
(a)
(b)
.,
/
Y
I
I
~
(c)
Figure 9.57. Local cubic approximation to planar data.
Local Approximation 451
(a)
(b)
Figure 9.58. Local cubic approximation to three-dimensional data containing planar
segments.
452 Curve and Surface Fitting
(c)
Figure 9.58. (Continued.)
EXERCISES
9.1. You want to interpolate the points Qk,l, k, f = 0,1,2,3 with a biquadratic surface
(p = q = 2). Instead of using repeated curve interpolation, use Eq. (9.25) directly to
set up a system of 16 linear equations in the 16 unknown Pi,js.
9.2. Assuming that the Ok were computed using Eq. (9.31), consider the unnormalized
Vk of Eq. (9.29). Convince yourself that the quantities Vkl.6.uk are good estimates
for the derivatives, if the .6.uk are computed using Eq. (9.5) (the normalized relative
chord length). Compute all the {Vk}, k = 0, ... ,4, for {Qk} = {(O, 0), (0,20), (20,40),
(30,30), (30, 20)}. What are their magnitudes? Compute the total chord length and the
.6.Uk according to Eq. (9.5). Do the quantities V kl .6.Uk seem like reasonable estimates
for derivatives?
Exercises 453
9.3. Draw figures as in Figures 9.48 and 9.49 and determine which Br values and
parameter index ranges must be recomputed for two quadratic cases: U = {O, 0, 0, 1, 2,
3,4,5,6,6,6}, with r = 5 and 8 = 1; and U = {O, 0, 0,1,2,3,3,4,5,6,6, 6}, with r = 6
and 8 = 2.
CHAPTER
TEN
Advanced Surface Construction Techniques
10.1 Introduction
In this chapter we cover several advanced surface construction techniques, name-
ly swung, skinned, swept, Gordon, and Coons surfaces. Roughly speaking, the
idea in this chapter is to take one or two curves, or sets of curves, and to cre-
ate a NURBS surface which interpolates these curves; i.e., the given curves are
isoparametric curves in the NURBS surface. Notice that this is fundamentally
different from the interpolation to discrete point and derivative data presented
in Chapter 9. In some of the constructions, it may not be obvious to the reader
that the surfaces created do indeed satisfy the desired constraints. We leave it
as an exercise for the reader to convince himself of this, either by mathematical
proof or by software implementation.
be a trajectory curve defined in the xy plane (see Figure 10.1). Denoting the
nonzero coordinate functions of P(u) and T(v) by Px(u), Pz(u), Tx(v), and
Ty(v), we define the swung surface by [Wood87]
S(u,v) = (aPx(u) Tx(v), aPx(u) Ty(v), Pz(u)) (10.3)
456 Advanced Surface Construction Techniques
Ps
Profile curve
TlO
.
Ts
:>
To -"Tg
T7'::
~ ... T6 y
,
x
Trajectory curve
Geometrically, S (u, v) is obtained by swinging P (u) about the z-axis and simul-
taneously scaling it according to T(v). a is an arbitrary scaling factor. Fixing
u yields curves having the shape of T( v) but scaled in the x and y directions.
Fixing v = vo, the isoparametric curve, Cvo(u), is obtained by rotating P(u)
into the plane containing the vector (Tx (vo), Ty (vo), 0), and scaling the x and
y coordinates of the rotated curve with the factor aIT(vo)l. The z coordinate
remains unsealed. It follows from the transformation invariancy property of
NURBS (P4. 24) that S (u, v) has a NURBS representation given by
n m
S(u,v) = L LRi,p;j,q(U,V)Qi,j (10.4)
i=O j=O
x
/
/
,
...
\ /
\ /
........ /
(a)
Figure 10.2. Swung surfaces. (a) Control net; (b) swung surface with no weights applied;
(c) swung surface with some weights applied.
Note that both P(u) and T(v) can be either open or closed; correspondingly,
S(u, v) can be open or closed in both u and v directions. Choosing 0: = 1 and
T(v) to be the circle with radius 1, centered at the origin, yields the surface of
revolution given in Chapter 8.
(b)
(c)
Figure 10.2. (Continued.)
curves. Filip and T. Ball [Fili89] describe a procedural method for lofting based
on arbitrary parametric section curves. Detailed descriptions of skinning using
B-splines are given in references [Till83; Wood87, 88; Hohm91].
Based on B-splines, we define skinning as follows. Let
n
Ck'(u) = L Ni,p(u)Pi,k k=O, ... ,K (10.7)
i=O
Skinned Surfaces 459
be the rational or nonrational section curves. We assume that all Ck' (u) are
defined on the same knot vector, U, and have common degree p. If necessary,
the curves can be brought to a common p and U, as described in Section 8.4 (in
fact, the ruled surface is a special case of a skinned surface). Then, for the v
direction a degree q is chosen, and parameters {Vk}, k = 0, ... , K, and a knot
vector, V, are computed. These are then used to do n + 1 curve interpolations
across the control points of the section curves, yielding the control points Qri of
the skinned surface. Therefore, Qri is the jth control point of the interpolating
curve through PI"o, ... , PI"K' Note that if even one of the Ck' (u) is rational, then
the v direction interpolatio~s through the PI"k are carried out in four-dimensional
space; otherwise, the three-dimensional poi~ts Pi,k are interpolated.
Figures 1O.3a-10.3d show the skinning process. The original section curves
are shown in Figure 1O.3a and are defined on the knot vectors
Co(u) : {0,0,1,1} (p = 1)
C 2 (u) : { 0,°'5'5'5'5,1,1
1234 } (p = 1)
,,
,
\
\
,
..-
Co(u)
x y
(a)
Figure 10.3. The process of surface skinning. (a) Cross-sectional curves; (b) cross-
sectional curves made compatible; (c) control points; (d) skinned surface.
460 Advanced Surface Construction Techniques
(b)
(c)
Figure 10.3. (Continued.)
Skinned Surfaces 461
z
(d)
Figure 10.3. (Continued.)
{ 1113322211
0,0,0,°'5' 5' 5' 10' 10' 5' 5' 5' 2' 2'
~ ~ ~ 1- 1- .! .! .! 1 Ill}
5'5'5'10'10'5'5'5' , , ,
This raises the number of control points in the u direction to 22. The compatible
curves are shown in Figure 1O.3b. Note the significant number of new control
points, the price one pays for flexibility. Figure 1O.3c shows the control net of
the skinned surface that is depicted in Figure 1O.3d.
Although simple to formulate, it is quite difficult to implement a robust and
usable skinning capability; and interactively designing skinned surfaces is often a
tedious and iterative process. Surface shape is difficult to control; it depends on
the number, shape, and positioning of the section curves (all of which the inter-
active designer usually controls), as well as on the method used for v-directional
interpolations (which is usually embedded in the software and the designer can-
not control). Often the design process consists of starting with a small number
462 Advanced Surface Construction Techniques
of section curves and then iteratively skinning, taking plane cuts to obtain addi-
tional section curves, modifying the new curves to obtain more desirable shapes,
and reskinning. Finally, a skinned surface can exhibit unwanted self-intersections
and twisting. However, in spite of these difficulties, skinning is a powerful and
widely used surface design technique.
We turn our attention now to the v-directional interpolations. We assume
for the moment that all section curves are nonrational; skinning across rational
sections presents a host of problems, which we return to at the end of this section.
Three items must be determined: the degree q, the parameters {Vk}, and knots
V = {Vi}. The degree q is arbitrary, the only restriction being q ~ K. The vk
are computed by averaging, for example
Vo =0
_ _ Vk-l
Vk -
_ + _1_ L n
IPi,k - Pi,k-ll
d k = 1, ... ,K-1 (10.8)
n+1 .
i=O •
where di denotes the total chord length of Pi,o, ... , Pi,K. The knots {Vi} are then
computed using Eq. (9.8). The skinned surface of Figure 1O.3d was constructed
using this method of interpolation.
Another common method is to use a so-called spine curve (also called a path
curve), that is
ns
Cs(v) = LRi,ps(V) Ri (10.9)
i=O
Spine curve
Cross-sectional curves
Figure 10.4. Spine curve and cross-sectional curves for spine-based skinning.
Skinned Surfaces 463
Uk
. = {III 1 I}
2' 2' 2' 2' 2
Each section curve is oriented so that its plane is perpendicular to the tangent
vector of the spine curve at the intersection of the spine curve and the section's
plane. The spine curve can also aid in v-directional shape control by providing
additional constraints for use in the v-directional interpolations. For example,
spine tangent directions can be used: Let {Vk}, k = 0, ... , K, be the v values of
the points on Cs(v) where the section curves are positioned; for planar sections
these are the v values corresponding to intersections of the spine with the section
planes. These values are generally known, and they can be input to the skinning
routine. Notice that, in general, Vk =I Vk if the Vk are computed using Eq. (10.8).
Of course, one can set Vk = -Uk, but this may not be a good idea if C s (v) is poorly
parameterized. Now let
k=O, ... ,K
Then for each i and k we compute a derivative vector, Di,k. For each i this yields
2(K + 1) interpolation constraints, Pi,Q, ... , Pi,K and Di,Q, ... , Di,K. The Di,k
are computed by letting
k= 1, ... ,K
(10.10)
(10.11)
•'/
Figure 10.6. Computation of derivatives for spine skinning.
Skinned Surfaces 465
that is, all partial derivatives with respect to v on the kth isoparametric curve
are parallel to D k . This follows from the fact that these partial derivatives are
linear combinations of the Di,k' Letting m = 2K + 1, we can now set up m + 1
linear equations for each fixed i (see Eqs. [9.19] and [9.20]), i.e.
m m
The knot vector V must contain m + q + 2 knots; Eqs. (9.22) and (9.23) give
suitable choices for the cases q = 2 and q = 3, respectively.
Figure 10.7a shows the control points of the skinned surface defined by the
data in Figure 10.5, using cubic interpolation with specified tangents as shown
in Figure 10.6; the surface is depicted in Figure 10.7b. The same data is in-
terpolated in Figures 10.8a and 10.8b, without specified derivatives. Note the
significant difference in surface shapes (Figures 1O.7b and 1O.8b). The position-
ing of section curves has a definite effect on surface shape, just as the positioning
of data points in curve and surface interpolation; Figures 1O.9a and 1O.9b show
two examples. In Figure 1O.9a the spine and section curve parameters are
Uk
Vk = {O,O.25,O.5,O.78,1} A
Uk =
{I"2' 10'
3 "2'1 10'
9 "2I}
We now consider the case in which some of the section curves are rational
(Eq. [10.7]). The v interpolations must now be carried out in homogeneous space.
Analogous to Eq. (10.8), the Vk are computed by averaging four-dimensional
distances, that is
Vo = °
n IP w
1 '"' p'!" I
_ __ + __ ',k -
.,k-l
k = 1, ... ,K-l (10.14)
Vk - Vk-l n +1~ d'!"
i=O •
where di denotes the total chord length of Pio,"" PiK' The knots {Vi} are
again computed using Eq. (9.8). Interpolations through the Pik yield the control
points Qrj' i = 0, ... , n, j = 0, ... , K, of the skinned surf~ce SW(u, v). The
isoparametric curves, C~k (u) = SW(u, Vk), are the original section curves, Ck'(u).
Although the designer may still use a spine curve to position and orient the
466 Advanced Surface Construction Techniques
/~ I , I
I \ '1/._ \
, I \./ \ \ \
\
~'---;---~'
, \ I
~---
,,
, y
\
(a)
(b)
Figure 10.7. Spine skinning with spine controlled interpolation. (a) Control net;
(b) skinned surface.
Skinned Surfaces 467
(a)
z
(b)
Figure 10.8. Spine skinning with no spine interpolation constraint. (a) Control net;
(b) skinned surface.
468 Advanced Surface Construction Techniques
(a)
(b)
Figure 10.9. Spine skinning. (a) Section curves are positioned at different spine param-
eters; (b) section curves are positioned at different section curve parameters.
Skinned Surfaces 469
• the surface may not be as smooth as the section curves indicate. For ex-
ample, let one section curve be the full circle given in Example Ex7 . 2. As
shown in that example, the circle is C 1 continuous, although its homoge-
neous counterpart is only CO continuous at the double knots. Assuming
that all other section curves are C1, one expects the resulting skinned sur-
face, S(u, v), to be C 1 continuous in the u direction. But SW(u,vJ is only
CO continuous in the u direction, since it is formed by blending C curves;
in general, arbitrary u-directional isoparametric curves on SW (u, v) are
only Co, and their projections to three-dimensional space may be only CO
continuous. Figures 1O.1Oa and 1O.1Ob show an example of this. The four
rational section curves are all C1 continuous in three-dimensional space.
They are quadratics, defined with a double knot at u = 1/2. The respective
weights of the section curves are
CO: {1,2,1,1,1}
C1 : {1,1,1,3,1}
C2 : {l,l,l,l,l}
C3 : {1,4,1,2,1}
470 Advanced Surface Construction Techniques
I
I
I
.'
Co(u)
I
(a)
(b)
Figure 10.10. Rational skinning. (a) C 1 continuous section curves; (b) skinned surface.
Skinned Surfaces 471
1 2 1 1 1]
1 0.94 1 4.43 1
[
Wi,j = 1 0.71 1 -0.75 1
1 4 1 2 1
(note the negative weight at P3,2). The surface shown in Figure 1O.lOb
exhibits only CO continuity in the u direction. To the authors' knowl-
edge, the only solutions to this dilemma involve the use of higher degree
section curves. For example, a full circle can be represented as a degree
5 NURBS curve with positive weights and no interior knots (Example
E7 .10), thereby eliminating the problem. Several solutions to this prob-
lem, all effectively raising the degree of the skinned surface, are discussed
in [Hohm91]. A general solution is to use so-called smoothing functions.
Suppose C k(u) is a C r continuous section curve on the knot vector U,
whose projection Ck(U) is C r +s continuous, s > O. Let f(u) be a B-spline
scalar-valued function on U, such that
L Nj,q(v)wJTj
T(v) = ~j=-~---------
LNj,q(v)wJ
j=O
n
L Ni,p(u)wf Qi
and C( u) = ..:....i=....::.~,---_ _ __
LNi,P(u)wf
i=O
n m
L LNi,P(u)Nj,q(V)Wi,jPi,j
Then S(u, v) = _i=_O-=-n_j=_o=m,----______________
L L Ni,p(u)Nj,q(V)Wi,j
i=O j=O
Swept Surfaces 473
and weights
i = 0, ... , n j = 0, ... , m (10.19)
T'(v)
o(v) = T(v) x(v) = IT'(v)1 (10.20)
B(v)
z(v) = IB(v)1 (10.21)
The determination of this function is a critical and nontrivial part of the sweeping
Section curve
y
Trajectory curve
x
(a)
Figure 10.11. Translational sweeping. (a) Trajectory and section curves; (b) swept
surface.
474 Advanced Surface Construction Techniques
(b)
Figure 10.11. (Continued.)
process. We return to the question of how to determine B(v) at the end of this
section; for now, we simply assume it is given. y(v) is then defined by
where S(v) is a 3x 3 diagonal matrix with diagonal elements (sx(v), Sy(v), sz(v)),
and A(v) is the general transformation matrix taking {O, X, Y, Z} into {o(v),
x( v), y(v), z( v)}. The isoparametric curves on S (u, v) at fixed v values are in-
stances of C(u), transformed by A(v)S(v) and translated by T(v). If C(u)
passes through the global origin at u = ii, then T(v) is the isoparametric curve
S(u=ii,v).
S(u,v) may not be representable in NURBS form. Clearly, if A(v) and S(v)
can be precisely represented as rational B-spline functions, then so can S( u, v).
S(v) is generally no problem. If scaling is applied at all, then it is common to use
a linear function or a higher degree B-spline approximation to a function which
is linear with respect to the arc length parameter. However, A(v) is generally
Swept Surfaces 475
not representable in NURBS form, even in the simple case that z( v) = Z for all
vo:S v :S vs. Hence, we must construct a NURBS approximation to Eq. (10.24).
Denote this approximation by S(u, v). We present three methods:
• The first method is to use Eq. (10.24) to evaluate an (n x m) grid of
points lying precisely on S(u, v), and then use either the interpolation or
approximation techniques of Chapter 9 to construct a nonrational B-spline
approximation, S( u, v). A disadvantage with this method is that none of
the u or v isoparametric curves on S(u, v) are precise;
• Another method is given by Bloomenthal and Riesenfeld [Blom91] and
by Coquillart [Coqu87a]; their method involves approximating the three-
dimensional offset curves of the trajectory. Their algorithm interpolates
T(v) as an isoparametric curve if C(u) passes through the origin; however,
instances of C(u) are not interpolated, except at v = Vo and v = VS.
Bloomenthal and Riesenfeld give error bounds for their method, based on
error bounds for the offsetting process;
• A third method, which we present in more detail here, is to use skinning.
We transform and place K + 1 instances of C(u) along T(v), and then skin
across these section curves. The accuracy of the resulting surface, S( u, v),
is increased by increasing K. Each instance of C(u) is interpolated as
an isoparametric curve on S(u, v). There are two strategies for the v-
directional fitting. The first makes use of the B-spline structure of T(v).
The trajectory's degree q and knot vector V are used for the fitting, hence
they are inherited by S( u, v). Furthermore, the parameters ih for the
fitting must be taken from T(v); if T(v) is rational, its weights must be
factored in prior to the v-directional fitting. This method is required if
C(u) passes through the global origin and it is desired that T(v) be an
isoparametric curve in S(u, v), but the method can be used in any case.
The other method does not make use of T( v) other than to position the
section curve; that is, the v-degree of S( u, v) is input, parameters and
knots are computed in some manner, and T(v)'s weights need not be
factored in.
Corresponding to the two methods of v-directional fitting, two sweeping al-
gorithms follow. In both cases, the swept surface, S(u, v), inherits its u-degree
p and the knot vector U from C(u). T and C are the trajectory and section
curves, and Bv and sv are input functions given by Eqs. (10.21) and (10.23),
respectively. In Algorithm A10. 1 the v-degree q is not required; the number K
is to be viewed as a minimum, because more instances of the section curve may
be required depending on the number of knots defining T(v).
ALGORITHM A10.l
SweepSurfacel(T,C,Bv,sv,K,V,Pw)
{ 1* Swept surface. Trajectory interpolated. *1
1* Input: T,C,Bv,sv,K *1
1* Output: V,Pw *1
q = degree of T(v).
476 Advanced Surface Construction Techniques
ALGORITHM Al0.2
SweepSurface2(T,C,Bv,sv,q,K,V,Pw)
{ 1* Swept surface. Trajectory not interpolated. *1
1* Input: T,C,Bv,sv,q,K *1
1* Output: V,Pw *1
Determine values vo, ... , VK at which to place the
instances of C(u). A reasonable choice is to select the
Vk so that the T(Vk) are approximately evenly
spaced.
for (k=O; k<=K; k++)
{ 1* Transform and position section control points *1
Let Qi and Wi be the control points and weights
of C(u), i=O,,,.,n.
Scale the control points Qi by sv.
Compute {o,x,y,Z}(Vk) from Eqs.(10.20)-(10.22).
Compute the transformation matrix A(Vk) transforming the
global system into {o,x,y,Z}(Vk).
Apply A(Vk) to the scaled Qi'
Reapply the weights Wi, and denote the resulting
weighted control points by Qk,i'
}
Determine vo, ... ,VK, the v-parameters for the
v-directional interpolations (Eqs.[10.8] or [10.14]).
Given q and the Vk, compute the knot vector V by averaging
(Eq. [9.8]).
for (i=O; i<=n; i++)
{
Interpolate across QOwi, ... ,QKi to obtain POwi"",PKi'
" "
}
}
Figure 1O.12a shows the trajectory and section curves, along with a start vec-
tor, B(vo). The section curve does not pass through the global origin. Figures
1O.12b and 1O.12c show the results of sweeping by Algorithms Al0. 2 and Al0 .1,
respectively. Since the section curve does not pass through the origin the tra-
jectory is not contained in the surface, even in Figure 10.12c. Also note the
larger number of section curve placements in Figure 10.12c. Figures 1O.13a-
1O.13c show sweeping examples where the section curve passes through the ori-
gin (Figure 1O.13a). No trajectory control was used (Algorithm Al0. 2). Figure
10.13b used no scaling, while Figure 1O.13c used a piecewise linear B-spline scal-
ing function defined by control points
., Cross-sectional curve
,
0:
y
Trajectory curve
x
(a)
(b)
Figure 10.12. Sweeping examples. (a) Two-dimensional trajectory and the section curve
not passing through the global origin; (b) swept surface with no trajectory controlled
interpolation; (c) swept surface obtained by trajectory controlled interpolation.
Swept Surfaces 479
z
(c)
Figure 10.12. (Continued.)
and knots
v = {O, 0, 130' 170,1,1 }
The previous two examples used a planar trajectory curve. Figure 1O.14a shows
a three-dimensional (twisted) trajectory. The trajectory was not maintained
in Figure 1O.14b (Algorithm A10.2), whereas the trajectory is an isocurve in
the surface of Figure 10.14c (Algorithm A10 .1). In both examples all section
instances were scaled with the constant vector (3/5,3/5,1).
The positioning and size of the section curve, as well as the shape (curva-
ture) of the trajectory, have a dramatic effect on surface shape. Two examples
are shown in Figures 1O.15a and 1O.15b. The trajectory is not interpolated in
Figure 1O.15a, but it is in Figure 10.15b. Both surfaces exhibit the so-called off-
setting phenomenon, i.e., they have self-intersections and unwanted oscillations.
We return now to the problem of determining a suitable orientation function,
B(v). If T(v) is a planar curve, the solution is simple: Let B(v) be a constant
function whose value is a vector normal to the plane of T(v). For arbitrary
trajectories the situation is more difficult. A common solution is to use the
so-called Prenet frame [DoCa76j Klok86; Bron92j Silt92]. Assume T(v) is twice
differentiable. Define B(v) by
T'(v) X T/(v)
B(v) = JT'(v) x T/(v)J (10.25)
480 Advanced Surface Construction Techniques
Cross-sectional curve
y
Trajectory curve
x
(a)
(b)
Figure 10.13. Sweeping examples. (a) Two-dimensional trajectory and section curve
passing through the global origin; (b) swept surface with no scaling; (c) swept surface
with scaled section curves.
Swept Surfaces 481
z
(c)
and N(v) by
N(v) = B(v) X T'(v) (10.26)
T'(v),N(v), and B(v) are mutually orthogonal for all v, and when normalized
they form a moving local coordinate system on T(v) called the Frenet frame.
B(v) (or a NURBS approximation of it) can then be used in Eq. (10.21) and
Algorithms Al0. 1 and Al0. 2. There are several disadvantages to this method:
• B(v) is not defined by Eqs. (10.25) and (10.26) for linear segments or at
inflection points (or more generally, where T"(V) x T'(v) = 0);
• B(v) flips abruptly to the opposite direction at an inflection point;
• for three-dimensional trajectories, the vectors given by B(v) can rotate
excessively around T(v), causing unwanted twisting ofthe resulting swept
surface. Figure 10.16 shows this phenomenon; notice how the Frenet frame
flips at the inflection point.
The first two problems can be dealt with rather easily [Klok86; Bron92; Silt92],
but the rotation of B(v) depends solely on the shape of T(v), hence it cannot
be avoided without changing the shape of T(v).
Siltanen and Woodward [Silt92] give an elegant method, called the projection
normal method, that avoids these three problems. Let Vo, ••• ,Vrn be an increasing
sequence of parameter values, with Vo and Vrn being the minimum and maximum
values, respectively, in the domain of T(v). At each Vi we compute a vector, B i ,
482 Advanced Surface Construction Techniques
Cross-sectional curve
(a)
(b)
Figure 10.14. Sweeping examples with scaled section curves. (a) Three-dimensional
trajectory and section curve; (b) trajectory is not interpolated; (c) trajectory
is interpolated.
Swept Surfaces 483
x
(c)
Figure 10.14. (Continued.)
and then use either interpolation or approximation to obtain the function B(v).
We use Siltanen and Woodward's method to compute the B i . Set Bo to an ar-
bitrary unit length vector orthogonal to T' (vo). Then for i = 1, ... , m, compute
and set
(10.27)
i = 1, ... ,m-1
The swept surfaces of Figures 10.12 to 10.15 used the projection normal method
to compute the Bi vectors. Figures 1O.17a and 10.17b show examples of how the
484 Advanced Surface Construction Techniques
(a)
(b)
Figure 10.15. Sweeping examples. (a) Trajectory is not interpolated; (b) trajectory is
interpolated.
Interpolation of a Bidirectional Curve Network 485
Figure 10.16. Sweeping example; section curve is placed by the Frenet frame.
-~--~
\
I
,
\ y
X
/
~
,,
~
h
(a)
Bv
I ./
,
~
~
~
~~----c:::-..
~ V
~
~ y
(b)
Figure 10.17. The change of B(v) and the Frenet frame along the trajectory. (a) Planar
trajectory; (b) three-dimensional trajectory.
Interpolation of a Bidirectional Curve Network 487
• as independent sets they are compatible in the B-spline sense, that is, all
the Ck{U) are defined on a common knot vector, uC; and all the Ct{v)
are defined on a common knot vector, V C ;
• there exist parameters 0 = Uo < UI < ... < Us-I < Us = 1 and 0 = Vo <
VI < ... < Vr-l < Vr = 1 such that
We want to construct a NURBS surface, S{u, v), which interpolates the two sets
of curves, that is
S{Ut,V) = Ct{v) £=0, ... ,8
iU i= i
<Pl(Ui) = {~ iU= i
if k i= i
~k(Vi) = {~ if k = i (10.31)
satisfies the interpolation conditions of Eq. (10.30). Hence, the desired surface
is composed of three simpler surfaces, namely two lofted surfaces, Ll (u, v) and
L 2 (u, v), and the tensor product, T(u, v). Gordon experimented with various sets
of blending functions, including simple step functions, Lagrange polynomials,
and cubic splines.
Our task is to produce a NURBS representation of S( u, v). Clearly, if Ll (u, v),
L 2 (u,v), and T(u,v) are all compatible in the B-spline sense (defined on the
same knot vectors), then they can be added and subtracted by applying the
corresponding operations to their control points, that is, the control points Pi,j
of S(u, v) are computed by
(10.33)
where ptJ, ptJ, and prj are the control points of L1(u,v), L 2 (u,v), and
T(u, v), respectively. Furthermore, it is easy to obtain NURBS representations
of L1(u,v), L 2 (u,v), and T(u,v); the first two are skinned surfaces, and the
latter is obtained by interpolating the points QI',k (see Section 9.3). The choice
of parameters and knots for the skinning and point interpolation processes is
determined by the given parameters, {u£l and {vd, and the knots U C and V C
of the {Ck(U)} and {CI'(v)}. We illustrate with a simple example.
Example
Figures 10.19a and 10.19b show the control points and the resulting
surface of the u-directionallofting operation. The knot vectors are
lJLl = {0,0,0,0,1,1,1,1}
VLl = {0,0,0,~,~,1,1,1}
The v-directional lofting is illustrated in Figures 1O.20a and 1O.20b. The
knot vectors are
lJL2 = {O,O,O,O, 130' 170,1,1, 1, I}
VL2 = {0,0,0,0.321,0.647,1,1,1}
As alluded to earlier, the degrees of the input curves, those degrees used for
lofting, and those used to construct T(u, v) can all be different. The final degree
(p,q) of S(u,v) is simply the maximum of those used. The degrees of L1(u,v),
L2(U,V), and T(u,v) must be raised to (p,q) before knot refinement. A sketch
of the complete algorithm follows. Ck [] and Cl [] are arrays of input curves,
and ul [] and vk [] are the parameters of the curve intersection points. To be
490 Advanced Surface Construction Techniques
\
\ y
(a)
(b)
Figure 10.19. u-directional lofted surface. (a) Control net; (b) surface interpolating
v curves.
Interpolation of a Bidirectional Curve Network 491
I
I
I
I
\ " I
-
/ " I
\
,
, I y
.'
\
Il", ..........
x
(a)
(b)
Figure 10.20. v-directional lofted surface. (a) Control net; (b) surface interpolating
u curves.
492 Advanced Surface Construction Techniques
,~-
\
\
\
\
\
\
\
--:0_'-<1 i '
" ,
I
\
,
I
\ \ I
\ I
\
./
\
)j
I
Y
\
\
x \ /
(a)
(b)
Figure 10.21. Tensor product surface. (a) Control net; (b) surface interpolating inter-
section points.
Interpolation of a Bidirectional Curve Network 493
,,
y
(a)
, ,, /
\
\
,, /
/
y
\ , ,'Ii pL2
to;
/' 5,1
x
(b)
Figure 10.22. Knot refinement to construct a Gordon surface. (a) Ruled surface in the
u direction refined; (b) ruled surface in the v direction refined.
494 Advanced Surface Construction Techniques
(c)
Figure 10.22. (Continued.) (c) tensor product in both directions refined.
completely general, the degrees pI, ql, pt ,qt used for lofting and interpolation
are also input. n,m,p,q,U,V,Pij define the output Gordon surface.
ALGORITHM A10.3
GordonSurface(Ck,Cl,ul,vk,r,s,pl,ql,pt,qt,n,m,p,q,U,V,Pij)
{ 1* Create Gordon surface. *1
1* Input: Ck,Cl,ul,vk,r,s,pl,ql,pt,qt *1
1* Output: n,m,p,q,U,V,Pij *1
pc = degree of the Ck curves.
qc = degree of the Cl curves.
Choose a suitable U1 and loft to obtain L1(u,v)
(degree (pl,qc».
Choose a suitable V2 and loft to obtain L2(u,v)
(degree (pc,ql».
Choose suitable UT and VT, and interpolate to obtain T(u,v)
(degree (pt,qt».
p = max(pc,pl,pt).
q = max(qc,ql,qt).
Degree elevate L1(u,v), L2(u,v) and T(u,v) to (p,q)
as necessary.
U Merge(U1,U2,UT).
V = Merge(V1,V2,VT).
Interpolation of a Bidirectional Curve Network 495
P5,8
/
/
,,
. y
..
/
+ pL2
/
/
P 5,1 pLI pT
/
5,1 5,1 - 5,1
x /
-. /
(a)
(b)
Figure 10.23. A Gordon surface. (a) Control net; (b) surface interpolating u- and v-
directional curves.
496 Advanced Surface Construction Techniques
and that we want to construct a surface having these four curves as its bound-
aries. Furthermore, we assume that the curves satisfy the compatibility condi-
tions
• as independent sets they are compatible in the B-spline sense, that is, the
two Ck(U) are defined on a common knot vector, U, and the two C£(v)
are defined on a common knot vector, V;
• So,o = Ck=o(u = 0) = C£=o(v = 0)
Sl,O = Ck=o(u = 1) = Ce=l(V = 0)
SO,l = Ck=l(U = 0) = Ce=o(v = 1)
Sl,l = C k=l(U = 1) = Ce=l(V = 1) (10.35)
(see Figure 10.24). We do not restrict the curves to be nonrational in this sec-
tion. The constructions given here usually yield satisfactory surfaces, even when
carried out in homogeneous space. However, this complicates the algorithms.
For example, Eq. (10.35) must hold in homogeneous space. This requires corner
weight compatibility, which can require rational reparameterization of the curves
(Section 6.4).
The bilinearly blended Coons patch is defined as
where R 1 (u,v) and R 2(u,v) are ruled surfaces between Ck=o(u) and C k=l(U),
and Ce=o( v) and C£=l (v), respectively, and T( u, v) is the bilinear tensor prod-
uct surface
T(u,v) = [1 u] [So,o SO,l] [1]
Sl,O Sl,l v
Coons Surfaces 497
I
Co(v)
Co(u)
x 8 1 ,0 = C o(1) = C 1 (0)
Figure 10.24. Compatible boundary curves to define a bilinearly blended Coons patch.
Clearly, this is a special case of the Gordon surface, and therefore Eq. (10.33) and
Algorithm A10. 3 (simplified, and modified to handle rational curves) can be used
to obtain a NURBS representation of the Coons surface given by Eq. (10.36). The
input arguments pl, ql, pt ,qt are set to 1 in this case. Figures 10.25a-1O.25d
show the construction of the bilinearly blended Coons patch defined by the curves
in Figure 10.24. Figure 1O.25a shows a ruled surface in the u direction, and
Figure 10.25b illustrates the v-directional ruled surface. Figure 1O.25c shows the
bilinear surface defined by the four corner points. The bilinearly blended Coons
patch is depicted in Figure 1O.25d. It is important to note that the bilinearly
blended Coons patch is, in general, not a bilinear surface.
Coons developed his patches in the mid 1960s [Coon67]. Although we present
the bilinearly blended Coons patch as a special case of Gordon surfaces, we
remark that Coons' work preceded and influenced the development of Gordon
surfaces. Coons was interested in interpolation to position and tangent informa-
tion in bidirectional networks of curves, as was Gordon later. Coons constructed
a patch within each set of four curves, hence his was a local interpolation method.
Gordon's method represents a global interpolation to a network of curves.
If two bilinearly blended Coons patches share a common boundary curve, they
possess, in general, only eO continuity across that boundary; that is, the com-
bined surface will have a crease along the common boundary. In order to obtain
smooth, en continuous (n > 0) joins of his patches, Coons developed higher
order patches using cross-boundary derivative fields. To illustrate, we present
the bicubically blended Coons patch. Let Ck(U) and Ct(v) be four boundary
498 Advanced Surface Construction Techniques
(a)
(b)
Figure 10.25. Bilinearly blended Coons patch. (a) A ruled surface in the u direction;
(b) a ruled surface in the v direction; (c) a bilinear surface; (d) a bilinearly blended
Coons patch.
Coons Surfaces 499
z
(c)
• the Ck(u) and the Dk(U) are compatible in the B-spline sense, as are the
Ct(v) and Dt{v)j
• dDk=O(U = 0) dDt=o(v = 0)
To 0 = = -..:......:-:---.-.:..
, du dv
500 Advanced Surface Construction Techniques
(d)
dDk=O(U = 1)
T 1 0 = --...:..,.:------'-
, du
dD k=I(U = 0) dD,,=o(v = 1)
To 1 = ---"----~-----'-
, du dv
T _ dD k =I(U = 1) dD"=I(V = 1)
1,1 - du (10.38)
dv
where 8 1 (u, v) is a cubic blend of the data Ck(u), Dk(U), k = 0,1; 8 2(u, v) is a
cubic blend of the data C,,(v), D,,(v), e = 0,1; and T(u, v) is a bicubic tensor
product surface (defined by 16 vector coefficients). Coons used cubic Hermite
polynomials to blend the boundary data and to form T( u, v). Since our goal is
to obtain a NURBS surface, we use cubic Bezier methods to blend and to form
T( u, v). 8 1 (u, v) is a cubic Bezier in the v direction. Its four rows of control
points are computed as (i = 0, ... , n)
Coons Surfaces 501
P i,2
SI _
-
P
k=l,i - 3"1 Qk=l,i
(10040)
Note that the two interior rows are derived using the Bezier derivative formulas
(Eq. [1.10]). The control points of S2(U,V) are computed analogously, i.e.
pg,j = Pl=O,j
(10041)
T(u,v) is a bicubic Bezier surface. Equations (1.10) and (3.24) are used to
derive the 16 control points, PT,j' i,j = 0,1,2,3. As an example, we show how
Figure 10.26. Compatible boundary curves along with cross-boundary tangent vector
functions and twists.
502 Advanced Surface Construction Techniques
to compute the four control points, prj, i,j = 0,1, adjacent to the corner So,o.
The other twelve are analogous.
PT _ 1T
1,1 - 9 0,0 + pT1,0 + pT0,1 - pT
0,0 (10.42)
The surfaces Sl(U, v), S2(U, v), and T(u, v) must then be made compatible using
degree elevation and knot refinement. Subsequently, the control points Pi,j of
the Coons surface are computed by the formula
Pi)'
J
= pS~
1,3
+ p?,~
'&,J
- pT.
1,,) (10.43)
y
x
(a)
y
x
(b)
Figure 10.27. Cubically blended surface in the u direction. (a) Control net; (b) surface
(Bezier in the u and B-spline in the v direction).
504 Advanced Surface Construction Techniques
y
x
(a)
x y
(b)
Figure 10.28. Cubically blended surface in the v direction. (a) Control net; (b) surface
(B-spline in the u and Bezier in the v direction).
Coons Surfaces 505
y
x
(a)
(b)
Figure 10.29. Bicubic tensor product surface. (a) Control net; (b) bicubic Bezier surface.
506 Advanced Surface Construction Techniques
y
x
(a)
y
x
(b)
Figure 10.30. Bicubically blended Coons surface. (a) Control net after degree raising
and knot refinement; (b) Coons surface.
Coons Surfaces 507
T~,o and T~,o are computed from the following control points of Dk=o(u)
and Dl=o(v): Qk=O,O, Qk=O,l and Ql=O,O, Ql=O,l. Set
To,o = "21 (k l)
To,o + To,o
Keeping Qk=O,O and Ql=O,O fixed, Qk=O,l and Ql=O,l can be modified to
yield the common twist, To,o. Knot insertion, applied prior to modifying
Qk=O,l and Ql=O,l, can be used to bound the angular error and restrict
its domain of influence. The process is even more complicated if any of
the curves or derivative fields are rational.
For a deeper and broader study of Coons patches, the reader should consult
Barnhill's article [Barn93] and the references cited therein.
CHAPTER
ELEVEN
Shape Modification Tools
11.1 Introduction
The purpose of this chapter is to develop tools which allow a designer to inter-
actively make local modifications to an existing NURBS curve or surface, in a
way that is natural and intuitive. A NURBS curve or surface is defined by its
control points, weights, and knots; modifying any of these changes the shape
of the curve or surface. Generally designers do not want to work with such
concepts; they prefer to specify constraints and shapes which apply directly to
the curve or surface. In this chapter we develop tools which take such con-
straints and shape specifications and convert them into modifications in control
point locations or weight values. Specifically, Sections 11.2 and 11.3 are based
on specifying point constraints (Le., the curve or surface is to change locally so
that it passes through a given point); multiple point and derivative constraints
are handled in Section 11.5, allowing control of tangent and curvature; and the
methods of Section 11.4 allow a designer to specify the "shape" that a curve or
surface is to assume in a selected region. These geometrically intuitive inputs
are converted into control point relocations in Sections 11.2, 11.4, and 11.5, and
into weight modifications in Section 11.3. The influence of control points and
weights on shape is geometrically clear and intuitive. This was already shown,
qualitatively, in previous figures, e.g., Figures 3.7, 3.23, 4.4, 4.6, 4.11, and 4.12;
this chapter quantifies this influence. Although knot locations also affect shape,
we know of no geometrically intuitive or mathematically simple interpretation
of this effect, hence we present no techniques for moving knot locations.
The methods of this chapter are local, due to the local support property of
B-splines. However, the extent of the curve or surface region which is to change-
can be made smaller by knot refinement, or larger by knot removal. Interactiv-
ity requires fast solutions, which in turn implies either simple equations, small
510 Shape Modification Tools
where {D:k} are scalars and {Pf,j} are the control points defining 8 k. The
NURBS construction of Gordon and Coons surfaces are examples of this (see
Eqs. [10.33J and [10.43]). This suggests the use of "additive" or "corrective"
surfaces or surface patches. One can work with small, simple pieces and then
superimpose them to form a new surface or to modify a region of an existing
surface. Boundary conditions are easily controlled. Several authors have used
such techniques for interactive surface design (see [Fors88; Mats92; Welc92]).
Control Point Repositioning 511
II> - PI = d = aIVIRk,p(u)
which yields
(11.3)
Po Ps
IIII IIII
Us
From a user interface point of view, there are two broad approaches to control
point repositioning, distinguished by whether the user picks on the control poly-
gon or the curve. In the first scenario, the user might specify a vector direction
and distance and then pick a point on the control polygon. If the picked point is
an existing control point, the system simply translates it and redraws the curve.
If not, then the system makes the point a control point through inverse knot in-
sertion (see Chapter 5, Eqs. [5.19]-[5.21]), and it subsequently translates the new
control point and redraws the curve. In the second scenario, the designer picks
a curve point, P (from which the system computes u), and then picks the point
P to which P is to be moved (from which the system computes d and V). It
remains for the system to choose a control point, Pk, to be translated in order to
produce the desired movement of P. In general there are up to p + 1 candidates,
but it is usually desirable to choose Pk so that Rk,p(U) is the basis function
whose maximum lies closest to u. A parameter value which generally lies quite
close to (but not necessarily coincident with) the maximum of an arbitrary basis
function, ~,p(u), is the so-called node, ti, defined by (see [Ries73])
1 p
ti = - ~:::Ui+j i = 0, ... , n (11.4)
p j=1
Note that ti is the average of the knots which are interior to the domain where
~,p (u) is nonzero. For interactive control point repositioning, we recommend
choosing k based on the node values instead of actually computing the maximums
of the ~,p(u); that is, k is chosen such that
lu - tkl = m~n lu - til (11.5)
•
Of course, the nodes can be used as start values to find the maximums using
Newton iteration.
Figures 11.2 and 11.3 show two control point repositionings in which the index
k was chosen based on the proximity of u to the nodes. Notice that Figure 11.2
is pleasing, while Figure 11.3 is asymmetric and not pleasing. The reason is that
in Figure 11.2 u is very close to the node tk (and to the maximum of Rk,p( u)),
therefore the curve translation is rather symmetrical about C(u) and roughly
maximum there. In Figure 11.3, u lies halfway between tk and tk+! (but tk was
chosen), therefore the maximum translation occurs to the left of C(u). There
are two solutions to this dilemma:
• insert a knot in order to put a node at u;
• reposition both P k and Pk+I.
Let us insert the knot it which forces tk+! (the new (k + 1)th node) to have
the value U. From Eq. (11.4) it is clear that Uk+! < it < Uk+p+!, hence
Figure 11.4 shows the curve of Figure 11.3. The knot u from Eq. (11.6) was
inserted to force u to be the (k + 1)th node. The resulting Qk+1 was then
moved to effect the desired curve modification. Notice the symmetry and the
decreased domain of change. We caution the reader that u may already be
a knot, and it may be undesirable to insert it. For example, let C(u) be a
quadratic curve on U = {O,O,0,1/4, 1/2,3/4,1,1,1} (see Figure 11.5). The nodes
are ti = {O,1/8,3/8,5/8,7/8, 1}. If the designer picks the point for which u = 1/2,
then by Eq. (11.6) u = 1/2. If u = 1/2 is inserted then u becomes the node t3,
and if Q3 (= C( 1/2)) is moved, the resulting curve has a cusp at u = 1/2, as
shown in Figure 11.5.
Suppose we now want to move P = C(u) along Va distance d by translating
both P k and Pk+1 in the direction V (assuming u E [Uk+ 1, Uk+p+1) ). Letting
Figure 11.4. Repositioning a new control point obtained by knot insertion; the curve
degree is three.
o ~ "( ~ 1, we set
Pk = Pk + (1 - "()aV
The parameter "( allows us to vary, on a linear scale, the movement of Pk and
Pk+1 relative to one another. The designer can set ,,(, or a good default is
(11.8)
Figure 11.5. Repositioning a new control point obtained by knot insertion; the curve
degree is two.
Control Point Repositioning 515
(11.9)
Figure 11.6a shows the curve of Figure 11.3. Both P 3 and P 4 were moved,
with 'Y = 0.47 (the default computed by Eq. [11.8]). Clearly, the disadvantage
with this method is the broader domain of change, namely [Uk, Uk+p+2). In
Figure 11.6b P 3 and P 4 were moved, with 'Y = 4/5.
Using these tools, it is easy to implement a user-friendly, interactive, graph-
ical interface for control point repositioning. Notice that the value Rk,p(U) in
Eq. (11.3) does not change when Pk is repeatedly translated along the same vec-
tor direction (therefore neither does a). Furthermore, only that portion of the
curve which is the image of [Uk, Uk+p+1) need be graphically updated for each
(a)
(b)
Figure 11.6. Simultaneous repositioning of P3 and P 4 ; u = 0.43. (a) "( = 0.47 (the
default); (b) "( = 4/5.
516 Shape Modification Tools
(11.10)
with (11.11)
Either the designer selects k and C, or the system chooses them based on the
proximity of u and v to the u and v nodes, Si and tj, defined by
1 p
Si = - LUi+r i = 0, ... ,n
p r=l
1 q
tj = - LVj+r j=O, ... ,m (11.12)
q r=l
Using formulas analogous to Eq. (11.6), a U or v knot, or both, can be computed
and inserted in order to decrease the domain of change and to bring u and/or v
to nodal positions. If 0 ~ 8" ~ 1, then Pk,e, Pk+ 1,e, Pk,£+ 1, and Pk+ 1,£+ 1 can
be translated simultaneously in the direction V by
Figure 11.7. Pulling the curve with equal increments by repositioning P4; il = %.
with (11.14)
Figures 1l.8a and 1l.8b show translation of one control point, and Figures 1l.9a
and 1l.9b illustrate simultaneous movement of four neighboring control points.
y
x
(a)
Figure 11.8. Repositioning P 4 ,3, with il = v = 0.55. (a) Control net; (b) a surface with
a local patch translated parallel to the direction of the control point movement.
518 Shape Modification Tools
z
y
x
(b)
Figure 11.8. (Continued.)
Analogous to the curve case, knot insertion can be used to restrict the rectan-
gular domain on which the surface is to change, and inverse knot insertion can
be used to obtain additional control points at specified locations on the edges of
the surface's control net. Point Qu, in the u direction, is inserted by the formula
(11.15)
with
(11.16)
y
x
(a)
y
x
(b)
Figure 11.9. Repositioning four surface control points, P4,3,P5,3,P4,4, and P 5 ,4, with
U= v = %. (a) Control net; (b) a surface with a local patch translated parallel to the
direction of the control point movement.
520 Shape Modification Tools
Let n
C(U) = L~'P(U)Pi (11.17)
i=O
- L -Ni,p(U)WiNk,p(U) p.
-;# (~N"(.)W.)' ,
Nk,p(U) (tNr,p(u)wr) - Nk,p(u)Nk,p(U)Wk
+ r=O 2 Pk
(~N"(.)W" )
= L n-Nk,p(u) ~,p(U)Pi
i# LNr,p(u)wr
r=O
Weight Modification 521
an+1C(u) _ a[a(n)(Pk-C(u))l
awz+1 - aWk
where
anaw
+1c(u)
+ = a(n+1) (P _ C(u))
k n = 1, 2, ... ,00 (11.19)
n 1
k
Equations (11.18)-(11.20) prove that an arbitrary curve point, C(u), moves along
a straight line toward Pk as Wk increases in value.
We now take a more geometric approach. Starting with the curve of Eq.
(11.17), let Wk vary, 0 :S Wk < 00. Denote the family of resulting curves by
C(u; Wk) (see Figure 11.10). Assume U E [Uk, Uk+p+1), and define the points
R = C(U;Wk = 0)
M = C(U;Wk = 1)
P = C(u; Wk # 0,1) (11.21)
Notice that Rand M are points on specific curves, but P can lie anywhere on
the line between Rand Pk, for Wk 2: O. Now M and P can be expressed as
M = (1- s) R + sPk
P = (1 - t) R + tPk (11.22)
522 Shape Modification Tools
Po
where
LNi,P(U)Wi + Nk,p(U)
i#
(11.23)
LNi,P(U) Wi Pi
R= _i#_k_________ Wk =0
LNi,P(U)Wi
i#
LNi,P(U) Wi Pi
'#
• n + Rk,p(U)Pk
LNi'P(U)Wi
i=O
Weight Modification 523
LNi,p(u)Wi
if.k
= n R + Rk,p(U)Pk
LNi'P(U)Wi
i=O
LNi,P(U)Wi + Nk,p(U)
if.k
From Eqs. (11.22) and (11.23) we have
_- -s-
1- s /1-
--t- -
t _ Pk M /
RM
PkP
RP (11.24)
524 Shape Modification Tools
Equation (11.24) says that Wk is the cross ratio of the four points, Pk , R, M, and
P, denoted by (Pk , R; M, P) (see [Coxe74; Boeh94]). The cross ratio is a funda-
mental quantity of projective geometry. With respect to shape modifications of
NURBS curves, we mention the following consequences of Eqs. (11.21)-(11.24):
• as Wk increases (decreases), t increases (decreases), thus the curve is pulled
(pushed) toward (away from) Pk ;
• P moves along a straight line segment passing through Pk ; thus, a modi-
fication of Wk changes the curve in a predictable manner;
• as P approaches P k , t approaches 1 and Wk tends to infinity.
Now suppose the point P = C(u) is to be pulled (pushed) toward (away from)
Pk to a new location, P, by modifying Wk. Set d = PP = IP-PI. The required
new weight, Wk, is derived as
PkM.(RP±d)
=
A
Wk
RM.(PkP =j= d)
PkM·RP ± d·PkM
RM.PkP =j=d·RM RM.(PkP =j=d)
PkM·RP
Using
Wk = RM.PkP
we have
(11.25)
Where ± or =j= appears, the top sign is to be taken in case of a pull operation,
and the bottom sign in case of a push operation [Pieg89c].
To implement a user interface for modification of one curve weight, a designer
picks a point P on the curve and a point on the control polygon. The system
Weight Modification 525
computes the parameter u such that P = C(u). If the picked point on the control
polygon is not already a control point, the system makes it a control point by
using inverse knot insertion. Denote the control point by Pk • The system then
draws a line through P and Pk . The designer picks the point P on this line,
allowing the system to then compute d, and finally Wk from Eq. (11.25). The
reader should note that
• two user picks determine u and k. It is possible (but not likely) that
u ~ [Uk, Uk+p+1); the system should catch this and report it to the user as
an invalid pick;
• in Eq. (11.25), the values Rk,p(U) and PkP change with each modification
of Wk, even when k and u remain constant; thus, if interactive incremental
or continuous modification of the weight is desired, it is best to save the
original Rk,p(U), Wk, and PkP values and use them to compute new d and
Wk values at each step;
• if we fix the weight change, f).wk, and consider the distance d(u) =
IC(U;Wk) - C(u;wk)1 as a function of u, it follows from Eq. (11.25) that
d(u) attains its maximum at the maximum of Rk,p(U) (Figure 11.11);
• from a practical point of view, weight modification can/should only be
used to effect small changes in a curve. For pull operations Pk is clearly
a built-in bound on possible length of pull. This bound can be quite
restrictive, particularly in cases where Pk was added through inverse knot
insertion. Moreover, even moderate push/pulls often require substantial
modifications in a weight; and widely varying weights can induce very poor
Figure 11.13 shows an example ofincremental pulls. Note the exponential change
of weights.
(11.27)
Figure 11.12. Pulling the curve at u = 0.46 a distance d = 0.075 toward P4 by changing
the weight W4 = 0.2; the new weight computed is W4 = 0.97.
Weight Modification 527
0.4 1.63
I I I I I c=- W4
0.2 0.77 6.11
Figure 11.13. Pulling the curve at t4 = U = 0.52 with equal increments ~ = 0.022
toward P4 by changing the weight W4 = 0.2; the new weights computed are W4 =
{0.4, 0.77,1.63, 6.11}.
Po
_ Nk+!,p(U)Wk+!
with n ak+1 - n (11.28)
LNi,p(U)Wi LNi,p(U)Wi
i=O i=O
Equation (11.27) says that P lies on the plane of the barycentric coordinate
system (RPk Pk+d (readers not familiar with barycentric coordinates should
consult Boehm and Prautzsch [Boeh94] or Farin [Fari93]). Assume now that P
moves to a new position, P. We must determine the new weights, Wk and Wk+I,
which cause the desired movement. By Eq. (11.27) P can be expressed as
Nk,p(U)Wk Nk+!,p(U)Wk+!
with
A A _
ak = d ak+! - d
(11.30)
(11.31)
where A, B, C, and D are points along Pk Pk+1 such that P A and PC are
parallel to RPk , and PB and PD are parallel to RPk+!. To have nonvanishing
ak, U must be within [Uk, Uk+p+!); similarly, for nonvanishing ak+! U must be
within [Uk+l, Uk+p+2). If P is chosen so that U is within the intersection of
these intervals, neither ak nor ak+! vanishes, and consequently P can be placed
Weight Modification 529
anywhere within the triangle RPkPk+1. If, however, U E [Uk, Uk+1), then ak+1 =
o and Eq. (11.27) degenerates to
(11.33)
Figure 11.15. Simultaneous pull at u = 1/2(t4 + ts) = 0.608 a distance d = 0.088 in the
direction of RQ by changing W4 = Ws = 0.05; the new weights are U4 = Ws = 1.23.
The curve change is neither perspective nor parallel.
530 Shape Modification Tools
Figure 11.14). These components, including the line segment RQ, are drawn on
the screen. The designer can now interactively reposition P along the line R Q
while the system computes new weights and redraws the affected curve segment.
Of course, the designer should be able to override the default, u, and the default
line segment, RQ.
Another scenario is to allow the designer to pick the curve point, P (and
thereby u), and the system subsequently chooses the polygon leg P k Pk+! by
finding two nodes, tk and tk+!, such that tk < u < tk+!' However, this is prob-
lematic if u is equal to or close to a node, as the push/pull effect is asymmetric if
a polygon leg is arbitrarily chosen. In this case a knot, il, can be inserted, which
puts u halfway between two nodes. Specifically
1 (
= 2 Uk+! + Uk+p + 2il + 2 L
k+p-l
Uj
)
P j=k+2
u
However, we caution the reader that may already be a knot; furthermore, the
resulting new polygon leg, PkPk+1. may pass very close to P = C(u), in which
case the available pull length is very limited.
Finally, note that we assumed previously that the two control points whose
weights we modified were neighbors. This was done because it yields pleasing
results and is generally what is desired. However, the derivations of Eqs. (11.27)-
(11.32) do not make use of this assumption. In fact, if P r and P s are chosen,
then the only requirement is that u E [u r , ur+p+d and u E [us, us+P+1), so that
the barycentric coordinates, ar and as, do not vanish. See [Pieg89cj for more
details of this case.
Modification of a single surface weight, Wk,l, is similar to the curve case. Assume
u E [Uk, uk+p+d and v E [Vl, Vl+q+1), and define
R = S(u, v; Wk,l = 0)
M = S(U,V;Wk,l = 1)
P = S(u, v; Wk,l i= 0,1) (11.35)
M = (1 - s) R + s Pk,l
P=(l-t)R+tPk,l (11.36)
where S
Nk,p(u)Nl,q(V)
= -------"-'--'----'-':...:......'------
L LNi,P(u)Nj,q(V)Wi,j + Nk,p(u)Nt,q(v)
i,ji'k,l
(11.37)
(i,j i= k,1! means exclude the (k,l!)th term.) Using Eqs. (11.36) and (11.37), one
obtains the cross ratio
• P moves along a straight line segment passing through Pk,l; thus, a mod-
ification of Wk,l changes the surface in a predictable manner;
• as P approaches Pk,l, t approaches 1 and Wk,l tends to infinity.
(11.39)
x
/ y
Figure 11.17. Surface push at u = v = 0.55 toward P4.3 a distance d = 1; notice the
perspective change in surface shape.
Shape Operators 533
P s ,···, P e - p- 1 (11.40)
where p is the degree of the curve. After the shaping operation, knot removal
typically removes many of the inserted knots. If the curve is not to be modified
outside [us, u e ], then only the following knots are candidates for removal
. p P 1
t=s+ "2, ... ,e-"2- if p is even
. p+1 p+1
t=s+ -2-, .. ·,e- -2- if p is odd (11.41)
11.4.1 WARPING
Warping is a tool which can be used to rather arbitrarily deform a local seg-
ment of a curve or region on a surface. First consider curve warping, which is
534 Shape Modification Tools
(11.42)
R 3,3 () N3,3(t)W3
t = -6::--'-':"':"':'-'--'-- (11.44)
L Ni,3(t)Wi
i=O
II 3 }
T= { 0,0,0,0'4'2'4,1,1,1,1 (11.45)
and weights
Wi = {I, 1, 1, W3, 1, 1, I}
Figure 11.18 shows f(t) for several different values of W3. Clearly, functions
of this form are appropriate for pulling out a bump or pushing in an indenta-
tion in a curve. Now suppose W3 is fixed and the designer specifies a maximum
f(tj W3)
1
Figure 11.18. Warping functions using the rational basis function R3,3(tj W3) with
W3 = {lI5, 1, 30}.
Shape Operators 535
where N(u) is the unit normal vector of C(u), and u(t) = (u e - us)t + us;
• the constant direction given by
(11.47)
The interval [us, ue ] is now refined, yielding control points Pi, i = s, ... , e-p-1
(Eq. [11.40]), which can be repositioned according to Eq. (11.42). In order to ap-
ply that equation, we must assign a parameter ti to each Pi, i = s, . .. ,e - p - 1.
Let 6 denote the total accumulated chordal distance along the control polygon
from P s- 1 to P e - p ' Denote by ti the accumulated chordal distance from P s- 1
to Pi, normalized by 6. Notice that 0 :::; ti :::; 1 for s :::; i :::; e - p - 1. Then Pi
is repositioned by
i = s, ... , e - p - 1 (11.48)
_.e._
0"- --&
/
d
/
/
,,
/
>
,
/
/
/
C(u s ) C(u.) ",
/
riJ \11
\
I.
I
W \
,
(a)
Figure 11.19. Curve warping. (a) The original curve with span [C(us), C(u e )] to be
warped in the direction of W a distance dj (b) a curve span refinedj (c) control points
repositionedj (d) knots removed.
536 Shape Modification Tools
,I
(b)
,
/.
/.
,
(c)
/. ,,
/.
,
(d)
Figure 11.19. (Continued.)
W3 = 1/5
1
30
(a)
(b)
0.10
0.15
(c)
Figure 11.20. Curve warps (a) using different weights W3 = {lis, 1, 30}; (b) using differ-
ent directions with W3 = 20; (c) using different distances d = {0.05,0.1,0.15}.
• for interactive warping the designer may wish to select a curve point which
is to be the center of the warp, and then to modify on a sliding scale the
magnitude d, the weight W3, and the extent of the warp segment. The
segment is chosen to be as symmetric as possible about the warp center,
measured in distance along the control polygon. Knot removal is done
after completion of the interaction; knot refinement must be done either
as a preprocessing step (either on the entire curve, or on a user-specified
"maximum" segment), or the refinement must be updated (expanded) as
the segment length is expanded;
538 Shape Modification Tools
f(t)
4---------------------------~~ t
(a)
f(t)
4----------------------------+-=-t
(b)
Figure 11.21. Curve warps with different shape functions.
Shape Operators 539
(11.49)
Analogous to curve warping, knot refinement is applied to the area [u", u/3] x
[v1" vol (shown by dashed lines in Figures 11.22a and 11.23a) before using Eq.
(11.49). Knot removal is applied in the appropriate region (see Eq. [11.41]) as
a postprocessing step. A parameter pair (Si' tj) must be associated with each
control point Pi,j, i = a, ... , (3 - p - 1, j = 'Y, ..• ,fJ - q - 1. These parameters
are used to determine which Pi,j are to be repositioned and to evaluate the func-
tions f and W of Eq. (11.49). Analogous to curve warping, we use normalized
accumulated chord length. In particular, we apply Algorithm A9. 3 to the set of
points Pi,j, i = a-I, .. . ,(3 - p and j = 'Y - 1, ... ,fJ - q. A Pi,j is repositioned
by Eq. (11.49) only if (Ui' Vj) is in the warp region n, where
f can be any scalar-valued function defined on [0,1] x [0,1]. As was the case
for curves, B-spline basis functions are appropriate for pulls and pushes. For
example, the normalized, bivariate, bicubic, rational B-spline basis function is
suitable for rectangular regions
-r - - - - - - - -t
+ + +++
I + + +++ I
+ + + ++
I + + +++ I
+ + +++
I + + + + +++++++++ + + + +
I + + + + + +++++++ + + + + +
+++++++++++++++++
I +++++++++++++++++
+ + + ++++++++t ++++
+ +
+ + + + ++++++++
+ +
+ + + +++++++++++ I
+ +
+ + + +++++++++++
+ +
+ + + + + + ++++++++ I
+ + + + + +++++++++++
++++++ I
++++++
I ++++++ I
++++++
I ++++++ I
++++++
1- - - - - - - - -l
(a)
Figure 11.22. Surface region warping. (a) A region with bounding box and control
points local to the region; (b) a surface warp after control point repositioning.
540 Shape Modification Tools
(b)
s= { 0,0,0,0'4'2'4,1,1,1,1
1 1 3 }
and 1 1 3
T = { 0,0,0,0, 4' 2' 4,1,1,1,1
}
All weights are set to 1 except W3,3, which is freely chosen. As another example,
a rotated, univariate B-spline basis function can be used if the desired warp
region exhibits circular symmetry.
Defining a warping function over arbitrary domains is difficult. The region
warps of Figures 11.22 and 11.23 were created using the simple function
l(s,t) = {I if (u(s),v(t)) E R
° otherwise (11.51 )
where
This warping function acts like a die punch, i.e., each control point for which
Shape Operators 541
I I
---~----- -----,---
----+-
I
(a)
Figure 11.23. Surface region warping. (a) A region with bounding box and control
points local to the region; (b) a surface warp after control point repositioning.
is a curve lying in the parameter space of S (u, v), and r is a distance measured
to both sides of C(A) along the line normal to C(A) at each A. Surface curve
warping is applied by repositioning all those surface control points Pi,j whose
parameters (U(Si),V(tj)) lie within distance r of C(A) (the field of gravity). The
relevant Pi,j are moved according to the formula
(11.53)
where di,j is the distance of (U(Si), v(tj )) to C(A), and Ai,j corresponds to the
projection of (U(Si),V(tj)) onto C(A). A reasonable definition of the warp direc-
tion is
W(A) = N(C(A)) (11.54)
where N(u, v) is the surface normal vector.
542 Shape Modification Tools
(b)
Figure 11.23. (Continued.)
I if di,j :S r
f ( d ij ) = {
, 0 otherwise (11.55)
The critical step in applying Eq. (11.53) is the computation of the di,j. This
is simplified if C('x) is a polyline. Figures 11.24 show an example of a polyline
warp. Figure 11.24a depicts the acronym NURBS described as five polylines.
Figure 11.24b shows the bounding box of the control points (marked with +s)
that lie within the gravity fields of the five letters. The final polyline warped
surface is illustrated in Figure 11.24c.
11.4.2 FLATTENING
The flatten operator allows a designer to easily introduce straight line segments
into curves and planar regions into surfaces. No multiple knots are inserted,
so the transition from the curved portions of the curve or surface into the flat
portions possesses the smoothness inherent in the original geometry.
Consider curve flattening first, as shown in Figures 11.25 and 11.26; a curve,
C(u), and a line, L, are given. Curve flattening consists of three steps:
Shape Operators 543
(a)
(b)
Figure 11.24. Surface polyline warping. (a) A polyline representing the acronym
NURBSj (b) control points local to the gravity field of the polylinej (c) a surface
polyline warp after control point repositioning.
"
(c)
Figure 11.24. (Continued.)
In addition to Land C(u), the following items can be specified, either by the
designer or defaulted by the system (Figure 11.25a):
• a vector, W, defining the line of projection, i.e., 1\ = Pi + oW (0 can
be negative or positive); this vector can be defaulted to be perpendicular
to L;
• parameters Us and u e : A control point, Pi, is projected only if it is local
to the interval [us, u e], Le., i = s, .. . , e - p - 1;
• two points, Ql and Q2, on the line L; a control point, Pi, is replaced by
its projection, Pi, only if Pi lies within the segment Ql Q2'
Notice that the last two items are rules indicating which Pi to project and which
Pi to accept, respectively. For the situation shown in Figure 11.25a, setting
Ql = C(us) and Q2 = C(u e) to be the points where L intersects C(u) is a
reasonable system default. If the curve is xy planar and intersects L, as in
Figure 11.25a, another intuitive rule is to project only those Pi which lie to one
side of L, as shown in Figure 11.25b. If only those control points are projected
which are local to [us, uel, unexpected results can occur if L intersects the curve
(Figure 11.25c). If the curve does not intersect L, projecting all control points
local to [us, uel flattens the segment [C(u s ), C(u e)], leaving the rest of the curve
unaffected. This is illustrated in Figures 11.26a and 11.26b.
Finally, we caution that a flat segment is obtained only if the projection results
in at least p + 1 consecutive points, Pi, where p is the degree of the curve. If
Shape Operators 545
Pi
w
e) , C(U
----~~~~----~~----~----~~----~He,~--~--L
,,
,
Q
I
I.
I \
,
(a)
--
/ ,
I \
I \
b
(b)
'- --
(c)
Figure 11.25. Curve flattening. (a) The original curve with span [C(Us), C(u e )] to be
flattened in the direction of W to the line L intersecting the curve; (b) a flattened
curve obtained by projecting all control points lying on one side of L; (c) a flattened
curve obtained by projecting control points local to the span [us, u e ].
this fails to be the case, then more knot refinement is required. If Us and U e are
specified, then refinement is required only in the interval lUi, Uj]' where Ui is the
largest knot satisfying Ui < Us, and Uj is the smallest knot such that U e < Uj.
546 Shape Modification Tools
,,
C(U e )
\
\
\
~ - - - -.-::-:-=-~--~
(a)
(b)
Figure 11.26. Curve flattening. (a) The original curve with span [C(us), C(u e )] to be
flattened in the direction perpendicular to the line L not intersecting the curve; (b) a
flattened curve obtained by projecting control points local to the span [us, u e ].
11.4.3 BENDING
Several authors have investigated circular bending of curves and cylindrical bend-
ing of surfaces, e.g., see references [Barr83; Four83; Cobb84]. These authors de-
velop equations based on trigonometry, which map points onto circles. Under
these mappings a straight line segment maps onto a circle, and a general curve
segment is bent in a circular fashion. Cobb [Cobb84] applies this technique,
together with knot refinement, to map control points, thereby bending B-spline
curves and surfaces.
We take a more general, geometric approach to bending. Analogous to the
other shape operators, bending takes place in three steps:
1. refine the region of the curve or surface to be bent;
2. bend the region by repositioning control points;
3. remove unnecessary knots.
Only Step 2 requires elaboration. Consider curves first (see Figure 11.28). We
bend the region of the curve C(u) between C(us) and C(u e ) about the bend
curve, B(w), by mapping the relevant control points, Pi of C(u), ''toward''
B(w). Assuming Us and U e are knots, only Ps , ••• , P e - p - 1 are mapped. Denote
the image of Pi by Pi. We require one additional point, 0, called the bend
center. Points ~ are obtained by intersecting each line segment, OPi , with
B(w). Finally, fixing a cross ratio, .x, the location of each Pi is determined by
.x, 0, R i , and Pi as follows. Analogous to Eq. (11.22), we have
548 Shape Modification Tools
(a)
(b)
Figure 11.27. Surface flattening. (a) A surface and plane; (b) a flattened surface ob-
tained by projecting all control points lying on one side of the plane.
Shape Operators 549
B(w)
Pi
C(U e )
Finally
yields (11.58)
00 ! B(w)
,
,,
A=1
A=2
C(u)
Figure 11.29. Curve bending examples using a circular arc as the bending curve B(w)j
the cross ratios are A = Ph, 1,2, 5}.
Shape Operators 551
B(w)
03
o I
I
\ I
\
, /
/
I
/
/
/
C(03)---~
Figure 11.30. Curve bending examples obtained by using different positions of the bend
center.
are obtained as the intersections of the line segments, 0 Pi';, with the surface,
B(s, t). If a curve, O(w), is given, then parameters Wi,j must be computed, and
the Ri,j are obtained by intersecting o (Wi,j)Pi,j with B(s, t). The Pi,j are then
computed using
O(W·t" ·)R··
or Si,j = O( )P
t"
(11.59)
W··
'&,3
..
'1.,3
(11.60)
Finally
p.'&,3·=(1-t··)O+t··p··
'&,3 ~J ~3
or p. ·=(1-t· ·)O(w·t,3·)+t·1,3.p.. (11.61)
~J ~J ~3
Subsequently, the unmapped control points must be rotated and translated into
positions which ensure a smooth and natural transition of the bent region into
the unbent region. Knot removal is applied as a final step. For example, one
obtains a spherical bend by letting B(s, t) be a sphere, with 0 its center. A
cylindrical bend is produced if B(s, t) is a cylinder and O(w) is its axis.
In its full generality, surface bending is clearly complex. The computation of
Ri,j requires line/surface intersections, obtaining suitable parameters Wi,j can
be difficult, and it is not obvious how to rotate and translate the unmapped
control points. We detail here the special case of general cylindrical bends about
the full length of an isocurve of a surface; that is, the bend region has one of
the forms [un, u{3l X [Vmin, vmaxl or [Umin, umaxl x [v"' vol, and B(s, t) is a general
circular cylinder obtained by sweeping a circle along the (possibly curved) axis,
552 Shape Modification Tools
/
/
/
""
/
/
/
/
S(u,v)
(11.62)
where N(u c , v) is the unit length surface normal vector at (u c , v) and d is a con-
stant offset distance. We remark that, in general, the shape of 0 (v) can be rad-
ically different from that of CUe ( V ), and 0 (v) cannot be represented precisely as
a NURBS curve (e.g., see [Till84; Coqu87b; Hosc88]). However, we assume here
that 0 (v) is well-behaved and similar in shape to CUe (v); for surface bending this
is a reasonable assumption. Moreover, we only need to compute selected points
on 0 (v) (using Eq. [11.62]); we do not require an explicit NURBS representation
of O(v). Finally, we note that in this case the parameter w corresponds to v.
The second method of defining 0 (w) is to let it be a straight line lying in the
plane defined by CuJv). In this case w does not correspond to v. By computing
a least squares plane (defined by the control points of CUe (v) ), this method can
be used even for nonplanar CuJv).
S( u, v) is bent by applying the curve bending method to the m + 1 rows of
control points; i.e., for j = 0, ... ,m, do the following:
1. for i = s, . .. ,e - p - 1:
1a. compute Wi,j so that 0 (Wi,j) is the point on 0 (w) closest to Pi,j; if
o (w) = Q +wV is a straight line, then Wi,j is given by the formula
(11.63)
Figure 11.33. Surface bending examples with a nontouching cylinder, >. = {Ij2, 3/2, -3}.
Figure 11.34. Surface bending examples with a touching cylinder, >. = PlIO, I, -I}.
Constraint-based Curve and Surface Shaping 555
Let C(u) = l:~=o ~,p(u) Pi be a NURBS curve. Suppose we are given parameter
values {u r }, r = 1, ... , R, and a set of derivative constraints, {AD~)}. AD~)
denotes the change in the kth derivative at U = U r . k can have any nonnegative
value, but typically k = 0, 1,2, because these are the values which control the
intuitive geometric properties of position, tangent, and curvature. Notice that
we specify constraints in terms of changes in derivatives, not in terms of the
target values.
Now fix k and r, and denote by D~) the kth derivative of C(u) at u = U r . Then
n
where R~k)
I,p denotes the kth derivative of the basis function. If the curve is
nonrational, the derivatives of the basis functions are computed using Algorithm
A2.3. Otherwise, the R~~~ are computed utilizing the same technique that was
used in Section 4.3 to obtain the derivatives of a rational curve, that is
(11.66)
with
556 Shape Modification Tools
or for brevity
BLlP = LlD (11.71)
For the moment, assume Af < lV. There exist infinitely many solutions to
Eq. (11.70). We want the minimum length solution, i.e., the one which minimizes
the combined movements of all control points (the one which minimizes the
length of the lV-dimensional vector, LlP). From linear algebra, we can write the
lV vector, LlP, in terms of two mutually orthogonal components, one in the row
space of B and the other in the null space of B, that is
(11.72)
LlD = BLlP
= B (BT,\+z)
= BBT)"+Bz
=BBT,\ (11.74)
and therefore
(11. 75)
Since the components of z are irrelevant to the system, yet they contribute to
the length of LlP (by Eq. [11.73]), we obtain the minimum-length solution to
Eq. (11.70) by setting z = O. Substituting Eq. (11.75) into (11.72) leads to
The matrix BBT is nonsingular if the rows of B are linearly independent. Finally,
if Af = lV there is a unique solution to Eq. (11.70) given by
We remark that it is also possible (and quite useful) to restrict certain control
points from changing. This is accomplished (mathematically) simply by setting
the corresponding column of B to zero. Algorithmically, this means that the
corresponding ~Pil does not appear in Eq. (11.70), and N is reduced by 1.
Normally, a constraint affects p + 1 control points, and up to p + 1 constraints
can be specified in any span. If a control point is restricted not to move, then
this reduces to p the number of constraints that can be specified in any span
influenced by this control point. We give examples of this below.
Equation (11.76) (or Eq. [11.77]) represents the first step in the solution pro-
cess. Before proceeding to the second step, we summarize the sequence of events
which brought us to this point:
1. the designer picks points on the curve, yielding parameters {u r } (deter-
mined by the system) at which constraints are to be imposed; he simul-
taneously indicates what types of constraints are to be imposed at each
parameter, but actual constraints need not be specified at this stage;
2. the system sets up Eq. (11.70); if it is overdetermined, the system either
informs the designer so that he can modify his selections, or it adds control
points by means of knot insertion and/or degree elevation in such a way
that the resulting equation system is under- or fully determined;
3. the matrix A is then computed, either by Eq. (11.76) or (11.77).
The designer can now interactively specify constraints [~Dj]. With each
change in constraints, the matrix A must be multiplied with the new vector
[ ~D j] to yield the changes in control point locations, [~P it]. The relevant
control points are then updated by
i= 1, ... ,N (11.78)
Example
Exll.1 Figure 11.35a shows a cubic curve defined by Po, ... , P 7 , and U =
{0,0,0,0,l/5,2/5,3/s,4/5,1,1,1,1}. We apply one point constraint at
U= 1/2
~D1 = ~D(~) = (0.04, -0.08,0)
Then B~P= [~Dl]
C(u)
(a)
(b)
Figure 11.35. Constraint-based curve modification using positional constraints. (a) The
original cubic curve with point to move; (b) all four local control points are allowed to
move; (c) only P 3 and P 4 are allowed to move; (d) only P 3 is allowed to move.
with components
It follows that
i = 2,3,4,5
The result of applying the ~Pi is shown in Figure 11.35b. Note that P3
and P 4 move the most, because these control points have the greatest
560 Shape Modification Tools
Pa
P4
_B_
=:::.::---:.---- '_...
(c)
Pa ,
,,
,
,, ,
//
/
""
4
II
I'
"
, , ,,
I'
_-;"'~:/_-1
/,
,,// Pa
,
(d)
Figure 11.35. (Continued.)
and D.P has components D.P3 and D.P4 . A has components ao and a1
(not the same as ao, a1 above), and
i = 3,4
Figure 11.35c shows the result of allowing only P 3 and P 4 to change, and
Figure 11.35d illustrates the case in which only P 3 is allowed to move.
Constraint-based Curve and Surface Shaping 561
This example clearly shows that for a given set of point and derivative con-
straints there is often flexibility in specifying how many and which control points
should change, and this choice affects both the extent and the appearance (e.g.,
symmetry) of the corresponding curve change. However, dealing with control
points can be less intuitive to a designer than imposing pure point and derivative
constraints on a curve. A good user interface should package both a reasonable
set of defaults and convenient handles for the more sophisticated designer to re-
strict control point movement. Finally, notice that any control point restrictions
must be worked into Eq. (11.70) and into the first stage of the solution process.
In Figures l1.36a-11.36c point and derivative constraints are illustrated. Fig-
ure l1.36a shows the application of a derivative constraint only, while allowing
P3, P 4 , and P 5 to move. The magnitude of the first derivative vector is increased
at u = 0.556, resulting in a local tension effect. It is interesting to observe what
happens if only one control point is allowed to move, as shown in Figure l1.36b.
The curve assumes the new derivative, but it suffers a positional displacement
due to the absence of a positional constraint. In Figure l1.36c this problem is
remedied by constraining the curve not to move at u = 0.556, and to assume a
new derivative obtained by decreasing the magnitude of the old one. Two con-
trol points are allowed to move in order to obtain a system of equations which
is not overdetermined.
In closing, we remark that Fowler and Bartels [Fow193] give a different (but
equivalent) method to represent matrix A in Eqs. (11.76) and (11.77). It is
somewhat more complicated mathematically but is more efficient in some cases.
,,
,
,
, I
",
, I
•
"
(a)
Figure 11.36. Constraint-based curve modification using positional and derivative con-
straints. (a) Derivative constraints are applied and P 3 , P 4 , and P s are allowed to move;
(b) derivative constraints are applied and only P 4 is allowed to move; (c) derivative
and positional constraints are applied, and P 3 and P 4 are allowed to move.
562 Shape Modification Tools
(b)
(c)
Figure 11.36. (Continued.)
Let S( u, v) = 2:~=0 2:;:0 Ri,p;j,q(u, v) Pi,j be a (p, q)th degree NURBS surface.
In this section we choose to write S( u, v) in the form
(n+l)(m+1)-l
S(u,v) = L Rs(u,v)Ps (11.79)
8=0
where s=j(n+1)+i (11.80)
Constraint-based Curve and Surface Shaping 563
. s
where i=smodn+l J = n+l (11.82)
The partial derivatives R~' l) (( u, V)r) can be computed in exactly the same way
as the S(k,l)(u, v) described in Section 4.5. Then, as was the case for curves, we
can set up the M x N system of linear equations
ALGORITHM Al1.1
ConstBasedSurfModl(n,m,p,q,U,V,Pw,CList,R,M,N,A,CpInd)
{ /* Build the A matrix for surface constraints */
/* Input: n,m,p,q,U,V,Pw,CList,R */
/* Output: M,N,A,CpInd */
Loop through the list CList and count constraints
to obtain M.
Nmax = Max«n+l)*(m+l),R*(p+l)*(q+l)); /* Max possible N */
for (i=O; i<M; i++)
for (j=O; j<Nmax; j++) B[i] [jJ 0.0;
for (i=O; i<=n; i++)
for (j=O; j<=m; j++) Map[i] [j] -1;
brow = 0; N = 0; /* N is computed in this loop */
for (r=l; r<=R; r++)
{
Extract (u,v) value from the rth list node.
FreeCtrlPts(u,v,FreeCp);
uspan = FindSpan(n,p,u,U);
vspan = FindSpan(m,q,v,V);
for (i=O; i<=p; i++)
Constraint-based Curve and Surface Shaping 565
(a)
x y
(b)
w
n,
f 1\
j~ \\
\ '
\ '
y
x
(a)
y
x
(b)
(a)
(b)
Figure 11.39. Constraint-based surface modification with positional and derivative con-
straints. (a) An increase in partial derivative magnitudes induces a local tension effect;
(b) a change in partial derivative directions induces a local twist effect.
Constraint-based Curve and Surface Shaping 569
allowed to move. Finally, in Figures l1.39a and l1.39b partial derivative and po-
sitional constraints are applied. In Figure l1.39a the magnitudes of the partials
are increased, resulting in a tension effect, whereas in Figure l1.39b the partials
are rotated about the point S(1/2, 1/2), yielding a twist in the surface shape.
In closing, we remark that Fowler [FowI92] gives an alternative (equivalent)
solution for solving for the ~ Pi,j, which makes use of the tensor product struc-
ture of S(u, v). It is less general than this method, but in some cases it is
more efficient.
CHAPTER
TWELVE
12.1 Introduction
The central theme of this chapter is the relationship of NURBS geometry, as
practiced in this book, to other methods of representing curves and surfaces,
and to several important standard formats for the exchange of geometric data
between two systems. We have used a specific form of knot vector throughout
this book; Section 12.2 discusses another type of knot vector and the conversion
between the two types. Section 12.3 describes how NURBS curves and surfaces
are defined within the three standards: IGES, STEP, and PHIGS. We remark
that our NURBS are compatible with the NURBS of these standards (with
the exception that IGES and PHIGS allow discontinuous curves and surfaces).
Finally, Section 12.4 gives some general guidelines for exchanging geometric data
between a NURBS system and another system.
clamped, nonuniform:
{0,0,0,2,3,6,7,7,7}
{0,0,0,0,1,2,2,3,4,5,5,5,5}
572 Standards and Data Exchange
unclamped, uniform:
U1 = {-3, -2, -1,0,1,2,3,4, 5}
U2 = {O, 1,2,3,4,5,6,7,8,9, 10, II}
unclamped, nonuniform:
{0,0,1,2,3,4}
{-2, -1, 0, 4, 5, 6, 7}
Hence clamped/unclamped refers to whether or not the first and last knot values
are repeated with multiplicity equal to degree plus one, and uniform/nonuniform
refers to the knot spacing. To be uniform and unclamped, all knot spans must
be of equal length. To be uniform and clamped, only the "internal" knot spans
must be of equal length. The reader has probably noticed that what we are
now calling clamped, uniform and nonuniform, is exactly that which we have
called nonperiooic, uniform and nonuniform, up to now. Following a brief study
of unclamped knot vectors, we will offer a flimsy excuse for this changing of
the terminology horse in the middle of the knot stream. Since clamped knot
vectors are assumed throughout the book, they require no further elaboration
here. However, before proceeding to a study of unclamped knot vectors we offer
the following reminders relative to clamped knot vectors:
• if we are given a clamped knot vector with m + 1 knots and end multiplic-
ities of p + 1, then we require n + 1 (= m - p) control points to define a
pth degree curve; that is, the knot vector determines the degree, number
of control points, and the valid parameter range;
• clamped curves can be open or closed, geometrically; if a curve is closed,
then whether or not it is closed with C k continuity depends on the first k
and last k internal knot spans, and the first k + 1 and last k + 1 weights
and control points.
Now consider the unclamped, uniform knot vector, U1 • Using the Cox-deBoor
algorithm, Eq. (2.5), we can compute 8 - p degree p basis functions, for p =
0, ... ,7. The degree 2 and 3 basis functions, along with a quadratic and cubic
curve, are shown in Figures 12.1a and 12.1b. The knot locations are marked on
the curves. Notice that the curves are not clamped at the ends, Le., their start
and end points do not coincide with control points. Furthermore, evaluation of
the curves at U E lUi, uHd requires the functions Ni-p,p(U), ... , Ni,p(u); thus,
the curves are defined only on the parameter range U E [up, urn-p], as is the
case for clamped curves. Thus, the quadratic curve of Figure 12.1a is defined on
U E [-1,3], and the cubic curve of Figure 12.1b is defined on U E [0,2]. Figure
12.2 shows how to define a closed, cubic curve using the unclamped, uniform knot
vector, U2 • Since m = 11 and p = 3, we require eight control points (n = 7).
We wrap around p (= 3) control points at the end; Le., P 5 = Po, P 6 = PI and
P 7 = P 2 . The valid parameter range is U E [3,8]. This yields curve closure, with
C 2 continuity.
Knot Vectors 573
, P3
'II>
,
,, , ,,
, ,
Po 0'
N o,2 N 5,2
-3 -2 -1 o 1 2 3 4 5
(a)
,~-------------------~,,
,,
,,
\
\
,,,
\
, \
,
,,
\
\
\
\
\
\
Pol!>
N o,3
-3 -2 -1 o 1 2 3 4 5
(b)
Figure 12.1. Undamped NURBS curves. (a) Quadratic curve; (b) cubic curve.
574 Standards and Data Exchange
Po =Ps
~-------------------~
\
\
\
\
,
\
,,
/
4> P 3
,, /
/
,, /
/
, /
,, /
/
,, /
/
Everything stated previously for undamped, uniform curves also holds for
undamped, nonuniform curves, with the exception of C p - 1 continuity at the
start/end of a dosed curve. Since continuity depends on knot values as well as
on control point locations, C p - 1 continuity of a dosed, nonuniform curve does
not necessarily imply precise wraparound of the control points. Figure 12.3a
shows a closed, cubic curve defined on the clamped, uniform knot vector
ll= {3,3,3,3,4,5,6,7,8,8,8,8}
The curve is C 2 continuous at the start/end point. Figures 12.3b and 12.3c show
unclamped versions of (precisely) the same curve; the curve in Figure 12.3b uses
the knots
II = {O, 0.5, 2.3, 3, 4, 5, 6, 7,8,8.7, 10.5, 11}
and the curve in Figure 12.3c uses the knots
P5 P4
~-----------------~
I \
I \
I \
I \
I \
I
I
I
P e ~' \
\
\
\
Po =P7
,,
, /
,, /
/
,, /
/
,
, /
/
(a)
Figure 12.3. Examples of unclamping a closed curve with different knot vectors.
(a) Closed clamped curve; (b) unclamping with no wraparound; (c) unclamping with
wraparound.
nonperiodic was synonymous with damped (as it is in this book), and these
were used to define open curves and surfaces (uniform at first, and nonuniform
later). Periodic was mathematically equivalent to undamped, uniform, and these
were used to construct C p - 1 continuous dosed curves and surfaces. Referring
to Figures 12.1a and 12.1b, one sees that the undamped, uniform basis func-
tions are all translates of one another, hence they are often called periodic. For
periodic B-splines there was no need to store a knot vector, the Cox-deBoor
algorithm was not required, and control point wraparound was not necessary to
obtain C p - 1 continuous dosed curves. A simple matrix formulation of the (one)
basis function, together with a special control point indexing scheme, were suffi-
cient to evaluate periodic B-spline curves (see [Mort85] for a detailed discussion).
Although more efficient, this special treatment of periodic B-splines has all but
disappeared from practice, probably due to the fact that the time required for
software development and maintenance has become much more expensive than
CPU time. Clamped and undamped are newer terms which will probably grow
in use, simply because they are more intuitive and accurate. Although one sees
these terms rather infrequently in the literature, they seem to be quite prevalent
in the CAD/CAM community. We use the term nonperiodic in this book simply
because we have not yet managed to break the habit.
Many systems today use only damped B-splines. However, both IGES and
STEP provide for the exchange of undamped B-splines. Precise conversions are
576 Standards and Data Exchange
Po Q P5 P4
,,
,~-------------------(i)\
1/ '
.
" \
" \
" \
~' "\
I
," \
" " \
,, ,,
,', \
\
\
\
~
\
P6 \I"
\
1\ /~ P3
P 1 <ll " '
,, ,
/
,
",
""
" /
\ /
\ /
~, /
"
/
\, /
/
",I,
, , /
, 0 P
P7 b 2
(b)
possible both ways. Clamping a curve is nothing more than inserting the knots
up and u m - p until they have multiplicity p, and then discarding the knots and
control points lying outside the clamped region. The knot insertion formula,
Eq. (5.15), is also valid for unclamped curves, as long as one does not index
knots outside the range 0 to m (which does not happen when clamping at up
and u m - p )' We recommend (but leave as an exercise) that the reader write a
routine to extract the subcurve between arbitrary parameters, Ul and U2, where
Ul < U2. Such a routine not only handles clamping but also has many other
uses, including one which we mention in the next section.
Unclamping is essentially knot removal. Although unclamping is rarely re-
quired (yes, there are systems which only handle unclamped B-splines), we
present here Algorithm A12.1, which computes the p - 1 new control points
at each end and p new knots at each end, all in place. We remind the reader
that the result is not unique (see Figures 12.3b and 12.3c). One is free to choose
the 2p new end knots rather arbitrarily, and the new control point locations
depend on the knots. We choose the new knots as follows
i = 0, ... ,p-1 (12.1)
and i = 0, ... ,p-1 (12.2)
This choice of knots produces wraparound of the control points, as in Figures 12.2
and 12.3c, in case the clamped curve is closed with C p - 1 continuity. The algo-
rithm is:
Knot Vectors 577
Po =Ps
~-------------------~
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
I \
= P6~,
I
PI /
~ P3
/
/
,, /
/
,, /
,,
/
,,
,,
,,
(c)
ALGORITHM A12.1
UnclampCurve(n,p,U,Pw)
{ /* Unclamp a clamped curve */
/* Input: n,p,U,Pw */
/* Output: U,Pw */
for (i=O; i<=p-2; i++) /* Unclamp at left end */
{
U[p-i-1] = U[p-i] - (U[n-i+l]-U[n-i]);
k = p-1;
for (j=i; j>=O; j--)
{
alfa = (U[p)-U[k)/(U[p+j+1)-U[k);
Pw[j) = (Pw[j)-alfa*Pw[j+1)/(1.0-alfa);
k = k-1;
}
}
U[O) = U[1) - (U[n-p+2)-U[n-p+1); /* Set first knot */
for (i=O; i<=p-2; i++) /* Unclamp at right end */
{
U[n+i+2) = U[n+i+1) + (U[p+i+1)-U[p+i);
for (j=i; j>=O; j--)
{
578 Standards and Data Exchange
alfa = (U[n+l)-U[n-j))/(U[n-j+i+2)-U[n-j));
Pw[n-j) = (Pw[n-j)-(1.0-alfa)*Pw[n-j-l))/alfa;
}
}
U[n+p+l) = U[n+p) + (U[2*p)-U[2*p-l)); /* Set last knot */
}
Figures 12.4a-12.4d show the steps in unclamping the left end of a degree
4 curve. Figures 12.4b-12.4d correspond to the completion of the ith step,
i = 0, 1,2, respectively. Figure 12.5a shows the quadratic full circle, with knots
I I 1 133 }
U = { 0,0,0, 4' 4' "2' "2' 4' 4' 1, 1, 1
(see Example Ex7. 2). The nine control points are marked. Figure 12.5b illus-
trates the circle after unclamping by Algorithm A12. 1. Notice that the control
polygon does not wrap around, in the sense that none of the control points co-
incide. This is because the circle is only CO continuous in homogeneous space.
The knot vector after unclamping is
\
\
\
\
\
Po
\
\
\
\
\
\
\
\
\
~--
P4 - --e
Ps
(a)
Figure 12.4. The process of unclamping a quartic curve at its left end. (a) Origi-
nal clamped curve; (b) i = 0; -> p8 computed; (c) i = 1; -> P~ and P~ computed;
(d) i = 2;-> p~,pt and P~ computed.
Knot Vectors 579
\
\
\
\
\
\
i!J
P8
\
\
\
\
\
\
I
\
\
\ /
Jt> P6
(b)
Pi I
1 ~
\ \
\ \
\
\
\
\
\
\
\
\
\
\ I
\
\
\ \
\
\ Jt> Pa
\ /
(c)
P~ P3
rp--------(i)
I \
\
I
I
I
\
I
\
I
I
I
p 21 c9. ,
,,
,, \
\
,, \
,, \
,, \
I
,, fb P6
,, /
,, \ /
P4 (9. - - _ _ _ _ 1/
,, - -€I
,, Ps
' 0 p2
o
(d)
Figure 12.4. (Continued.)
12.3.1 IGES
IGES, an American National Standard (ANS), is the most widely used format for
exchanging product data among today's CAD/CAM/CAE systems. Developed
NURBS Within the Standards 581
P3 P2 Pl
~------------ -----------~
Po =Ps
I I
~-----------~-~~--~-----------~
P5 P6 P7
(a)
P3 ~ - - - - - - - - - - -.~-.;o___e_..oc...::o- - - - - - - - - - - ~ Pl
I
I
I
I
I
c;> Po
P5 -----------~-~A_~-----------~ P7
(b)
Figure 12.5. Unclamping the nine-point NURBS circle. (a) Original curve; (b) un-
clamped curve.
in the early 1980s, IGES specifies formats for exchanging graphics and geome-
try data, with support for various applications such as drafting, circuit design,
finite elements, and piping. Curves, surfaces, and three-dimensional solids are
supported. A NURBS curve is specified in IGES by:
582 Standards and Data Exchange
z
x
y
(a)
Figure 12.6. Unclamping a degree (3,2) surface. (a) Original surface; (b) unclamping in
the u direction; (c) unclamping in the v direction; (d) unclamping in both directions.
«,
...
,,
,, ,
x , , ,I
-. y
(b)
Figure 12.6. (Continued.)
12.3.2 STEP
x
y
(c)
... , ......\,.,
.. "'........ """"
.. "" , \ "
,~: \ \ "
,
,,,
,
,
,,
,,
I
I
,,
I
x y
,, ,,
,,
I
, I
, ,
, I
, I
¥
(d)
Figure 12.6. (Continued.)
NURBS Within the Standards 585
12.3.3 PHIGS
Whereas IGES and STEP are data exchange standards, PHIGS is an inter-
national standard specifying a device-independent interactive graphics program-
ming interface. PRIGS emerged in the mid 1980s, and NURBS were incorporated
into the standard in 1992 as part of the PRIGS PLUS extension [Howa91b]. A
PHIGS implementation supporting NURBS allows an application programmer
to pass down NURBS curves and surfaces directly for display. A NURBS curve
is defined in PRIGS by:
586 Standards and Data Exchange
Assuming that System B can represent the analytic types, the exchange of these
between Systems A and B is geometrically precise in both directions. Consider
the direction from B to A. Most systems represent the analytic types either in a
rational form (e.g., rational power basis or Bezier), or in a form from which it is
easy to derive the geometric characteristics such as center, axes, radii, vertices,
etc. Section 6.6 shows how to convert from piecewise rational power basis or
Bezier form to NURBSj going from other rational forms to NURBS is similar.
Constructing the NURBS representations of the analytic types from their ge-
ometric characteristics is the topic of Chapters 7 and 8. Passing the analytic
types from System A to B is more difficult. The problem is that the NURBS
representation of a curve or surface is not unique. For example, there are in-
finitely many combinations of degree, knots, control points, and weights which
produce the full unit circle centered at the origin. Hence it is not simple to
determine if a NURBS curve is an analytic type and, if so, to compute its geo-
metric characteristics. Section 7.6 presents a method to determine the geometric
characteristics of a quadratic rational Bezier curve. However, degree reduction
and knot insertion may be required to bring the NURBS curve into piecewise
quadratic rational form (if possible). Moreover, the NURBS curve is a conic
only if it yields the same geometric characteristics (to within a tolerance) on
each Bezier segment. We emphasize that we make assumptions only about what
constitutes a NURBS curve or surface in System Aj we make no assumptions
about how the specific analytic types are constructed as NURBS. Indeed, such
geometry may be created in another system, in NURBS form, but using different
combinations of knots, weights, and control points than presented in this book,
and then passed into System A. Providing type-tags for NURBS geometry, as
allowed in IGES and STEP (see Section 12.3), offers some help in this regardj
but it does not eliminate the problem.
Now consider more complex geometry, ranging from general ruled and revolved
surfaces to offsets, blends, fillets, and general free-form curves and surfaces.
System B might use three methods to represent such geometry:
• implicit equations of the form !(x, y) = 0 or !(x, y, z) = OJ
• procedural definitionsj
• one of the many forms of polynomial or rational splines.
Theoretically, a precise conversion of a NURBS to piecewise implicit form is
possible, using techniques known as implicitization (e.g., see [deMo84j Sede84j
Hoff89] and the references therein). However, it is not computationally practicalj
precise conversion from implicit to NURBS form is generally not possible, and
thus approximation is required. In practice, implicit equations are rarely used
to represent complex geometry, therefore we pursue the topic no further.
We say that a curve or surface is defined procedurally if it is not defined
directly in terms of explicit coefficients or functions, but rather indirectly by
means of other base curves or surfaces, together with a procedure or formula
to compute points on the intended geometry from points on the base geometry.
588 Standards and Data Exchange
where S(u, v) is the base surface, d =f. 0 is a constant scalar, and N(u, v) is the
unit length normal vector of S (u, v) at (u, v). Offset curves and surfaces are
mathematically complex and, in general, can rarely be represented precisely in
NURBS form (see [Till84; Faro86; Coqu87b; Hosc88]). Blend and fillet surfaces
are sometimes defined procedurally [Choi91], and Filip and Ball [Fili89] describe
a procedural method of skinning. Such surfaces can seldom be passed into a
NURBS (or any other) system without approximation.
Most CAD/CAM/CAE systems use piecewise polynomial or rational curves
and surfaces to represent complex geometry. We refer to these, collectively, as
splines. There are many different types of splines; but no matter what fancy
name it has, a spline curve (surface) simply consists of a number of segments
(patches), pieced together with some form of continuity. For brevity, we restrict
our discussion to curves for the remainder of this section, but similar statements
and algorithms hold for surfaces. In order to determine if a particular type of
spline curve has an equivalent NURBS representation (and vice versa), one must
consider three things:
• degree;
• rationality;
• continuity.
Degree and rationality are easy. Degree can be precisely raised, but not lowered;
and a polynomial is a rational function, but the converse is not true. Since our
System A allows rational curves of arbitrary degree, there are no problems in this
regard in bringing geometry from System B into System A. However, if System B
restricts degree or allows only nonrational geometry, then the corresponding
curves must be approximated in going from System A to System B.
Continuity is more complicated. Let C(u) be a spline curve consisting of the
segments Ci(u), i = 1, ... ,m. Ci(u) is defined on the interval [Ui-bUi], where
Uo < Ul < ... < Urn-l < Urn. We call the values {Ui} the breakpoints; if C(u)
is in B-spline form, then the {Ui} are the distinct knot values. Each pair of
segments, Ci(u) and C i +1(u), joins with some type and order of continuity, and
the fundamental question in data exchange always boils down to whether or not
the receiving system can represent the segments, connected with the appropriate
continuity. By continuity type we mean parametric (C) versus geometric (G)
continuity; see Section 9.3.1 and [Bars89, 90; Hosc93] and the references therein
for more details on geometric continuity and various types of splines constructed
to have G continuity. We remind the reader that:
• G l continuity at Ui means that the first derivative vectors, C~(Ui) and
C~+1 (Ui), point in the same direction but can have different magnitudes;
Data Exchange to and from a NURBS System 589
u= \Uo,.~. ,UO)Ul,'"
_____
,Ub .. ' ,Um-b'" ,Um-bUm,'" ,um}
' v I~
p+l p p p+l
3. apply knot removal (to a zero tolerance), but all breakpoints must remain
with multiplicity at least one so that they are equally spaced.
Note that if this algorithm is used to pass a curve from A to B and then back
to A, the original and the returned curves in A differ parametrically and in their
number of knots. Notice also that, even though the curves are geometrically
equivalent, if they are used in System A to construct ruled surfaces (for example)
then the resulting surfaces may not be geometrically equivalent.
Regardless of the type of spline used in System B, the continuity issue is
comprised of two parts:
• does the representation allow for nonuniformly spaced breakpointsj
• what types and orders of continuity are possible?
We remark that the first part can be answered even for systems in which there is
no concept of global breakpoints. For example, many geometrically continuous
splines are constructed by local methods using a local parameter t, t E [0,1],
590 Standards and Data Exchange
for each segment. Such systems may allow for a global parameterization, in
which case global breakpoints, Ui, are available, and nonuniform spacing is most
probably allowed. In systems with no concept of a global parameterization,
equally spaced global breakpoints are implied. As seen previously, reparameteri-
zation can be used to transform nonuniformly spaced breakpoints into uniformly
spaced ones; however, parametric continuity is altered in the process. Con-
versely, reparameterization which transforms uniformly spaced breakpoints to
nonuniformly spaced ones is useful in converting (geometrically precisely) a G k
continuous spline to a C k continuous B-spline (e.g., this was done in Section 9.3.2,
Eqs. [9.37J-[9.39]). With regard to the second part, one must determine the min-
imum order of continuity allowed. For example, a system based on fifth-degree
G2 continuous splines can represent all quintic Gk continuous splines, for k ~ 2;
however, a quintic Gk continuous spline with k < 2 must be approximated. As
another example, curves of a B-spline system allowing only single internal knots
are C p - 1 continuous. Hence all orders of continuity are possible, but the de-
gree must be at least one greater than the minimum desired continuity (Le., the
minimum order of continuity may depend on the degree).
We now summarize the exchange of spline curves between Systems A and B. All
spline curves which are at least CO continuous can be passed precisely (geomet-
rically and parametrically) from System B to A. Multiple knots are necessary for
G continuous curves, but, if desired, reparameterization can be used to achieve
C continuity and lower the multiplicity of internal knots. The use of reparame-
terized curves in certain types of surface constructions (e.g., ruled surfaces) can
change surface geometry. A typical algorithm to effect the conversion first com-
putes either the power basis or Bezier coefficients for each segment, and it then
applies the techniques of Section 6.6 to build the NURBS representation.
The conversion from System A to System B can be more complicated. Algo-
rithm A12. 2 gives the logical thought process necessary to determine how such
a conversion should proceed. Denote the pth degree NURBS curve by C, and
assume System B can represent splines of degree k, where Pmin ~ k :5 Pmax.
ALGORITHM A12.2
if (C is rational and System B only represents polynomials)
{
Approximate C;
return;
}
if (p > Pmax)
{
Approximate C;
return;
}
if (p < Pmin)
{
DegreeElevateCurve(C); /* to degree Pmin */
return;
Data Exchange to and from a NURBS System 591
}
Let Tn be the minimum order continuity allowed in System B
for a degree p curve.
Determine the minimum order, k, of continuity at any
breakpoint of C.
if (k < Tn)
{
Approximate C;
return;
}
Extract the segments of C (knot insertion), and convert them
to the segment coefficients required by System B
(reparameterization may be necessary).
If applicable, load the global breakpoints into System B.
13.1 Introduction
In the previous twelve chapters we introduced different aspects of modeling with
NURBS. These chapters covered basically two things: (1) the underlying mathe-
matics, and (2) algorithms illustrating how the tools can be turned into computer
code. Although the pseudocodes presented in each chapter are fairly detailed,
containing all the necessary information to turn them into workable routines, it
is a long way from the algorithmic sketch to a useful system. How to design
a useful system is a very difficult question (contrary to many researchers who
consider it as a minor "implementation issue"). A NURBS system has to satisfy
many requirements in order to be useful in a complex surface or solid modeler.
In this chapter we introduce a number of programming concepts that, we believe,
contribute to good programming practices. We are fully aware of the diversity
of programming styles and conventions. Consequently, we do not attempt to
present the best or the ultimate solution simply because there is none.
During the course of writing this book we developed a comprehensive library,
Nlib V2.0, implemented in ANSI C. This library contains numerous routines
necessary to implement every tool discussed in the book. In this chapter we
present the philosophy, architecture, and organization of that library. While de-
veloping Nlib V2.0 we required our routines to adhere to the following general
standards [see Stra92]:
• toolability: available tools should be used to build new routines;
• portability: it should be easy to port the software to different software and
hardware platforms;
• reusability: the program should be written in such a way as to be able to
reuse sections of the code;
• testability: the code should be made consistent and simple so that testing
and debugging become easy;
• reliability: errors should be handled consistently and gracefully;
594 B-spline Programming Concepts
One of the most difficult tasks in floating point calculations is to deal with
numerical imprecision. It is almost impossible not to use tolerances for point co-
incidence or to measure the equality of two floating point numbers. In Nlib V2.0
we use the following constants defined by the compiler:
#define BIGD DBLMAX
#define SMAD DBL...MIN
#define BIGI INT...MAX
#define SMAI INT...MIN
#define DEPS DBLJEPSILON
BIGD and SMAD are the largest and the smallest double precision numbers, re-
spectively. The ANSI C standard specifies that they must be defined in float. h.
It also requires BIGD to be at least 1037 or greater and SMAD to be at least 10- 37
or smaller. The requirement for the double precision epsilon DEPS is at least
10- 9 or smaller.
Limits for integer variables are stored in limits. h. Some typical ranges are
-32,768 to 32,767 for int, and -2,147,483,648 to 2,147,483,647 for long.
The range for the unsigned long is up to 4,294,967,295. Working with these
constants ensures the consistency of computations no matter which hardware
platform one uses.
Operations and domain portabilities are ensured through special arithmetic
functions operating on objects. Examples are given in subsequent sections.
abstraction. For example, when dealing with curves for interactive design, he
works with them without regard to the number of control points and knots. Or,
for example, when dealing with curve/curve intersection, he might descend his
thinking to the level of the control polygon if the overlapping of bounding boxes is
what needs to be examined. For these and many other similar reasons, Nlib V2.0
considers every geometric entity as an object built from simpler components.
In the design of a huge structure, simple building blocks are created first from
basic data types. One of the basic elements of a curve object is the control point.
It can be rational or nonrational, two-dimensional or three-dimensional, that is,
it needs to hold two, three, or four coordinates. In addition, it plays a dual role
as a control point for B-spline computations and as a Euclidean point used for
simple geometric manipulations, such as computing distances, bounding boxes,
and so on. A third requirement is to be able to refer to this entity as P [i) , just
as its mathematical abstraction is referred to in the book. To simplify matters
and to satisfy object based concepts, we separated control points from "regular"
Euclidean points just as we did in the book, by writing P for a Euclidean point
and pw for a control point that can be weighted. Hence the definitions of points
are (see Figure 13.1):
typedef struct point
{
REAL x,
y,
z;
} POINT;
P: z
Pw: x y z w
pol: n
I I I
In other words, the control polygon object is simply a structure containing the
highest index and a pointer to an array of control points. The knot vector also
has a highest index field and a pointer to the array of knots. These structures
contain the bare minimum of data. One can extend them according to special
needs, e.g., the control polygon structure can store information on the bounding
box, or the knot vector structure can store a flag as to whether it is uniform or
nonuniform. Now, given a control polygon, a knot vector, and a specified degree,
one can build a curve from these constituents as follows (see Figure 13.4):
typedef struct curve
{
CPOLYGON *pol;
DEGREE p;
KNOTVECTOR *knt;
} CURVE;
that is, a curve object consists of a polygon pointer, the degree, and a knot
vector pointer. The beauty of this definition is that the various constituents are
easily extracted for further processing. For example, if one needs to compute
the bounding box of a curve, in that routine the polygon subobject is extracted
and passed on to another routine that deals with bounding box computation.
Similarly, if a knot span is sought in which a parameter lies, the knot vector
object is detached from the curve and passed on to a routine. Assuming that
the current routine receives a curve pointer, the programming is fairly simple.
CPOLYGON *pol;
KNOTVECTOR *knt;
knt:
Uo
cur: p
I I I
n m
I I I
-~
-
-
~
pol cur->pol;
knt cur->knt;
N_polbox(pol, ... );
N_findsp(knt, ... );
In other words, simple pointer assignments allow the program to descend to
a lower level of abstraction, perform the necessary operations, and return the
result to the calling routine's level.
The definition of a surface object is quite similar. It needs a control net, two
degrees, and two knot vectors. The control net is defined as (see Figure 13.5):
n m
I I I I
net
r-
-
-=u wXo,o wyo,o wZo,o
WO,l
it-=-
-
- r---
-
Lc=-
is the jth offset in this column. Putting the control net, the degrees, and two
knot vectors together results in a surface defined as (see Figure 13.6):
typedef struct surface
{
CNET *net;
DEGREE p,
q;
KNOTVECTOR *knu,
*knv;
} SURFACE;
Again, the control net and the knot vectors are extracted easily to perform
various operations. If one has to perform many operations on the same curve or
surface, these definitions become fairly natural to use and very economical; only
pointers to different structures need to be passed around.
sur: p q
r I I I I
rn Im Ir Is
net : knu: knv:
r:=- ,-L- ,-'---
f-- f--
-
f-- f--
s=-
f---
f-- f--
-
f--- f---
f--
f-- f--
-
L-c=- '--- '---
L-.
One can easily see that n + 1 memory allocations require n( n + 1) /2 lines of code
for deallocation to handle the possible error, e.g., a code requiring 21 arrays
contains 210 lines of free statements just to deal with the possible failure of
dynamic memory allocation.
To make matters more manageable, Nlib V2.0 has a three-step process to
handle memory allocation and deallocation:
• on entering a new program, a memory stack is initialized to the empty
stack;
• if memory is needed, special routines are called that allocate the re-
quired memory and save the memory pointers on appropriate stacks (see
Figure 13.7);
• upon leaving the program the memory stacks are traversed, and memory,
pointed to by the saved pointers, is deallocated.
As the programming examples in a later section show, this type of memory
management is fairly clean, hides all unnecessary detail, and makes sure that all
allocated memory is deallocated properly. Let us now examine the three steps
in more detail.
The structure of every NURBS routine is sketched using this simple example:
FLAG error = 0;
INDEX n, m;
CPDINT **Pw;
stacks:
STACKS S;
Pw S_getc2d(n,m,&S);
if ( Pw == NULL ) { error 1; goto EXIT; }
EXIT:
N_enurbs(&S) ;
return( error );
Each routine has its own memory stack defined in nurbs.h as follows (see Figure
13.7):
typedef struct stacks
{
I1DNODE *i1d;
I2DNODE *i2d;
R1DNODE *rld;
R2DNODE *r2d;
KNTNODE *knt;
} STACKS;
In other words, it is a structure of pointers pointing to linked lists of nodes that
store the different types of memory pointers - one- or two-dimensional INTEGER
and REAL arrays, POINT arrays, and so on. When a routine is entered, memory
for this structure is allocated and the pointers are set to NULL by the N_inurbs 0
routine. In order to allocate memory, the program (1) declares the appropriate
memory pointer (**Pw in the previous example), and (2) calls a memory routine
(S_getc2dO). The memory routine then allocates the required memory and
saves the pointer(s) on the stack. As an example, let us see how S_getc2dO
allocates memory for a two-dimensional array of control points (error handling,
used in this routine, is discussed in Section 3.5).
#inc1ude "nurbs.h"
static STRING rname = "S_GETC2D";
ClDNODE *cld;
C2DNODE *c2d;
/* Allocate memory */
Pw = (CPOINT **) malloc ( (n+l)*sizeof(CPOINT *) );
if ( Pw == NULL )
{
E_seterr(MEMJ&RR,rname);
return NULL;
}
Qw = (CPOINT *) malloc ( (n+l)*(m+l)*sizeof(CPOINT) );
if ( Qw == NULL )
{
E_seterr(MEMJ&RR,rname);
free( Pw );
return NULL;
}
/* Make pointer assignments */
1 = 0;
for ( k=O; k<=n; k++ )
{
Pw[k] = &Qw[l];
1 = l+m+l;
}
/* Put pointers on memory stacks */
cld = (C1DNODE *) malloc ( sizeof(C1DNODE) );
if ( cld == NULL )
{
E_seterr(MEMJ&RR,rname);
free( Pw ); free( Qw);
return NULL;
}
cld->ptr = Qw;
cld->next = S->cld;
S->cld = cld;
c2d = (C2DNODE *) malloc ( sizeof(C2DNODE) );
if ( c2d == NULL )
{
E_seterr(MEMJ&RR,rname);
free( Pw );
606 B-spline Programming Concepts
return NULL;
}
c2d->ptr = Pw;
c2d->next = S->c2d;
S->c2d = c2d;
1* Exit *1
return Pw;
}
The nodes C1DNODE and C2DNODE are defined in geometry. h as
typedef struct cldnode
{
CPOINT *ptr;
struct cldnode *next;
} ClDNODE;
KNTNODE *knp;
representing the lines, has corrupt information (e.g., a line of zero length). Since
this error can possibly be corrected from the calling routine and hence the process
completed with success, it is totally unacceptable to kill the entire session and
print an error message.
NURBS routines need to handle errors in the background by passing error
flags back to each calling routine. This can be done in a number of different
ways. One sophisticated method is to use an error stack. If a routine locates
an error it is put on the stack and control is returned to the calling routine.
This routine either deals with the error or puts its own error onto the stack and
returns control to a higher level routine. At each higher level, the calling routine
receives a stack of errors (see Figure 13.8) that show the error history, and at
each level the routine can correct the error, if possible, or pass the stack (with
its own error on top) one level higher. Ultimately, a routine at a level higher
than the NURBS library deals with the error. Let us consider a simple example.
The data reduction algorithm discussed in Chapter 9 uses the following simple
calling hierarchy:
Data reduction;
Interpolate with given knot vector;
Remove knots;
Compute degree elevated knot vector;
Least-squares approximation with given knot vector;
LU decomposition;
If LU decomposition fails at the deepest level, least-squares approximation can-
not be performed. Instead of killing the entire process, the data reduction routine
can elect to restart the entire process with a higher degree interpolatory curve
(which is exactly what the actual implementation does).
Although error stacking is a sophisticated technique, it requires some program-
ming to respond to the different errors at each level. In Nlib V2.0 this technique
is not employed, mainly for two reasons: (1) each NURBS routine calls only a
few other routines, i.e., the call stack is fairly small, and (2) the calling routine
calling routine:
Err=1 in M_ludcmp
checks for most errors, hence only a few errors remain to be detected in lower
level routines. Thus it seems reasonable for Nlib V2.0 to pass around only one
error flag, and to make each routine responsible for dealing with this error. The
error flag is a simple structure defined in datastr. h as:
typedef struct enode
{
INTEGER eno;
STRING fna;
} ENODE;
that is, the structure contains an error number and the name of the routine where
the error was detected. The most frequently occurring errors are numbered and
defined in datastr. h. Some examples are:
#define CUR~ 1
#define SUR~ 2
#define DEG~ 3
#define KNT~ 4
#define WEI~ 5
#define MEM~ 15
where CUR~ is curve definition error; KNT~ is knot vector error, for ex-
ample decreasing knots; MEM~ is memory allocation error, and so on; as a
convenience, an error file can be created where all these errors are explained
in more detail. Using these error numbers, a global error variable is required.
Nlib V2.0 defines and initializes the error variable NERR in globals. h as
extern volatile ENODE NERR ={ 0, " " };
As soon as an error is detected, NERR receives a new value by means of the error
routine E_seterr 0 :
#include "nurbs.h"
extern volatile ENODE NERR;
#include "nurbs.h"
1* Check knots *1
for ( i=O; i<m; i++ )
{
if ( U[i] > U[i+1] )
{
E_seterr(KNTJ&RR,mame);
error = 1;
break;
}
}
1* Exit *1
return( error );
}
In other words, if no error is found the routine returns 0, otherwise it returns 1
and sets NERR to the appropriate value.
In many applications curve data is read from a file, for example from an IGES
file. Before calling any NURBS routine it is prudent to make sure that the
file contains correct information, i.e., it is useful (and necessary) to perform a
complete curve (surface) check. An additional positive feature of this check is
that further curve (surface) error checking is not required when curves and sur-
faces are passed to a NURBS routine. Before the complete curve check routine is
considered, two more error routines are discussed: (1) check curve definition con-
sistency, and (2) check weights. First consider the curve definition check routine.
#include "nurbs.h"
DEGREE p;
CPOINT *Pw;
1* Check definition *1
if ( (n+p+1) != m )
{
E_seterr(CURJ&RR,rname);
error = 1;
goto EXIT;
}
1* Exit *1
EXIT:
return( error );
}
612 B-spline Programming Concepts
1* Exit *1
return( error );
}
FLAG error;
KNOTVECTOR *knt;
1* Exit *1
return(O);
}
Each NURBS routine can, in principle, handle error checking individually.
However, with error routines programming becomes a lot cleaner. The program-
mer can focus on the task at hand, e.g., curve refinement, and miscellaneous tasks
such as error checking and memory allocation are handled at a conceptual level.
cur->pol = pol;
cur->p = p;
cur->knt = knt;
}
This is probably the simplest type of utility responsible for assigning pointers
of existing structures to the elements of the curve structure. Polygons and knot
vectors can also be created by utility routines. A simple example is:
#include "nurbs.h"
FLAG UJmakpI2( CPOLYGON *pol, REAL *wx, REAL *wy, REAL *wz,
REAL *w, INDEX n, STACKS *S )
{
INDEX i;
CPOINT *Pw;
1* Exit *1
return (0);
}
Utility Routines 615
This routine not only creates a polygon structure (memory to store the structure
is allocated in the calling routine), it also converts the traditional (wx, wy, wz, w)
type input to the more object based point input. And it also takes care of the
proper setting of the z and w components for nonrational or planar curves. We
present a similar routine that creates a curve from the smallest bits and pieces:
#include "nurbs.h"
FLAG U..makcu3( CURVE *cur , REAL *wx, REAL *wy, REAL *wz,
REAL *w, INDEX n, DEGREE p, REAL *U, INDEX m,
STACKS *S )
{
CPOINT *Pw;
CPOLYGON *pol;
KNOTVECTOR *knt;
1* Allocate memory *1
Pw = S_getcpa(wx,wy,wz,w,n,S);
if ( Pw == NULL ) return (1);
pol = S~etpol(S);
if ( pol == NULL ) return (1);
knt = S~etknt(S);
if ( knt == NULL ) return (1);
1* Exit *1
return (0);
}
Notice how well the memory routines S_getcpaO, S_getpolO, and S_getknt 0
are integrated with this utility. No explicit allocation and deallocation is taking
place, yet there is proper error handling through the global error flag NERR. This
routine is also a good example illustrating how errors are handled in a higher level
routine. If an error is detected in any of the three previous memory routines, NERR
is set and control is returned. U..makcu3 handles the error by returning the control
one level higher. Since memory allocation is the problem in both the memory
routines and in the utility routine, no new setting of the global NERR is required.
616 B-spline Programming Concepts
#include "nurbs.h"
VOID A_euclid( CPOINT Pw, POINT *P )
{
if ( Pw.w != ~OW )
{
P->x = Pw.x/Pw.Wj
P->y = Pw.y/Pw.w;
if ( Pw.z != ~OZ )
P->z = Pw.z/Pw.w;
else
P->z = 0.0;
}
else
{
P->x = Pw.x;
P->y = Pw.y;
if ( Pw.z != ~OZ )
P->z = Pw.Zj
else
P->z = 0.0;
}
}
These routines are used in the next section to illustrate two NURBS routines,
curve and surface evaluations.
STACKS S;
1* Check parameter *1
error = E_parval(knt,u,rname);
if ( error == 1 ) goto EXIT;
N = S_getr1d(p,&S);
if ( N == NULL ) { error = 1; goto EXIT; }
error = N_allbas(knt,p,u,LEFT,N,&j);
if( error == 1 ) goto EXIT;
N_enurbs (&S) ;
return(error);
}
As mentioned earlier, each NURBS routine starts with N_inurbsO, which
initializes the memory stacks to NULL. After initialization, local notations are
normally introduced to help follow the computational details. The notation
Pv[k] is visually more pleasing than cur->pol->Pv[k] and much closer to the
customary notation, Pk'. The next step in almost every NURBS routine is to
check the incoming parameters for possible error. E_parval() checks if the given
parameter u is outside of the range luG, urn]. The rest of the code deals with the
620 B-spline Programming Concepts
CW(u) = L Nk,p(u)Pk'
k=j-p
and to locate the point in the Euclidean space; note the index transformation
to use the proper basis functions. Finally, N_enurbs 0 deallocates all allocated
memory, and control is returned to the calling routine by returning either zero
(no error) or one (error saved in NERR).
This next test program shows how easy it is to compute a point on the curve.
#include "nurbs.h"
#include "globals.h"
main( )
{
FLAG error;
CURVE cur;
PARAMETER u;
POINT C;
STACKS S;
1* Start processing *1
}
printf( "C = %1£ %1£ %1£", C.x, C.y, C.z );
1* End NURBS session *1
EXIT:
The many utility routines allow the programmer to define a curve in a num-
ber of different ways, e.g., reading in a curve file, receiving the (wx, wy, wz, w)
coordinates from a curve sketching interface, and so on.
The structure of surface programs is very similar to the curve programs. This
next surface evaluator shows an example.
#include "nurbs.h"
static STRING rname = "N...EVNSUR";
extern CPOINT CZERO;
1* Check parameters *1
error = E_parval(knu,u,rname);
if ( error == 1 ) goto EXIT;
error = E_parval(knv,v,rname);
622 B-spline Programming Concepts
NU = S~etr1d(p,&ST);
if ( NU == NULL ) { error = 1; goto EXIT; }
NV = S~etr1d(q,&ST);
if ( NV == NULL ) { error = 1; goto EXIT; }
error = N_allbas(knu,p,u,LEFT,NU,&ju);
if ( error == 1 ) goto EXIT;
error = N_allbas(knv,q,v,LEFT,NV,&jv);
if ( error == 1 ) goto EXIT;
EXIT:
N_enurbs(&ST);
return(error);
}
The next test program shows another way to create a surface and to evaluate
a point on it. The routine U_inpsurO reads in a data file, named SURFACE. OAT,
containing the control polygon and knot vector information. U_inisurO is a
routine that initializes the surface object to the NULL object to let U_inpsur 0
know that memory allocation is required.
Additional Structures 623
#include "nurbs.h"
#include "globals.h"
main( )
{
FLAG error;
SURFACE sur;
PARAMETER u, v;
POINT S;
STACKS ST;
/* Start processing */
N_inurbs(&ST) ;
/* Read in surface data */
U_inisur(&sur);
error = U_inpsur(&sur,"SURFACE.DAT",&ST);
i f ( error > 0 )
{
printf( "error %d %s", NERR.eno, NERR.fna );
goto EXIT;
}
/* Compute surface point */
printf( "Enter parameters <u,v> = " ); scanf( ''%If%lf'', &u, &v);
error = N_evnsur(&sur,u,v,&S);
if ( error > 0 )
{
printf( "error %d %s", NERR.eno, NERR.fna );
goto EXIT;
}
printf( "s = %If %If %If'', S.x, S.y, S.z );
/* End NURBS session */
EXIT:
N_enurbs (&ST) ;
}
NURBS
Bezier
Geometry
Mathematics
Utility
rare that a geometry routine has to make a call to an existing NURBS program.
If this happens to be the case, a special lower level routine can be written so
that the correspondence among the layers remains unidirectional. This isolation
of the different layers becomes important if parts of the system are to be used
for purposes other than NURBS geometry. For example, the mathematics and
geometry libraries should be stand-alone libraries so that they can be used for
simple geometric and mathematical computations without worrying about the
much larger Bezier and NURBS libraries.
We close this section by restating our opinion on system design: it is very
difficult, it is not unique, and it is changing as computer technology advances.
However, designing and implementing a system is enlightening and essential in
obtaining a broad and deep knowledge of NURBS technology. As Herbert B.
Voelcker puts it [Pieg93j
This book is intended to provide both the theory and the implementation of
NURBS. Let the reader judge whether this goal has been successfully met.
REFERENCES
[Ahuj68] Ahuja, D.V., and Coons, S.A., Geometry for construction and display,
IBM Syst. Jour., Nos. 3-4, pp. 188-205, 1968.
[Akim70] Akima, H., A new method of interpolation and smooth curve fitting based
on local procedures, Jour. ACM, Vol. 17, pp. 589-602, 1970.
[Akma92] Akman, V., and Arslan, A., Sweeping with all graphical ingredients in a
topological picturebook, Comput. and Gmph., Vol. 16, No.3, pp. 273-281,
1992.
[BalI74] Ball, A., eONSURF. Part 1: Introduction to the conic lofting tile, CAD,
Vol. 6, No.4, pp. 243-249, 1974.
[BaIl75] Ball, A., eONSURF. Part 2: Description of the algorithms, CAD, Vol. 7,
No.4, pp. 237-242, 1975.
[Ball77] Ball, A., eONSURF. Part 3: How the program is used, CAD, Vol. 9, No.1,
pp. 9-12, 1977.
[Baly94] Ballay, H., and Storn, R, A tool for checking e coding conventions,
C/C++ Users Journal, Vol. 12, No. 27, pp. 41-50, 1994.
[Barn93] Barnhill, R., Coons' patches and convex combinations, in [Pieg93].
[Barr83] Barr, A.H., Global and local deformations of solid primitives, SIGGRAPH
83 Thtorial Notes, Detroit, 1983.
[Bars89] Barsky, B.A., and DeRose, T.D., Geometric continuity of parametric
curves: Three equivalent characterizations, IEEE Comput. Gmph. and
Appl., Vol. 9, No.6, pp. 60-68, 1989.
[Bars90] Barsky, B.A., and DeRose, T.D., Geometric continuity of parametric
curves: Construction of geometrically continuous splines, IEEE Comput.
Gmph. and Appl., Vol. 10, No.1, pp. 60-68, 1990.
[Bart87] Bartels, RH., Beatty, J.C., and Barsky, B.A., An Introduction to Splines
for Use in Computer Gmphics and Geometric Modeling, San Mateo, CA:
Morgan Kaufmann, 1987.
[Beac91] Beach, Re., An Introduction to the Curves and Surfaces of Computer-
Aided Design, New York: Van Nostrand Reinhold, 1991.
630 References
[Cohe80] Cohen, E., Lyche, T., and Riesenfeld, R.F., Discrete B-splines and sub-
division techniques in Computer-Aided Geometric Design and Computer
Graphics, Comput. Gmph. and Image Process., Vol. 14, pp. 87-111, 1980.
[Cohe85] Cohen, E., Lyche, T., and Schumaker, L.L., Algorithms for degree-raising
of splines, ACM TOG, Vol. 4, No.3, pp. 171-181, 1985.
[Coon67] Coons, S.A., Surfaces for computer-aided design of space forms, MAC-
TR-41 , MIT, June 1967.
[Coqu87a] Coquillart, S., A control-point-based sweeping technique, IEEE Comput.
Gmph. and Appl., Vol. 7, No. 11, pp. 36-45, 1987.
[Coqu87b] Coquillart, S., Computing offsets of B-spline curves, CAD, Vol. 19, No.6,
pp. 305-309, 1987.
[Coqu90] Coquillart, S., Extended free-form deformation: A sculpturing tool for 3D
geometric modeling, Comput. Gmph., Vol. 24, No.4, pp. 187-193, 1990.
[Coqu91] Coquillart, S., and Jancene, P., Animated free-form deformation: An in-
teractive animation technique, Comput. Gmph., Vol. 25, No.4, pp. 23-26,
1991.
[Cox72] Cox, M.G., The numerical evaluation of B-splines, Jour. Inst. Math. Ap-
plic., Vol. 10, pp. 134-149, 1972.
[Coxe67] Coxeter, H.S.M., and Greitzer, S.L., Geometry Revisited, Washington,
DC: Mathematical Association of America, 1967.
[Coxe74] Coxeter, H.S.M., Projective Geometry, Toronto, Canada: Univ. of
Toronto Press, 1974.
[Coxe80] Coxeter, H.S.M., Introduction to Geometry, New York: John Wiley, 1980.
[Curr47] Curry, H.B., and Schoenberg, I.J., On spline distributions and their limits:
the P6lya distribution functions, Abstract 380t, Bull. Amer. Math. Soc.,
Vol. 53, p. 109, 1947.
[Dani89] Daniel, M., and Daubisse, J.C., The numerical problem of using Bezier
curves and surfaces in the power basis, Comput. Aid. Geom. Des., Vol. 6,
pp. 121-128, 1989.
[Dann85] Dannenberg, L., and Nowacki, H., Approximate conversion of surface rep-
resentations with polynomial bases, Comput. Aid. Geom. Des.,
Vol. 2, pp. 123-132, 1985.
[DeBo72] De Boor, C., On calculating with B-splines, Jour. Approx. Theory, Vol. 6,
pp. 50-62, 1972.
[DeBo78] De Boor, C., A Pmctical Guide to Splines, New York: Springer-Verlag,
1978.
[DeBo87] De Boor, C., Cutting corners always works, Comput. Aid. Geom. Des.,
Vol. 4, Nos.1-2, pp. 125-131, 1987.
[DeBo93] De Boor, C., B(asic)-spline basics, in [Pieg93].
[deCa86] de Casteljau, P., Shape Mathematics and CAD, London: Kogan Page,
1986.
632 References
[deCa93] de Casteljau, P., Polar forms for curve and surface modeling as used at
Citroen, in [Pieg93].
[deMo84] de Montaudouin, Y., and Tiller, W., The Cayley method in computer-
aided geometric design, Comput. Aid. Geom. Des., Vol. 1, No.4, pp. 309-
326, 1984.
[DoCa76] Do Carmo, M.P., Differential Geometry of Curves and Surfaces, Engle-
wood Cliffs, NJ: Prentice-Hall, 1976.
[Eck93] Eck, M., Degree reduction of Bezier curves, Comput. Aid. Geom. Des.,
Vol. 10, pp. 237-251, 1993.
[Fari83] Farin, G.E., Algorithms for rational Bezier curves, CAD, Vol. 15, No.2,
pp. 73-77, 1983.
[Fari89] Farin, G.E., Rational curves and surfaces, in Mathematical Aspects in
Computer Aided Geometric Design, Lyche, T., and Schumaker, L.L., Eds.,
New York: Academic Press, 1989.
[Fari93] Farin, G.E., Curves and Surfaces for Computer Aided Geometric Design
- A Practical Guide, 3rd ed., Boston: Academic Press, 1993.
[Faro86] Farouki, R., The approximation of non-degenerate offset surfaces, Com-
put. Aid. Geom. Des., Vol. 3, pp. 15-43, 1986.
[Faro87] Farouki, RT., and Raj an, V.T., On the numerical condition of polyno-
mials in Bernstein form, Comput. Aid. Geom. Des., Vol. 4, pp. 191-216,
1987.
[Faro88] Farouki, RT., and Rajan, V.T., Algorithms for polynomials in Bernstein
form, Comput. Aid. Geom. Des., Vol. 5, pp. 1-26, 1988.
[Faux81] Faux, I.D., and Pratt, M.J., Computational Geometry for Design and
Manufacture, Chichester, UK: Ellis Horwood Ltd., 198!.
[Ferg66] Ferguson, J.C., Form, characterized in a special class of parametrized
curves, Report 3122-31, TRW Corporation, Redondo Beach, CA, 1966.
[Ferg67] Ferguson, J.C., Form, characterized in a special class of parametrized
curves - II, Report 3122-3-237, TRW Corporation, Redondo Beach, CA,
1967.
[Ferg69] Ferguson, J.C., and Miller, K.L., Characterization of shape in a class of
third degree algebraic curves, Report 5322-3-5, TRW Corporation, Re-
dondo Beach, CA, 1969.
[Ferg93] Ferguson, J.C., F-methods for free-form curve and hypersurface definition,
in [Pieg93].
[Fili89] Filip, D., and Ball, T., Procedurally representing lofted surfaces, IEEE
Comput. Graph. and Appl., Vol. 9, No.6, pp. 27-33, 1989.
[Fole90] Foley, J., van Dam, A., Feiner, S., and Hughes, J., Computer Graphics:
Principles and Practice, Reading, MA: Addison-Wesley, 1990.
[Forr68] Forrest, A.R, "Curves and Surfaces for Computer-Aided Design," Ph.D.
dissertation, Cambridge University, Cambridge, UK, 1968.
References 633
[Forr70] Forrest, A.R., Shape classification of the non-rational twisted cubic curve
in terms of Bezier polygons, CAD Group Document No. 52, Cambridge
Univ., Cambridge, UK, 1970.
[Forr72] Forrest, A.R., Interactive interpolation and approximation by Bezier poly-
nomials, The Comput. Jour., Vol. 15, No.1, pp. 71-79, 1972. Corrected
and updated version in CAD, Vol. 22, No.9, pp. 527-537, 1990.
[Forr80] Forrest, A.R., The twisted cubic curve: A computer-aided geometric de-
sign approach, CAD, Vol. 12, No.2, pp. 165-172, 1980.
[Fors88] Forsey, D., and Bartels, R., Hierarchical B-spline refinement, Comput.
Groph., Vol. 22, No.4, pp. 205-212, 1988.
[Four83] Fournier, A., and Wesley, M., Bending polyhedral objects, CAD, VoLl5,
No.2, pp. 79-87, 1983.
[FowI92] Fowler, B., Geometric manipulation of tensor product surfaces, Special
Issue of Comput. Groph., Symposium on Interactive 3D Graphics, pp. 101-
108, 1992.
[FowI93] Fowler, B., and Bartels, R., Constraint-based curve manipulation, IEEE
Comput. Groph. and Appl., Vol. 13, No.5, pp. 43--49, 1993.
[Fuhr92] Fuhr, R.D., and Kallay, M., Monotone linear rational spline interpolation,
Comput. Aid. Geom. Des., Vol. 9, No.4, pp. 313-319, 1992.
[Geis90] Geise, G., and Langbecker, U., Finite quadratic segments with four conic
boundary curves, Comput. Aid. Geom. Des., Vol. 7, pp. 141-150, 1990.
[Good81] Goodman, T., Hermite-Birkhoff interpolation by Hermite-Birkhoff
splines, Proc. Roy. Soc. Edinburgh, Vol. 88(A), Parts 3/4, pp. 195-201,
1981.
[Gord69] Gordon, W., Spline-blended surface interpolation through curve networks,
Jour. Math. Mech., Vol. 18, No. 10, pp. 931-952, 1969.
[Gord71] Gordon, W., Blending-function methods of bivariate and multivariate in-
terpolation and approximation, SIAM Jour. Numer. Anal., Vol. 8,
pp. 158-177, 1971.
[Gord74a] Gordon, W.J., and Riesenfeld, R.F., Bernstein-Bezier methods for the
computer-aided design of free-form curves and surfaces, Jour. Assoc. Com-
puting Mach., Vol. 21, No.2, pp. 293-310, 1974.
[Gord74b] Gordon, W.J., and Riesenfeld, R.F., B-spline curves and surfaces, in Com-
puter Aided Geometric Design, Barnhill, R.E., and Riesenfeld,
R.F., Eds., New York: Academic Press, 1974.
[Gord93] Gordon, W., Sculptured surface definition via blending function methods,
in [Pieg93].
[Gugg89] Guggenheimer, H., Computing frames along a trajectory, Comput. Aid.
Geom. Des., Vol. 6, pp. 77-78, 1989.
[Hoff89] Hoffmann, C.M., Geometric & Solid Modeling, San Mateo, CA: Morgan
Kaufmann, 1989.
634 References
[Hohm91] Hohmeyer, M. and Barsky, B., Skinning rational B-spline curves to con-
struct an interpolatory surface, Comput. Vis., Gmph. and Image Process-
ing: Gmphical Models and Image Processing, Vol. 53, No.6, pp. 511-521,
1991.
[Hosc88] Hoschek, J., Spline approximation of offset curves, Comput. Aid. Geom.
Des., Vol. 5, pp. 33-40, 1988.
[Hosc92a] Hoschek, J., Bezier curves and surface patches on quadrics, in Mathe-
matical Methods in Computer Aided Geometric Design II, Lyche, T., and
Schumaker, L., Eds., New York: Academic Press, pp. 331-342, 1992.
[Hosc92b] Hoschek, J., Circular splines, CAD, Vol. 24, No. 11, pp. 611-618, 1992.
[Hosc93] Hoschek, J., and Lasser, D., Fundamentals of Computer Aided Geometric
Design, Wellesley, MA: A.K. Peters, Ltd., 1993.
[Howa91a] Howard, T., Evaluating PHIGS for CAD and general graphics applica-
tions, CAD, Vol. 23, No.4, pp. 244-251, 1991.
[Howa91b] Howard, T.L.J., Hewitt, W.T., Hubbold, RJ., and Wyrwas, K.M., A
Pmctical Introduction to PHIGS and PHIGS PLUS, Reading, MA: Addi-
son-Wesley, 1991.
[Hsu92] Hsu, W., Hughes, J., and Kaufman, H., Direct manipulation of free-form
deformations, Comput. Gmph., Vol. 26, No.2, pp. 177-184, 1992.
[IGE93] The Initial Graphics Exchange Specification (IGES) Version 5.2, ANSI
YI4.26M, available from U.S. Product Data Association (US PRO), Fair-
fax, VA, USA, 1993.
[Ilyi84] Ilyin, V.A., and Poznyak, E.G., Analytic Geometry, Moscow: Mir Pub-
lishers, 1984.
[KapI52] Kaplan, W., Advanced Calculus, Reading, MA: Addison Wesley, 1952.
[Klok86] Klok, F., Two moving coordinate frames for sweeping along a 3D trajec-
tory, Comput. Aid. Geom. Des., Vol. 3, pp. 217-229, 1986.
[Knut73] Knuth, D.E., The Art of Computer Progmmming. Vol. 1, Fundamental
Algorithms, Reading, MA: Addison-Wesley, 1973.
[Lach88] Lachance, M.A., Chebyshev economization for parametric surfaces,
Comput. Aid. Geom. Des., Vol. 5, pp. 195-208, 1988.
[Lanc86] Lancaster, P., and Salkauskas, K., Curve and Surface Fitting, New York:
Academic Press, 1986.
[Lane80] Lane, J.M., and Riesenfeld, RF., A theoretical development for the com-
puter generation and display of piecewise polynomial surfaces, IEEE
Trans. Patt. Anal. Mach. Intell., Vol. PAMI-2, No.1, pp. 35-46, 1980.
[Lane83] Lane, J.M., and Riesenfeld, RF., A geometric proof for the variation
diminishing property of B-spline approximation, Jour. Approx. Theory,
Vol. 37, pp. 1-4, 1983.
[Laur93] Laurent-Gengoux, P., and Mekhilef, M., Optimization of a NURBS rep-
resentation, CAD, Vol. 25, No. 11, pp. 699-710, 1993.
References 635
[Lawr72] Lawrence, J.D., A Catalog of Special Plane Curves, New York: Dover,
1972.
[Lee83] Lee, E.T.Y., B-spline Primer, Boeing Document, 1983.
[Lee87] Lee, E.T.Y., Rational quadratic Bezier representation for conics, in Geo-
metric Modeling: Algorithms and New Trends, Farin, G.E., Ed., Philadel-
phia: SIAM, pp. 3-19, 1987.
[Lee89] Lee, E.T.Y., Choosing nodes in parametric curve interpolation, CAD,
Vol. 21, pp. 363-370, 1989.
[Lee91] Lee, E.T.Y., and Lucian, M.L., Mobius reparametrization of rational B-
splines, Comput. Aid. Geom. Des., Vol. 8, pp. 213-215, 1991.
[Limi44] Liming, R.A., Practical Analytic Geometry with Applications to Aircraft,
New York: Macmillan, 1944.
[Limi79] Liming, R.A., Mathematics for Computer Graphics, Fallbrook, CA: Aero
Publishers Inc., 1979.
[Lin94] Lin, F., and Hewitt, W., Expressing Coons-Gordon surfaces as NURBS,
CAD, Vol. 26, No.2, pp. 145-155, 1994.
[Lore86] Lorentz, G.G., Berntein Polynomials, New York: Chelsea Publishing Co.,
1986.
[Lych85] Lyche, T., Cohen, E., and Morken, K., Knot line refinement algorithms
for tensor product splines, Comput. Aid. Geom. Des., Vol. 2, Nos. 1-3,
pp. 133-139, 1985.
[Lych87] Lyche, T., and Morken, K., Knot removal for parametric B-spline curves
and surfaces, Comput. Aid. Geom. Des., Vol. 4, pp. 217-230, 1987.
[Lych88] Lyche, T., and Morken, K., A data reduction strategy for splines with
applications to the approximation of functions and data, IMA Jour. Num.
Anal., Vol. 8, pp. 185-208, 1988.
[Mats92) Matsuki, N., An interactive shape modification method for B-spline sur-
faces, in Human Aspects in Computer Integrated Manufacturing, Olling,
G., and Kimura, F., Eds., Amsterdam: Elsevier Science Publishers B.V.
(North-Holland) (IFIP), pp. 385-397, 1992.
[Mort85] Mortenson, M.E., Geometric Modeling, New York: John Wiley, 1985.
[Patt85] Patterson, R.R., Projective transformations of the parameter of a Bern-
stein-Bezier curve, ACM TOG, Vol. 4, No.4, pp. 276-290, 1985.
[Pieg86] Piegl, L., A geometric investigation of the rational Bezier scheme of Com-
puter Aided Design, Comput. in Industry, Vol. 7, pp. 401-410, 1986.
[Pieg87a] Piegl, L., and Tiller, W., Curve and surface constructions using rational
B-splines, CAD, Vol. 19, No.9, pp. 485-498, 1987.
[Pieg87b] Piegl, L., A technique for smoothing scattered data with conic sections,
Comput. in Industry, Vol. 9, pp. 223-237, 1987.
[Pieg87c] Piegl, L., On the use of infinite control points in CAGD, Comput. Aid.
Geom. Des., Vol. 4, pp. 155-166, 1987.
636 References
[Pieg87d] Piegl, L., Interactive data interpolation by rational Bezier curves, IEEE
Comput. Graph. and Appl., Vol. 7, No.4, pp. 45-58, 1987.
[Pieg88a] Piegl, L., Hermite- and Coons-like interpolants using rational Bezier ap-
proximation form with infinite control points, CAD, Vol. 20, No.1,
pp. 2-10, 1988.
[Pieg88b] Piegl, L., Coons-type patches, Comput. and Graph., Vol. 12, No.2,
pp. 221-228, 1988.
[Pieg89a] Piegl, L., Key developments in computer-aided geometric design, CAD,
Vol. 21, No.5, pp. 262-273, 1989.
[Pieg89b] Piegl, L., and Tiller, W., A menagerie of rational B-spline circles, IEEE
Comput. Graph. and Appl., Vol. 9, No.5, pp. 48-56, 1989.
[Pieg89c] Piegl, L., Modifying the shape of rational B-splines. Part 1: curves, CAD,
Vol. 21, No.8, pp. 509-518, 1989.
[Pieg89d] Piegl, L., Modifying the shape of rational B-splines. Part 2: surfaces,
CAD, Vol. 21, No.9, pp. 538-546, 1989.
[Pieg90] Piegl, L., Algorithms for computing conic splines, Jour. Comput. in Civil
Engmg., Vol. 4, No.3, pp. 180-197, 1990.
[Pieg91a] Piegl, L., On NURBS: A Survey, IEEE Comput. Graph. and Appl., Vol. 10,
No.1, pp. 55-71, 1991.
[Pieg91b] Piegl, L., and Tiller, W., Storage efficient decomposition of B-spline
curves, CSE 91-01, Department of Computer Science and Engineering,
Univ. of South Florida, Tampa, FL, 1991.
[Pieg93] Piegl, L., Ed., Fundamental Developments of Computer Aided Geometric
Modeling, London: Academic Press, 1993.
[Pieg94] Piegl, L., and Tiller, W., Software engineering approach to degree eleva-
tion of B-spline curves, CAD, Vol. 26, No.1, pp. 17-28, 1994.
[Pieg95] Piegl, L., and Tiller, W., Algorithm for degree reduction of B-spline
curves, CAD, Vol. 27, No.2, 1995.
[Prau84] Prautzsch, H., Degree elevation of B-spline curves, Comput. Aid. Geom.
Des., Vol. 1, No.1, pp. 193-198, 1984.
[Prau91] Prautzsch, H., and Piper, B., A fast algorithm to raise the degree of spline
curves, Comput. Aid. Geom. Des., Vol. 8, pp. 253-265, 1991.
[Prau92] Prautzsch, H., and Gallagher, T., Is there a geometric variation diminish-
ing property for B-spline or Bezier surfaces?, Comput. Aid. Geom. Des.,
Vol. 9, No.2, pp. 119-124, 1992.
[Pres88] Press, W., Flannery, B., Teukolsky, S., and Vetterling, W., Numerical
Recipes in C, Cambridge, UK: Cambridge University Press, 1988.
[PHIG92] Programmer's Hierarchical Interactive Graphics System (PHIGS), ISO/
IEC 9592-4: (1992), available from National Institute of Standards and
Technology (NIST), Gaithersburg, MD, USA.
[Rams87] Ramshaw, L., Blossoming: A connect-the-dots approach to splines, Report
19, Digital, Systems Research Center, Palo Alto, CA, 1987.
References 637
[Su89] Su, B., and Liu, D., Computational Geometry - Curves and Surface Mod-
eling, Boston: Academic Press, 1989.
[Till83] Tiller, W., Rational B-splines for curve and surface representation, IEEE
Comput. Gmph. and Appl., Vol. 3, No.6, pp. 61-69, 1983.
[Till84] Tiller, W., and Hanson, E., Offsets of two-dimensional profiles, IEEE
Comput. Gmph. and Appl., Vol. 4, No.9, pp. 36-46, 1984.
[Till92] Tiller, W., Knot-removal algorithms for NURBS curves and surfaces,
CAD, Vol. 24, No.8, pp. 445-453, 1992.
[Vand83] Vandergraft, J., Introduction to Numerical Computations, New York: Aca-
demic Press, 1983.
[Verg91] Vergeest, J., CAD surface data exchange using STEP, CAD, Vol. 23, No.4,
pp. 269-281, 1991.
[Vers75] Versprille, K.J., "Computer-Aided Design Applications of the Rational
B-spline Approximation Form," Ph.D. dissertation, Syracuse Univ., 1975.
[Wang81] Wang, C.Y., Shape classification of the parametric cubic curve and the
parametric B-spline cubic curve, CAD, Vol. 13, No.4, pp. 199-206, 1981.
[Watk88] Watkins, M.A., and Worsey, A.J., Degree reduction of Bezier curves, CAD,
Vol. 20, No.7, pp. 398-405, 1988.
[Wein92] Weinstein, S.E., and Xu, Y., Degree reduction of Bezier curves by approx-
imation and interpolation, in Approximation Theory, Anastassiou, G. A.,
Ed., New York: Dekker, 1992, pp. 503-512.
[Welc92] Welch, W., and Witkin, A., Variational surface modeling, Comput. Gmph.,
Vol. 26, No.2, pp. 157-166, 1992.
[Wood87] Woodward, C., Cross-sectional design of B-spline surfaces, Comput. and
Cmph., Vol. 11, No.2, pp. 193-201, 1987.
[Wood88] Woodward, C., Skinning techniques for interactive B-spline surface inter-
polation, CAD, Vol. 20, No.8, pp. 441-451, 1988.
[Yama88] Yamaguchi, F., Curves and Surfaces in Computer Aided Geometric De-
sign, New York: Springer-Verlag, 1988.
Nlib Ordering Information 639
To purchase a copy of the latest version of Nlib, send your name, address, af-
filiation, telephone number, Fax number and/or e-mail address (as appropriate)
to:
Dr. Wayne Tiller
GeomWare, Inc.
3036 Ridgetop Road
Tyler, TX 75703
Phone: (903) 839-5042
Fax: (903) 839-5042
E-mail: 76504.3045@CompuServe.com