1#ifndef GIM_MATH_H_INCLUDED
2#define GIM_MATH_H_INCLUDED
40#define GUINT unsigned int
42#define GUSHORT unsigned short
43#define GINT64 long long
44#define GUINT64 unsigned long long
46#define G_PI 3.14159265358979f
47#define G_HALF_PI 1.5707963f
49#define G_TWO_PI 6.28318530f
51#define G_ROOT3 1.73205f
52#define G_ROOT2 1.41421f
53#define G_UINT_INFINITY 0xffffffff
54#define G_REAL_INFINITY FLT_MAX
55#define G_SIGN_BITMASK 0x80000000
56#define G_EPSILON SIMD_EPSILON
70#define G_DEGTORAD(X) ((X)*3.1415926f / 180.0f)
71#define G_RADTODEG(X) ((X)*180.0f / 3.1415926f)
74#define GIM_IR(x) ((GUINT&)(x))
77#define GIM_SIR(x) ((GINT&)(x))
80#define GIM_AIR(x) (GIM_IR(x) & 0x7fffffff)
83#define GIM_FR(x) ((GREAL&)(x))
85#define GIM_MAX(a, b) (a < b ? b : a)
86#define GIM_MIN(a, b) (a > b ? b : a)
88#define GIM_MAX3(a, b, c) GIM_MAX(a, GIM_MAX(b, c))
89#define GIM_MIN3(a, b, c) GIM_MIN(a, GIM_MIN(b, c))
91#define GIM_IS_ZERO(value) (value < G_EPSILON && value > -G_EPSILON)
93#define GIM_IS_NEGATIVE(value) (value <= -G_EPSILON)
95#define GIM_IS_POSISITVE(value) (value >= G_EPSILON)
97#define GIM_NEAR_EQUAL(v1, v2) GIM_IS_ZERO((v1 - v2))
100#define GIM_CLAMP(number, minval, maxval) (number < minval ? minval : (number > maxval ? maxval : number))
102#define GIM_GREATER(x, y) btFabs(x) > (y)
105#define GIM_SWAP_NUMBERS(a, b) \
112#define GIM_INV_SQRT(va, isva) \
114 if (va <= 0.0000001f) \
116 isva = G_REAL_INFINITY; \
120 GREAL _x = va * 0.5f; \
121 GUINT _y = 0x5f3759df - (GIM_IR(va) >> 1); \
123 isva = isva * (1.5f - (_x * isva * isva)); \
127#define GIM_SQRT(va, sva) \
129 GIM_INV_SQRT(va, sva); \
GREAL gim_inv_sqrt(GREAL f)
Computes 1.0f / sqrtf(x). Comes from Quake3. See http://www.magic-software.com/3DGEDInvSqrt....
#define GIM_SQRT(va, sva)
#define GIM_INV_SQRT(va, isva)