Class CurveInterpolator
java.lang.Object
com.irurueta.numerical.interpolation.CurveInterpolator
Computes curve interpolation of multidimensional points using cubic splines.
This interpolator uses an ordered set of N tabulated points in dim dimensions that lie on
a one-dimensional curve, x0... xn-1, and interpolates values along the curve.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[]
Result of interpolation.private final boolean
True indicates a closed curve, false indicates an open one.private final int
Number of points dimensions.private final CubicSplineInterpolator[]
Array of one dimensional cubic spline interpolators. -
Constructor Summary
ConstructorsConstructorDescriptionCurveInterpolator
(com.irurueta.algebra.Matrix ptsin) Constructor assuming that curve is NOT closed.CurveInterpolator
(com.irurueta.algebra.Matrix ptsin, boolean close) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate double
fprime
(double[] x, double[] y, int pm, int xoff, int yoff) Utility for estimating the derivatives at the endpoints, x and y point to the abscissa and ordinate of the endpoint.double[]
interpolate
(double t) Interpolates a point on the stored curve.private double
rad
(double[] p1, double[] p2) Computes the euclidean distance between two points.
-
Field Details
-
dim
private final int dimNumber of points dimensions. -
cls
private final boolean clsTrue indicates a closed curve, false indicates an open one. -
ans
private final double[] ansResult of interpolation. -
srp
Array of one dimensional cubic spline interpolators.
-
-
Constructor Details
-
CurveInterpolator
public CurveInterpolator(com.irurueta.algebra.Matrix ptsin, boolean close) throws InterpolationException Constructor.- Parameters:
ptsin
- matrix containing points on each row. Number of columns determines number of dimensions of each point.close
- true indicates that points lie in a closed curve, false indicates they lie on an open one.- Throws:
InterpolationException
- if a numerical exception occurs.
-
CurveInterpolator
Constructor assuming that curve is NOT closed.- Parameters:
ptsin
- matrix containing points on each row. Number of columns determines number of dimensions of each point.- Throws:
InterpolationException
- if a numerical exception occurs.
-
-
Method Details
-
interpolate
Interpolates a point on the stored curve. The point is parameterized by t, in the range [0,1]. For open curves, values of t outside this range will return extrapolations (dangerous!). For closed curves t is periodic with period 1.- Parameters:
t
- position in the curve to be interpolated.- Returns:
- result of interpolation.
- Throws:
InterpolationException
- if interpolation fails for numerical reasons.
-
fprime
private double fprime(double[] x, double[] y, int pm, int xoff, int yoff) Utility for estimating the derivatives at the endpoints, x and y point to the abscissa and ordinate of the endpoint. If pm is +1, points to the right will be used (left endpoint): if it is -1, points to the left will be used (right endpoint).- Parameters:
x
- abscissa of endpoint.y
- ordinate of endpoint.pm
- +1 or -1.xoff
- offset of x.yoff
- offset of y.
-
rad
private double rad(double[] p1, double[] p2) Computes the euclidean distance between two points.- Parameters:
p1
- first point.p2
- second point.- Returns:
- euclidean distance.
-