com.graphbuilder.curve
Class LagrangeCurve

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

public class LagrangeCurve
extends ParametricCurve

The Lagrange curve passes through the control-points specified by the group-iterator. It uses a knot-vector to control when the curve passes through each control-point. That is, if there is a knot-value for every control-point, then the curve will pass through point i when the value of t is knot[i], which is an interesting property. Figure 1 is an example of this.

In addition, when there is a knot-value for every point then the base-index should be 0, and the base-length should be n-1, where n is the size of the group-iterator.

A knot-vector with size less than n can still be used. In this case the Lagrange curve is generated in multiple sections. This approach works better when the points are roughly equally spaced. Figure 2 is an example of this.

Lagrange curves and also be closed as shown in figures 3 & 4.

Notes on the knot-vector, base-index and base-length. The size of the knot-vector specifies how many points are used for each section of the curve. The base-index specifies which point a section starts at. The base-index + base-length specify which point the section ends at. Once a section has been generated, the next section is generated starting from the end of the last section.


Field Summary
 
Fields inherited from class com.graphbuilder.curve.Curve
connect, cp, gi
 
Constructor Summary
LagrangeCurve(ControlPath cp, GroupIterator gi)
          Creates a LagrangeCurve with knot vector [0, 1/3, 2/3, 1], baseIndex == 1, baseLength == 1, interpolateFirst and interpolateLast are both false.
 
Method Summary
 void appendTo(MultiPath mp)
          For the control-points to be interpolated in order, the knot-vector values should be strictly increasing, however that is not required.
protected  void eval(double[] p)
          The eval method evaluates a point on a curve given a parametric value "t".
 int getBaseIndex()
          Returns the base-index.
 int getBaseLength()
          Returns the base-length.
 boolean getInterpolateFirst()
          If baseIndex > 0 then the first control-points will only be interpolated if interpolate-first is set to true.
 boolean getInterpolateLast()
          If baseIndex + baseLength < numKnots - 1 then the last control-points will only be interpolated if interpolate-last is set to true.
 ValueVector getKnotVector()
          Returns the knot-vector for this curve.
 int getSampleLimit()
          Returns a value of 1.
 void resetMemory()
          Resets the shared memory to the initial state.
 void setBaseIndex(int b)
          The base-index is an index location into the knot vector such that, for each section, the curve is evaluated between [knot[baseIndex], knot[baseIndex + baseLength]].
 void setBaseLength(int b)
          The base-length along with the base-index specify the interval to evaluate each section.
 void setInterpolateFirst(boolean b)
          Sets the value of the interpolateFirst flag.
 void setInterpolateLast(boolean b)
          Sets the value of the interpolateLast flag.
 void setKnotVector(ValueVector v)
          Sets the knot-vector for this curve.
 
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

LagrangeCurve

public LagrangeCurve(ControlPath cp,
                     GroupIterator gi)
Creates a LagrangeCurve with knot vector [0, 1/3, 2/3, 1], baseIndex == 1, baseLength == 1, interpolateFirst and interpolateLast are both false. The knot vector, baseIndex and baseLength along with the control points define the shape of curve. See the appendTo method for more information.

See Also:
appendTo(MultiPath)
Method Detail

getBaseIndex

public int getBaseIndex()
Returns the base-index. The default value is 1.

See Also:
setBaseIndex(int)

setBaseIndex

public void setBaseIndex(int b)
The base-index is an index location into the knot vector such that, for each section, the curve is evaluated between [knot[baseIndex], knot[baseIndex + baseLength]].

Throws:
java.lang.IllegalArgumentException - If base-index < 0.
See Also:
getBaseIndex()

getBaseLength

public int getBaseLength()
Returns the base-length. The default value is 1.

See Also:
setBaseLength(int)

setBaseLength

public void setBaseLength(int b)
The base-length along with the base-index specify the interval to evaluate each section.

Throws:
java.lang.IllegalArgumentException - If base-length <= 0.
See Also:
getBaseLength()

getInterpolateFirst

public boolean getInterpolateFirst()
If baseIndex > 0 then the first control-points will only be interpolated if interpolate-first is set to true.

See Also:
setInterpolateFirst(boolean)

getInterpolateLast

public boolean getInterpolateLast()
If baseIndex + baseLength < numKnots - 1 then the last control-points will only be interpolated if interpolate-last is set to true.

See Also:
setInterpolateLast(boolean)

setInterpolateFirst

public void setInterpolateFirst(boolean b)
Sets the value of the interpolateFirst flag.

See Also:
getInterpolateFirst()

setInterpolateLast

public void setInterpolateLast(boolean b)
Sets the value of the interpolateLast flag.

See Also:
getInterpolateLast()

getKnotVector

public ValueVector getKnotVector()
Returns the knot-vector for this curve.

See Also:
setKnotVector(ValueVector)

setKnotVector

public void setKnotVector(ValueVector v)
Sets the knot-vector for this curve.

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

getSampleLimit

public int getSampleLimit()
Returns a value of 1.

Specified by:
getSampleLimit in class ParametricCurve

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

appendTo

public void appendTo(MultiPath mp)
For the control-points to be interpolated in order, the knot-vector values should be strictly increasing, however that is not required. The requirements are the group-iterator must be in range and baseIndex + baseLength < numKnots. As well, the number of points defined by the group-iterator must be >= numKnots, otherwise the curve does not have enough control-points to define itself. If any of these requirements are not met, then 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