Class LagrangeCurve
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
-
Constructor Summary
ConstructorsConstructorDescriptionLagrangeCurve(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
Modifier and TypeMethodDescriptionvoidFor the control-points to be interpolated in order, the knot-vector values should be strictly increasing, however that is not required.protected voideval(double[] p) The eval method evaluates a point on a curve given a parametric value "t".intReturns the base-index.intReturns the base-length.booleanIf baseIndex > 0 then the first control-points will only be interpolated if interpolate-first is set to true.booleanIf baseIndex + baseLength < numKnots - 1 then the last control-points will only be interpolated if interpolate-last is set to true.Returns the knot-vector for this curve.intReturns a value of 1.voidResets the shared memory to the initial state.voidsetBaseIndex(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]].voidsetBaseLength(int b) The base-length along with the base-index specify the interval to evaluate each section.voidsetInterpolateFirst(boolean b) Sets the value of the interpolateFirst flag.voidsetInterpolateLast(boolean b) Sets the value of the interpolateLast flag.voidSets the knot-vector for this curve.Methods inherited from class com.graphbuilder.curve.Curve
getConnect, getControlPath, getGroupIterator, setConnect, setControlPath, setGroupIterator
-
Constructor Details
-
LagrangeCurve
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:
-
-
Method Details
-
getBaseIndex
public int getBaseIndex()Returns the base-index. The default value is 1.- See Also:
-
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:
IllegalArgumentException- If base-index < 0.- See Also:
-
getBaseLength
public int getBaseLength()Returns the base-length. The default value is 1.- See Also:
-
setBaseLength
public void setBaseLength(int b) The base-length along with the base-index specify the interval to evaluate each section.- Throws:
IllegalArgumentException- If base-length <= 0.- See Also:
-
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:
-
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:
-
setInterpolateFirst
public void setInterpolateFirst(boolean b) Sets the value of the interpolateFirst flag.- See Also:
-
setInterpolateLast
public void setInterpolateLast(boolean b) Sets the value of the interpolateLast flag.- See Also:
-
getKnotVector
Returns the knot-vector for this curve.- See Also:
-
setKnotVector
Sets the knot-vector for this curve.- Throws:
IllegalArgumentException- If the value-vector is null.- See Also:
-
getSampleLimit
public int getSampleLimit()Returns a value of 1.- Specified by:
getSampleLimitin classParametricCurve
-
eval
protected void eval(double[] p) Description copied from class:ParametricCurveThe 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:
evalin classParametricCurve
-
appendTo
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. -
resetMemory
public void resetMemory()Description copied from class:CurveResets the shared memory to the initial state.- Overrides:
resetMemoryin classCurve
-