com.graphbuilder.curve
Class BezierCurve

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

public class BezierCurve
extends ParametricCurve

General n-point Bezier curve implementation. The Bezier curve defines itself using all the points from the control-path specified by the group-iterator. To compute a single point on the curve requires O(n) multiplications where n is the group-size of the group-iterator. Thus, the Bezier curve is considered to be expensive, but it has several mathematical properties (not discussed here) that make it appealing. Figure 1 shows an example of a Bezier curve.

The maximum number of points that the Bezier curve can use is 1030 because the evaluation of a point uses the nCr (n-choose-r) function. The computation uses double precision, and double precision cannot represent the result of 1031 choose i, where i = [500, 530].

See Also:
Curve, PascalsTriangle

Field Summary
 
Fields inherited from class com.graphbuilder.curve.Curve
connect, cp, gi
 
Constructor Summary
BezierCurve(ControlPath cp, GroupIterator gi)
           
 
Method Summary
 void appendTo(MultiPath mp)
          The only requirement for this curve is the group-iterator must be in range or this method returns quietly.
 void eval(double[] p)
          The eval method evaluates a point on a curve given a parametric value "t".
 int getSampleLimit()
          The sample limit specifies how many additional subdivisions are done to ensure that there are no missed pieces of the curve.
 void resetMemory()
          Resets the shared memory to the initial state.
 void setInterval(double t_min, double t_max)
          Specifies the interval that the curve should define itself on.
 void setSampleLimit(int limit)
          Sets the sample-limit.
 double t_max()
          Returns the finishing interval value.
 double t_min()
          Returns the starting interval value.
 
Methods inherited from class com.graphbuilder.curve.Curve
getConnect, getControlPath, getGroupIterator, setConnect, setControlPath, setGroupIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BezierCurve

public BezierCurve(ControlPath cp,
                   GroupIterator gi)
Method Detail

eval

public 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()
Description copied from class: ParametricCurve
The sample limit specifies how many additional subdivisions are done to ensure that there are no missed pieces of the curve. The sample limit must be >= 0.

Specified by:
getSampleLimit in class ParametricCurve

setSampleLimit

public void setSampleLimit(int limit)
Sets the sample-limit. For more information on the sample-limit, see the BinaryCurveApproximationAlgorithm class. The default sample-limit is 1.

Throws:
java.lang.IllegalArgumentException - If sample-limit < 0.
See Also:
BinaryCurveApproximationAlgorithm, getSampleLimit()

setInterval

public void setInterval(double t_min,
                        double t_max)
Specifies the interval that the curve should define itself on. The default interval is [0.0, 1.0].

Throws:
java.lang.IllegalArgumentException - If t_min > t_max.
See Also:
t_min(), t_max()

t_min

public double t_min()
Returns the starting interval value.

See Also:
setInterval(double, double), t_max()

t_max

public double t_max()
Returns the finishing interval value.

See Also:
setInterval(double, double), t_min()

appendTo

public void appendTo(MultiPath mp)
The only requirement for this curve is the group-iterator must be in range or this method returns quietly.

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

resetMemory

public void resetMemory()
Description copied from class: Curve
Resets the shared memory to the initial state.

Overrides:
resetMemory in class Curve