math: Move lerp function into SGMisc.

This commit is contained in:
Mathias Froehlich
2012-03-03 12:03:09 +01:00
parent 9414874e1d
commit 57a3b0fd1e
4 changed files with 10 additions and 29 deletions
-1
View File
@@ -2,7 +2,6 @@ include (SimGearComponent)
set(HEADERS
Math.hxx
SGBox.hxx
SGCMath.hxx
SGGeoc.hxx
-23
View File
@@ -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
+5
View File
@@ -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!