#include <LinearInterpolator.h>
Inheritance diagram for O_SESSAME::LinearInterpolator:
Works for either a single function, or Vector of functions (such as interpolating a state).
// Interpolate the sin() function // Build the sin() function int stepsize = 0.1; Vector timeVec(2*M_PI / stepsize); Matrix sinOutput(timeVec[MatrixRowsIndex].getIndexBound(), 1); for (int jj = 1; jj < timeVec[MatrixRowsIndex].getIndexBound(); ++jj) { timeVec(jj) = jj * stepsize; sinOutput(jj,1) = sin(jj * stepsize); } // Create interpolator LinearInterpolator interp(timeVec,sinOutput); Vector chk = interp.Evaluate(0.25);
Definition at line 43 of file LinearInterpolator.h.
Public Member Functions | |
LinearInterpolator () | |
Creates an empty linear interpolation. | |
LinearInterpolator (const Vector &_timePoints, const Matrix &_dataPoints) | |
Creates a linear interpolation from the data points. | |
virtual | ~LinearInterpolator () |
Default Deconstructor. | |
virtual void | Interpolate (const Vector &_timePoints, const Matrix &_dataPoints) |
Creates an interpolation from the vector of time points and matrix of corresponding data points. | |
virtual Vector | Evaluate (const double &_inputPoint) |
Evaluate interpolation curve at a specified time. | |
virtual int | GetNumberDataPoints () |
Returns the number of data points required for interpolation. | |
virtual LinearInterpolator * | NewPointer () |
Return a pointer to a new instance of a linear interpolator type. | |
virtual LinearInterpolator * | Clone () |
Return a pointer to a copy of the linear interpolator instance. | |
virtual bool | GetValid () |
Returns whether the current interpolation parameters are valid. | |
Protected Member Functions | |
void | BuildLinearInterpolation (const double &_x1, const double &_y1, const double &_x2, const double &_y2, double &_Slope, double &_Offset) |
Computes the slope and offset (intercept) of the linear interpolation given two data points. | |
virtual void | SetNumberDataPoints (const int &_numberDataPoints) |
Doesn't do anything for linear interpolator since there are always only 2 data points. | |
virtual void | SetValid (const bool &_newValidValue) |
Sets the validity value of the interpolation parameters. | |
Private Attributes | |
int | m_NumDataPoints |
Number of data points used for interpolation, should always be 2 for linear interpolation. | |
int | m_NumElements |
Number of elements in the state vector. | |
Vector | m_Slope |
Vector of slope parameters. | |
Vector | m_Offset |
Vector of offset parameters. | |
Vector | m_tempOutput |
|
Creates an empty linear interpolation.
Definition at line 15 of file LinearInterpolator.cpp. |
|
Creates a linear interpolation from the data points. See Interpolate Definition at line 20 of file LinearInterpolator.cpp. |
|
Default Deconstructor.
Definition at line 25 of file LinearInterpolator.cpp. |
|
Creates an interpolation from the vector of time points and matrix of corresponding data points.
Implements O_SESSAME::Interpolator. Definition at line 29 of file LinearInterpolator.cpp. |
|
Evaluate interpolation curve at a specified time. Output = m_Slope * _inputPoint + m_Offset
Implements O_SESSAME::Interpolator. Definition at line 46 of file LinearInterpolator.cpp. |
|
Returns the number of data points required for interpolation. the number of data points is the number of X-values (time) required to interpolate.
Implements O_SESSAME::Interpolator. Definition at line 88 of file LinearInterpolator.h. |
|
Return a pointer to a new instance of a linear interpolator type. This is used to request memory for a new instance of a LinearInterpolator. It is necessary when attempting to get a pointer from the abstract data type Interpolator and the actual representation type isn't known.
Implements O_SESSAME::Interpolator. Definition at line 64 of file LinearInterpolator.cpp. |
|
Return a pointer to a copy of the linear interpolator instance. This is used to request memory for a copy of this instance of LinearInterpolator. It is necessary when attempting to get a pointer from the abstract data type Interpolator and the actual representation type isn't known.
Implements O_SESSAME::Interpolator. Definition at line 69 of file LinearInterpolator.cpp. |
|
Computes the slope and offset (intercept) of the linear interpolation given two data points.
point1: (_x1, _y1) | point2: (_x2, _y2) Definition at line 58 of file LinearInterpolator.cpp. |
|
Doesn't do anything for linear interpolator since there are always only 2 data points.
Definition at line 116 of file LinearInterpolator.h. |
|
Returns whether the current interpolation parameters are valid.
Definition at line 116 of file Interpolator.h. |
|
Sets the validity value of the interpolation parameters.
Definition at line 122 of file Interpolator.h. |
|
Number of data points used for interpolation, should always be 2 for linear interpolation.
Definition at line 119 of file LinearInterpolator.h. |
|
Number of elements in the state vector. Used to determine how many linear interpolations there are per data set. Definition at line 121 of file LinearInterpolator.h. |
|
Vector of slope parameters. One slope parameter per element. Definition at line 123 of file LinearInterpolator.h. |
|
Vector of offset parameters. One slope parameter per element. Definition at line 125 of file LinearInterpolator.h. |
|
Definition at line 126 of file LinearInterpolator.h. |