public class CubicHermiteSpline3d extends java.lang.Object implements Scannable, java.lang.Iterable<CubicHermiteSpline3d.Knot>
Modifier and Type | Class and Description |
---|---|
static class |
CubicHermiteSpline3d.Knot |
Constructor and Description |
---|
CubicHermiteSpline3d()
Creates a empty spline
|
CubicHermiteSpline3d(java.util.ArrayList<? extends Vector3d> xVals,
java.util.ArrayList<Vector3d> dxdsVals)
Creates a spline from data containing the values of x and dxds at each
knot point, with the interval between each knot point assumed to have a
length of 1.
|
CubicHermiteSpline3d(CubicHermiteSpline3d spline)
Creates a spline from a copy of an existing one.
|
CubicHermiteSpline3d(double[] sVals,
java.util.ArrayList<? extends Vector3d> xVals,
java.util.ArrayList<Vector3d> dxdsVals)
Creates a spline from data containing the values of s, x and dxds at each
knot point.
|
Modifier and Type | Method and Description |
---|---|
CubicHermiteSpline3d.Knot |
addKnot(double s,
Vector3d x,
Vector3d dxds)
Adds another knot point to this cubic hermite spline, consisting of an s
coordinate, along with x and dxds values.
|
void |
clearKnots()
Removes all knots from from this spline.
|
CubicHermiteSpline3d |
copy()
Creates a copy of this spline.
|
boolean |
epsilonEquals(CubicHermiteSpline3d spline,
double tol)
Queries whether this spline is equal to another spline within a specified
absolute tolerance.
|
boolean |
equals(CubicHermiteSpline3d 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.
|
Vector3d |
evalDx2(double s)
Evaluates the second derivative (with respect to the parameter) of this
spline for a specific parameter value.
|
Vector3d |
evalDx2(double s,
IntHolder lastIdx)
Evaluates the second derivative (with respect to the parameter) of this
spline for a specific parameter value.
|
CubicHermiteSpline3d.Knot |
getFirstKnot()
Returns the first knot in this spline, or
null if there
are no knots. |
CubicHermiteSpline3d.Knot |
getKnot(int idx)
Returns the
idx -th knot in this spline. |
CubicHermiteSpline3d.Knot |
getLastKnot()
Returns the last knot in this spline, or
null if there
are no knots. |
CubicHermiteSpline3d.Knot |
getNextKnot(double s)
Find the knot immediately following s.
|
CubicHermiteSpline3d.Knot |
getPreceedingKnot(double s)
Find the knot immediately preceeding s.
|
CubicHermiteSpline3d.Knot |
getPreceedingKnot(double s,
IntHolder lastIdx)
Find the knot immediately preceeding s.
|
double |
getS0()
Returns the start value of the parameter controlling this spline.
|
java.util.ArrayList<Vector3d> |
getSampledValues(int numv)
Creates and returns a list of values sampled uniformly along 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.
|
boolean |
isWritable()
Returns
true if this component should in fact be written to
secondary storage. |
java.util.Iterator<CubicHermiteSpline3d.Knot> |
iterator()
Returns an iterator for the knots in this spline.
|
int |
numKnots()
Returns the number of knots in this spline.
|
boolean |
removeKnot(CubicHermiteSpline3d.Knot knot)
Removes a knot from this spline.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this spline from a ReaderTokenizer.
|
void |
set(CubicHermiteSpline3d spline)
Sets this spline to be a copy of another spline.
|
void |
set(double[] sVals,
java.util.ArrayList<? extends Vector3d> xVals,
java.util.ArrayList<Vector3d> dxdsVals)
Sets this spline from specified values of s, x and dxds at each knot
point.
|
void |
setMultiSegment(java.util.ArrayList<? extends Vector3d> xVals,
double[] svals)
Sets this spline to one consisting of n segments with n+1 knots, at s
values given by
svals , with the coeffcients computed to best fit
a set of x values uniformly placed along the entire interval. |
void |
setSingleSegment(java.util.ArrayList<? extends Vector3d> xVals,
double s0,
double s1)
Sets this spline to one consisting of a single segment with two knots,
with the coeffcients computed to best fit a set of x values uniformly
placed along the interval s in [s0, s1].
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this spline to a PrintWriter.
|
public CubicHermiteSpline3d()
public CubicHermiteSpline3d(java.util.ArrayList<? extends Vector3d> xVals, java.util.ArrayList<Vector3d> dxdsVals)
xVals
- x values for each knot pointdxdsVals
- dxds values for each knot pointpublic CubicHermiteSpline3d(double[] sVals, java.util.ArrayList<? extends Vector3d> xVals, java.util.ArrayList<Vector3d> dxdsVals)
sVals
- s values at each knot pointxVals
- x values for each knot pointdxdsVals
- dxds values for each knot pointpublic CubicHermiteSpline3d(CubicHermiteSpline3d spline)
spline
- spline to copypublic void set(double[] sVals, java.util.ArrayList<? extends Vector3d> xVals, java.util.ArrayList<Vector3d> dxdsVals)
sVals
- s values at each knot pointxVals
- x values for each knot pointdxdsVals
- dxds values for each knot pointpublic void setSingleSegment(java.util.ArrayList<? extends Vector3d> xVals, double s0, double s1)
public void setMultiSegment(java.util.ArrayList<? extends Vector3d> xVals, double[] svals)
svals
, with the coeffcients computed to best fit
a set of x values uniformly placed along the entire interval. C(2)
continuity is enforced between intervals, with the second derivatives at
the end points equal to 0.public CubicHermiteSpline3d.Knot addKnot(double s, Vector3d x, Vector3d dxds)
s
- parameter value at which the knot should be addedx
- value at the knotx
- derivative value at the knotpublic boolean removeKnot(CubicHermiteSpline3d.Knot knot)
knot
- knot to removepublic void clearKnots()
public CubicHermiteSpline3d.Knot getPreceedingKnot(double s)
knot.getS0() <= s
. If no such knot exists, null
is returned.s
- value for which preceeding knot is soughtpublic CubicHermiteSpline3d.Knot getPreceedingKnot(double s, IntHolder lastIdx)
knot.x0 <= 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 CubicHermiteSpline3d.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 Vector3d evalDx2(double s)
s
- parameter for which the derivative should be computedpublic Vector3d evalDx2(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
7 n
numeric values giving
the s, x and dxdx 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 2.0 5.0 -1.0 1.0 0.0 5.0 1.2 -2.0 1.0 0.0 ]describes a spline with two knots, with s, x and dxds equal to
0
,
(0, 4, 1)
and (2, 5, -1)
for the first knot and 1
, (0, 5, 1.2)
and (-2, 1, 0)
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 CubicHermiteSpline3d.Knot getKnot(int idx)
idx
-th knot in this spline.idx
- index of the requested knotidx
-th knotpublic CubicHermiteSpline3d.Knot getFirstKnot()
null
if there
are no knots.public CubicHermiteSpline3d.Knot getLastKnot()
null
if there
are no knots.public double getS0()
public double getSLast()
public double getSLength()
public java.util.Iterator<CubicHermiteSpline3d.Knot> iterator()
iterator
in interface java.lang.Iterable<CubicHermiteSpline3d.Knot>
public void set(CubicHermiteSpline3d spline)
spline
- spline to copypublic java.util.ArrayList<Vector3d> getSampledValues(int numv)
numv
- number of values to samplepublic CubicHermiteSpline3d copy()
public boolean equals(CubicHermiteSpline3d spline)
spline
- spline to compare to this onetrue
if the splines are equalpublic boolean epsilonEquals(CubicHermiteSpline3d spline, double tol)
spline
- spline to compare to this onetol
- absolute tolerance with which to compare the splinestrue
if the splines are equal within tolerance