aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-22 16:01:14 -0800
committerChris Robinson <[email protected]>2018-12-22 16:01:14 -0800
commit334b3a905a1a387d5fb5f74483a7520bb5d5449a (patch)
tree8f6aa333bb1b4eecbf9bcfe3f3f972c895345480 /common
parentd4d98e2fe9820f390515baf581dea7dc9bec1431 (diff)
Clean up some math stuff
Diffstat (limited to 'common')
-rw-r--r--common/math_defs.h23
-rw-r--r--common/vecmat.h3
2 files changed, 4 insertions, 22 deletions
diff --git a/common/math_defs.h b/common/math_defs.h
index 513570f0..4686e96b 100644
--- a/common/math_defs.h
+++ b/common/math_defs.h
@@ -2,9 +2,6 @@
#define AL_MATH_DEFS_H
#include <math.h>
-#ifdef HAVE_FLOAT_H
-#include <float.h>
-#endif
#ifndef M_PI
#define M_PI (3.14159265358979323846)
@@ -14,25 +11,9 @@
#define F_PI_2 (1.57079632679489661923f)
#define F_TAU (6.28318530717958647692f)
-#ifndef FLT_EPSILON
-#define FLT_EPSILON (1.19209290e-07f)
-#endif
-
-#define SQRT_2 1.41421356237309504880
-#define SQRT_3 1.73205080756887719318
-
-#define SQRTF_2 1.41421356237309504880f
#define SQRTF_3 1.73205080756887719318f
-#ifndef HUGE_VALF
-static const union msvc_inf_hack {
- unsigned char b[4];
- float f;
-} msvc_inf_union = {{ 0x00, 0x00, 0x80, 0x7F }};
-#define HUGE_VALF (msvc_inf_union.f)
-#endif
-
-#define DEG2RAD(x) ((float)(x) * (float)(M_PI/180.0))
-#define RAD2DEG(x) ((float)(x) * (float)(180.0/M_PI))
+constexpr inline float Deg2Rad(float x) noexcept { return x * float{M_PI/180.0}; }
+constexpr inline float Rad2Deg(float x) noexcept { return x * float{180.0/M_PI}; }
#endif /* AL_MATH_DEFS_H */
diff --git a/common/vecmat.h b/common/vecmat.h
index 1ecc4b7c..ab407b15 100644
--- a/common/vecmat.h
+++ b/common/vecmat.h
@@ -3,6 +3,7 @@
#include <cmath>
#include <array>
+#include <limits>
#include <algorithm>
#include "math_defs.h"
@@ -41,7 +42,7 @@ public:
float normalize()
{
const float length{std::sqrt(mVals[0]*mVals[0] + mVals[1]*mVals[1] + mVals[2]*mVals[2])};
- if(length > FLT_EPSILON)
+ if(length > std::numeric_limits<float>::epsilon())
{
float inv_length = 1.0f/length;
mVals[0] *= inv_length;