|
VR-Engage
2.2
|
This template class provides linear interpolation between a start and end value over a specified time period. Specializations are provided for float, double, and DtVector types.
| T | The type of value to interpolate |
#include <linearInterpolator.h>
Public Member Functions | |
| DtLinearInterpolator (T start, T stop, double period) | |
| ~DtLinearInterpolator () | |
| void | tick (double dt) |
| T | value () const |
| bool | isDone () const |
| void | reset () |
| void | reset (T start, T stop, double period) |
| T | start () const |
| T | stop () const |
| double | timeRemaining () const |
Protected Attributes | |
| T | myStart |
| T | myEnd |
| T | myCurrentValue |
| double | myPeriod |
| double | myCurrentTime |
|
inline |
Constructor.
Initializes the interpolator with start and end values and the time period
| start | The starting value |
| stop | The ending value |
| period | The time period over which to interpolate (in seconds) |
References myCurrentTime, myCurrentValue, myEnd, myPeriod, myStart, start(), and stop().
|
inline |
Destructor.
| void makVre::DtLinearInterpolator< T >::tick | ( | double | dt | ) |
Updates the interpolation based on elapsed time.
This function advances the interpolation by the given time step, recalculating the current value based on the elapsed time. Specialized implementations are provided for float, double, and DtVector.
| dt | The time step in seconds |
|
inline |
Gets the current interpolated value.
References myCurrentValue.
| bool makVre::DtLinearInterpolator< T >::isDone | ( | ) | const |
Checks if the interpolation has completed.
References myCurrentTime, and myPeriod.
| void makVre::DtLinearInterpolator< T >::reset | ( | ) |
Resets the interpolation to the beginning.
Sets the current value back to the start value and resets the time to zero
References myCurrentTime, myCurrentValue, and myStart.
| void makVre::DtLinearInterpolator< T >::reset | ( | T | start, |
| T | stop, | ||
| double | period ) |
Resets the interpolation with new parameters.
| start | The new starting value |
| stop | The new ending value |
| period | The new time period (in seconds) |
References myCurrentTime, myCurrentValue, myEnd, myPeriod, myStart, start(), and stop().
|
inline |
Gets the start value.
References myStart.
Referenced by DtLinearInterpolator(), and reset().
|
inline |
Gets the end value.
References myEnd.
Referenced by DtLinearInterpolator(), and reset().
|
inline |
Gets the time remaining in the interpolation.
References myCurrentTime, and myPeriod.
|
protected |
The starting value.
Referenced by DtLinearInterpolator(), reset(), reset(), and start().
|
protected |
The ending value.
Referenced by DtLinearInterpolator(), reset(), and stop().
|
protected |
The current interpolated value.
Referenced by DtLinearInterpolator(), reset(), reset(), and value().
|
protected |
The total time period for the interpolation (in seconds)
Referenced by DtLinearInterpolator(), isDone(), reset(), and timeRemaining().
|
protected |
The current elapsed time (in seconds)
Referenced by DtLinearInterpolator(), isDone(), reset(), reset(), and timeRemaining().