🛠️🐜 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.

36 lines
958 B

  1. #ifndef COMMON_ALNUMBERS_H
  2. #define COMMON_ALNUMBERS_H
  3. #include <utility>
  4. namespace al {
  5. namespace numbers {
  6. namespace detail_ {
  7. template<typename T>
  8. using as_fp = std::enable_if_t<std::is_floating_point<T>::value, T>;
  9. } // detail_
  10. template<typename T>
  11. static constexpr auto pi_v = detail_::as_fp<T>(3.141592653589793238462643383279502884L);
  12. template<typename T>
  13. static constexpr auto inv_pi_v = detail_::as_fp<T>(0.318309886183790671537767526745028724L);
  14. template<typename T>
  15. static constexpr auto sqrt2_v = detail_::as_fp<T>(1.414213562373095048801688724209698079L);
  16. template<typename T>
  17. static constexpr auto sqrt3_v = detail_::as_fp<T>(1.732050807568877293527446341505872367L);
  18. static constexpr auto pi = pi_v<double>;
  19. static constexpr auto inv_pi = inv_pi_v<double>;
  20. static constexpr auto sqrt2 = sqrt2_v<double>;
  21. static constexpr auto sqrt3 = sqrt3_v<double>;
  22. } // namespace numbers
  23. } // namespace al
  24. #endif /* COMMON_ALNUMBERS_H */