From 8b00d67febf133e89f6a0bfabc41feed555dc4a9 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 12 Jan 2019 21:48:33 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E6=8E=89=E6=96=87=E4=BB=B6=E5=89=8D=E7=BC=80?= =?UTF-8?q?je=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/math/je_math.h | 115 ---------------------------------------------- 1 file changed, 115 deletions(-) delete mode 100644 src/libjin/math/je_math.h (limited to 'src/libjin/math/je_math.h') 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 - inline T min(T a, T b) - { - return a < b ? a : b; - } - - template - inline T max(T a, T b) - { - return a > b ? a : b; - } - - template - inline T clamp(T a, T mi, T ma) - { - return min(max(a, mi), ma); - } - - template - inline bool within(T a, T mi, T ma) - { - return a >= mi && a <= ma; - } - - template - inline bool without(T a, T mi, T ma) - { - return a < mi || a > ma; - } - - template - inline T lowerBound(T a, T lower) - { - return a < lower ? lower : a; - } - - template - inline T upperBound(T a, T upper) - { - return a > upper ? upper : a; - } - - inline float lerp(float a, float b, float f) - { - f = clamp(f, 0, 1); - return a + f * (b - a); - } - - template - inline T abs(T a) - { - return a > 0 ? a : -a; - } - - template - inline T reverse(T a) - { - return -a; - } - - template - inline T lerp(T a, T b, float t) - { - return a + t * (b - a); - } - - template - 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(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 - inline T nlerp(T a, T b, float t) - { - - } - - } // namespace Math -} // namespace JinEngine - -#endif // __JE_UTILS_MATH_H__ \ No newline at end of file -- cgit v1.1-26-g67d0