#ifndef __SCOP_MATHS_CONSTANTS__ #define __SCOP_MATHS_CONSTANTS__ #include #include #include namespace Scop { template constexpr std::size_t BitCount = CHAR_BIT * sizeof(T); template struct MathConstants { static constexpr T Infinity() { static_assert(std::numeric_limits::has_infinity); return std::numeric_limits::infinity(); } static constexpr T Max() { return std::numeric_limits::max(); } static constexpr T Min() { return std::numeric_limits::min(); } static constexpr T NaN() { static_assert(std::numeric_limits::has_signaling_NaN); return std::numeric_limits::quiet_NaN(); } // Math constants static constexpr T HalfPi() { static_assert(std::is_floating_point_v); return T(1.5707963267948966192313216916398); } static constexpr T Pi() { static_assert(std::is_floating_point_v); return T(3.1415926535897932384626433832795); } static constexpr T Sqrt2() { static_assert(std::is_floating_point_v); return T(1.4142135623730950488016887242097); } static constexpr T Sqrt3() { static_assert(std::is_floating_point_v); return T(1.7320508075688772935274463415059); } static constexpr T Sqrt5() { static_assert(std::is_floating_point_v); return T(2.2360679774997896964091736687313); } static constexpr T Tau() { static_assert(std::is_floating_point_v); return T(6.2831853071795864769252867665590); } }; template constexpr auto Infinity() { return MathConstants::Infinity(); } template constexpr auto MaxValue() { return MathConstants::Max(); } template constexpr auto MinValue() { return MathConstants::Min(); } template constexpr auto NaN() { return MathConstants::NaN(); } template constexpr auto HalfPi() { return MathConstants::HalfPi(); } template constexpr auto Pi() { return MathConstants::Pi(); } template constexpr auto Sqrt2() { return MathConstants::Sqrt2(); } template constexpr auto Sqrt3() { return MathConstants::Sqrt3(); } template constexpr auto Sqrt5() { return MathConstants::Sqrt5(); } template constexpr auto Tau() { return MathConstants::Tau(); } } #endif