🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.0 KiB

  1. #ifndef AL_MATH_DEFS_H
  2. #define AL_MATH_DEFS_H
  3. #include <math.h>
  4. #ifndef M_PI
  5. #define M_PI 3.14159265358979323846
  6. #endif
  7. constexpr inline float Deg2Rad(float x) noexcept { return x * static_cast<float>(M_PI/180.0); }
  8. constexpr inline float Rad2Deg(float x) noexcept { return x * static_cast<float>(180.0/M_PI); }
  9. namespace al {
  10. template<typename Real>
  11. struct MathDefs { };
  12. template<>
  13. struct MathDefs<float> {
  14. static constexpr inline float Pi() noexcept { return 3.14159265358979323846f; }
  15. static constexpr inline float Tau() noexcept { return 3.14159265358979323846f * 2.0f; }
  16. static constexpr inline float Sqrt3() noexcept { return 1.73205080756887719318f; }
  17. };
  18. template<>
  19. struct MathDefs<double> {
  20. static constexpr inline double Pi() noexcept { return 3.14159265358979323846; }
  21. static constexpr inline double Tau() noexcept { return 3.14159265358979323846 * 2.0; }
  22. static constexpr inline double Sqrt3() noexcept { return 1.73205080756887719318; }
  23. };
  24. } // namespace al
  25. #endif /* AL_MATH_DEFS_H */