Package gaiasky.util.gaia.utils
Class Interpolator
java.lang.Object
gaiasky.util.gaia.utils.Interpolator
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Kind of interpolation: for derivative, value or integral -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 polynomialsprotected 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)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) static Quaterniond
qEval
(double tx, double[] t, Quaterniond[] q, Quaterniond[] qDot, int left, Interpolator.Kind kind) Evaluates the quaternion derivative, value or integral at point tx, using Hermite interpolation in t[], q[], qDot[].static Quaterniond[]
qHermiteAverage
(double ta, double tb, double[] t, int indx, Quaterniond[] q, Quaterniond[] 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.
-
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 pointy0
- function value at x0yp0
- first derivative at x0x1
- abscissa of second pointy1
- function value at x1yp1
- 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 Quaterniond[] qHermiteAverage(double ta, double tb, double[] t, int indx, Quaterniond[] q, Quaterniond[] 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 intervaltb
- end time of the averaging intervalt
- 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 arrayq
- 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 Quaterniond qEval(double tx, double[] t, Quaterniond[] q, Quaterniond[] 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 evaluatedt
- array of times (length >= 2)q
- array of quaternionsqDot
- array of quaternion derivativesleft
- 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.Mantis 14225, deprecated August 2, 2012. UseAttitudeUtils.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 valuesxaLength
- - ???x
- - value to locate- Returns:
- left index
-