LinearApproximation

LinearApproximation

LinearApproximation

Functions for performing linear interpolation.

See:

Methods

<static> getRequiredDataPoints

Given the desired degree, returns the number of data points required for interpolation.

Parameters:
Name Type Description
degree The desired degree of interpolation.
Throws:
DeveloperError : Linear interpolation can only generate a first degree polynomial.
Returns:
The number of required data points needed for the desired degree of interpolation.

<static> interpolateOrderZero

Interpolates values using the supplied interpolation algorithm. The appropriate subset of input values to use for the interpolation is determined automatically from an interpolation given degree.

The xTable array can contain any number of elements, and the appropriate subset will be selected according to the degree of interpolation requested. For example, if degree is 5, the 6 elements surrounding x will be used for interpolation. When using LinearApproximation the degree should be 1 since it always deals with only 2 elements surrounding x. The yTable array should contain a number of elements equal to: xTable.length * yStride. If insufficient elements are provided to perform the requested degree of interpolation, the highest possible degree of interpolation will be performed.

Parameters:
Name Type Description
x Number The independent variable for which the dependent variables will be interpolated.
xTable Array The array of independent variables to use to interpolate. The values in this array must be in increasing order and the same value must not occur twice in the array.
yTable Array The array of dependent variables to use to interpolate. For a set of three dependent values (p,q,w) and their derivatives (dp, dq, dw) at time 1 and time 2 this should be as follows: {p1, q1, w1, dp1, dq1, dw1, p2, q2, w2, dp2, dq2, dw2}.
yStride Number The number of dependent variable values in yTable corresponding to each independent variable value in xTable.
Returns:
An array of interpolated values. The array contains at least yStride elements, each of which is an interpolated dependent variable value.
See: