diff options
author | chai <chaifix@163.com> | 2019-01-12 21:48:33 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-12 21:48:33 +0800 |
commit | 8b00d67febf133e89f6a0bfabc41feed555dc4a9 (patch) | |
tree | fe48ef17c250afa40c2588300fcdb5920dba6951 /src/libjin/math/je_math.h | |
parent | a907c39756ef6b368d06643afa491c49a9044a8e (diff) |
*去掉文件前缀je_
Diffstat (limited to 'src/libjin/math/je_math.h')
-rw-r--r-- | src/libjin/math/je_math.h | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/src/libjin/math/je_math.h b/src/libjin/math/je_math.h deleted file mode 100644 index 4036696..0000000 --- a/src/libjin/math/je_math.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef __JE_UTILS_MATH_H__ -#define __JE_UTILS_MATH_H__ - -#include "je_constant.h" -#include "je_matrix.h" -#include "je_quad.h" - -namespace JinEngine -{ - namespace Math - { - - #ifdef min - #undef min - #endif // min - #ifdef max - #undef max - #endif // max - - template<typename T> - inline T min(T a, T b) - { - return a < b ? a : b; - } - - template<typename T> - inline T max(T a, T b) - { - return a > b ? a : b; - } - - template<typename T> - inline T clamp(T a, T mi, T ma) - { - return min<T>(max<T>(a, mi), ma); - } - - template<typename T> - inline bool within(T a, T mi, T ma) - { - return a >= mi && a <= ma; - } - - template<typename T> - inline bool without(T a, T mi, T ma) - { - return a < mi || a > ma; - } - - template<typename T> - inline T lowerBound(T a, T lower) - { - return a < lower ? lower : a; - } - - template<typename T> - inline T upperBound(T a, T upper) - { - return a > upper ? upper : a; - } - - inline float lerp(float a, float b, float f) - { - f = clamp<float>(f, 0, 1); - return a + f * (b - a); - } - - template<typename T> - inline T abs(T a) - { - return a > 0 ? a : -a; - } - - template<typename T> - inline T reverse(T a) - { - return -a; - } - - template<typename T> - inline T lerp(T a, T b, float t) - { - return a + t * (b - a); - } - - template<typename T> - inline T slerp(T start, T end, float percent) - { - // Dot product - the cosine of the angle between 2 vectors. - float dot = start * end; - // Clamp it to be in the range of Acos() - // This may be unnecessary, but floating point - // precision can be a fickle mistress. - dot = clamp<float>(dot, -1.0f, 1.0f); - // Acos(dot) returns the angle between start and end, - // And multiplying that by percent returns the angle between - // start and the final result. - float theta = Mathf.Acos(dot)*percent; - Vector3 RelativeVec = end - start * dot; - RelativeVec.Normalize(); - // Orthonormal basis - // The final result. - return ((start*Mathf.Cos(theta)) + (RelativeVec*Mathf.Sin(theta))); - } - - template<typename T> - inline T nlerp(T a, T b, float t) - { - - } - - } // namespace Math -} // namespace JinEngine - -#endif // __JE_UTILS_MATH_H__
\ No newline at end of file |