|
|
|
|
@ -13,7 +13,7 @@ namespace math {
|
|
|
|
|
* @tparam T Any arithmetic type |
|
|
|
|
* @param t Value to compute sign of |
|
|
|
|
* @return -1 if t < 0, 1 if t > 0, 0 if t == 0 |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
template <typename T> |
|
|
|
|
int Sign(T t) |
|
|
|
|
{ |
|
|
|
|
@ -28,7 +28,7 @@ int Sign(T t)
|
|
|
|
|
* @param b High interpolation value (returned when t == 1) |
|
|
|
|
* @param t Interpolator, commonly in range [0..1], values outside this range will extrapolate |
|
|
|
|
* @return a + (b - a) * t |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
template <typename V, typename T> |
|
|
|
|
V Lerp(V a, V b, T t) |
|
|
|
|
{ |
|
|
|
|
@ -42,7 +42,7 @@ V Lerp(V a, V b, T t)
|
|
|
|
|
* @param b High key value (function returns 1 if v == b) |
|
|
|
|
* @param v Mixing factor, commonly in range [a..b] to get a return [0..1] |
|
|
|
|
* @return Value t so that v = Lerp(a, b, t); or 0 if b == a |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
template <typename T> |
|
|
|
|
T InvLerp(T a, T b, T v) |
|
|
|
|
{ |
|
|
|
|
@ -61,7 +61,7 @@ T InvLerp(T a, T b, T v)
|
|
|
|
|
* @param outMax Second bound of output range |
|
|
|
|
* @param v Value to remap |
|
|
|
|
* @return Transformed value so that InvLerp(inMin, inMax, v) == InvLerp(outMin, outMax, return) |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
template <typename T> |
|
|
|
|
T Remap(T inMin, T inMax, T outMin, T outMax, T v) |
|
|
|
|
{ |
|
|
|
|
|