com.graphbuilder.curve
Class NURBSpline

java.lang.Object
  extended bycom.graphbuilder.curve.Curve
      extended bycom.graphbuilder.curve.ParametricCurve
          extended bycom.graphbuilder.curve.BSpline
              extended bycom.graphbuilder.curve.NURBSpline

public class NURBSpline
extends BSpline

General implementation of the Non-Uniform Rational B-spline or NURB-Spline. The main advantage of the NURB-Spline over the B-Spline is the ability to represent conic sections. To do this, a curve with degree of 2 is used. Figure 1 contains examples of conic arcs.

NURB-Splines can also be used to generate circles as shown in figure 2.

As seen in the figures, every control-point has an associated weight value. The weight-values control how much relative pull each control-point has on the curve. If the weight-value is 0, then the associated point will have no affect on the curve. If a point has an associated weight of 0, but the curve is expected to pass through that point, then it is likely that the result of evaluation will be the origin. All weights must be >= 0.


Field Summary
 
Fields inherited from class com.graphbuilder.curve.BSpline
NON_UNIFORM, UNIFORM_CLAMPED, UNIFORM_UNCLAMPED
 
Fields inherited from class com.graphbuilder.curve.Curve
connect, cp, gi
 
Constructor Summary
NURBSpline(ControlPath cp, GroupIterator gi)
           
 
Method Summary
 void appendTo(MultiPath mp)
          The requirements of the appendTo method include the requirements of the BSpline appendTo method, plus a couple more.
protected  void eval(double[] p)
          The eval method evaluates a point on a curve given a parametric value "t".
 boolean getUseWeightVector()
          Returns the value of the useWeightVector flag.
 ValueVector getWeightVector()
          Returns the weight-vector.
 void resetMemory()
          Resets the shared memory to the initial state.
 void setUseWeightVector(boolean b)
          Sets the value of the useWeightVector flag.
 void setWeightVector(ValueVector v)
          Sets the weight-vector.
 
Methods inherited from class com.graphbuilder.curve.BSpline
getDegree, getKnotVector, getKnotVectorType, getSampleLimit, getUseDefaultInterval, N, setDegree, setInterval, setKnotVector, setKnotVectorType, setSampleLimit, setUseDefaultInterval, t_max, t_min
 
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

NURBSpline

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

Overrides:
eval in class BSpline

getWeightVector

public ValueVector getWeightVector()
Returns the weight-vector.

See Also:
setWeightVector(ValueVector)

setWeightVector

public void setWeightVector(ValueVector v)
Sets the weight-vector.

Throws:
java.lang.IllegalArgumentException - If the value-vector is null.
See Also:
getWeightVector()

getUseWeightVector

public boolean getUseWeightVector()
Returns the value of the useWeightVector flag. The default value is true.

See Also:
setUseWeightVector(boolean)

setUseWeightVector

public void setUseWeightVector(boolean b)
Sets the value of the useWeightVector flag. If the flag is true, then the internal weightVector will be used. If the flag is false, then all weights will be assumed to be 1.

See Also:
getUseWeightVector()

appendTo

public void appendTo(MultiPath mp)
The requirements of the appendTo method include the requirements of the BSpline appendTo method, plus a couple more. The additional requirements only apply if the useWeightVector flag is true. If so, then the weight-vector must have size equal to the group-size of the GroupIterator and all weights must have a value >= 0. This method returns quietly if these requirements are not met.

Overrides:
appendTo in class BSpline
See Also:
BSpline.appendTo(MultiPath)

resetMemory

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

Overrides:
resetMemory in class BSpline