ToyGine2 26.2.0
Game Engine for retro consoles
Loading...
Searching...
No Matches
constants.hpp File Reference

Mathematical constants for floating-point and toy::math::fixed_point types. More...

Include dependency graph for constants.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  toy
 Root namespace containing all engine modules.
namespace  toy::math
 Mathematical types, constants, and utilities: fixed-point, vectors, point.
namespace  toy::math::constants
 Variable templates for mathematical constants.

Concepts

concept  toy::math::FractionalConstantType
 Type that can be used with toy::math::constants variable templates.

Variables

template<FractionalConstantType T>
constexpr T toy::math::constants::e_v = std::numbers::e_v<T>
 Mathematical constant e.
template<FractionalConstantType T>
constexpr T toy::math::constants::pi_v = std::numbers::pi_v<T>
 Mathematical constant π.
template<FractionalConstantType T>
constexpr T toy::math::constants::log2e_v = std::numbers::log2e_v<T>
 Base-2 logarithm of e.
template<FractionalConstantType T>
constexpr T toy::math::constants::log10e_v = std::numbers::log10e_v<T>
 Base-10 logarithm of e.
template<FractionalConstantType T>
constexpr T toy::math::constants::sqrt2_v = std::numbers::sqrt2_v<T>
 Square root of 2.
template<FractionalConstantType T>
constexpr T toy::math::constants::sqrt3_v = std::numbers::sqrt3_v<T>
 Square root of 3.
template<FractionalConstantType T>
constexpr T toy::math::constants::inv_pi_v = std::numbers::inv_pi_v<T>
 1 over π.
template<FractionalConstantType T>
constexpr T toy::math::constants::inv_sqrtpi_v = std::numbers::inv_sqrtpi_v<T>
 1 over square root of π.
template<FractionalConstantType T>
constexpr T toy::math::constants::ln2_v = std::numbers::ln2_v<T>
 Natural logarithm of 2.
template<FractionalConstantType T>
constexpr T toy::math::constants::ln10_v = std::numbers::ln10_v<T>
 Natural logarithm of 10.
template<FractionalConstantType T>
constexpr T toy::math::constants::egamma_v = std::numbers::egamma_v<T>
 Euler–Mascheroni constant γ.
template<FractionalConstantType T>
constexpr T toy::math::constants::phi_v = std::numbers::phi_v<T>
 Golden ratio Φ.
template<FractionalConstantType T>
constexpr T toy::math::constants::rad_per_deg_v = static_cast<T>(std::numbers::pi_v<long double> / 180.0L)
 π over 180 (radians per degree).
template<FractionalConstantType T>
constexpr T toy::math::constants::deg_per_rad_v = static_cast<T>(180.0L / std::numbers::pi_v<long double>)
 180 over π (degrees per radian).

Detailed Description

Mathematical constants for floating-point and toy::math::fixed_point types.

Variable templates analogous to std::numbers (C++20). Supported types: float, double, long double, and toy::math::fixed. Values for built-in floating-point types come from the standard library; values for toy::math::fixed come from std::numbers specializations in math/fixed_std_extension.hpp.

Constant Description
e_v The mathematical constant e.
pi_v The mathematical constant π.
log2e_v Base-2 logarithm of e.
log10e_v Base-10 logarithm of e.
sqrt2_v Square root of 2
sqrt3_v Square root of 3.
inv_pi_v 1 over π.
inv_sqrtpi_v 1 over square root of π.
ln2_v Natural logarithm of 2.
ln10_v Natural logarithm of 10.
egamma_v Euler–Mascheroni constant γ.
phi_v Golden ratio Φ.
rad_per_deg_v π over 180 (radians per degree)
deg_per_rad_v 180 over π (degrees per radian)
Note
Included by math.hpp; do not include this file directly.
See also
https://en.cppreference.com/w/cpp/numeric/constants