10 #ifndef __CU_MATH_BASE_H__
11 #define __CU_MATH_BASE_H__
12 #include "../base/CUBase.h"
16 #if defined (__WINDOWS__)
17 #define M_PI_2 1.57079632679489661923f // pi/2
18 #define M_PI_4 0.785398163397448309616f // pi/4
23 #define CU_MATH_DEG_TO_RAD(x) ((x) * 0.0174532925f)
25 #define CU_MATH_RAD_TO_DEG(x) ((x)* 57.29577951f)
27 #define CU_MATH_APPROX(x,y,t) ( -(t) < (x)-(y) && (x)-(y) < (t) )
29 #define CU_MATH_FLOAT_SMALL 1.0e-37f
30 #define CU_MATH_EPSILON 1.0e-7f
33 #if defined (__ANDROID__) && defined (__arm64__)
34 #define CU_MATH_VECTOR_NEON64
35 #elif defined (__ANDROID__)
36 #define CU_MATH_VECTOR_ANDROID
37 #elif defined (__MACOSX__)
39 #define CU_MATH_VECTOR_APPLE
40 #elif defined (__IPHONE__)
41 #define CU_MATH_VECTOR_IOS
42 #elif defined (__SSE__)
43 #define CU_MATH_VECTOR_SSE
48 inline float clampf(
float value,
float min,
float max) {
49 return value < min ? min : value < max? value : max;
52 inline GLubyte clampb(GLuint value, GLubyte min, GLubyte max) {
53 return static_cast<GLubyte
>(value < min ? min : value < max? value : max);