In the
mathematical
Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
subfield of
numerical analysis
Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of numerical methods th ...
de Boor's algorithm
[C. de Boor ]971
Year 971 ( CMLXXI) was a common year starting on Sunday (link will display the full calendar) of the Julian calendar.
Events
By place
Byzantine Empire
* Battle of Dorostolon: A Byzantine expeditionary army (possibly 30–40,000 men ...
"Subroutine package for calculating with B-splines", Techn.Rep. LA-4728-MS, Los Alamos Sci.Lab, Los Alamos NM; p. 109, 121. is a polynomial-time and
numerically stable
In the mathematical subfield of numerical analysis, numerical stability is a generally desirable property of numerical algorithms. The precise definition of stability depends on the context. One is numerical linear algebra and the other is algor ...
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
for evaluating
spline curve
In mathematics, a spline is a special function defined piecewise by polynomials.
In interpolating problems, spline interpolation is often preferred to polynomial interpolation because it yields similar results, even when using low degree pol ...
s in
B-spline
In the mathematical subfield of numerical analysis, a B-spline or basis spline is a spline function that has minimal support with respect to a given degree, smoothness, and domain partition. Any spline function of given degree can be express ...
form. It is a generalization of
de Casteljau's algorithm In the mathematical field of numerical analysis, De Casteljau's algorithm is a recursive method to evaluate polynomials in Bernstein form or Bézier curves, named after its inventor Paul de Casteljau. De Casteljau's algorithm can also be used to sp ...
for
Bézier curve
A Bézier curve ( ) is a parametric curve used in computer graphics and related fields. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. Usually the curve is intended to approximate a real-world shape ...
s. The algorithm was devised by
Carl R. de Boor
Carl-Wilhelm Reinhold de Boor (born 3 December 1937) is a German-American mathematician and professor emeritus at the University of Wisconsin–Madison.
In 1993, de Boor was elected as a member into the National Academy of Engineering for contr ...
. Simplified, potentially faster variants of the de Boor algorithm have been created but they suffer from comparatively lower stability.
Introduction
A general introduction to B-splines is given in the
main article. Here we discuss de Boor's algorithm, an efficient and numerically stable scheme to evaluate a spline curve
at position
. The curve is built from a sum of B-spline functions
multiplied with potentially vector-valued constants
, called control points,
:
B-splines of order
are connected piece-wise polynomial functions of degree
defined over a grid of knots
(we always use zero-based indices in the following). De Boor's algorithm uses
O(p
2) +
O(p) operations to evaluate the spline curve. Note: the
main article about B-splines and the classic publications
use a different notation: the B-spline is indexed as
with
.
Local support
B-splines have local support, meaning that the polynomials are positive only in a finite domain and zero elsewhere. The Cox-de Boor recursion formula
[C. de Boor, p. 90] shows this:
:
:
Let the index
define the knot interval that contains the position,
. We can see in the recursion formula that only B-splines with are non-zero for this knot interval. Thus, the sum is reduced to:
:
It follows from that . Similarly, we see in the recursion that the highest queried knot location is at index . This means that any knot interval which is actually used must have at least additional knots before and after. In a computer program, this is typically achieved by repeating the first and last used knot location times. For example, for and real knot locations , one would pad the knot vector to .
The algorithm
With these definitions, we can now describe de Boor's algorithm. The algorithm does not compute the B-spline functions directly. Instead it evaluates through an equivalent recursion formula.
Let be new control points with for . For the following recursion is applied:
:
:
Once the iterations are complete, we have , meaning that is the desired result.
De Boor's algorithm is more efficient than an explicit calculation of B-splines with the Cox-de Boor recursion formula, because it does not compute terms which are guaranteed to be multiplied by zero.
Optimizations
The algorithm above is not optimized for the implementation in a computer. It requires memory for temporary control points . Each temporary control point is written exactly once and read twice. By reversing the iteration over (counting down instead of up), we can run the algorithm with memory for only temporary control points, by letting reuse the memory for . Similarly, there is only one value of used in each step, so we can reuse the memory as well.
Furthermore, it is more convenient to use a zero-based index for the temporary control points. The relation to the previous index is . Thus we obtain the improved algorithm:
Let for . Iterate for :
: ( must be counted down)
:
After the iterations are complete, the result is .
Example implementation
The following code in the Python (programming language)">Python programming language
Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.
Python is dynamically-typed and garbage-collected. It supports multiple programming par ...
is a naive implementation of the optimized algorithm.
def deBoor(k: int, x: int, t, c, p: int):
"""Evaluates S(x).
Arguments
---------
k: Index of knot interval that contains x.
x: Position.
t: Array of knot positions, needs to be padded as described above.
c: Array of control points.
p: Degree of B-spline.
"""
d = [c[j + k - p] for j in range(0, p + 1)]
for r in range(1, p + 1):
for j in range(p, r - 1, -1):
alpha = (x - t[j + k - p]) / (t[j + 1 + k - r] - t[j + k - p])
d[j] = (1.0 - alpha) * d - 1+ alpha * d
return d
See also
*
De Casteljau's algorithm In the mathematical field of numerical analysis, De Casteljau's algorithm is a recursive method to evaluate polynomials in Bernstein form or Bézier curves, named after its inventor Paul de Casteljau. De Casteljau's algorithm can also be used to sp ...
*
Bézier curve
A Bézier curve ( ) is a parametric curve used in computer graphics and related fields. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. Usually the curve is intended to approximate a real-world shape ...
*
NURBS
Non-uniform rational basis spline (NURBS) is a mathematical model using basis splines (B-splines) that is commonly used in computer graphics for representing curves and surfaces. It offers great flexibility and precision for handling both analy ...
External links
De Boor's Algorithm
Computer code
PPPACK contains many spline algorithms in
Fortran
GNU Scientific Library C-library, contains a sub-library for splines ported from
PPPACK
SciPy Python-library, contains a sub-library ''scipy.interpolate'' with spline functions based on
FITPACK
TinySpline C-library for splines with a C++ wrapper and bindings for C#, Java, Lua, PHP, Python, and Ruby
Einspline C-library for splines in 1, 2, and 3 dimensions with Fortran wrappers
References
Works cited
*{{cite book , author = Carl de Boor , title = A Practical Guide to Splines, Revised Edition , publisher = Springer-Verlag , year = 2003, isbn=0-387-95366-3
Numerical analysis
Splines (mathematics)
Interpolation