com.graphbuilder.curve
Class CubicBSpline

java.lang.Object
  extended bycom.graphbuilder.curve.Curve
      extended bycom.graphbuilder.curve.ParametricCurve
          extended bycom.graphbuilder.curve.CubicBSpline

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 PointsTimes Faster
104.6
206.9
309.5
4011
Table 1: Efficiency of CubicBSpline

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.

See Also:
BSpline

Field Summary
 
Fields inherited from class com.graphbuilder.curve.Curve
connect, cp, gi
 
Constructor Summary
CubicBSpline(ControlPath cp, GroupIterator gi)
           
 
Method Summary
 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.
 
Methods inherited from class com.graphbuilder.curve.Curve
getConnect, getControlPath, getGroupIterator, resetMemory, setConnect, setControlPath, setGroupIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CubicBSpline

public CubicBSpline(ControlPath cp,
                    GroupIterator gi)
Method Detail

eval

protected void eval(double[] p)
Description copied from class: ParametricCurve
The eval method evaluates a point on a curve given a parametric value "t". The parametric value "t" is stored in the last index location of the specified double array. This value should not be changed. The dimension of the point to evaluate is p.length - 1. The result of the evaluation is placed in index locations 0 .. p.length - 2 (inclusive). The eval method should remain protected except for those curves that do no need any preparation to be done in the appendTo method.

Specified by:
eval in class ParametricCurve

getSampleLimit

public int getSampleLimit()
Returns a value of 1.

Specified by:
getSampleLimit in class ParametricCurve

setInterpolateEndpoints

public 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.

See Also:
getInterpolateEndpoints()

getInterpolateEndpoints

public boolean getInterpolateEndpoints()
Returns the interpolateEndpoints value. The default value is false.

See Also:
setInterpolateEndpoints(boolean)

appendTo

public 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. If these requirements are not met then this method returns quietly.

Specified by:
appendTo in class Curve
See Also:
MultiPath, BinaryCurveApproximationAlgorithm