PikeAero::CArrayInterpolator< S, D > Class Template Reference

#include <carrayinterpolator.h>

Inheritance diagram for PikeAero::CArrayInterpolator< S, D >:

Inheritance graph
[legend]
Collaboration diagram for PikeAero::CArrayInterpolator< S, D >:

Collaboration graph
[legend]

Public Member Functions

 CArrayInterpolator (CArray< S > *scale=NULL, CArray< D > *data=NULL)
CArray< D > * data ()
CMachine::real interpolate (const S &reference)
 Interpolate the sample scale data and return the intorpolated data.
CArray< S > * scale ()
void setData (CArray< D > *data)
void setScale (CArray< S > *scale)
 ~CArrayInterpolator ()

Private Member Functions

CMachine::real dataOffset (CMachine::real scaleValueOffset, const D &lo, const D &hi)
 Determine the data offset as a real value between 0 and 1 relative to lo and hi data values.
CMachine::ubit32 scaleHi (const S &reference)
 Find the hi value on the scale relative to sample.
CMachine::ubit32 scaleLo (const S &reference)
 Find the lo value on the scale relative to sample.
CMachine::real scaleOffset (const S &sample, const S &lo, const S &hi)
 Determine the sample scale offset as a decimal real between 0 and 1 relative to lo and hi scale values.

Private Attributes

CArray< D > * mData
CArray< S > * mScale

Detailed Description

template<class S, class D>
class PikeAero::CArrayInterpolator< S, D >

Template class that interpolates scale value based on the scale and data CArray objects. NOTE: Scale and Data are assumed to be the same size. NOTE: Scale is assumed to be ascending. NOTE: Data can be either ascending or descending.
Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 35 of file carrayinterpolator.h.


Constructor & Destructor Documentation

template<class S , class D >
PikeAero::CArrayInterpolator< S, D >::CArrayInterpolator ( CArray< S > *  scale = NULL,
CArray< D > *  data = NULL 
) [inline]

Definition at line 24 of file carrayinterpolator.cpp.

00025  : CObject()
00026  , mScale(scale)
00027  , mData(data)
00028 {
00029 }

template<class S , class D >
PikeAero::CArrayInterpolator< S, D >::~CArrayInterpolator (  )  [inline]

Definition at line 32 of file carrayinterpolator.cpp.

00033 {
00034 }


Member Function Documentation

template<class S , class D >
CArray<D>* PikeAero::CArrayInterpolator< S, D >::data (  )  [inline]

Definition at line 45 of file carrayinterpolator.h.

References PikeAero::CArrayInterpolator< S, D >::mData.

Referenced by PikeAero::CArrayInterpolator< S, D >::interpolate().

00045 {return mData;}

Here is the caller graph for this function:

template<class S , class D >
CMachine::real PikeAero::CArrayInterpolator< S, D >::dataOffset ( CMachine::real  scaleValueOffset,
const D &  lo,
const D &  hi 
) [inline, private]

Determine the data offset as a real value between 0 and 1 relative to lo and hi data values.

Definition at line 81 of file carrayinterpolator.cpp.

References PikeAero::CArrayInterpolator< S, D >::scale().

Referenced by PikeAero::CArrayInterpolator< S, D >::interpolate().

00082 {
00083     CMachine::real scale = hi - lo;
00084     return scale * scaleValueOffset;
00085 }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class S , class D >
CMachine::real PikeAero::CArrayInterpolator< S, D >::interpolate ( const S &  reference  )  [inline]

Interpolate the sample scale data and return the intorpolated data.

Definition at line 91 of file carrayinterpolator.cpp.

References PikeAero::CArray< T >::at(), PikeAero::CArrayInterpolator< S, D >::data(), PikeAero::CArrayInterpolator< S, D >::dataOffset(), PikeAero::CArrayInterpolator< S, D >::scale(), PikeAero::CArrayInterpolator< S, D >::scaleHi(), PikeAero::CArrayInterpolator< S, D >::scaleLo(), and PikeAero::CArrayInterpolator< S, D >::scaleOffset().

