|
Not Enough Math
Lightweight zero-dependency C++ math library
|
#include <concepts>#include <type_traits>#include <cassert>#include "consts.hpp"#include "err.hpp"#include "config.hpp"#include "intrinsics.hpp"Go to the source code of this file.
Namespaces | |
| namespace | nem |
Functions | |
| template<std::floating_point T> | |
| constexpr T | nem::is_infinite (T value) noexcept |
| template<std::floating_point T> | |
| constexpr T | nem::is_nan (T value) noexcept |
| template<std::floating_point T> | |
| constexpr T | nem::copysign (T to, T from) noexcept |
| Copies the sign of {from} over to {to}. If the signs were the same, it doesn't change. | |
| template<nem::scalar_type T> | |
| constexpr T | nem::sign (T value) noexcept |
| template<typename T > | |
| constexpr T | nem::abs (T value) noexcept |
| template<nem::scalar_type T> | |
| constexpr bool | nem::is_zero (T a) noexcept |
| Is a nearly 0? Given an Epsilon > 0, within each all numbers are considered indistinguisable from 0, |a| < eps. | |
| template<nem::scalar_type T> | |
| constexpr bool | nem::is_zero_or_neg (T a) noexcept |
| template<nem::scalar_type T> | |
| constexpr bool | nem::equal (T a, T b) noexcept |
| Are a and b nearly equal? Given an Epsilon > 0, within each all numbers are considered indistinguisable from 0, |a - b| < eps. | |
| template<nem::scalar_type T> | |
| constexpr T | nem::get_max (T a, T b) noexcept |
| template<nem::scalar_type T> | |
| constexpr T | nem::get_min (T a, T b) noexcept |
| template<nem::scalar_type T> | |
| constexpr T | nem::average (T a, T b) noexcept |
| template<typename T > | |
| constexpr T | nem::pow2 (T value) noexcept |
| template<typename T > | |
| constexpr T | nem::pow3 (T value) noexcept |
| template<typename T > | |
| constexpr T | nem::pow4 (T value) noexcept |
| template<typename T > | |
| constexpr T | nem::sqr (T value) noexcept |
| template<typename T > | |
| constexpr T | nem::cube (T value) noexcept |
| template<nem::scalar_type T> | |
| constexpr T | nem::truncate (T value) noexcept |
| template<nem::scalar_type T> | |
| constexpr T | nem::floor (T value) noexcept |
| Floors always towards -infinity. | |
| template<nem::scalar_type T> | |
| constexpr T | nem::ceil (T value) noexcept |
| Ceils always towards +infinity. | |
| template<nem::scalar_type T> | |
| constexpr T | nem::mod (T a, T b) |
| Calculates euclidean modulo of a % b = r, where r belongs to [0, b). Unline standard C++ modulo operator, works with any floating-point numbers and can never yield negative numbers. | |
| template<std::floating_point T> | |
| constexpr T | nem::frac (T value) noexcept |
| Returns the fractional part of the floating-point number, with respect to sign 3.5 -> 0.5 4.0 -> 0.0 -2.1 -> -0.1. | |
| template<std::floating_point T> | |
| constexpr T | nem::round (T value) noexcept |
| template<std::floating_point T> | |
| constexpr T | nem::floor (T value, T step) |
| template<std::floating_point T> | |
| constexpr T | nem::ceil (T value, T step) |
| template<std::floating_point T> | |
| constexpr T | nem::round (T value, T step) |
| template<nem::scalar_type T> | |
| constexpr T | nem::repeat (T value, T lengthExcl) |
| Unwinds number to 0 when goes past length. Lengh is excluded: when value == lengthExcl, value becomes 0. | |
| template<nem::scalar_type T> | |
| constexpr T | nem::repeat (T value, T minIncl, T maxExcl) |
| Unwinds number to minimum when goes past maximum. Max value is excluded: when value == maxExcl, value becomes minIncl. | |
| template<nem::scalar_type T> | |
| constexpr T | nem::pingpong (T value, T length) |
| template<nem::scalar_type T> | |
| constexpr T | nem::pingpong (T value, T minIncl, T maxExcl) |
| template<std::totally_ordered T> | |
| constexpr T | nem::clamp (T value, T minIncl, T maxIncl) noexcept |
| template<std::totally_ordered T> | |
| constexpr T | nem::clamp01 (T value) noexcept |
| template<typename T > | |
| constexpr T | nem::smoothstep (T edge0, T edge1, T x) |
| template<typename T > | |
| constexpr T | nem::lerp (T a, T b, T t) |
| template<nem::scalar_type T> | |
| constexpr T | nem::remap (T value, T fromMin, T fromMax, T toMin, T toMax) |
| template<std::floating_point T> | |
| constexpr T | nem::is_whole (T value) |
| Is a floating point number whole (same as integer) | |