An Introduction to NURBS

by

David F. Rogers


Gathered here are a number of useful algorithms. The algorithms are implementations of the pseudocode in Appendix C of An Introduction to NURBS. Here the algorithms have been loosely translated into a `real' programming language, i.e., C. Hopefully, the availability of the algorithms in C will increase your understanding of the algorithms and hence of the underlying mathematics. However, although each program has been tested, errors may have been introduced during implementation that have escaped the testing process. Consequently, before depending on these C implementations you should carefully check the algorithms against the mathematics presented in the text and conduct further testing, i.e., the algorithms are presented as is without any warranties implied or otherwise. Use them at your own risk.

The algorithms are designed to be educational, i.e., they are intended to support the mathematical techniques discussed in the text. They are not intended to be the most efficient implementations possible. Frequently, computational inefficiencies are accepted if the resulting algorithm more closely follows the discussion in the text. An example is the B-spline surface algorithm bsplsurf.c. In the C implementation given below, the B-spline basis functions for each parameter value are calculated inside the main loop. This reduces memory requirements. However, it is computationally more efficient to calculate all of the basis functions externally to the main loop, form their products and store them in a large array. Appropriate elements of the array are then used within the main loop to calculate position vectors on the surface. A few minutes' thought shows that, for reasonably complex surfaces, the array size becomes quite large. However, the algorithm runs several times faster than the C implementation presented.

Notice also that in implementing the algorithms generally only linear arrays are used for storage and that all indexing into the arrays is done locally. Also notice that the zero index element in a C array is ignored and that data always starts with an index value of one. This is more consistent with matrix algebra representations.

Finally many of the pseudocode implementations that use matrix functions to calculate individual points on a curve or surface are done in the C implementations without matrix functions. This provides an example of an alternate implementation technique. It also avoids having to deal with C multiple dimension arrays!

The algorithms are grouped by chapter and alphabetically by name within each chapter. Each algorithm is accompanied by a test program named by prepending a t to the algorithm name (and sometimes shortening the name in obvious ways). For completeness within each chapter all the supporting files for the main routines are also listed, e.g., the routine to generate an open knot vector, knot.c, and the routine to generate a B-spline basis function, basis.c, are listed in several different chapters.

COPYRIGHT:    Each of the C implementations is copyrighted by the author. Noncommercial use is authorized. Commercial use requires written permission of the author.

DOWNLOADING:

You may download individual algorithms or entire chapters or all the algorithms currently available. Individual files download as text. Chapter groups and the entire list are available as .zip or UNIX .tar.gz files. If you download individual files, be sure to also download the appropriate test program.

All programs have been compiled under UNIX and under MSDOS. Compilation under MSDOS used the MS C Compiler Version 5.0.

Click on the chapter number to see the algorithms available for download.

Table of Contents

Chapter 2   Bezier Curves
Chapter 3   B-spline Curves
Chapter 4   Rational B-spline (NURBS) Curves
Chapter 5   Bezier Surfaces
Chapter 6   B-spline Surfaces
Chapter 7   Rational B-spline (NURBS) Surfaces
 

Chapter 2   Bezier Curves
 
bezier.c  tbezier.c  Calculates a Bezier curve.
dbezier.c  tdbez.c  Calculates a Bezier curve and it's derivatives.
chap2all.zip    ZIP file for all of Chapter 2.
chap2all.tar.gz    UNIX tar file for all of Chapter 2. Top of page
 
Chapter 3   B-spline Curves
 
basis.c  tbasis.c  Calculates the B-spline basis functions.
bspline.c  tbspline.c  Calculates a B-spline curve.
bsplineu.c  tbsplinu.c  Calculates a periodic B-spline curve.
dbasis.c  tdbasis.c  Calculates the B-spline basis functions and derivatives.
dbasisu.c  tdbasisu.c  Calculates the periodic B-spline basis functions.
dbspline.c  tdbspl.c  Calculates a B-spline curve and derivatives.
dbsplinu.c  tdbsplu.c  Calculates a periodic B-spline curve and derivatives.
knot.c  tknot.c  Calculates an open knot vector.
knotc.c  tknotc.c  Calculates a chord length approximation open knot vector.
knotu.c  tknotu.c  Calculates a periodic knot vector.
param.c  tparam.c  Calculates the chord length paramter values.
chap3all.zip    ZIP file for all of Chapter 3.
chap3all.tar.gz    UNIX tar file for all of Chapter 3.    Top of page
 
 

Chapter 4   Rational B-spline (NURBS) Curves
 
knot.c  tknot.c  Calculates an open knot vector.
knotu.c  tknotu.c  Calculates a periodic knot vector.
rbasis.c  trbasis.c  Calculates the rational B-spline basis functions.
rbspline.c  trbsplin.c  Calculates an open rational B-spline curve.
rbsplinu.c  trbspliu.c  Calculates a periodic rational B-spline curve.
chap4all.zip    ZIP file for all of Chapter 4.
chap4all.tar.gz    UNIX tar file for all of Chapter 4.    Top of page
 
 

Chapter 5   Bezier Surfaces
 
bezsurf.c  tbezsurf.c  Calculates a Bezier surface.
chap5all.zip    ZIP file for all of Chapter 5.
chap5all.tar.gz    UNIX tar file for all of Chapter 5.    Top of page
 
 
Chapter 6   B-spline Surfaces
 
basis.c  tbasis.c  Calculates the B-spline basis functions.
bsplsurf.c  tbsurf.c  Calculates a B-spline surface.
bspsurfu.c  tbsurfu.c  Calculates a periodic B-spline surface.
dbasis.c  tdbasis.c  Calculates the B-spline basis functions and derivatives.
dbsurf.c  tdbsurf.c  Calculates a B-spline surface and derivatives.
knot.c  tknot.c  Calculates an open knot vector.
knotu.c  tknotu.c  Calculates a periodic knot vector.
rdpnp.c  Support routine - inputs PNP (polygon net point) file.
chap6all.zip    ZIP file for all of Chapter 6.
chap6all.tar.gz    UNIX tar file for all of Chapter 6.    Top of page
 
 
Chapter 7   Rational B-spline (NURBS) Surfaces
 
basis.c  tbasis.c  Calculates the B-spline basis functions.
frbsurf.c  tfrbsurf.c  Calculates and test the fast B-spline surface algorithm.
knot.c  tknot.c  Calculates an open knot vector.
rbspsurf.c  trbsurf.c  Calculates a rational B-spline (NURBS) surface.
rbsurf.h    Header file for fast rational B-spline surface program
sumrbas.c    Calculates the Sum function for a rational B-spline surface.
chap7all.zip    ZIP file for all of Chapter 7.
chap7all.tar.gz    UNIX tar file for all of Chapter 7.    Top of page
 
 

  Front Cover    Back Cover    Table of Contents    About the Author 
 Sample Worked Example 
 Reviewer Comments 
 Order 

 Home 

Copyright © 2000 David F. Rogers. All rights reserved.