math: Move lerp function into SGMisc.
This commit is contained in:
@@ -2,7 +2,6 @@ include (SimGearComponent)
|
||||
|
||||
|
||||
set(HEADERS
|
||||
Math.hxx
|
||||
SGBox.hxx
|
||||
SGCMath.hxx
|
||||
SGGeoc.hxx
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef SIMGEAR_MATH_MATH_HXX
|
||||
#define SIMGEAR_MATH_MATH_HXX 1
|
||||
namespace simgear
|
||||
{
|
||||
namespace math
|
||||
{
|
||||
/** Linear interpolation between two values.
|
||||
*/
|
||||
template<typename T>
|
||||
inline T lerp(const T& x, const T& y, double alpha)
|
||||
{
|
||||
return x * (1.0 - alpha) + y * alpha;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T lerp(const T& x, const T& y, float alpha)
|
||||
{
|
||||
return x * (1.0f - alpha) + y * alpha;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -87,6 +87,11 @@ public:
|
||||
static int roundToInt(const T& v)
|
||||
{ return int(round(v)); }
|
||||
|
||||
// Linear interpolation between two arbitrary typed values
|
||||
template<typename S>
|
||||
static S lerp(const S& val0, const S& val1, const T& t)
|
||||
{ return val0*(T(1) - t) + val1*t; }
|
||||
|
||||
#ifndef NDEBUG
|
||||
/// Returns true if v is a NaN value
|
||||
/// Use with care: allways code that you do not need to use that!
|
||||
|
||||
Reference in New Issue
Block a user