MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Static Public Member Functions | List of all members
Mezzanine::LinearInterpolator< T > Class Template Reference

A simple functor for interpolating data points in a simple way. More...

#include <interpolator.h>

Public Types

typedef T InterpolatableType
 The type this will interpolate. More...
 
typedef std::vector
< InterpolatableType
Storage
 The storage to use with thison tracks.
 

Static Public Member Functions

template<typename TIterator >
static T GetInterpolatedFromMultiple (TIterator Begin, TIterator End, Real Location)
 Handles Interpolation of multiple points. More...
 
template<typename TIterator >
static T Interpolate (TIterator Begin, TIterator End, Real Location)
 This will interpolates data points with GetInterpolatedFromMultiple or InterpolateMath a required. More...
 
static T InterpolateMath (T Begin, T End, Real Location)
 Get a value at a given location between exactly two others. More...
 

Detailed Description

template<typename T>
class Mezzanine::LinearInterpolator< T >

A simple functor for interpolating data points in a simple way.

This interpolator provides certain guarantees.

Definition at line 73 of file interpolator.h.

Member Typedef Documentation

template<typename T >
typedef T Mezzanine::LinearInterpolator< T >::InterpolatableType

The type this will interpolate.

Note
All Interpolators need to declare an InterpolatableType

Definition at line 78 of file interpolator.h.

Member Function Documentation

template<typename T >
template<typename TIterator >
static T Mezzanine::LinearInterpolator< T >::GetInterpolatedFromMultiple ( TIterator  Begin,
TIterator  End,
Real  Location 
)
inlinestatic

Handles Interpolation of multiple points.

This will treat each data point as if it were equidistant from its neighbors and find the datasegment the desired point resides in. Then it will return a data point partway through that data segment. For example if you have three Vector2's defining two data segments as follows:
0,0 - 1,1 - 2,0

Requesting the following locations would return the following data points:
0.0 = 0,0
0.5 = 1,1
1.0 = 2,0

0.25 = 0.5,0.5
0.75 = 1.5,0.5

Any floating point location between 0 and 1 could be requested following this pattern.

Should the data segments not actually be equal in size that they will each still be treated as an equal length when calcuting size. For example if you have 2 data segments like the previous example, then .25 will be halfway through the first segment and .75 will be halfwy through the second. If you are interpolating a series of points through segment like these the larger data segment will be traversed faster. For example consider the following Real value values as data points:
-5, 0, 100 Requesting the following locations would return the following data points:
0.0 = -5
0.5 = 0
1.0 = 100

0.25 = -2.5
0.75 = 50

0.0 = -5
0.1 = -4
0.2 = -3
0.3 = -2
0.4 = -1
0.5 = 0
0.6 = 20
0.7 = 40
0.8 = 60
0.9 = 80
1.0 = 100

Note how even though the location increase by only 0.1 each step the resulting interpolated data point move relative to the length of the segment.

Parameters
BeginAn iterator at the beginning of a rande of data point
EndAn iterator one past the end of the data range to interpolate.
LocationA value between 0.0 and 1.0 that represents
Returns
A T at a location along the data segments defined by Begin and End.

Definition at line 141 of file interpolator.h.

template<typename T >
template<typename TIterator >
static T Mezzanine::LinearInterpolator< T >::Interpolate ( TIterator  Begin,
TIterator  End,
Real  Location 
)
inlinestatic

This will interpolates data points with GetInterpolatedFromMultiple or InterpolateMath a required.

read about GetInterpolatedFromMultiple or InterpolateMath to see what kinds of results this can produce.

Parameters
BeginAn iterator at the beginning of a range of data point
EndAn iterator one past the end of the data range to interpolate.
LocationA value between 0.0 and 1.0 that represents
Returns
A T at a location along the data segments defined by Begin and End.

Definition at line 170 of file interpolator.h.

template<typename T >
static T Mezzanine::LinearInterpolator< T >::InterpolateMath ( Begin,
End,
Real  Location 
)
inlinestatic

Get a value at a given location between exactly two others.

Parameters
BeginThe data point at one end of line segment
EndThe data point at the other end of line segment
LocationA value between 0.0 and 1.0 indicate what point on the line segment defined by Begin and End you want.
Returns
A Value equal to Begin if 0.0 is passed, equal to End if 1.0 is passed equal to a point exactly in the middle if 0.5 is passed.

Definition at line 87 of file interpolator.h.


The documentation for this class was generated from the following file: