public class LinearSpline3d extends java.lang.Object implements Scannable, java.lang.Iterable<LinearSpline3d.Knot>
Modifier and Type | Class and Description |
---|---|
static class |
LinearSpline3d.Knot |
Constructor and Description |
---|
LinearSpline3d()
Creates a empty spline
|
LinearSpline3d(java.util.ArrayList<? extends Vector3d> xVals,
java.util.ArrayList<Vector3d> dxdsVals)
Creates a spline from a set of values, withthe interval between each knot
point assumed to have a length of 1.
|
LinearSpline3d(double[] sVals,
java.util.ArrayList<? extends Vector3d> xVals)
Creates a spline from data containing the values of s and x at each
knot point.
|
LinearSpline3d(LinearSpline3d spline)
Creates a spline from a copy of an existing one.
|
Modifier and Type | Method and Description |
---|---|
LinearSpline3d.Knot |
addKnot(double s,
Vector3d x)
Adds another knot point to this spline at a specified s coordinate.
|
void |
clearKnots()
Removes all knots from from this spline.
|
LinearSpline3d |
copy()
Creates a copy of this spline.
|
boolean |
equals(LinearSpline3d spline)
Queries whether this spline is equal to another spline.
|
Vector3d |
eval(double s)
Evaluates the value of this spline for a specific parameter value.
|
Vector3d |
eval(double s,
IntHolder lastIdx)
Evaluates the value of this spline for a specific parameter value.
|
Vector3d |
evalDx(double s)
Evaluates the derivative (with respect to the parameter) of this spline
for a specific parameter value.
|
Vector3d |
evalDx(double s,
IntHolder lastIdx)
Evaluates the derivative (with respect to the parameter) of this spline
for a specific parameter value.
|
LinearSpline3d.Knot |
getFirstKnot()
Returns the first knot in this spline, or
null if there
are no knots. |
LinearSpline3d.Knot |
getKnot(int idx)
Returns the
idx -th knot in this spline. |
LinearSpline3d.Knot |
getLastKnot()
Returns the last knot in this spline, or
null if there
are no knots. |
LinearSpline3d.Knot |
getNextKnot(double s)
Find the knot immediately following s.
|
LinearSpline3d.Knot |
getPreceedingKnot(double s)
Find the knot immediately preceeding s.
|
LinearSpline3d.Knot |
getPreceedingKnot(double s,
IntHolder lastIdx)
Find the knot immediately preceeding s.
|
double |
getS0()
Returns the start value of the parameter controlling this spline.
|
double |
getSLast()
Returns the last value of the parameter controlling this spline.
|
double |
getSLength()
Returns the length of the parameter interval controlling this spline.
|
double[] |
getSValues()
Returns an array giving the values of s at each knot.
|
boolean |
isWritable()
Returns
true if this component should in fact be written to
secondary storage. |
java.util.Iterator<LinearSpline3d.Knot> |
iterator()
Returns an iterator for the knots in this spline.
|
int |
numKnots()
Returns the number of knots in this spline.
|
boolean |
removeKnot(LinearSpline3d.Knot knot)
Removes a knot from this spline.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this spline from a ReaderTokenizer.
|
void |
set(double[] sVals,
java.util.ArrayList<? extends Vector3d> xVals)
Sets this spline from specified values of s and x at each knot point.
|
void |
set(LinearSpline3d spline)
Sets this spline to be a copy of another spline.
|
<T extends Vector3d> |
setUsingDistance(java.util.ArrayList<T> xVals)
Sets this spline from a specified set of values, using the distance
between each value as the interpolating parameter.
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this spline to a PrintWriter.
|
public LinearSpline3d()
public LinearSpline3d(java.util.ArrayList<? extends Vector3d> xVals, java.util.ArrayList<Vector3d> dxdsVals)
xVals
- x values for each knot pointdxdsVals
- dxds values for each knot pointpublic LinearSpline3d(double[] sVals, java.util.ArrayList<? extends Vector3d> xVals)
sVals
- s values at each knot pointxVals
- x values for each knot pointpublic LinearSpline3d(LinearSpline3d spline)
spline
- spline to copypublic void set(double[] sVals, java.util.ArrayList<? extends Vector3d> xVals)
sVals
- s values at each knot pointxVals
- x values for each knot pointpublic <T extends Vector3d> void setUsingDistance(java.util.ArrayList<T> xVals)
xVals
- x values for each knot pointpublic double[] getSValues()
public LinearSpline3d.Knot addKnot(double s, Vector3d x)
s
- parameter value at which the knot should be addedx
- value at the knotpublic boolean removeKnot(LinearSpline3d.Knot knot)
knot
- knot to removepublic void clearKnots()
public LinearSpline3d.Knot getPreceedingKnot(double s)
knot.getS0() <= s
. If no such knot exists, null
is returned.s
- value for which preceeding knot is soughtpublic LinearSpline3d.Knot getPreceedingKnot(double s, IntHolder lastIdx)
knot.getS0() <= s
. If no such knot exists, null
is returned.
The optional parameter lastIdx
, described below, can be used
to significantly reduce the search speed when queries are made with
increasing values of s.
s
- value for which preceeding knot is soughtlastIdx
- if non-null, specifies a index value giving a hint on
where to start the knot search. On output, this value is set to the index
of the returned knot, or -1 if no knot is found.public LinearSpline3d.Knot getNextKnot(double s)
knot.x0 > s
. If no such knot exists, null
is returned.s
- value for which next knot is soughtpublic Vector3d eval(double s)
s
- parameter for which the value should be computedpublic Vector3d eval(double s, IntHolder lastIdx)
The optional parameter lastIdx
, described below, can be used
to significantly reduce the search speed when queries are made with
increasing values of s.
s
- parameter for which the value should be computedlastIdx
- if non-null, specifies a index value giving a hint on
where to search for the knot preceeding s. On output, this value is set
to the index of the preceeding knot, or -1 if no preceeding knot is
found.public Vector3d evalDx(double s)
s
- parameter for which the derivative should be computedpublic Vector3d evalDx(double s, IntHolder lastIdx)
The optional parameter lastIdx
, described below, can be used
to significantly reduce the search speed when queries are made with
increasing values of s.
s
- parameter for which the derivative should be computedlastIdx
- if non-null, specifies a index value giving a hint on
where to search for the knot preceeding s. On output, this value is set
to the index of the preceeding knot, or -1 if no preceeding knot is
found.public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
4 n
numeric values giving
the s and x values for each of the n
knots, and terminated
with a closing square bracket. Whitespace characters are ignored. For
example,
[ 0.0 0.0 4.0 1.0 1.0 0.0 5.0 1.2 ]describes a spline with two knots, with s and x equal to
0
,
and (0, 4, 1)
)} for the first knot and 1
and (0, 5, 1.2)
for the second knot.public void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
scan
.public boolean isWritable()
true
if this component should in fact be written to
secondary storage. This gives subclasses control over whether or
not they are actually written out.isWritable
in interface Scannable
true
if this component should be written to
secondary storage.public int numKnots()
public LinearSpline3d.Knot getKnot(int idx)
idx
-th knot in this spline.idx
- index of the requested knotidx
-th knotpublic LinearSpline3d.Knot getFirstKnot()
null
if there
are no knots.public LinearSpline3d.Knot getLastKnot()
null
if there
are no knots.public double getS0()
public double getSLast()
public double getSLength()
public java.util.Iterator<LinearSpline3d.Knot> iterator()
iterator
in interface java.lang.Iterable<LinearSpline3d.Knot>
public void set(LinearSpline3d spline)
spline
- spline to copypublic LinearSpline3d copy()
public boolean equals(LinearSpline3d spline)
spline
- spline to compare to this onetrue
if the splines are equal