Jamba  3.0.2
pongasoft::Utils::Lerp< TFloat, X, Y > Class Template Reference

#include <Lerp.h>

Public Member Functions

computeX (Y iY) const
 
computeY (X iX) const
 
 Lerp (X iX1, Y iY1, X iX2, Y iY2)
 
 Lerp (Y iY0, Y iY1)
 

Static Public Member Functions

static Lerp mapRange (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh)
 
static Y mapValue (X iValue, X iFromLow, X iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 

Private Attributes

const TFloat fA
 
const TFloat fB
 

Detailed Description

template<typename TFloat, typename X, typename Y>
class pongasoft::Utils::Lerp< TFloat, X, Y >

Util class to compute linear interpolation. Use SPLerp/DPLerp and mapValueSP/mapRangeSP (resp mapValueDP/mapRangeDP) for convenience.

Providing iX1 == iX2 will result in undefined behavior

Constructor & Destructor Documentation

◆ Lerp() [1/2]

template<typename TFloat , typename X , typename Y >
pongasoft::Utils::Lerp< TFloat, X, Y >::Lerp ( iX1,
iY1,
iX2,
iY2 
)
inline

◆ Lerp() [2/2]

template<typename TFloat , typename X , typename Y >
pongasoft::Utils::Lerp< TFloat, X, Y >::Lerp ( iY0,
iY1 
)
inline

Shortcut for when x=0 => iY0 and x=1.0 => iY1

Member Function Documentation

◆ computeX()

template<typename TFloat , typename X , typename Y >
X pongasoft::Utils::Lerp< TFloat, X, Y >::computeX ( iY) const
inline

◆ computeY()

template<typename TFloat , typename X , typename Y >
Y pongasoft::Utils::Lerp< TFloat, X, Y >::computeY ( iX) const
inline

◆ mapRange()

template<typename TFloat , typename X , typename Y >
static Lerp pongasoft::Utils::Lerp< TFloat, X, Y >::mapRange ( iFromLow,
iFromHigh,
iToLow,
iToHigh 
)
inlinestatic

Inspired by the map function in Processing language, another way to look at Lerp is to map a range of values into another range: [iFromLow, iFromHigh] -> [iToLow, iToHigh]. Note that low can be greater than high: for example you can map [1, -1] to the range [0, height] (display where 0 is at the top and height is the bottom)

◆ mapValue()

template<typename TFloat , typename X , typename Y >
static Y pongasoft::Utils::Lerp< TFloat, X, Y >::mapValue ( iValue,
iFromLow,
iFromHigh,
iToLow,
iToHigh,
bool  iClamp = true 
)
inlinestatic

Inspired by the map function in Processing language, another way to look at Lerp is to map a range of values into another range: [iFromLow, iFromHigh] -> [iToLow, iToHigh]. This function then return the iValue mapped from the first range into the second range. When iClamp is set to true, the incoming value will first be clamped to the from range. ex:

mapValue(5, 10, 20, 100, 200, true) returns 100 mapValue(5, 10, 20, 100, 200, false) returns 50

Parameters
iValuewill be constrained to the range [min(iFromLow, iFromHigh), max(iFromLow, iFromHigh)]

Member Data Documentation

◆ fA

template<typename TFloat , typename X , typename Y >
const TFloat pongasoft::Utils::Lerp< TFloat, X, Y >::fA
private

◆ fB

template<typename TFloat , typename X , typename Y >
const TFloat pongasoft::Utils::Lerp< TFloat, X, Y >::fB
private

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