Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

Interpolator Class Reference

#include <Interpolator.h>

Inheritance diagram for Interpolator:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Interpolator (unsigned int dim, unsigned int num_samples, bool use_tangents=false)
virtual ~Interpolator ()
unsigned int GetDimension () const
unsigned int GetNumSamples () const
virtual void Reset ()
virtual void GetSample (unsigned int i, float *p_time, T *sample, T *tangent=NULL)
virtual bool AddSample (float t, const T *sample, const T *tangent=NULL)
virtual void Eval (float t, T *value)=0

Protected Member Functions

virtual void ComputeTangents (unsigned int i)
int FindNearestSample (float t)
Memory management
T ** AllocateSamples (unsigned int num_samples, unsigned int size_sample)
void DeallocateSamples (T **vec_samples, unsigned int num_samples, unsigned int size_sample)
void ShiftSamples (T **vec_samples, unsigned int num_samples, unsigned int size_sample)

Protected Attributes

unsigned int m_Dimension
unsigned int m_NumSamples
bool m_bInitialized
float * m_vecTimes
T ** m_vecSamples
T ** m_vecTangents

Detailed Description

Interpolator abstract base class.

This class defines the interface of a general purpose interpolator for interpolating a sequence of n samples: { {t_0, S_0} .. {t_n-1, S_n-1} } each one consisting of a vector of dim elements of class T: S_i = [ T_0 .. T_dim-1 ]

The Interpolator class manages the data insertion and memory allocation/deallocation leaving only the Eval() method to be implemented in each subclasses/interpolation scheme.

Todo:
ALLOW the use of externam memory for the samples and the sample times, to avoid unnecessary replication in data stored originally in the correct format. => Maybe putting the time in the first position of the vector of T would help to make it easier (i T is float)

Extend it to handle periodic functions/cyclic animations

The class can be templarized, allowing for interpolation of vectors of T class elements if T is "additive". (no quaternions or rotation matrices here! But works for vectors or euler angles)

Shifting could be avoided using a "circular vector" of samples.


Constructor & Destructor Documentation

Interpolator::Interpolator unsigned int  dim,
unsigned int  num_samples,
bool  use_tangents = false
[inline]
 

virtual Interpolator::~Interpolator  )  [inline, virtual]
 


Member Function Documentation

virtual bool Interpolator::AddSample float  t,
const T *  sample,
const T *  tangent = NULL
[inline, virtual]
 

Adds a sample to the end of the sample sequence.

Time t must be > than the previously inserted ones (samples should be inserted in chronological order).

Tangents can be specified or not, but they only will be stored if 'use_tangents' was true when the Interpolator was created.

If tangents are needed but not specified for some sample, method ComputeTangents() will be called to initialize it.

Returns false if there was some error.

T** Interpolator::AllocateSamples unsigned int  num_samples,
unsigned int  size_sample
[inline, protected]
 

virtual void Interpolator::ComputeTangents unsigned int  i  )  [inline, protected, virtual]
 

Virtual method to compute/guess the tangent of the new added i-th sample.

MUST be redefined by subclasses that use tangents in order to properly initialize unspecified tangents.

MAY change the tangents of previous samples using the new i-th sample information.

[OSCAR] Currently used for splines only

Reimplemented in InterpolatorCubicSpline.

void Interpolator::DeallocateSamples T **  vec_samples,
unsigned int  num_samples,
unsigned int  size_sample
[inline, protected]
 

virtual void Interpolator::Eval float  t,
T *  value
[pure virtual]
 

Evaluates the function in t using the specific interpolation method (defined in a subclass).

Implemented in InterpolatorLinear, InterpolatorQuadratic, and InterpolatorCubicSpline.

int Interpolator::FindNearestSample float  t  )  [inline, protected]
 

Searches the nearest sample S_i with t_i <= t and returns its index. Notice that when the index -1 or N-1 is returned, t is ouside of the sampled interval [t_0..t_N-1). In this case we may want to extrapolate instead of interpolate.

unsigned int Interpolator::GetDimension  )  const [inline]
 

unsigned int Interpolator::GetNumSamples  )  const [inline]
 

virtual void Interpolator::GetSample unsigned int  i,
float *  p_time,
T *  sample,
T *  tangent = NULL
[inline, virtual]
 

Returns the i-th time, sample and tangent (optional).

virtual void Interpolator::Reset  )  [inline, virtual]
 

Resets the interpolator.

void Interpolator::ShiftSamples T **  vec_samples,
unsigned int  num_samples,
unsigned int  size_sample
[inline, protected]
 


Member Data Documentation

bool Interpolator::m_bInitialized [protected]
 

unsigned int Interpolator::m_Dimension [protected]
 

unsigned int Interpolator::m_NumSamples [protected]
 

T** Interpolator::m_vecSamples [protected]
 

T** Interpolator::m_vecTangents [protected]
 

float* Interpolator::m_vecTimes [protected]
 


The documentation for this class was generated from the following file:
Generated on Tue Aug 10 15:58:30 2004 for Saphyre2 by doxygen 1.3.5