O_SESSAME::LinearInterpolator Class Reference
[Interpolation Library]

#include <LinearInterpolator.h>

Inheritance diagram for O_SESSAME::LinearInterpolator:

Inheritance graph
[legend]
List of all members.

Detailed Description

Interpolates between a given set of data points to create a linear functional approximation.

Works for either a single function, or Vector of functions (such as interpolating a state).

Example:
// 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


Constructor & Destructor Documentation

O_SESSAME::LinearInterpolator::LinearInterpolator  ) 
 

Creates an empty linear interpolation.

Definition at line 15 of file LinearInterpolator.cpp.

O_SESSAME::LinearInterpolator::LinearInterpolator const Vector _timePoints,
const Matrix _dataPoints
 

Creates a linear interpolation from the data points.

See Interpolate

Definition at line 20 of file LinearInterpolator.cpp.

O_SESSAME::LinearInterpolator::~LinearInterpolator  )  [virtual]
 

Default Deconstructor.

Definition at line 25 of file LinearInterpolator.cpp.


Member Function Documentation

void O_SESSAME::LinearInterpolator::Interpolate const Vector _timePoints,
const Matrix _dataPoints
[virtual]
 

Creates an interpolation from the vector of time points and matrix of corresponding data points.

Parameters:
_timePoints Vector of time (seconds) points of the data values.
_dataPoints Matrix of data points at each time step in the _timePoints vector.

Implements O_SESSAME::Interpolator.

Definition at line 29 of file LinearInterpolator.cpp.

Vector O_SESSAME::LinearInterpolator::Evaluate const double &  _inputPoint  )  [virtual]
 

Evaluate interpolation curve at a specified time.

Output = m_Slope * _inputPoint + m_Offset

Parameters:
_inputPoint Input point (time) at which to evaluate the vector of interpolations.
Returns:
Vector of output values from the evaluated interpolation.

Implements O_SESSAME::Interpolator.

Definition at line 46 of file LinearInterpolator.cpp.

virtual int O_SESSAME::LinearInterpolator::GetNumberDataPoints  )  [virtual]
 

Returns the number of data points required for interpolation.

the number of data points is the number of X-values (time) required to interpolate.

Returns:
the number of data points, centered about the evaluation time, req'd to interpolate.

Implements O_SESSAME::Interpolator.

Definition at line 88 of file LinearInterpolator.h.

LinearInterpolator * O_SESSAME::LinearInterpolator::NewPointer  )  [virtual]
 

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.

Returns:
a pointer to a new allocation of memory for the LinearInterpolator object.

Implements O_SESSAME::Interpolator.

Definition at line 64 of file LinearInterpolator.cpp.

LinearInterpolator * O_SESSAME::LinearInterpolator::Clone  )  [virtual]
 

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.

Returns:
a pointer to a copy of the LinearInterpolator object.

Implements O_SESSAME::Interpolator.

Definition at line 69 of file LinearInterpolator.cpp.

void O_SESSAME::LinearInterpolator::BuildLinearInterpolation const double &  _x1,
const double &  _y1,
const double &  _x2,
const double &  _y2,
double &  _Slope,
double &  _Offset
[protected]
 

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.

virtual void O_SESSAME::LinearInterpolator::SetNumberDataPoints const int &  _numberDataPoints  )  [protected, virtual]
 

Doesn't do anything for linear interpolator since there are always only 2 data points.

Definition at line 116 of file LinearInterpolator.h.

virtual bool O_SESSAME::Interpolator::GetValid  )  [virtual, inherited]
 

Returns whether the current interpolation parameters are valid.

Returns:
TRUE if the current interpolation is valid, FALSE if it is not and should not be used to Evaluate without being reinterpolated.

Definition at line 116 of file Interpolator.h.

virtual void O_SESSAME::Interpolator::SetValid const bool &  _newValidValue  )  [protected, virtual, inherited]
 

Sets the validity value of the interpolation parameters.

Definition at line 122 of file Interpolator.h.


Member Data Documentation

int O_SESSAME::LinearInterpolator::m_NumDataPoints [private]
 

Number of data points used for interpolation, should always be 2 for linear interpolation.

Definition at line 119 of file LinearInterpolator.h.

int O_SESSAME::LinearInterpolator::m_NumElements [private]
 

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 O_SESSAME::LinearInterpolator::m_Slope [private]
 

Vector of slope parameters.

One slope parameter per element.

Definition at line 123 of file LinearInterpolator.h.

Vector O_SESSAME::LinearInterpolator::m_Offset [private]
 

Vector of offset parameters.

One slope parameter per element.

Definition at line 125 of file LinearInterpolator.h.

Vector O_SESSAME::LinearInterpolator::m_tempOutput [private]
 

Definition at line 126 of file LinearInterpolator.h.


Generated on Wed Aug 6 12:59:32 2003 for Open-Sessame Framework by doxygen1.3