math_defs.h 750 B

1234567891011121314151617181920212223242526
  1. #ifndef AL_MATH_DEFS_H
  2. #define AL_MATH_DEFS_H
  3. constexpr float Deg2Rad(float x) noexcept { return x * 1.74532925199432955e-02f/*pi/180*/; }
  4. constexpr float Rad2Deg(float x) noexcept { return x * 5.72957795130823229e+01f/*180/pi*/; }
  5. namespace al {
  6. template<typename Real>
  7. struct MathDefs { };
  8. template<>
  9. struct MathDefs<float> {
  10. static constexpr float Pi() noexcept { return 3.14159265358979323846e+00f; }
  11. static constexpr float Tau() noexcept { return 6.28318530717958647692e+00f; }
  12. };
  13. template<>
  14. struct MathDefs<double> {
  15. static constexpr double Pi() noexcept { return 3.14159265358979323846e+00; }
  16. static constexpr double Tau() noexcept { return 6.28318530717958647692e+00; }
  17. };
  18. } // namespace al
  19. #endif /* AL_MATH_DEFS_H */