aboutsummaryrefslogtreecommitdiffstats
path: root/common/math_defs.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-04-01 22:22:50 -0700
committerChris Robinson <[email protected]>2020-04-01 22:22:50 -0700
commit6fb59f1182965a0e1e45d60e81e3ff02db45944c (patch)
tree43f192cb9288e375dc633083a84692ca0b52dca3 /common/math_defs.h
parentbf48dcd37535ccf3146082cee421f418bb0cb66b (diff)
Avoid using M_PI
Diffstat (limited to 'common/math_defs.h')
-rw-r--r--common/math_defs.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/common/math_defs.h b/common/math_defs.h
index 0362a956..d90eaae5 100644
--- a/common/math_defs.h
+++ b/common/math_defs.h
@@ -3,12 +3,8 @@
#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-constexpr inline float Deg2Rad(float x) noexcept { return x * static_cast<float>(M_PI/180.0); }
-constexpr inline float Rad2Deg(float x) noexcept { return x * static_cast<float>(180.0/M_PI); }
+constexpr inline float Deg2Rad(float x) noexcept { return x * 1.74532925199432955e-02f/*pi/180*/; }
+constexpr inline float Rad2Deg(float x) noexcept { return x * 5.72957795130823229e+01f/*180/pi*/; }
namespace al {
@@ -17,14 +13,14 @@ struct MathDefs { };
template<>
struct MathDefs<float> {
- static constexpr inline float Pi() noexcept { return static_cast<float>(M_PI); }
- static constexpr inline float Tau() noexcept { return static_cast<float>(M_PI * 2.0); }
+ static constexpr inline float Pi() noexcept { return 3.14159265358979323846e+00f; }
+ static constexpr inline float Tau() noexcept { return 6.28318530717958647692e+00f; }
};
template<>
struct MathDefs<double> {
- static constexpr inline double Pi() noexcept { return M_PI; }
- static constexpr inline double Tau() noexcept { return M_PI * 2.0; }
+ static constexpr inline double Pi() noexcept { return 3.14159265358979323846e+00; }
+ static constexpr inline double Tau() noexcept { return 6.28318530717958647692e+00; }
};
} // namespace al