B-Splines
B-Splines provide a method for approximating a set of points with a curve made up of polynomials of degree that gives continuity. Unlike the Bezier splines of the previous section, B-Splines allow curves to be generated for any desired degree of continuity (almost up to the number of points). B-Splines are, therefore, a prefered method for specifying very smooth curves (high degrees of continuity) in computer graphics. If we want a (or higher) curve through an arbitrary number of points, B-Splines are probably the right method.
The approach of using B-Splines represents a curve using a spline (a piecewise polynomial function) that is expressed as a linear combination of a set of basis functions. Since these basis functions are themselves splines, we call them Basis Splines or B-Splines for short. Each B-Spline or basis function is made up of a set of polynomials each of degree The methods of B-Splines provide general procedures for defining these functions.
The term B-Spline specifically refers to one of the basis functions, not the function created by the linear combination of a set of B-Splines. However, there is inconsistency in how the term is used in computer graphics. Commonly, a “B-Spline Curve” is used to mean a curve represented by the linear combination of B-Splines.
The idea of representing a polynomial as the linear combination of other polynomials has been discussed in Section Polynomial Notation, and Blending Functions. Representing a spline as a linear combination of other splines was shown in Section Knots. In fact, the example given is a simple case of a B-Spline.
The general notation for representing a function as a linear combination of other functions is
A set of B-Splines can be defined for a number of coefficients (or points) and a parameter value1 The value of is one more than the degree of the polynomials used to make the B-Splines ()
B-Splines are important because they provide a very general method for creating functions (that will be useful for representing curves) that have a number of useful properties. A curve with points made with B-Splines with parameter value is:
- continuous;
- made of polynomials of degree ;
- has local control. Any site on the curve only depends on of the control points;
- is bounded by the convex hull of the points;
- exhibits the variation diminishing property illustrated in Figure Figure (See below).
A curve created using B-Splines does not necessarily interpolate its control points.
We will introduce B-Splines by first looking at a specific, simple case to introduce the concepts. We will then generalize the methods, and show why they are interesting. Because the method for computing B-Splines is very general, we delay introducing it until we have shown what these generalizations are.
Uniform Linear B-Splines
Consider a set of basis functions of the following form:
Each of these functions looks like a little triangular “hat” between and with its peak at Each is a piecewise polynomial, with knots at , , and Two of them are graphed in Figure Figure (See below).
Figure 1:
B-Splines with d=2.For terminology, each of these functions is a B-Spline. A (or first degree, or linear) B-Spline with uniform knots, to be more specific. Because we will consider B-Splines of other parameter values later, we denote these with the 2 in the subscript.
Notice that we have chosen to put the lower edge of the B-Spline (e.g. its first knot) at Therefore the first knot of the first B-Spline () is at . This convention is chosen since its easier to talk about “the first” B-Spline or “the first” element of a vector, rather than the “zeroth.” It also makes the last element be Iteration over the B-Splines or elements of the coefficient vector is from to (see Equation Equation 1). When B-Splines are implemented, as well as in many other discussions of them, they often are numbered from to
If we had a set of coefficients or control points to create a function from, we could use Equation Equation 1, with these functions used for the to create an “overall” function that was influenced by the coefficients. For lack of a better term, I will refer to this function that is made of a linear combination of B-Splines as the “overall function.”
If we were to use these B-Splines to define the overall function, we would define a piecewise polynomial function that linearly interpolated the coefficients between and
Note that while B-Splines interpolate their all of their coefficients, B-Splines of higher order only do this under some specific conditions that we will discuss in Section Repeated Knots and B-Spline Interpolation.
Some properties of B-Splines can be seen in this simple case. We will write these in the general form using , the parameter, and for the number of coefficients or control points.
- Each B-Spline has knots.
- Each B-Spline is zero before its first knot and after its last knot.
- The overall spline has local control because each coefficient is only multiplied by one B-Spline, and this B-Spline is non-zero only between knots.
- The overall spline has knots.
- Each B-Spline is continuous, therefore the overall spline is continuous.
- The set of B-Splines sums to 1 for all parameter values between knots and This range is where there are B-Splines that are non-zero. Summing to 1 is important because it means that the B-Splines are shift invariant: translating the control points will translate the entire curve.
- Between each of its knots, the B-Spline is a single, degree polynomial. Therefore, the overall curve (that sums these together) can also be expressed as a single, degree polynomial between any adjacent knots.
In this example, we have chosen the knots to be uniformly spaced. We will consider B-Splines with non-uniform spacing later. When the knot spacing is uniform, each of the B-Splines are identical except for being shifted. B-Splines with uniform knot spacing are sometimes called uniform B-Splines or periodic B-Splines.
Uniform Quadratic B-Splines
The properties of B-Splines listed in the previous section were intentionally written for arbitrary and . A general procedure for constructing the B-Splines will be provided later, but first, lets consider another specific case with
The B-Spline is shown in Figure Figure (See below). It is made of quadratic pieces (degree 2), and has 3 of them. It is continuous, and is non-zero only within the 4 knots that it spans.
Figure 2:
The B-Spline b_{2,3} with uniform knot spacing.Notice that a quadratic B-Spline is made of 3 pieces, one between knot 1 and 2, one between knot 2 and 3, and one between knot 3 and 4. In Section Non-Uniform B-Splines we will see a general procedure for building these functions. For now, we simply examine these functions:
If we evaluate the overall function made from summing together the B-Splines, at any time only (3 in this case) of them are non zero. One of them will be in the first part of Equation Equation 3, one will be in the second part, and one will be in the third part. Therefore, we can think of any piece of the overall function as being made up of an degree polynomial that depends on coefficients. For the case, we can write
If we have a set of points, we can use the B-Splines to create a curve. If we have 7 points, we will need a set of 7 B-Splines. A set of 7 B-Splines for is shown in Figure Figure (See below). Notice that there are (10) knots, that the sum of the B-Splines is 1 over the range to (knots 3 through 8). A curve specified using these B-Splines and a set of points is shown in Figure Figure (See below).
Figure 3:
The set of 7 B-Splines with k=3 and uniform knot spacing [1,2,3,4,5,6,7,8,10].Figure 4:
Curve made from 7 quadratic (k=3) B-Splines, using 7 control points.Uniform Cubic B-Splines
Because cubic polynomials are so popular in computer graphics, the special case of B-Splines with is sufficiently important that we consider it before discussing the general case. A B-Spline of third degree is defined by 4 cubic polynomial pieces. The general process by which these pieces are determined is described later, but the result is:
Figure 5:
The cubic (k=4) B-Spline with uniform knots. WARNING: THE FIGURE IN THE DOCUMENT ALICE SENT ME IS CORRUPTED.We can write the function for the overall curve between knots and as a function of the parameter between and and the four control points that influence it:
Non-Uniform B-Splines
One nice feature of B-Splines is that they can be defined for any So if we need a smoother curve, we can simply raise the value of This is illustrated in Figure Figure (See below).
Figure 6:
B-Spline curves using the same uniform set of knots and the same control points, for various values of k. Note that as k increases, the valid parameter range for the curve shrinks.So far, we have said that B-Splines generalize to any and any There is one last generalization to introduce before we show how to actually compute these B-Splines. B-Splines are defined for any non-decreasing knot vector.
For a given and the set of B-Splines (and the function created by their linear combination) has knots. We can write the value of these knots as a vector, that we will denote as For the uniform B-Splines, the knot vector is However, B-Splines can be generated for any knot vector of length providing the values are non-decreasing (e.g. ).
There are two main reasons why non-uniform knot spacing is useful: it gives us control over what parameter range of the overall function each coefficient effects, and it allows us to repeat knots (e.g. create knots with no spacing in between) to create functions with different properties around these points. The latter will be considered in Section Repeated Knots and B-Spline Interpolation.
The ability to specify knot values for B-Splines is similar to being able to specify the interpolation sites for interpolating spline curves. It allows us to associate curve features with parameter values. By specifying a non-uniform knot vector, we specify what parameter range each coefficient of a B-Spline curve effects. Remember that B-Spline is non-zero only between knot and knot Therefore, the coefficient associated with it only effects the curve between these parameter values.
One place where control over knot values is particularly useful is in inserting or deleting knots near the beginning of a sequence. To illustrature this, consider a curve defined using linear B-Splines () as discussed in Section Uniform Linear B-Splines. For the uniform knot vector is This curve would be controlled by a set of 4 points, and span the parameter range to The “end” of the curve () interpolates the last control point. If we insert a new point in the middle of the point set, we would need a longer knot vector. The locality properties of the B-Splines prevent this insertion from affecting the values of the curve at then ends. The longer curve would still interpolate its last control point at its end. However, if we chose to keep the uniform knot spacing, the new knot vector would be the end of the curve would be at and the parameter value at which the last control point is interpolated at a different parameter value than before the insertion. With non-uniform knot spacing, we can use the knot vector so that the ends of the curve are unaffected by the change. The abilities to have non-uniform knot spacing makes the locality property of B-Splines an algebraic property, as well as a geometric one.
We now introduce the general method for defining B-Splines. Given values for the number of coefficients the B-Spline parameter and the knot vector (which has length ), the following recursive equations define the B-Splines:
As an example, consider how we would have derived Equation Equation 3. Using a uniform knot vector We use this vector and the value in Equation Equation 9 to give:
To see that this expression is equivalent to Equation Equation 3, we note that each of the B-Splines is like a switch, turning on only for a particular parameter range. For instance, is only non-zero between and So, if only the first of the B-Splines in the expression is non-zero, so
Repeated Knots and B-Spline Interpolation
While B-Splines have many nice properties, functions defined using them generally do not interpolate the coefficients. This can be inconvenient if we are using them to define a curve that we want to interpolate a specific point.
One way to cause B-Splines to interpolate their coefficients is to repeat knots. If all of the interior knots for a particular B-Spline have the same value, then the overall function will interpolate this B-Spline’s coefficient. An example of this is shown in Figure Figure (See below).
Figure 7:
Uniform KnotsFigure 8:
Non-Uniform KnotsA curve parameterized by Quadratic B-Splines (d=3) with 7 control points. On the left, uniform knots vector is used. On the right, the non-uniform knot spacing is used. The duplication of the 4th and 8th knot means that all interior knots of the 3rd and 7th B-Spline are equal, so the curve interpolates the control point associated with those points.
Interpolation by repeated knots comes at a high cost: it removes the smoothness of the B-Spline and the resulting overall function and represented curve. However, at the beginning and end of the spline, where continuity is not an issue, knot repetition is useful for creating endpoint interpolating B-Splines. While the first (or last) knot’s value is not important for interpolation, for simplicity, we make the first (or last) knots have the same value to achieve interpolation.
The endpoint interpolating Quadratic B-Splines are shown in Figure Figure (See below). The first two and last two B-Splines are different than the uniform ones. Their expressions can be derived through the use of the Cox-de Boor recurrence:
Figure 9:
Endpoint-interpolating Quadratic (k=3) B-Splines, for n=8. The knot vector is [0,0,0,1,2,3,4,5,6,6,6]. The first and last two B-Splines are aperiodic, while the middle 4 (shown as dotted lines) are periodic, and identical to the ones in Figure Figure (See below).NURBS
Despite all of the generality B-Splines provide, there are some functions that cannot be exactly represented using them. In particular, B-Splines cannot represent conic sections. To represent such curves, a ratio of two polynomials is used. Non-Uniform B-Splines are used to represent both the numerator and the denominator. The most general form of these are Non-Uniform Rational B-Splines, or NURBS for short.
NURBS associate a scalar weight with every control point and use the same B-Splines for both:
NURBS are very widely used to represent curves and surfaces in geometric modelling because of the amazing versatility they provide, in addition to the useful properties of B-Splines.
The B-Spline parameter is actually the order of the polynomials used in the B-Splines, using the terminology of de Boor (Source: deboor). While this terminology is not uniform in the literature, the use of the B-Spline parameter as a value one greater than the polynomial degree is widely used, although some texts (such as (Source: Reisenfeld)) write all of the equations in terms of polynomial degree. ↩︎