aboutsummaryrefslogtreecommitdiff
path: root/include/math/defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/math/defs.h')
-rw-r--r--include/math/defs.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/include/math/defs.h b/include/math/defs.h
index f67ee97..f572d8f 100644
--- a/include/math/defs.h
+++ b/include/math/defs.h
@@ -14,7 +14,7 @@ typedef double R;
14#define R_MIN DBL_MIN 14#define R_MIN DBL_MIN
15#define R_MAX DBL_MAX 15#define R_MAX DBL_MAX
16#else // floats 16#else // floats
17typedef float R; 17typedef float R;
18#define R_MIN FLT_MIN 18#define R_MIN FLT_MIN
19#define R_MAX FLT_MAX 19#define R_MAX FLT_MAX
20#endif 20#endif
@@ -29,13 +29,15 @@ typedef float R;
29#define TO_DEG (180.0 / PI) 29#define TO_DEG (180.0 / PI)
30 30
31#ifdef MATH_USE_DOUBLE 31#ifdef MATH_USE_DOUBLE
32static inline double min(R a, R b) { return fmin(a, b); } 32static inline R min(R a, R b) { return fmin(a, b); }
33static inline double max(R a, R b) { return fmax(a, b); } 33static inline R max(R a, R b) { return fmax(a, b); }
34static inline double rlog2(R a) { return log2(a); } 34static inline R rlog2(R a) { return log2(a); }
35static inline R rmod(R a, R m) { return fmodf(a, m); }
35#else // floats 36#else // floats
36static inline float min(R a, R b) { return fminf(a, b); } 37static inline R min(R a, R b) { return fminf(a, b); }
37static inline float max(R a, R b) { return fmaxf(a, b); } 38static inline R max(R a, R b) { return fmaxf(a, b); }
38static inline float rlog2(R a) { return log2f(a); } 39static inline R rlog2(R a) { return log2f(a); }
40static inline R rmod(R a, R m) { return fmod(a, m); }
39#endif 41#endif
40 42
41static inline R rabs(R x) { return x >= 0.0 ? x : -x; } 43static inline R rabs(R x) { return x >= 0.0 ? x : -x; }
@@ -51,3 +53,4 @@ static inline R sign(R x) {
51 } 53 }
52} 54}
53static inline R lerp(R a, R b, R t) { return a + (b - a) * t; } 55static inline R lerp(R a, R b, R t) { return a + (b - a) * t; }
56static inline R R_eq(R a, R b, R eps) { return rabs(a - b) <= eps; }