Browse Source

Added invSmoothStep.

Бранимир Караџић 5 years ago
parent
commit
279b8ff3c0
2 changed files with 8 additions and 0 deletions
  1. 5 0
      include/bx/inline/math.inl
  2. 3 0
      include/bx/math.h

+ 5 - 0
include/bx/inline/math.inl

@@ -344,6 +344,11 @@ namespace bx
 		return square(_a)*(3.0f - 2.0f*_a);
 		return square(_a)*(3.0f - 2.0f*_a);
 	}
 	}
 
 
+	inline BX_CONST_FUNC float invSmoothStep(float _a)
+	{
+		return 0.5f - sin(asin(1.0f - 2.0f * _a) / 3.0f);
+	}
+
 	inline BX_CONSTEXPR_FUNC float bias(float _time, float _bias)
 	inline BX_CONSTEXPR_FUNC float bias(float _time, float _bias)
 	{
 	{
 		return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f);
 		return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f);

+ 3 - 0
include/bx/math.h

@@ -282,6 +282,9 @@ namespace bx
 	///
 	///
 	BX_CONSTEXPR_FUNC float smoothStep(float _a);
 	BX_CONSTEXPR_FUNC float smoothStep(float _a);
 
 
+	///
+	BX_CONST_FUNC float invSmoothStep(float _a);
+
 	///
 	///
 	BX_CONSTEXPR_FUNC float bias(float _time, float _bias);
 	BX_CONSTEXPR_FUNC float bias(float _time, float _bias);