Suppose that you are interested not in controlled design
but in interpolation. In other words, data points
are given and you want a relaxed cubic spline curve
for
such that
; i.e., the
curve goes through the data points.
One easy approach is to use B-splines as an intermediate
step. This time, though, you know the points
and you must compute the appropriate control points
before you will be able to compute the Bézier
control points for the individual pieces.
Of course, and
. To
find
, we can use the linear equations
already found above for the
in terms of the
and solve them treating the
as unknowns and the
as constants. When the linear equations are written in matrix form,
they look like this (for
):
Here the and
are points, so that in
R
they are pairs of numbers. These equations are
equivalent to two sets of equations with the same coefficient
matrix, one set for
coordinates and one for
coordinates. To solve them, though, it is easiest to use one of
two more direct methods. Let
be the matrix of
coefficients (which we can call the ``1 4 1 matrix''), let
be the matrix whose rows are
, and let
be the matrix of constants on the right.
Note: The
matrix
is
nonsingular for any
. In general, a matrix is
guaranteed to be well behaved if its diagonal entries are
all large in absolute value compared to the sums of the
absolute values of the off-diagonal entries in each row.
Problem. Find Bézier control points for the four
segments of the relaxed cubic spline curve through the data
points
,
,
,
,
, as shown in
Figure
. Useful information:
.
Solution. , so the ``1 4 1'' equations in matrix
form are
:
. Solving these equations
by using the matrix inverse, we get
Therefore the B-spline control points are
,
,
,
,
. The four sets of cubic
Bézier control points are as follows, and together they
give Bézier curves that go together to make the curve
shown in Figure
.
Derivation of the ``1 4 1'' equations. The first and last
equations are different from the middle ones. For all
equations, recall that
. For the middle
equations, just multiply this relation by
to get
.
For the first equation,
;
recall that
and subtract
from both
sides. The last equation is handled similarly, by using the
fact that
.
Remark.
As you see, we used B-splines to do interpolation. Usually
when you hear someone talk about a ``B-spline'' problem, though,
the control points will be given; when you hear someone
talk about a ``spline interpolation'' problem, the
will
be given and the person may or may not be thinking of using
B-splines to get the answer.