Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cValueLerp< TYPE > Class Template Reference

#include <cValueLerp.h>

Public Member Functions

 cValueLerp (TYPE nValCur=0) noexcept
 
TYPE get_Val () const noexcept
 
void put_Val (TYPE nValCur) noexcept
 
bool TickCap (float fValPerSec, TYPE nValEnd, TIMESYS_t TimeNow=cTimeSys::k_CLEAR)
 
 UNITTEST_FRIEND (cValueLerp)
 

Static Public Member Functions

static bool TickX (TYPE &nValCur, TYPE nValEnd, TIMESECF_t fTimePassed, float fValPerSec)
 

Detailed Description

template<typename TYPE>
class GrayLib::cValueLerp< TYPE >

Linear Interpolation from one value to another over time. ASSUME TYPE is float, BYTE, UINT32 or int

Constructor & Destructor Documentation

◆ cValueLerp()

template<typename TYPE >
GrayLib::cValueLerp< TYPE >::cValueLerp ( TYPE  nValCur = 0)
inlinenoexcept

Member Function Documentation

◆ get_Val()

template<typename TYPE >
TYPE GrayLib::cValueLerp< TYPE >::get_Val ( ) const
inlinenoexcept

◆ put_Val()

template<typename TYPE >
void GrayLib::cValueLerp< TYPE >::put_Val ( TYPE  nValCur)
inlinenoexcept

Move from the old value to the new value over time.

◆ TickCap()

template<typename TYPE >
bool GrayLib::cValueLerp< TYPE >::TickCap ( float  fValPerSec,
TYPE  nValEnd,
TIMESYS_t  TimeNow = cTimeSys::k_CLEAR 
)
inline

Move toward nValEnd over time.

  • fValPerSec = fVal per second change rate. (MUST be positive) nValEnd = stop here. m_nValCur = the current value.
    Returns
    true = changed ? false = failed or no change.

◆ TickX()

template<typename TYPE >
static bool GrayLib::cValueLerp< TYPE >::TickX ( TYPE nValCur,
TYPE  nValEnd,
TIMESECF_t  fTimePassed,
float  fValPerSec 
)
inlinestatic

Lerp to a value then stop. works for fixed (integer) or floating point values.

  • nValEnd = Where are we trying to go?
  • fValPerSec = rate of change per second. always positive.
  • fTimePassed = time since last tick. always positive or 0.
    Returns
    false = no change. (time diff may be too small?) true = changed.

◆ UNITTEST_FRIEND()

template<typename TYPE >
GrayLib::cValueLerp< TYPE >::UNITTEST_FRIEND ( cValueLerp< TYPE )

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