diff --git a/maths.hpp b/maths.hpp index 4b681fdb..3f1bb930 100644 --- a/maths.hpp +++ b/maths.hpp @@ -582,7 +582,8 @@ namespace util { // min/max clamping template - constexpr T + constexpr + T limit (const T val, const U lo, const V hi) { assert (lo <= hi); @@ -596,6 +597,7 @@ namespace util { //------------------------------------------------------------------------- // clamped cubic hermite interpolation template + constexpr T smoothstep (T a, T b, T x) { @@ -605,6 +607,18 @@ namespace util { } + //------------------------------------------------------------------------- + template + constexpr + std::enable_if_t::value, U> + mix (U a, U b, T t) + { + assert (t >= 0); + assert (t <= 1); + + return a * (1 - t) + b * t; + } + /////////////////////////////////////////////////////////////////////////// // renormalisation of unit floating point and/or normalised integers