pbpt
|
Provides basic, constexpr-aware mathematical functions. More...
Go to the source code of this file.
Namespaces | |
namespace | pbpt::math |
The namespace for math library implementation. | |
namespace | pbpt::math::detail |
Contains internal implementation details for the math library. |
Macros | |
#define | M_PI 3.14159265358979323846 |
Define _USE_MATH_DEFINES for M_PI on MSVC, or just define pi ourselves for portability. |
Functions | |
template<typename T> | |
constexpr T | pbpt::math::detail::sqrt_newton_raphson (T x, T curr, T prev) |
A constexpr implementation of the square root function using the Newton-Raphson method. | |
template<typename T> | |
constexpr T | pbpt::math::detail::sin_taylor (T x) |
A constexpr implementation of the sine function using a Taylor series expansion. | |
template<typename T> | |
constexpr T | pbpt::math::detail::cos_taylor (T x) |
A constexpr implementation of the cosine function using a Taylor series expansion. | |
template<typename T> | |
constexpr T | pbpt::math::abs (T x) |
A constexpr implementation of the absolute value function. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr T | pbpt::math::rad2deg (T rad) |
Converts an angle from radians to degrees. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr T | pbpt::math::deg2rad (T deg) |
Converts an angle from degrees to radians. | |
template<typename T> | |
constexpr T | pbpt::math::sqrt (T x) |
Calculates the square root of a number with constexpr support. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr T | pbpt::math::sin (T x) |
Calculates the sine of an angle with constexpr support. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr T | pbpt::math::cos (T x) |
Calculates the cosine of an angle with constexpr support. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr T | pbpt::math::tan (T x) |
Calculates the tangent of an angle with constexpr support. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr bool | pbpt::math::is_equal (T a, T b) |
Compares two floating-point values for equality. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr bool | pbpt::math::is_greater (T a, T b) |
Compares if a is greater than b. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr bool | pbpt::math::is_less_equal (T a, T b) |
Compares if a is less than or equal to b. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr bool | pbpt::math::is_less (T a, T b) |
Compares if a is less than b. | |
template<typename T> requires std::is_floating_point_v<T> | |
constexpr bool | pbpt::math::is_greater_equal (T a, T b) |
Compares if a is greater than or equal to b. |
Provides basic, constexpr-aware mathematical functions.
This file contains fundamental math utilities like sqrt and abs. The functions are designed to be "context-aware," meaning they will use a constexpr implementation during compile-time evaluation and fall back to the highly optimized standard library versions (e.g., std::sqrt) at runtime. This is achieved by checking std::is_constant_evaluated().