]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGMisc.hxx
math: Move lerp function into SGMisc.
[simgear.git] / simgear / math / SGMisc.hxx
index 89417cb3ff417521965cfdc2157d51bc3bc6de7d..5e69077eab6c98c469ecd681a5f8c3b86cfd2168 100644 (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!