Added Lerp and ClampedLerp

This commit is contained in:
Paolo Cignoni 2017-03-15 14:42:22 +01:00
parent c630e4064d
commit b2a2e170af
1 changed files with 12 additions and 0 deletions

View File

@ -180,6 +180,18 @@ inline SCALAR Clamp( const SCALAR & val, const SCALAR& minval, const SCALAR& ma
return val; return val;
} }
template <class SCALAR>
inline SCALAR Lerp(SCALAR a, SCALAR b, SCALAR lambda)
{
return a * lambda + (1-lambda) * b;
}
template <class SCALAR>
inline SCALAR ClampedLerp(SCALAR a, SCALAR b, SCALAR lambda)
{
math::Clamp(lambda, 0.f, 1.f);
return a * lambda + (1-lambda) * b;
}
inline float ToDeg(const float &a){return a*180.0f/float(M_PI);} inline float ToDeg(const float &a){return a*180.0f/float(M_PI);}