00092 {
00093     CMachine::ubit32 scaleIndexLo = scaleLo( sample );
00094     CMachine::ubit32 scaleIndexHi = scaleHi( sample );
00095     S scaleValueLo = scale()->at( scaleIndexLo );
00096     S scaleValueHi = scale()->at( scaleIndexHi );
00097     D dataValueLo = data()->at( scaleIndexLo );
00098     D dataValueHi = data()->at( scaleIndexHi );
00099 
00100     CMachine::real scaleValueOffset = scaleOffset( sample, scaleValueLo, scaleValueHi );
00101     CMachine::real dataValueOffset = dataOffset( scaleValueOffset, dataValueLo, dataValueHi );
00102     return (CMachine::real)dataValueLo + dataValueOffset;
00103 }

Here is the call graph for this function:

template<class S , class D >
CArray<S>* PikeAero::CArrayInterpolator< S, D >::scale (  )  [inline]

template<class S , class D >
CMachine::ubit32 PikeAero::CArrayInterpolator< S, D >::scaleHi ( const S &  reference  )  [inline, private]

Find the hi value on the scale relative to sample.

Definition at line 55 of file carrayinterpolator.cpp.

References PikeAero::CArrayInterpolator< S, D >::scale(), and PikeAero::CArray< T >::size().

Referenced by PikeAero::CArrayInterpolator< S, D >::interpolate().

00056 {
00057     CMachine::ubit32 size = scale->size();
00058     for( CMachine::ubit32 i = 0; i < size; i++ )
00059     {
00060         if ( scale()->at(i) >= sample )
00061         {
00062             return i;
00063         }
00064     }
00065     return size > 0 ? (size-1) : 0;
00066 }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class S , class D >
CMachine::ubit32 PikeAero::CArrayInterpolator< S, D >::scaleLo ( const S &  reference  )  [inline, private]

Find the lo value on the scale relative to sample.

Definition at line 39 of file carrayinterpolator.cpp.

References PikeAero::CArrayInterpolator< S, D >::scale().

Referenced by PikeAero::CArrayInterpolator< S, D >::interpolate().

00040 {
00041     for( CMachine::bit32 i = (scale()->size()-1); i > 0; i-- )
00042     {
00043         if ( scale()->at((CMachine::ubit32)i) <= sample )
00044         {
00045             return (CMachine::ubit32)i;
00046         }
00047 
00048     }
00049     return 0;
00050 }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class S , class D >
CMachine::real PikeAero::CArrayInterpolator< S, D >::scaleOffset ( const S &  sample,
const S &  lo,
const S &  hi 
) [inline, private]

Determine the sample scale offset as a decimal real between 0 and 1 relative to lo and hi scale values.

Definition at line 71 of file carrayinterpolator.cpp.

References PikeAero::CArrayInterpolator< S, D >::scale().

Referenced by PikeAero::CArrayInterpolator< S, D >::interpolate().

00072 {
00073     CMachine::real diff = sample - lo;
00074     CMachine::real scale = hi - lo;
00075     return diff / scale;
00076 }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class S , class D >
void PikeAero::CArrayInterpolator< S, D >::setData ( CArray< D > *  data  )  [inline]

Definition at line 42 of file carrayinterpolator.h.

References PikeAero::CArrayInterpolator< S, D >::mData.

00042 {mData=data;}

template<class S , class D >
void PikeAero::CArrayInterpolator< S, D >::setScale ( CArray< S > *  scale  )  [inline]

Definition at line 41 of file carrayinterpolator.h.

References PikeAero::CArrayInterpolator< S, D >::mScale.

00041 {mScale=scale;}


Field Documentation

template<class S , class D >
CArray<D>* PikeAero::CArrayInterpolator< S, D >::mData [private]

template<class S , class D >
CArray<S>* PikeAero::CArrayInterpolator< S, D >::mScale [private]


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

Generated on Sun Oct 25 13:59:43 2009 for stingray3 by  doxygen 1.5.8