Class Interpolator

java.lang.Object
gaiasky.util.gaia.utils.Interpolator

public class Interpolator extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Kind of interpolation: for derivative, value or integral
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    findLeftIndex(long[] xa, int xaLength, long x)
    Deprecated.
    Mantis 14225, deprecated August 2, 2012.
    static int
    getLeft(double ta, double[] t, int indx)
    Find left such that t[left] <= ta < t[left+1]
    static int
    getLeftVar(double ta, double[] t, int indx)
    Find left such that t[left] <= ta < t[left+1] (but one less if ta == t[left+1])
    static double[]
    hermite3(double x, double x0, double y0, double yp0, double x1, double y1, double yp1)
    Static method for cubic Hermite interpolation between two points, given their values and derivatives.
    protected static double[]
    interPolDer(double x)
    For normalized argument x (between 0 and 1), calculate the derivatives ap0(x), ap1(x), bp0(x), bp1(x) of the four interpolating polynomials
    protected static double[]
    interPolInt(double x)
    For normalized argument x (between 0 and 1), calculate the integrals A0(x), A1(x), B0(x), B1(x) of the interpolating polynomials
    protected static double[]
    interPolVal(double x)
    For normalized argument x (between 0 and 1), calculate the four interpolating polynomials a0(x), a1(x), b0(x), b1(x) [DRO-012, Eq.
    static double[]
    linear(double x, double x0, double y0, double x1, double y1)
     
    qEval(double tx, double[] t, QuaternionDouble[] q, QuaternionDouble[] qDot, int left, Interpolator.Kind kind)
    Evaluates the quaternion derivative, value or integral at point tx, using Hermite interpolation in t[], q[], qDot[].
    qHermiteAverage(double ta, double tb, double[] t, int indx, QuaternionDouble[] q, QuaternionDouble[] qDot)
    Static method for computing the average attitude quaternion over a finite time interval ta <= t <= tb, using cubic Hermite interpolation, as well as the average time derivative

    Methods inherited from class java.lang.Object

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

    • dtMin

      protected static double dtMin
  • Constructor Details

    • Interpolator

      public Interpolator()
  • Method Details

    • hermite3

      public static double[] hermite3(double x, double x0, double y0, double yp0, double x1, double y1, double yp1)
      Static method for cubic Hermite interpolation between two points, given their values and derivatives.
      Parameters:
      x - desired abscissa (normally between x0 and x1)
      x0 - abscissa of first point
      y0 - function value at x0
      yp0 - first derivative at x0
      x1 - abscissa of second point
      y1 - function value at x1
      yp1 - derivative at x1
      Returns:
      array with interpolated function value at x and its derivative
    • linear

      public static double[] linear(double x, double x0, double y0, double x1, double y1)
    • qHermiteAverage

      public static QuaternionDouble[] qHermiteAverage(double ta, double tb, double[] t, int indx, QuaternionDouble[] q, QuaternionDouble[] qDot)
      Static method for computing the average attitude quaternion over a finite time interval ta <= t <= tb, using cubic Hermite interpolation, as well as the average time derivative

      It is assumed that ta <= tb. If tb-ta is less than dtMin then no average is computed but the instantaneous (interpolated) values at the instant (ta+tb)/2 are returned instead.

      The times ta, tb, t[] are in [days] from some arbitrary but common origin. Time derivatives are in [1/day].

      The lengths of the array arguments must be: t.length >= 2, q.length >= t.length, qDot-length >= t.length. No check is made of these conditions.

      The argument indx is such that t[indx] is not far from ta and tb. It must be in the range 0 <= indx <= t.length-2

      Parameters:
      ta - start time of the averaging interval
      tb - end time of the averaging interval
      t - array array of increasing times encompassing the averaging interval (i.e., t[0] <= ta and tb <= t[t.length-1])
      indx - an index in the array t[] that is a suitable starting point for locating ta and tb in the array
      q - array of attitude quaternions at times t[]
      qDot - array of attitude quaternion rates [1/timeUnit] at times t[]
      Returns:
      array containing the average attitude quaternion as the first element and the average attitude quaternion rate [1/timeUnit] as the second element
    • qEval

      public static QuaternionDouble qEval(double tx, double[] t, QuaternionDouble[] q, QuaternionDouble[] qDot, int left, Interpolator.Kind kind)
      Evaluates the quaternion derivative, value or integral at point tx, using Hermite interpolation in t[], q[], qDot[]. left is such that t[left] <= tx < t[left+1]. Kind = DER returns the derivative at tx, VAL returns the value at tx, and INT returns the integral from t[left] to tx.
      Parameters:
      tx - time at which the derivative, value or integral is evaluated
      t - array of times (length >= 2)
      q - array of quaternions
      qDot - array of quaternion derivatives
      left - index in t, q and qDot susch that t[left] <= tx < t[left+1]
      kind - which kind of result is returned (derivative, value or integral)
      Returns:
      The quaternion
    • getLeft

      public static int getLeft(double ta, double[] t, int indx)
      Find left such that t[left] <= ta < t[left+1]
      Parameters:
      ta -
      t -
      indx - starting index
      Returns:
      The left index
    • getLeftVar

      public static int getLeftVar(double ta, double[] t, int indx)
      Find left such that t[left] <= ta < t[left+1] (but one less if ta == t[left+1])
      Parameters:
      ta -
      t -
      indx - starting index
      Returns:
      The left index
    • interPolVal

      protected static double[] interPolVal(double x)
      For normalized argument x (between 0 and 1), calculate the four interpolating polynomials a0(x), a1(x), b0(x), b1(x) [DRO-012, Eq. (8)]
      Parameters:
      x -
      Returns:
      double array containing a0, a1, b0, b1 at x
    • interPolDer

      protected static double[] interPolDer(double x)
      For normalized argument x (between 0 and 1), calculate the derivatives ap0(x), ap1(x), bp0(x), bp1(x) of the four interpolating polynomials
      Parameters:
      x - The value
      Returns:
      double array containing ap0, ap1, bp0, bp1 at x
    • interPolInt

      protected static double[] interPolInt(double x)
      For normalized argument x (between 0 and 1), calculate the integrals A0(x), A1(x), B0(x), B1(x) of the interpolating polynomials

      A0(x) = int_0^x a0(y)*dy (etc)

      Parameters:
      x - The value
      Returns:
      double array containing A0, A1, B0, B1 at x
    • findLeftIndex

      @Deprecated public static int findLeftIndex(long[] xa, int xaLength, long x)
      Deprecated.
      Mantis 14225, deprecated August 2, 2012. Use AttitudeUtils.findLeftIndex(long, long[], int). Remove by GT 18.0.
      In the non-decreasing sequence xa[0:n-1], finds the left index such that xa[left] <= x < xa[left+1]

      If x < xa[0] the method returns -1 if x >= xa[n-1], the last index to the array (n-1) is returned

      Uses a straight bisection method to locate the left index.

      Parameters:
      xa - - array of non-decreasing values
      xaLength - - ???
      x - - value to locate
      Returns:
      left index