💿🐜 Antkeeper source code 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.

69 lines
1.7 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_MATH_CONSTANTS_HPP
  20. #define ANTKEEPER_MATH_CONSTANTS_HPP
  21. #include <limits>
  22. namespace math {
  23. /// Positive infinity.
  24. template <class T>
  25. constexpr T inf{std::numeric_limits<T>::infinity()};
  26. /// Pi.
  27. template <class T>
  28. constexpr T pi = T{3.1415926535897932384626433832795};
  29. /// Pi * 2.
  30. template <class T>
  31. constexpr T two_pi = pi<T> * T{2};
  32. /// Pi * 4.
  33. template <class T>
  34. constexpr T four_pi = pi<T> * T{4};
  35. /// Pi / 2.
  36. template <class T>
  37. constexpr T half_pi = pi<T> / T{2};
  38. /// 1 / Pi.
  39. template <class T>
  40. constexpr T inverse_pi = T{1} / pi<T>;
  41. /// sqrt(0.5)
  42. template <class T>
  43. constexpr T sqrt_half = T{0.70710678118654752440084436210485};
  44. /// sqrt(2)
  45. template <class T>
  46. constexpr T sqrt_2 = T{1.4142135623730950488016887242097};
  47. /// sqrt(3)
  48. template <class T>
  49. constexpr T sqrt_3 = T{1.7320508075688772935274463415059};
  50. /// sqrt(5)
  51. template <class T>
  52. constexpr T sqrt_5 = T{2.2360679774997896964091736687313};
  53. } // namespace math
  54. #endif // ANTKEEPER_MATH_CONSTANTS_HPP