Contents
De Boor's algorithm
In the mathematical subfield of numerical analysis, de Boor's algorithm is a polynomial-time and numerically stable algorithm for evaluating spline curves in B-spline form. It is a generalization of de Casteljau's algorithm for Bézier curves. The algorithm was devised by German-American mathematician Carl R. de Boor. 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 x. The curve is built from a sum of B-spline functions B_{i,p}(x) multiplied with potentially vector-valued constants, called control points, B-splines of order p + 1 are connected piece-wise polynomial functions of degree p defined over a grid of knots (we always use zero-based indices in the following). De Boor's algorithm uses O(p2) + 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 B_{i,n}(x) with n = p + 1.
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 shows this: Let the index k 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 i \geq 0 that k \geq p. Similarly, we see in the recursion that the highest queried knot location is at index k + 1 + p. This means that any knot interval which is actually used must have at least p additional knots before and after. In a computer program, this is typically achieved by repeating the first and last used knot location p times. For example, for p = 3 and real knot locations (0, 1, 2), 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 B_{i,p}(x) 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 B_{i,p}(x) 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 i (counting down instead of up), we can run the algorithm with memory for only p + 1 temporary control points, by letting reuse the memory for. Similarly, there is only one value of \alpha 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 : Note that j must be counted down. After the iterations are complete, the result is.
Example implementation
The following code in the Python programming language is a naive implementation of the optimized algorithm.
Computer code
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.