27 #ifndef _ALGEBRA3D_GLOBAL_H_
28 #define _ALGEBRA3D_GLOBAL_H_
43 #define _PRECISION(FP_TYPE) ( \
44 (sizeof(FP_TYPE) == sizeof(float)) * 1.0e-5 \
45 + (sizeof(FP_TYPE) > sizeof(float)) * 1.0e-12\
51 #define PRECISION _PRECISION(fpType)
55 #define PRECISION_D _PRECISION(double)
59 #define PRECISION_F _PRECISION(float)
64 #define _INF(FP_TYPE) (std::numeric_limits<FP_TYPE>::infinity())
69 #define INF _INF(fpType)
73 #define INF_D _INF(double)
77 #define INF_F _INF(float)
83 #define N_A_N (INF - INF)
87 #define N_A_N_D (INF_D - INF_D)
91 #define N_A_N_F (INF_F - INF_F)
107 template<
class fpType>
108 inline int sign(
const fpType &val) {
110 return (val > 0) - (val < 0);
121 template<
class fpType>
124 return (val >= 0) - (val < 0);
136 template<
class fpType>
137 inline bool isInf(
const fpType &number) {
138 return number == std::numeric_limits<fpType>::infinity()
139 || -number == std::numeric_limits<fpType>::infinity();
151 template<
class fpType>
152 inline bool isNaN(
const fpType &number) {
153 return number != number;
174 template<
class fpType>
175 inline int compare(
const fpType &d1,
const fpType&d2,
const fpType &precision =
178 return (isNaN<fpType>(d1) || isNaN<fpType>(d2)) * 2 + (d1 - d2 > precision)
179 - (d2 - d1 > precision);
193 template<
class fpType>
203 template<
class fpType>
205 return acos(cosAlpha) * ((sinAlpha > 0.0) - (sinAlpha < 0.0));
fpType normalizeAngle(const fpType &angle)
bool isInf(const fpType &number)
Definition: global.h:137
int compare(const fpType &d1, const fpType &d2, const fpType &precision=PRECISION)
Definition: global.h:175
#define PRECISION
Definition: global.h:51
int signStar(const fpType &val)
Definition: global.h:122
bool isNaN(const fpType &number)
Definition: global.h:152
fpType getAngleFromSinCose(fpType sinAlpha, fpType cosAlpha)
Definition: global.h:204
int sign(const fpType &val)
Definition: global.h:108