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;
static int roundToInt(const T& v)
{ return int(round(v)); }
-#ifndef NDEBUG
+ // 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; }
+
/// 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)
return !(v == v);
#endif
}
-#endif
};
#endif