Added invLerp.

This commit is contained in:
Бранимир Караџић
2019-10-26 08:18:06 -07:00
parent 741d11e7a4
commit 267727d318
2 changed files with 9 additions and 0 deletions

View File

@@ -127,6 +127,11 @@ namespace bx
return _a + (_b - _a) * _t;
}
inline BX_CONSTEXPR_FUNC float invLerp(float _a, float _b, float _value)
{
return (_value - _a) / (_b - _a);
}
inline BX_CONSTEXPR_FUNC float sign(float _a)
{
return _a < 0.0f ? -1.0f : 1.0f;

View File

@@ -146,6 +146,10 @@ namespace bx
///
BX_CONSTEXPR_FUNC float lerp(float _a, float _b, float _t);
/// Returns inverse linear interpolation of _value between two values _a and _b.
///
BX_CONSTEXPR_FUNC float invLerp(float _a, float _b, float _value);
/// Returns the sign of _a.
///
BX_CONSTEXPR_FUNC float sign(float _a);