rll/math.h file

Namespaces

namespace rll
Contract-programming related functions and classes.

Functions

template <typename T>
auto abs(T const& v) →  T constexpr
Returns the absolute value of a number.
template <typename T>
auto approx_eq(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) →  bool constexpr
Returns true if numbers are approximately equal within given epsilon.
template <typename T, typename = std::enable_if_t<is_num_v<T>>>
auto div_euclid(T a, T b) →  T
Calculates Euclidean division, the matching method for rem_euclid().
template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>>
auto floor(T val) →  T constexpr
Rounds val down to the nearest integer.
auto fmod(f32 const x, f32 const y) →  f32 constexpr
Returns the remainder of the division of x by y.
template <typename T>
auto is_null(T a, T epsilon = std::numeric_limits<T>::epsilon()) →  bool constexpr
Returns true if number is approximately zero within given epsilon.
template <typename T>
auto max(T&& v) →  T constexpr
Returns the maximum of a single value.
template <typename T, typename... Args>
auto max(T const& v1, T const& v2, Args const&... args) →  T constexpr
Returns the maximum value among the provided arguments.
template <typename T>
auto min(T&& v) →  T constexpr
Returns the minimum of a single value.
template <typename T, typename... Args>
auto min(T const& v1, T const& v2, Args const&... args) →  T constexpr
Returns the minimum value among the provided arguments.
template <typename T, typename = std::enable_if_t<is_num_v<T>>>
auto rem_euclid(T a, T b) →  T
Calculates the least nonnegative remainder of self (mod rhs).
template <typename T, typename = std::enable_if_t<is_num_v<T>>>
auto to_degrees(T radians) →  T constexpr noexcept
Converts radians to degrees.
template <typename T, typename = std::enable_if_t<is_num_v<T>>>
auto to_radians(T degrees) →  T constexpr noexcept
Converts degrees to radians.