public class CubicBSpline extends ParametricCurve
The cubic B-spline is defined by third order polynomial basis functions. Each point on the curve is locally controlled by 4 control-points. In general, the curve does not pass through the control points, only near. The exceptions to this are the first and last control-points and if there are duplicate sequential control-points.
The CubicBSpline is the same as the BSpline with degree 3. However, the CubicBSpline is much faster to compute than the BSpline. The following table represents the approximate speed difference in computation between the CubicBSpline and BSpline of degree 3.
Number of Points | Times Faster |
10 | 4.6 |
20 | 6.9 |
30 | 9.5 |
40 | 11 |
As the number of points increases, the BSpline gets slower and slower. The reason is the CubicBSpline is built in segments, using 4 points at a time. However, the BSpline is a single segment, and requires iteration through all the points to compute a single point on the curve. Unlike the BSpline, the CubicBSpline does not have a knot vector, a definable sample limit, range or degree, which means the memory required for the CubicBSpline is less than the BSpline.
Relative to other curves, the cubic B-spline is computationally inexpensive, and easy to work with. To create a closed cubic B-spline, use "0:n-1,0:2" as the control-string and set interpolateEndpoints to false. Figures 1, 2 & 3 show some examples of cubic B-splines. See the appendTo method for more information.
BSpline
Constructor and Description |
---|
CubicBSpline(ControlPath cp,
GroupIterator gi) |
Modifier and Type | Method and Description |
---|---|
void |
appendTo(MultiPath mp)
The requirements for this curve are the group-iterator must be in-range and have a group size of at least 4.
|
protected void |
eval(double[] p)
The eval method evaluates a point on a curve given a parametric value "t".
|
boolean |
getInterpolateEndpoints()
Returns the interpolateEndpoints value.
|
int |
getSampleLimit()
Returns a value of 1.
|
void |
setInterpolateEndpoints(boolean b)
Sets the curve to start at the first control-point and end at the last control-point specified by
the group-iterator.
|
getConnect, getControlPath, getGroupIterator, resetMemory, setConnect, setControlPath, setGroupIterator
public CubicBSpline(ControlPath cp, GroupIterator gi)
protected void eval(double[] p)
ParametricCurve
eval
in class ParametricCurve
public int getSampleLimit()
getSampleLimit
in class ParametricCurve
public void setInterpolateEndpoints(boolean b)
getInterpolateEndpoints()
public boolean getInterpolateEndpoints()
setInterpolateEndpoints(boolean)
public void appendTo(MultiPath mp)
appendTo
in class Curve
MultiPath
,
BinaryCurveApproximationAlgorithm
Copyright © 2016. All rights reserved.