/* * Copyright (C) 2023 Christopher J. Howard * * This file is part of Antkeeper source code. * * Antkeeper source code is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Antkeeper source code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Antkeeper source code. If not, see . */ #ifndef ANTKEEPER_MATH_NUMBERS_HPP #define ANTKEEPER_MATH_NUMBERS_HPP #include #include namespace math { /// Mathematical constants. namespace numbers { /// Positive infinity. template inline constexpr T inf = std::numeric_limits::infinity(); /// e. template inline constexpr T e = std::numbers::e_v; /// log2(e). template inline constexpr T log2_e = std::numbers::log2e_v; /// log10(e). template inline constexpr T log10_e = std::numbers::log10e_v; /// Pi. template inline constexpr T pi = std::numbers::pi_v; /// Pi * 2. template inline constexpr T two_pi = pi * T{2}; /// Pi * 4. template inline constexpr T four_pi = pi * T{4}; /// Pi / 2. template inline constexpr T half_pi = pi / T{2}; /// 1 / Pi. template inline constexpr T inv_pi = std::numbers::inv_pi_v; /// 1 / sqrt(Pi). template inline constexpr T inv_sqrt_pi = std::numbers::inv_sqrtpi_v; /// ln(2). template inline constexpr T ln_2 = std::numbers::ln2_v; /// ln(10). template inline constexpr T ln_10 = std::numbers::ln10_v; /// sqrt(0.5) template inline constexpr T sqrt_half = T{0.70710678118654752440084436210485}; /// sqrt(2) template inline constexpr T sqrt_2 = std::numbers::sqrt2_v; /// sqrt(3) template inline constexpr T sqrt_3 = std::numbers::sqrt3_v; /// 1 / sqrt(3) template inline constexpr T inv_sqrt_3 = std::numbers::inv_sqrt3_v; /// sqrt(5) template inline constexpr T sqrt_5 = T{2.2360679774997896964091736687313}; /// Euler–Mascheroni constant. template inline constexpr T egamma = std::numbers::egamma_v; /// Golden ratio constant. template inline constexpr T phi = std::numbers::phi_v; /// Degrees-to-radians conversion factor. template inline constexpr T deg2rad = pi / T{180}; /// Radians-to-degrees conversion factor. template inline constexpr T rad2deg = T{180} / pi; } // namespace numbers // Bring math::numbers into math namespace using namespace numbers; } // namespace math #endif // ANTKEEPER_MATH_NUMBERS_HPP