Class CurveInterpolator

java.lang.Object
com.irurueta.numerical.interpolation.CurveInterpolator

public class CurveInterpolator extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
    CurveInterpolator(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 Type
    Method
    Description
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dim

      private final int dim
      Number of points dimensions.
    • cls

      private final boolean cls
      True indicates a closed curve, false indicates an open one.
    • ans

      private final double[] ans
      Result of interpolation.
    • srp

      private final CubicSplineInterpolator[] 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

      public CurveInterpolator(com.irurueta.algebra.Matrix ptsin) throws InterpolationException
      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

      public double[] interpolate(double t) throws InterpolationException
      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.