#include <Interpolator.h>
Inheritance diagram for Interpolator:
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 |
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.
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.
|
|
|
|
|
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. |
|
|
|
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. |
|
|
|
Evaluates the function in t using the specific interpolation method (defined in a subclass). Implemented in InterpolatorLinear, InterpolatorQuadratic, and InterpolatorCubicSpline. |
|
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. |
|
|
|
|
|
Returns the i-th time, sample and tangent (optional). |
|
Resets the interpolator. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|