B-spline parametric
curve demonstration
A B-spline is one specific type
of parametric curve of which there are several. These types
of curves are used extensively in CAD and other graphics applications requiring
compound,
non-circular curves. This applet uses cubic, uniform B-splines
to demonstrate the principles behind B-splines in general.
A B-spline is defined by an ordered
set of control points or control polygon which determines
what path the curve will follow and consequently how the curve will look.
A longer B-spline is actually made up of several curve segments,
each one of which is defined by some number of control points in its viscinity.
For a cubic B-spline, this number is four. A point on a particular curve
segment is calculated by simply adding up the coordinate values of its
defining control points after they have been multiplied by a weighting
factor. The weighting factor is calculated using a set of
parametric
basis or blending functions. Each control point is weighted by
the value of just one blending function for a specific curve segment. For
each curve segment, the value of the parameter varies from zero to one
in the blending functions. The value of the blending functions across the
range of the parameter multiplied by the control point's coordinates define
a number of intermediate points, which form a curve when connected.
The applet below will let you play with
some splines yourself to see:
-
how the control points determine the path
of the spline and
-
how the weight (i.e. influence on the shape
of the spline) of a particular control point changes over the length of
the spline.
Note: In order to use the applet you
must be using a browser that supports Sun's jdk1.1 api.
How to use the applet:
-
The buttons on the left select the mode.
-
First add some points in add mode (note that
no curve will be drawn until at least four points have been added). Adjacent
curve segments are drawn in different colors.
-
Move the control points around using move
mode to see how the curve changes shape.
-
Move the scroll bar to change the trace point
position. The trace point is shown as a small asterisk on the curve. As
the trace point moves along the curve, the four control points currently
contributing to its position will be highlighted in red. Their relative
weights are given next to the point number as a percentage.
-
You can delete points one at a time with the
delete function, or clear all the control points at once with the clear
function.
Things to notice:
B-splines have a couple of features that
make them popular curve representations.
-
Locality. This means that changing the
position of one control point only changes the sections of the curve near
it. The farther away a curve segment is from the control point being
moved, the smaller the change. Try moving one of the fat red control
points in the applet. The position of the trace point changes
a lot because this point is weighted heavily for the trace position (hence
the fat dot). Move one of the smaller red control points and the
position of the trace point changes less. If you move one of the
black control points, the trace point doesn't move at all. Those
control points aren't contributing anything to the trace point's position.
-
Continuity. Because adjacent curve segments
share control points by definition, B-splines have built in 2nd order continuity.
That means that every point has a first and a second derivative.
More intuitively it means that there are no sharp spikes or inflection
points within a curve segment. You can simulate a discontinuity by
stacking several control points on top of one another. Three control
points at the same location suffice to create a sharp spike that interpolates
(passes through) that location. Try it in the applet!
-
B-splines are easily extended to three dimensional
curves and surfaces.
Last modified on 9/4/98 by stj