15 #define G_PI 3.14159265358979323846 16 #define G_PI_R 0.318309886183790671538 18 #define G_EPSILON_F 1.192092896e-07F 19 #define G_EPSILON_D 2.2204460492503131e-016 21 #define G_ABS(num) ( ( (num) > 0 ) ? (num) : (-(num)) ) //RETURN THE ABSOLUTE VALUE OF THE INPUT NUMBER 22 #define G_LARGER(A, B) ( ( (A) > (B) ) ? (A) : (B) ) //RETURN THE LARGER INPUT NUMBER 23 #define G_SMALLER(A, B) ( ( (A) < (B) ) ? (A) : (B) ) //RETURN THE SMALLER INPUT NUMBER 24 #define G_ABS_LARGER(A, B) ( ( G_ABS(A) > G_ABS(B) ) ? G_ABS(A) : G_ABS(B) ) 26 #define G_DEVIATION_EXACT 0 27 #define G_DEVIATION_PRECISE_F G_EPSILON_F 28 #define G_DEVIATION_STANDARD_F G_EPSILON_F * 10 29 #define G_DEVIATION_LOOSE_F G_EPSILON_F * 100 31 #define G_DEVIATION_PRECISE_D G_EPSILON_D 32 #define G_DEVIATION_STANDARD_D G_EPSILON_D * 10 33 #define G_DEVIATION_LOOSE_D G_EPSILON_D * 100 35 #define G_FIRST_COMPARISON_F(num1 , num2) ( G_ABS( (num1) - (num2) ) <= ( G_EPSILON_F ) ) //FIRST CHECK IF TWO INPUT FLOATS' DIFF ARE LESS THAN EPSILON 36 #define G_SECOND_COMPARISON_F(num1 , num2) ( G_ABS( (num1) - (num2) ) <= ( G_DEVIATION_STANDARD_F * G_ABS_LARGER(num1, num2)) ) //SECOND CHECK IF TWO INPUT FLOATS' DIFF ARE LESS THAN EPSILON MULTIPLY THE LARGER INPUT FLOAT 37 #define G_COMPARISON_STANDARD_F(num1 , num2) ( G_FIRST_COMPARISON_F( (num1), (num2) ) ? true : G_SECOND_COMPARISON_F( (num1) , (num2) ) ) 38 #define G_COMPARISON_F(num1, num2, deviation) ( G_FIRST_COMPARISON_F( (num1), (num2) ) ? true : ( G_ABS( (num1) - (num2) ) <= ( deviation * G_ABS_LARGER(num1, num2)) ) ) 40 #define G_FIRST_COMPARISON_D(num1 , num2) ( G_ABS( (num1) - (num2) ) <= ( G_EPSILON_D ) ) //FIRST CHECK IF TWO INPUT FLOATS' DIFF ARE LESS THAN EPSILON 41 #define G_SECOND_COMPARISON_D(num1 , num2) ( G_ABS( (num1) - (num2) ) <= ( G_DEVIATION_STANDARD_D * G_ABS_LARGER(num1, num2)) ) //SECOND CHECK IF TWO INPUT FLOATS' DIFF ARE LESS THAN EPSILON MULTIPLY THE LARGER INPUT FLOAT 42 #define G_COMPARISON_STANDARD_D(num1 , num2) ( G_FIRST_COMPARISON_D( (num1), (num2) ) ? true : G_SECOND_COMPARISON_D( (num1) , (num2) ) ) 43 #define G_COMPARISON_D(num1 , num2, deviation) ( G_FIRST_COMPARISON_D( (num1), (num2) ) ? true :( G_ABS( (num1) - (num2) ) <= ( deviation * (G_ABS_LARGER(num1, num2))) ) ) 45 #define G_LERP(start , end, ratio) ( start + ratio * (end - start) ) //LINEAR INTERPOLATE TWO POINT WITH THE RATIO 46 #define G_CLAMP(num , top, bottom) ((((num) > (top)) ? (top) : (num)) < (bottom)) ? (bottom) : (num) //CLAMP THE NUMBER BETWEEN THE TOP NUMBER AND THE BOTTOM NUMBER 48 #define G_DEGREE_TO_RADIAN(degree) ( (degree) * ( (G_PI) / (180.0) ) ) 49 #define G_RADIAN_TO_DEGREE(radian) ( (radian) * ( (180.0) / (G_PI) ) ) 165 static const GVECTORF GIdentityVectorF{ 0,0,0,1 };
166 static const GVECTORD GIdentityVectorD{ 0,0,0,1 };
167 static const GVECTORF GZeroVectorF{ 0,0,0,0 };
168 static const GVECTORD GZeroVectorD{ 0,0,0,0 };
170 static const GMATRIXF GIdentityMatrixF{ 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1 };
171 static const GMATRIXD GIdentityMatrixD{ 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1 };
172 static const GMATRIXF GZeroMatrixF{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
173 static const GMATRIXD GZeroMatrixD{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
175 static const GQUATERNIONF GIdentityQuaternionF{ 0,0,0,1 };
176 static const GQUATERNIOND GIdentityQuaternionD{ 0,0,0,1 };
177 static const GQUATERNIONF GZeroQuaternionF{ 0,0,0,0 };
178 static const GQUATERNIOND GZeroQuaternionD{ 0,0,0,0 };
To hold all math structs and variables.
Definition: GMathDefines.h:68
Matrix with 4 double vectors which represent for each row.
Definition: GMathDefines.h:116
Quaternion with 4 double elements.
Definition: GMathDefines.h:148
Quaternion with 4 float elements.
Definition: GMathDefines.h:132
Vector with 4 double elements.
Definition: GMathDefines.h:84
Matrix with 4 float vectors which represent for each row.
Definition: GMathDefines.h:99
The core namespace to which all Gateware interfaces/structures/defines must belong.
Definition: GAudio.h:20