X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGMisc.hxx;h=8eaa124e27704eca149bf7f8c912fcd661670aba;hb=b99f53fda3b06378668bdccd4a9d07161f263366;hp=a154d632b38c7baff1d9b31ab3bddb982a5ae388;hpb=6440ece177ff4388f128309d209897a56a3e39f0;p=simgear.git diff --git a/simgear/math/SGMisc.hxx b/simgear/math/SGMisc.hxx index a154d632..8eaa124e 100644 --- a/simgear/math/SGMisc.hxx +++ b/simgear/math/SGMisc.hxx @@ -65,7 +65,7 @@ public: return min; T normalized = value - range*floor((value - min)/range); // two security checks that can only happen due to roundoff - if (value <= min) + if (normalized <= min) return min; if (max <= normalized) return min; @@ -87,7 +87,11 @@ public: static int roundToInt(const T& v) { return int(round(v)); } -#ifndef NDEBUG + // Linear interpolation between two arbitrary typed values + template + static S lerp(const S& val0, const S& val1, const T& t) + { return val0*(T(1) - t) + val1*t; } + /// Returns true if v is a NaN value /// Use with care: allways code that you do not need to use that! static bool isNaN(const T& v) @@ -104,7 +108,6 @@ public: return !(v == v); #endif } -#endif }; #endif