![]() |
ToyGine2 26.2.0
Game Engine for retro consoles
|
Math utilities, fixed-point arithmetic, and related types. More...
Functions | |
| template<typename T> | |
| constexpr T | toy::math::abs (const T &value) noexcept |
| Returns the absolute value of value. | |
| template<typename T> | |
| constexpr bool | toy::math::isEqual (const T &a, const T &b, T absEpsilon=8 *numeric_limits< T >::epsilon(), T relEpsilon=64 *numeric_limits< T >::epsilon()) noexcept |
| Compares two values for approximate equality. | |
| template<typename T> | |
| constexpr T | toy::math::deg2rad (const T &angle) noexcept |
| Converts angle from degrees to radians. | |
| template<typename T> | |
| constexpr T | toy::math::rad2deg (const T &angle) noexcept |
| Converts angle from radians to degrees. | |
Math utilities, fixed-point arithmetic, and related types.
float, double, long double), and fixed-point; branch-free for integral and common float types where applicable.numeric_limits<T>::epsilon()); overloads for standard floating-point and fixed-point types.noexcept operations.
|
nodiscardconstexprnoexcept |
Returns the absolute value of value.
Supports signed integers, floating-point, and fixed-point. Branch-free for signed integrals and fixed-point, for floating-point uses a conditional. Usable in constant expressions.
| T | Must satisfy toy::math::signed_integral, toy::math::floating_point, or toy::math::fixed_point. |
| value | The value (signed integer, floating-point, or fixed-point). |
|
nodiscardconstexprnoexcept |
Converts angle from degrees to radians.
| T | Scalar type; must satisfy toy::math::floating_point or toy::math::fixed_point. |
| angle | Angle in degrees. |
float, double, long double, and toy::math::fixed.
|
nodiscardconstexprnoexcept |
Compares two values for approximate equality.
Combined absolute and relative epsilon test: small values by absEpsilon, large values by relEpsilon scaled by max(|a|, |b|). Supports floating-point and fixed-point. For floating-point, does not support NaN inputs (assert in debug).
| T | Must satisfy toy::math::floating_point or toy::math::fixed_point. |
| a | The first value. |
| b | The second value. |
| absEpsilon | The maximum absolute difference treated as equal (default: 8× numeric_limits<T>::epsilon()). |
| relEpsilon | The maximum relative difference (default: 64× numeric_limits<T>::epsilon()). |
true if a and b are considered equal under the chosen tolerances, false otherwise.
|
nodiscardconstexprnoexcept |
Converts angle from radians to degrees.
| T | Scalar type; must satisfy toy::math::floating_point or toy::math::fixed_point. |
| angle | Angle in radians. |
float, double, long double, and toy::math::fixed.