An alternative to the Bezier spline technology is based on the B-splines. The technology allows a set of input points to be either interpolated or approxi-mated, providing much more flexibility. The curves are still directed by control points, however, they are not given a priori, they are computed as part of the process. The technology, therefore, is more flexible than the Bezier technology and is preferred in the industry.
A general non-uniform, non-rational B-spline is described by
S(t) =
n i=0
Bi,k(t)Qi,
where Qi are the yet unknown control points and Bi,k are the B-spline basis functions of degree k. They are computed based on a certain parameteriza-tion influencing the shape of the curve. Note that for now we are focusing on
0, t < ti, t≥ ti+1
and higher order terms are recursively computed:
Bi,k(t) = t− ti
ti+k− ti
Bi,k−1(t) + ti+k+1− t
ti+k+1− ti+1Bi+1,k−1(t).
The parameter values for the spline may be assigned via various methods. The simplest, and most widely used method is the uniform spacing. The method for n + 1 points is defined by the parameter vector
t =
0 1 2 . . . n .
When the input points are geometrically somewhat equidistant this is proven to be a good method for parameterization. When the input points are spaced in widely varying intervals, a parameterization based on the chord length may also be used.
The parameter vector is commonly normalized as t =
0 1/n 2/n . . . 1 .
Such normalization places all the parameter values in the interval (0, 1) easing the complexity of the evaluation of the basis functions.
First we seek to interpolate a given set of points Pj = (P xj, P yj, P zj); j = 0, . . . , m,
requiring that the B-spline (S(t) at parameter value tj passes through the given point Pj. This results in the equation
⎡
Using a matrix notation, the problem is P = BQ,
where the P column matrix contains m + 1 terms and the Q column matrix contains n + 1 terms, resulting in a rectangular system matrix B with (m + 1) rows and (n + 1) columns. This problem may not be solved in general when
m < n, the case when the number of points given is less than the number of control points. The problem may also be only solved in a least squares sense when m > n, having more input points than control points.
The problem has a unique solution for the case of m = n and in this case the sequence of unknown control points is obtained in the form of
Q = B−1P,
where the inverse is shown for the sake of simplicity, it is not necessarily com-puted. In fact, the B matrix exhibits a banded pattern that is dependent on the degree k of the spline chosen. Specifically, the semi-bandwidth is less than the order k.
Bi,k(tj) = 0; f or|i − j| >= k.
This fact should be exploited to produce an efficient solution.
The second approach is to approximate the input points in a least squares sense, resulting in a distinctly different curve. This may be obtained by find-ing a minimum of the squares of the distances between the spline and the points.
m j=0
(S(tj)− Pj)2.
Substituting the B-spline formulation and the basis functions results in
m j=0
(
n i=0
Bi,k(tj)Qi− Pj)2.
The derivative with respect to an unknown control point Qp is
2
m j=0
Bp,k(tj)(
n i=0
Bi,k(tj)Qi− Pj) = 0,
where p = 0, 1, . . . , n. This results in a system of equations, with n + 1 rows and columns, in the form:
BTBQ = BTP
with the earlier introduced B matrix. The solution of this system produces an approximated, not interpolated solution.
The technology may also be extended to include smoothing considerations and directional constraints to the splines, topics that are discussed at length in [3].
coordinates may be obtained simultaneously.
For a fixed degree, say k = 3, and uniformly parameterized B-spline segments the basis functions may be analytically computed as:
B0,3=1
For the case of 4 points (n = 3) the uniform parameter vector becomes:
t =
0 1 2 3 .
For this case the interpolation system matrix is easily computed by hand as
B = 1
The matrix is positive definite and its inverse is:
B−1 =1
The solution for the control points is obtained as Q = B−1P,
where P is the vector of input points. For example for the points
P =
⎡
⎢⎢
⎣ 0 0 1 1 2 1 3 0
⎤
⎥⎥
⎦ ,
the control points obtained are
Q =
⎡
⎢⎢
⎣
−1 −11/6 0 1/6 1 7/6 2 7/6
⎤
⎥⎥
⎦ .
Figure 2.7 shows the curve generated from the control points interpolating the given input points, while spanning the parameter range from 0 to 3.
FIGURE 2.7 B spline interpolation
To evaluate the spline curve as function of any parameter value in the span, the following matrix formula (conceptually similar to the Bezier form) may
C = 1
where the C matrix is gathered from the coefficients of the analytic basis func-tions above, and
T =
1 t t2t3 .
This formula enables the validation of the spline going through the input points. For example
St=1 = T CQ = 1 1
, which of course agrees with the second input point.
For demonstration of the approximation computation, we add another input point to the above set. The given set of 5 input points are:
P =
For the case of 5 points (n = 4) the parameter vector becomes:
t =
0 1 2 3 4 . For this case the B matrix is
B = 1
The solution for the control points in this case is obtained as Q = (BTB)−1BTP.
Figure 2.8 shows the curve generated from these control points approximat-ing the given input points, while spannapproximat-ing the parameter range from 0 to 4.
The evaluation yields the approximation points
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5
-0.5 0 0.5 1 1.5 2 2.5 3
’input.dat’
’control.dat’
x(t), y(t)
FIGURE 2.8 B spline approximation
Sapp=
⎡
⎢⎢
⎢⎢
⎣
0.028571−0.014286 0.885714 1.057143 2.171429 0.914286 2.885714 0.057143 2.028571−1.014286
⎤
⎥⎥
⎥⎥
⎦,
which reasonably well approximate the input points, while producing a smooth curve.
The selection of the parameter values enables interesting and useful shape variations of the spline around the same set of given points. For example, re-peated values of the parameter values at both ends enforce a clamped bound-ary condition, forcing the curve through the end points. Figure 2.9 shows the curve generated from these control points and for the same input points, still approximating them.
Note that the number of pre-assigned parameter values, in this case be-comes 9 and the parameter vector will be
t =
0 0 0 1/4 1/2 3/4 1 1 1 .
-1 -0.5 0
0 0.5 1 1.5 2 2.5 3
FIGURE 2.9 Clamped B spline approximation
Also note that the number of sections of the spline increased to 6 in this case.
The figure depicts the sections of the spline with different line patterns as shown on the legend, while spanning the parameter range from 0 to 1.
Finally, the curve adhering to the same set of input points may also be closed by repeating an input point. The starting point repeated at the end results in the closed curve shown in Figure 2.10, in this case with 5 sections.
This example also demonstrated that a level continuity between the seg-ments of the B-spline is automatically assured depending on the degree k of the spline. There is no need for special considerations when large number of input points are given.
-1 -0.5 0 0.5 1
0 0.5 1 1.5 2 2.5 3
’input’
x1(t), y1(t) x2(t), y2(t) x3(t), y3(t) x4(t), y4(t) x5(t), y5(t)
FIGURE 2.10 Closed B spline approximation