Not Enough Math
Lightweight zero-dependency C++ math library
Loading...
Searching...
No Matches
nem Namespace Reference

Namespaces

namespace  accurate
 
namespace  color
 
namespace  ease
 
namespace  error
 
namespace  experimental
 
namespace  fast
 
namespace  intr
 

Classes

struct  is_subset_of
 
struct  mat
 
struct  quat_t
 
struct  safe_t
 
struct  sincos
 
struct  storage
 
struct  storage< _T, 2 >
 
struct  storage< _T, 3 >
 
struct  storage< _T, 4 >
 
struct  unsafe_t
 
struct  vec
 

Concepts

concept  scalar_type
 
concept  CanBeNaN
 
concept  CanBeNaNIfConfig
 

Typedefs

using nem_string = const char*
 
using real = float
 
using mat2 = mat<real, 2, 2>
 
using mat3 = mat<real, 3, 3>
 
using mat4 = mat<real, 4, 4>
 
using quat = quat_t<nem::real>
 
using int2 = nem::vec<int , 2>
 
using int3 = nem::vec<int , 3>
 
using int4 = nem::vec<int , 4>
 
using float2 = nem::vec<float , 2>
 
using float3 = nem::vec<float , 3>
 
using float4 = nem::vec<float , 4>
 
using double2 = nem::vec<double, 2>
 
using double3 = nem::vec<double, 3>
 
using double4 = nem::vec<double, 4>
 

Enumerations

enum class  Precision : unsigned char { Fast = 0 , Accurate = 1 }
 

Functions

const char * GET_C_STRING (nem_string str)
 
template<nem::scalar_type T>
constexpr T abs_to_rel_error (T x, T abs_error)
 
template<nem::scalar_type T>
constexpr T eps ()
 
template<nem::scalar_type T, nem::Precision Prec = nem::default_precision>
constexpr T abs_error ()
 
template<nem::scalar_type T, nem::Precision Prec = nem::default_precision>
constexpr T rel_error (T x)
 
template<typename T , size_t C, size_t R>
std::string tostr (const mat< T, C, R > &matrix)
 
template<typename T , size_t C, size_t R>
std::ostream & operator<< (std::ostream &os, const mat< T, C, R > &matrix)
 
template<typename T , size_t C, size_t R>
std::istream & operator>> (std::istream &is, mat< T, C, R > &matrix)
 
template<typename T , size_t C, size_t R, typename F >
constexpr nem::mat< T, C, R > transform_items (nem::mat< T, C, R > m, F &&func)
 
template<typename T , size_t C, size_t R>
constexpr nem::mat< T, R, C > transpose (const nem::mat< T, C, R > &m)
 
template<typename T , size_t N>
constexpr nem::mat< T, N, N > identity ()
 
template<typename M >
constexpr nem::mat< typename M::ITEM_TYPE, M::COLUMNS, M::ROWS > identity ()
 
template<typename T , size_t C1, size_t R1, size_t C2, size_t R2>
constexpr nem::mat< T, C2, R2 > upscale (const nem::mat< T, C1, R1 > &m)
 
template<typename T , size_t N>
constexpr nem::mat< T, N+1, N+1 > homogenous (const nem::mat< T, N, N > &m)
 
template<typename T >
constexpr T determinant (const nem::mat< T, 2, 2 > &m)
 
template<std::floating_point T>
constexpr nem::mat< T, 2, 2 > rotate (T radians)
 
template<std::floating_point T>
constexpr nem::mat< T, 3, 3 > rotate_x (nem::sincos< T > a)
 
template<std::floating_point T>
constexpr nem::mat< T, 3, 3 > rotate_y (nem::sincos< T > a)
 
template<std::floating_point T>
constexpr nem::mat< T, 3, 3 > rotate_z (nem::sincos< T > a)
 
template<std::floating_point T>
constexpr nem::mat< T, 3, 3 > rotate (T yaw_z, T pitch_y, T roll_x)
 
template<std::floating_point T>
constexpr nem::mat< T, 3, 3 > translate_2D (const nem::vec< T, 2 > &value)
 
template<std::floating_point T>
constexpr nem::mat< T, 4, 4 > translate_3D (const nem::vec< T, 3 > &value)
 
template<std::floating_point T, size_t N>
constexpr nem::mat< T, N, N > scale (const nem::vec< T, N > &value)
 
template<std::floating_point T>
constexpr nem::mat< T, 4, 4 > transform (const nem::vec< T, 3 > &translation, const nem::quat_t< T > &rotation, const nem::vec< T, 3 > scaler)
 
template<std::floating_point T = float, nem::Precision Prec = nem::default_precision>
constexpr T log2 (T x)
 
template<std::floating_point T, nem::Precision Prec = nem::default_precision>
constexpr T log (T base, T value)
 
template<std::floating_point T, nem::Precision Prec = nem::default_precision>
constexpr T ln (T value)
 
template<std::floating_point T, nem::Precision Prec = nem::default_precision>
constexpr T exp2 (T x)
 
template<nem::scalar_type T, std::integral E>
constexpr T pow (T base, E exp)
 
template<std::floating_point T, nem::Precision Prec = nem::default_precision>
constexpr T pow (T base, T exp, nem::unsafe_t)
 
template<std::floating_point T, nem::Precision Prec = nem::default_precision>
constexpr T pow (T base, T exp, nem::safe_t=nem::safe)
 
template<typename T >
sqrt (T value)
 
template<std::floating_point T, int Precision = 20>
constexpr T csqrt (T value)
 
int isqrt (unsigned x)
 
int icbrt (unsigned x)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const nem::quat_t< T > &q)
 
template<typename T >
std::istream & operator>> (std::istream &is, nem::quat_t< T > &q)
 
template<typename T >
std::string to_str (const nem::quat_t< T > &q)
 
template<typename T = nem::real>
constexpr T sqr_length (const nem::quat_t< T > &q)
 
template<typename T = nem::real>
length (const nem::quat_t< T > &q)
 
template<typename T = nem::real>
nem::quat_t< T > normalize (nem::quat_t< T > q)
 
template<typename T = nem::real>
constexpr nem::quat_t< T > make_quat (const nem::vec< T, 4 > &vec4)
 
template<typename T = nem::real>
constexpr nem::quat_t< T > make_quat (T scalar, T x, T y, T z)
 
template<typename T = nem::real>
constexpr nem::quat_t< T > conjugate (const nem::quat_t< T > &q)
 Conjugates the quaternion, yielding a quaternion with the same angle (scalar) but inverse axis (vector)
 
template<typename T = nem::real>
constexpr nem::quat_t< T > inverse (const nem::quat_t< T > &q)
 
template<typename T = nem::real>
nem::quat_t< T > from_axis_angle (const nem::vec< T, 3 > &axis, T radians)
 
template<typename T = nem::real>
nem::quat_t< T > from_euler (T pitch, T yaw, T roll)
 
template<typename T = nem::real>
constexpr nem::mat< T, 3, 3 > norm_quaterion_to_rotation_matrix (const nem::quat_t< T > &q)
 
template<typename T >
constexpr nem::vec< T, 3 > extract_vector (const nem::quat_t< T > &q)
 
template<nem::scalar_type T>
constexpr T degrees (T degrees) noexcept
 Converts degrees to radians. Used to make units explicit.
 
template<nem::scalar_type T>
constexpr T radians (T radians) noexcept
 Converts radians to radians (passes the argument unchanged). Used to make units explicit.
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T ft_sin_q1 (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T ft_cos_q1 (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T sin (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T cos (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr nem::sincos< T > get_sincos (T radians)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T tan (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T ctg (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T sec (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T csc (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T ft_atan_q1 (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T atan (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T atan2 (T y, T x)
 
template<std::floating_point T>
constexpr T acos (T x)
 
template<std::floating_point T>
constexpr T asin (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T actg (T x)
 
template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
constexpr T actg2 (T x, T y)
 
template<std::floating_point T>
constexpr T is_infinite (T value) noexcept
 
template<std::floating_point T>
constexpr T is_nan (T value) noexcept
 
template<std::floating_point T>
constexpr T 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 sign (T value) noexcept
 
template<typename T >
constexpr T abs (T value) noexcept
 
template<nem::scalar_type T>
constexpr bool 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 is_zero_or_neg (T a) noexcept
 
template<nem::scalar_type T>
constexpr bool 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 get_max (T a, T b) noexcept
 
template<nem::scalar_type T>
constexpr T get_min (T a, T b) noexcept
 
template<nem::scalar_type T>
constexpr T average (T a, T b) noexcept
 
template<typename T >
constexpr T pow2 (T value) noexcept
 
template<typename T >
constexpr T pow3 (T value) noexcept
 
template<typename T >
constexpr T pow4 (T value) noexcept
 
template<typename T >
constexpr T sqr (T value) noexcept
 
template<typename T >
constexpr T cube (T value) noexcept
 
template<nem::scalar_type T>
constexpr T truncate (T value) noexcept
 
template<nem::scalar_type T>
constexpr T floor (T value) noexcept
 Floors always towards -infinity.
 
template<nem::scalar_type T>
constexpr T ceil (T value) noexcept
 Ceils always towards +infinity.
 
template<nem::scalar_type T>
constexpr T 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 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 round (T value) noexcept
 
template<std::floating_point T>
constexpr T floor (T value, T step)
 
template<std::floating_point T>
constexpr T ceil (T value, T step)
 
template<std::floating_point T>
constexpr T round (T value, T step)
 
template<nem::scalar_type T>
constexpr T 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 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 pingpong (T value, T length)
 
template<nem::scalar_type T>
constexpr T pingpong (T value, T minIncl, T maxExcl)
 
template<std::totally_ordered T>
constexpr T clamp (T value, T minIncl, T maxIncl) noexcept
 
template<std::totally_ordered T>
constexpr T clamp01 (T value) noexcept
 
template<typename T >
constexpr T smoothstep (T edge0, T edge1, T x)
 
template<typename T >
constexpr T lerp (T a, T b, T t)
 
template<nem::scalar_type T>
constexpr T remap (T value, T fromMin, T fromMax, T toMin, T toMax)
 
template<std::floating_point T>
constexpr T is_whole (T value)
 Is a floating point number whole (same as integer)
 
template<typename T , size_t N>
std::ostream & operator<< (std::ostream &os, const nem::vec< T, N > &vec)
 
template<typename T , size_t N>
std::istream & operator>> (std::istream &is, nem::vec< T, N > &vec)
 
template<typename T , size_t N>
std::string tostr (const nem::vec< T, N > &vec)
 
template<typename T , size_t N>
bool is_zero (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
bool is_zero (const nem::vec< T, N > &&v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > is_infinite (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > is_nan (const nem::vec< T, N > &v)
 
template<std::floating_point T, size_t N>
constexpr nem::vec< T, N > copysign (const nem::vec< T, N > &to, const nem::vec< T, N > &from)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > sign (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > abs (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr bool is_zero_or_neg (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr bool equal (const nem::vec< T, N > &a, const nem::vec< T, N > &b)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > get_max (const nem::vec< T, N > &a, const nem::vec< T, N > &b)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > get_min (const nem::vec< T, N > &a, const nem::vec< T, N > &b)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > average (const nem::vec< T, N > &a, const nem::vec< T, N > &b)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > pow2 (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > pow3 (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > pow4 (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > sqr (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > cube (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > truncate (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > floor (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > ceil (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > mod (const nem::vec< T, N > &a, const nem::vec< T, N > &b)
 
template<std::floating_point T, size_t N>
constexpr nem::vec< T, N > frac (const nem::vec< T, N > &v)
 
template<std::floating_point T, size_t N>
constexpr nem::vec< T, N > round (const nem::vec< T, N > &v)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > floor (const nem::vec< T, N > &v, const nem::vec< T, N > &step)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > ceil (const nem::vec< T, N > &v, const nem::vec< T, N > &step)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > round (const nem::vec< T, N > &v, const nem::vec< T, N > &step)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > repeat (const nem::vec< T, N > &value, const nem::vec< T, N > &lengthExcl)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > repeat (const nem::vec< T, N > &value, const nem::vec< T, N > &minIncl, const nem::vec< T, N > &maxExcl)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > pingpong (const nem::vec< T, N > &value, const nem::vec< T, N > &length)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > pingpong (const nem::vec< T, N > &value, const nem::vec< T, N > &minIncl, const nem::vec< T, N > &maxExcl)
 
template<std::totally_ordered T, size_t N>
constexpr nem::vec< T, N > clamp (const nem::vec< T, N > &value, const nem::vec< T, N > &minIncl, const nem::vec< T, N > &maxIncl)
 
template<std::totally_ordered T, size_t N>
constexpr nem::vec< T, N > clamp01 (const nem::vec< T, N > &value)
 
template<typename T , size_t N>
constexpr nem::vec< T, N > smoothstep (const nem::vec< T, N > &edge0, const nem::vec< T, N > &edge1, const nem::vec< T, N > &x)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > remap (const nem::vec< T, N > &value, const nem::vec< T, N > &fromMin, const nem::vec< T, N > &fromMax, const nem::vec< T, N > &toMin, const nem::vec< T, N > &toMax)
 
template<nem::scalar_type T, size_t N>
constexpr nem::vec< T, N > is_whole (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
dot (const nem::vec< T, N > &a, const nem::vec< T, N > &b)
 
template<typename T >
nem::vec< T, 3 > cross (const nem::vec< T, 3 > &a, const nem::vec< T, 3 > &b)
 
template<typename T , size_t N>
horizontal_sum (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
horizontal_mul (const nem::vec< T, N > &v)
 
template<typename T , size_t N>
nem::vec< T, N > reflect (const nem::vec< T, N > &vector, const nem::vec< T, N > &normal)
 
template<typename T , size_t N>
static constexpr nem::vec< T, N > lerp (const nem::vec< T, N > &a, const nem::vec< T, N > &b, float t)
 
template<typename T , size_t N>
constexpr T sqr_length (const nem::vec< T, N > &vec)
 
template<typename T , size_t N>
length (const nem::vec< T, N > &vec)
 
template<typename T , size_t N>
nem::vec< T, N > normalize (const nem::vec< T, N > &vec)
 
template<typename T >
bool orthogonal_3d_basis (const nem::vec< T, 3 > &vector, nem::vec< T, 3 > &b1, nem::vec< T, 3 > &b2)
 

Variables

constexpr bool ERR_THROW = true
 
constexpr bool ERR_LOG = true
 
constexpr bool ERR_USE_NAN = true
 
constexpr bool ERR_SAFE_FALLBACK = false
 
constexpr bool USE_C_STRING = true
 
constexpr safe_t safe {}
 
constexpr unsafe_t unsafe {}
 
constexpr nem::Precision default_precision = nem::Precision::Fast
 
template<class From , class To >
constexpr bool is_subset_of_v = is_subset_of<From, To>::value
 
template<std::floating_point T>
constexpr T SQRT2 = (T)1.414213562373095
 
template<std::floating_point T>
constexpr T SQRT3 = (T)1.73205080756887
 
template<std::floating_point T>
constexpr T SQRT5 = (T)2.236067977499789
 
template<std::floating_point T>
constexpr T PI = (T)3.141592653589793
 
template<std::floating_point T>
constexpr T HALF_PI = (T)nem::PI<T> * (T)0.5
 
template<std::floating_point T>
constexpr T QUARTER_PI = (T)nem::PI<T> * (T)0.25
 
template<std::floating_point T>
constexpr T TWO_PI = (T)nem::PI<T> * (T)2.0
 
template<std::floating_point T>
constexpr T E = (T)2.718281828459045
 
template<std::floating_point T>
constexpr T ESQR = nem::E<T> * nem::E<T>
 
template<std::floating_point T>
constexpr T PHI = (T)1.618033988749894
 
template<std::floating_point T>
constexpr T DEG_TO_RAD = nem::TWO_PI<T> / (T)360.0
 
template<std::floating_point T>
constexpr T RAD_TO_DEG = (T)1.0 / nem::DEG_TO_RAD<T>
 
template<std::floating_point T>
constexpr T LN2 = (T)0.6931471805599453094
 
template<std::floating_point T>
constexpr T LOG2E = (T)1.44269504088896340735992
 log(2, e)
 
static constexpr const char * MATRIX_COLUMN_SEPARATOR = ", "
 
static constexpr const char * MATRIX_ROW_SEPARATOR = "\n"
 
static constexpr const char * MATRIX_L_BRACE = "["
 
static constexpr const char * MATRIX_R_BRACE = "]"
 
static constexpr const char * QUAT_SEPARATOR = " + "
 
static constexpr const char * QUAT_L_BRACE = "("
 
static constexpr const char * QUAT_R_BRACE = ")"
 
static constexpr int DEFAULT_TRIG_PRECISION = 1
 
static constexpr float DEFAULT_TRIG_EPSILON = 0.01f
 
static constexpr const char * VECTOR_SEPARATOR = ", "
 
static constexpr const char * VECTOR_L_BRACE = "("
 
static constexpr const char * VECTOR_R_BRACE = ")"
 

Typedef Documentation

◆ double2

using nem::double2 = nem::vec<double, 2>

Definition at line 261 of file vec.hpp.

◆ double3

using nem::double3 = nem::vec<double, 3>

Definition at line 262 of file vec.hpp.

◆ double4

using nem::double4 = nem::vec<double, 4>

Definition at line 263 of file vec.hpp.

◆ float2

using nem::float2 = nem::vec<float , 2>

Definition at line 258 of file vec.hpp.

◆ float3

using nem::float3 = nem::vec<float , 3>

Definition at line 259 of file vec.hpp.

◆ float4

using nem::float4 = nem::vec<float , 4>

Definition at line 260 of file vec.hpp.

◆ int2

using nem::int2 = nem::vec<int , 2>

Definition at line 255 of file vec.hpp.

◆ int3

using nem::int3 = nem::vec<int , 3>

Definition at line 256 of file vec.hpp.

◆ int4

using nem::int4 = nem::vec<int , 4>

Definition at line 257 of file vec.hpp.

◆ mat2

using nem::mat2 = mat<real, 2, 2>

Definition at line 149 of file mat.hpp.

◆ mat3

using nem::mat3 = mat<real, 3, 3>

Definition at line 150 of file mat.hpp.

◆ mat4

using nem::mat4 = mat<real, 4, 4>

Definition at line 151 of file mat.hpp.

◆ nem_string

using nem::nem_string = const char*

Definition at line 47 of file config.hpp.

◆ quat

Definition at line 112 of file quat.hpp.

◆ real

using nem::real = float

Definition at line 55 of file config.hpp.

Enumeration Type Documentation

◆ Precision

enum class nem::Precision : unsigned char
strong
Enumerator
Fast 
Accurate 

Definition at line 66 of file config.hpp.

Function Documentation

◆ abs() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::abs ( const nem::vec< T, N > & v)
constexpr

Definition at line 90 of file vec_utils.hpp.

◆ abs() [2/2]

template<typename T >
T nem::abs ( T value)
constexprnoexcept

Definition at line 38 of file utils.hpp.

◆ abs_error()

template<nem::scalar_type T, nem::Precision Prec = nem::default_precision>
T nem::abs_error ( )
constexpr

Definition at line 144 of file config.hpp.

◆ abs_to_rel_error()

template<nem::scalar_type T>
T nem::abs_to_rel_error ( T x,
T abs_error )
constexpr

Definition at line 75 of file config.hpp.

◆ acos()

template<std::floating_point T>
T nem::acos ( T x)
constexpr

Minimax polynomial approximation of acos, valid on [-1, 1], with a max error of roughly 6.7e-5. A widely used public-domain approximation (see e.g. "Efficient approximations for the arc cosine function", Lee, 2008, and countless graphics-programming write-ups building on it).

Definition at line 273 of file trig.hpp.

◆ actg()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::actg ( T x)
constexpr

Definition at line 294 of file trig.hpp.

◆ actg2()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::actg2 ( T x,
T y )
constexpr

Two-argument arc-cotangent: the angle whose cotangent is x / y, equivalent to nem::atan2 with the arguments given in x/y order instead of y/x.

Definition at line 302 of file trig.hpp.

◆ asin()

template<std::floating_point T>
T nem::asin ( T x)
constexpr

Definition at line 288 of file trig.hpp.

◆ atan()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::atan ( T x)
constexpr

Definition at line 240 of file trig.hpp.

◆ atan2()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::atan2 ( T y,
T x )
constexpr

Two-argument arctangent: the angle of the point (x, y), in (-PI, PI], resolved using the sign of both arguments instead of just their ratio.

Definition at line 254 of file trig.hpp.

◆ average() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::average ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b )
constexpr

Definition at line 153 of file vec_utils.hpp.

◆ average() [2/2]

template<nem::scalar_type T>
T nem::average ( T a,
T b )
constexprnoexcept

Definition at line 62 of file utils.hpp.

◆ ceil() [1/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::ceil ( const nem::vec< T, N > & v)
constexpr

Definition at line 249 of file vec_utils.hpp.

◆ ceil() [2/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::ceil ( const nem::vec< T, N > & v,
const nem::vec< T, N > & step )
constexpr

Definition at line 308 of file vec_utils.hpp.

◆ ceil() [3/4]

template<nem::scalar_type T>
T nem::ceil ( T value)
constexprnoexcept

Ceils always towards +infinity.

Definition at line 101 of file utils.hpp.

◆ ceil() [4/4]

template<std::floating_point T>
T nem::ceil ( T value,
T step )
constexpr

Ceils the value to a uniform linear grid with step {step}. Same as normal ceil, when step = 1. Step has to always be positive. (v = 0.9, s = 1.0) -> 1.0 (v = 0.2, s = 1.0) -> 1.0 (v = 0.4, s = 0.25) -> 0.5 (v = 0.1, s = 0.25) -> 0.5 (v = -0.1, s = 0.25) -> 0.0 (v = 423.163123, s = 0.1) -> 423.2

Ceils the value to a uniform linear grid with step {step}. Same as normal ceil, when step = 1. Step has to always be positive. (v = 5, s = 3) -> 3 (v = -4, s = 3) -> -6

Definition at line 189 of file utils.hpp.

◆ clamp() [1/2]

template<std::totally_ordered T, size_t N>
nem::vec< T, N > nem::clamp ( const nem::vec< T, N > & value,
const nem::vec< T, N > & minIncl,
const nem::vec< T, N > & maxIncl )
constexpr

Definition at line 378 of file vec_utils.hpp.

◆ clamp() [2/2]

template<std::totally_ordered T>
T nem::clamp ( T value,
T minIncl,
T maxIncl )
constexprnoexcept

Definition at line 261 of file utils.hpp.

◆ clamp01() [1/2]

template<std::totally_ordered T, size_t N>
nem::vec< T, N > nem::clamp01 ( const nem::vec< T, N > & value)
constexpr

Definition at line 389 of file vec_utils.hpp.

◆ clamp01() [2/2]

template<std::totally_ordered T>
T nem::clamp01 ( T value)
constexprnoexcept

Definition at line 267 of file utils.hpp.

◆ conjugate()

template<typename T = nem::real>
nem::quat_t< T > nem::conjugate ( const nem::quat_t< T > & q)
constexpr

Conjugates the quaternion, yielding a quaternion with the same angle (scalar) but inverse axis (vector)

Definition at line 48 of file quat_utils.hpp.

◆ copysign() [1/2]

template<std::floating_point T, size_t N>
nem::vec< T, N > nem::copysign ( const nem::vec< T, N > & to,
const nem::vec< T, N > & from )
constexpr

Sign operations

Definition at line 68 of file vec_utils.hpp.

◆ copysign() [2/2]

template<std::floating_point T>
T nem::copysign ( T to,
T from )
constexprnoexcept

Copies the sign of {from} over to {to}. If the signs were the same, it doesn't change.


Sign operations

Definition at line 31 of file utils.hpp.

◆ cos()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::cos ( T x)
constexpr

Definition at line 100 of file trig.hpp.

◆ cross()

template<typename T >
nem::vec< T, 3 > nem::cross ( const nem::vec< T, 3 > & a,
const nem::vec< T, 3 > & b )
inline

Definition at line 457 of file vec_utils.hpp.

◆ csc()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::csc ( T x)
constexpr

Definition at line 201 of file trig.hpp.

◆ csqrt()

template<std::floating_point T, int Precision = 20>
T nem::csqrt ( T value)
constexpr

Definition at line 197 of file power.hpp.

◆ ctg()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::ctg ( T x)
constexpr

Definition at line 179 of file trig.hpp.

◆ cube() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::cube ( const nem::vec< T, N > & v)
constexpr

Definition at line 212 of file vec_utils.hpp.

◆ cube() [2/2]

template<typename T >
T nem::cube ( T value)
constexprnoexcept

Definition at line 73 of file utils.hpp.

◆ degrees()

template<nem::scalar_type T>
T nem::degrees ( T degrees)
constexprnoexcept

Converts degrees to radians. Used to make units explicit.

Definition at line 28 of file trig.hpp.

◆ determinant()

template<typename T >
T nem::determinant ( const nem::mat< T, 2, 2 > & m)
constexpr

Definition at line 88 of file mat_utils.hpp.

◆ dot()

template<typename T , size_t N>
T nem::dot ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b )
inline

Definition at line 446 of file vec_utils.hpp.

◆ eps()

template<nem::scalar_type T>
T nem::eps ( )
constexpr

Definition at line 90 of file config.hpp.

◆ equal() [1/2]

template<nem::scalar_type T, size_t N>
bool nem::equal ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b )
constexpr

Definition at line 118 of file vec_utils.hpp.

◆ equal() [2/2]

template<nem::scalar_type T>
bool nem::equal ( T a,
T b )
constexprnoexcept

Are a and b nearly equal? Given an Epsilon > 0, within each all numbers are considered indistinguisable from 0, |a - b| < eps.

Definition at line 56 of file utils.hpp.

◆ exp2()

template<std::floating_point T, nem::Precision Prec = nem::default_precision>
T nem::exp2 ( T x)
constexpr

Exponentiation

Definition at line 106 of file power.hpp.

◆ extract_vector()

template<typename T >
nem::vec< T, 3 > nem::extract_vector ( const nem::quat_t< T > & q)
constexpr

Definition at line 99 of file quat_utils.hpp.

◆ floor() [1/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::floor ( const nem::vec< T, N > & v)
constexpr

Definition at line 238 of file vec_utils.hpp.

◆ floor() [2/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::floor ( const nem::vec< T, N > & v,
const nem::vec< T, N > & step )
constexpr

Rounding, flooring and ceiling with step

Definition at line 297 of file vec_utils.hpp.

◆ floor() [3/4]

template<nem::scalar_type T>
T nem::floor ( T value)
constexprnoexcept

Floors always towards -infinity.

Definition at line 87 of file utils.hpp.

◆ floor() [4/4]

template<std::floating_point T>
T nem::floor ( T value,
T step )
constexprnoexcept

Rounding, flooring and ceiling with step

Floors the value to a uniform linear grid with step {step}. Same as normal floor, when step = 1. Step has to always be positive. (v = 0.9, s = 1.0) -> 0.0 (v = 0.2, s = 1.0) -> 0.0 (v = 0.4, s = 0.25) -> 0.25 (v = 0.1, s = 0.25) -> 0.0 (v = -0.1, s = 0.25) -> -0.25 (v = 423.163123, s = 0.1) -> 423.1

Floors the value to a uniform linear grid with step {step}. Same as normal floor, when step = 1. Step has to always be positive. (v = 5, s = 3) -> 3 (v = -4, s = 3) -> -6

Definition at line 165 of file utils.hpp.

◆ frac() [1/2]

template<std::floating_point T, size_t N>
nem::vec< T, N > nem::frac ( const nem::vec< T, N > & v)
constexpr

Definition at line 271 of file vec_utils.hpp.

◆ frac() [2/2]

template<std::floating_point T>
T nem::frac ( T value)
constexprnoexcept

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.

Definition at line 133 of file utils.hpp.

◆ from_axis_angle()

template<typename T = nem::real>
nem::quat_t< T > nem::from_axis_angle ( const nem::vec< T, 3 > & axis,
T radians )

Definition at line 60 of file quat_utils.hpp.

◆ from_euler()

template<typename T = nem::real>
nem::quat_t< T > nem::from_euler ( T pitch,
T yaw,
T roll )

Definition at line 72 of file quat_utils.hpp.

◆ ft_atan_q1()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::ft_atan_q1 ( T x)
constexpr

Inverse trigonometric functions

Core polynomial approximation of atan(x), valid on [-1, 1]. nem::atan reduces any other argument into this range first via atan(x) = sign(x) * HALF_PI - atan(1 / x). Minimax coefficients fitted for P = 1, 2, 3 (max error roughly 5e-3, 6e-4, 8e-5).

Definition at line 219 of file trig.hpp.

◆ ft_cos_q1()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::ft_cos_q1 ( T x)
constexpr

Definition at line 63 of file trig.hpp.

◆ ft_sin_q1()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::ft_sin_q1 ( T x)
constexpr

Definition at line 43 of file trig.hpp.

◆ GET_C_STRING()

const char * nem::GET_C_STRING ( nem_string str)
inline

Definition at line 49 of file config.hpp.

◆ get_max() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::get_max ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b )
constexpr

Definition at line 131 of file vec_utils.hpp.

◆ get_max() [2/2]

template<nem::scalar_type T>
T nem::get_max ( T a,
T b )
constexprnoexcept

Definition at line 58 of file utils.hpp.

◆ get_min() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::get_min ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b )
constexpr

Definition at line 142 of file vec_utils.hpp.

◆ get_min() [2/2]

template<nem::scalar_type T>
T nem::get_min ( T a,
T b )
constexprnoexcept

Definition at line 60 of file utils.hpp.

◆ get_sincos()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
nem::sincos< T > nem::get_sincos ( T radians)
constexpr

Computes sin and cos together in a single range reduction pass, instead of paying for it twice (once per nem::sin/nemcos call). Both quadrant-1 polynomials still have to be evaluated once each (they're different polynomials), but the division + rounding + multiply-subtract range reduction and the sign/abs extraction only happen once.

Definition at line 120 of file trig.hpp.

◆ homogenous()

template<typename T , size_t N>
nem::mat< T, N+1, N+1 > nem::homogenous ( const nem::mat< T, N, N > & m)
constexpr

Definition at line 74 of file mat_utils.hpp.

◆ horizontal_mul()

template<typename T , size_t N>
T nem::horizontal_mul ( const nem::vec< T, N > & v)
inline

Definition at line 478 of file vec_utils.hpp.

◆ horizontal_sum()

template<typename T , size_t N>
T nem::horizontal_sum ( const nem::vec< T, N > & v)
inline

Definition at line 467 of file vec_utils.hpp.

◆ icbrt()

int nem::icbrt ( unsigned x)
inline

binary search for the approximation of integer cubic root. original implementation from "Hacker's Delight, Ch. 11: Integer Cube Root"

Definition at line 247 of file power.hpp.

◆ identity() [1/2]

template<typename T , size_t N>
nem::mat< T, N, N > nem::identity ( )
constexpr

Definition at line 39 of file mat_utils.hpp.

◆ identity() [2/2]

template<typename M >
nem::mat< typename M::ITEM_TYPE, M::COLUMNS, M::ROWS > nem::identity ( )
constexpr

Definition at line 50 of file mat_utils.hpp.

◆ inverse()

template<typename T = nem::real>
nem::quat_t< T > nem::inverse ( const nem::quat_t< T > & q)
constexpr

Definition at line 54 of file quat_utils.hpp.

◆ is_infinite() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::is_infinite ( const nem::vec< T, N > & v)
constexpr

Metadata

Definition at line 42 of file vec_utils.hpp.

◆ is_infinite() [2/2]

template<std::floating_point T>
T nem::is_infinite ( T value)
constexprnoexcept

Metadata

Definition at line 19 of file utils.hpp.

◆ is_nan() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::is_nan ( const nem::vec< T, N > & v)
constexpr

Definition at line 53 of file vec_utils.hpp.

◆ is_nan() [2/2]

template<std::floating_point T>
T nem::is_nan ( T value)
constexprnoexcept

Definition at line 20 of file utils.hpp.

◆ is_whole() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::is_whole ( const nem::vec< T, N > & v)
constexpr

Properties

Definition at line 435 of file vec_utils.hpp.

◆ is_whole() [2/2]

template<std::floating_point T>
T nem::is_whole ( T value)
constexpr

Is a floating point number whole (same as integer)

Is an integer number whole. Always true, here for compatibility.


Properties

Definition at line 307 of file utils.hpp.

◆ is_zero() [1/3]

template<typename T , size_t N>
bool nem::is_zero ( const nem::vec< T, N > && v)
inline

Definition at line 25 of file vec_utils.hpp.

◆ is_zero() [2/3]

template<typename T , size_t N>
bool nem::is_zero ( const nem::vec< T, N > & v)
inline

Definition at line 12 of file vec_utils.hpp.

◆ is_zero() [3/3]

template<nem::scalar_type T>
bool nem::is_zero ( T a)
constexprnoexcept

Is a nearly 0? Given an Epsilon > 0, within each all numbers are considered indistinguisable from 0, |a| < eps.


Comparisons

Definition at line 48 of file utils.hpp.

◆ is_zero_or_neg() [1/2]

template<nem::scalar_type T, size_t N>
bool nem::is_zero_or_neg ( const nem::vec< T, N > & v)
constexpr

Comparisons

Definition at line 105 of file vec_utils.hpp.

◆ is_zero_or_neg() [2/2]

template<nem::scalar_type T>
bool nem::is_zero_or_neg ( T a)
constexprnoexcept

Definition at line 51 of file utils.hpp.

◆ isqrt()

int nem::isqrt ( unsigned x)
inline

binary search for the approximation of integer square root. original implementation from "Hacker's Delight, Ch. 11: Integer square root, simple binary search."

Definition at line 230 of file power.hpp.

◆ length() [1/2]

template<typename T = nem::real>
T nem::length ( const nem::quat_t< T > & q)
inline

Definition at line 19 of file quat_utils.hpp.

◆ length() [2/2]

template<typename T , size_t N>
T nem::length ( const nem::vec< T, N > & vec)

Definition at line 517 of file vec_utils.hpp.

◆ lerp() [1/2]

template<typename T , size_t N>
static constexpr nem::vec< T, N > nem::lerp ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b,
float t )
staticconstexpr

Definition at line 495 of file vec_utils.hpp.

◆ lerp() [2/2]

template<typename T >
T nem::lerp ( T a,
T b,
T t )
constexpr

Definition at line 286 of file utils.hpp.

◆ ln()

template<std::floating_point T, nem::Precision Prec = nem::default_precision>
T nem::ln ( T value)
constexpr

Definition at line 86 of file power.hpp.

◆ log()

template<std::floating_point T, nem::Precision Prec = nem::default_precision>
T nem::log ( T base,
T value )
constexpr

Definition at line 72 of file power.hpp.

◆ log2()

template<std::floating_point T = float, nem::Precision Prec = nem::default_precision>
T nem::log2 ( T x)
constexpr

Logs

Definition at line 50 of file power.hpp.

◆ make_quat() [1/2]

template<typename T = nem::real>
nem::quat_t< T > nem::make_quat ( const nem::vec< T, 4 > & vec4)
constexpr

Definition at line 33 of file quat_utils.hpp.

◆ make_quat() [2/2]

template<typename T = nem::real>
nem::quat_t< T > nem::make_quat ( T scalar,
T x,
T y,
T z )
constexpr

Definition at line 39 of file quat_utils.hpp.

◆ mod() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::mod ( const nem::vec< T, N > & a,
const nem::vec< T, N > & b )
constexpr

Definition at line 260 of file vec_utils.hpp.

◆ mod() [2/2]

template<nem::scalar_type T>
T nem::mod ( T a,
T b )
constexpr

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.

Definition at line 115 of file utils.hpp.

◆ norm_quaterion_to_rotation_matrix()

template<typename T = nem::real>
nem::mat< T, 3, 3 > nem::norm_quaterion_to_rotation_matrix ( const nem::quat_t< T > & q)
constexpr

Definition at line 81 of file quat_utils.hpp.

◆ normalize() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::normalize ( const nem::vec< T, N > & vec)

Definition at line 523 of file vec_utils.hpp.

◆ normalize() [2/2]

template<typename T = nem::real>
nem::quat_t< T > nem::normalize ( nem::quat_t< T > q)
inline

Definition at line 25 of file quat_utils.hpp.

◆ operator<<() [1/3]

template<typename T , size_t C, size_t R>
std::ostream & nem::operator<< ( std::ostream & os,
const mat< T, C, R > & matrix )

Definition at line 32 of file mat_io.hpp.

◆ operator<<() [2/3]

template<typename T >
std::ostream & nem::operator<< ( std::ostream & os,
const nem::quat_t< T > & q )

Definition at line 16 of file quat_io.hpp.

◆ operator<<() [3/3]

template<typename T , size_t N>
std::ostream & nem::operator<< ( std::ostream & os,
const nem::vec< T, N > & vec )

Definition at line 16 of file vec_io.hpp.

◆ operator>>() [1/3]

template<typename T , size_t C, size_t R>
std::istream & nem::operator>> ( std::istream & is,
mat< T, C, R > & matrix )

Definition at line 48 of file mat_io.hpp.

◆ operator>>() [2/3]

template<typename T >
std::istream & nem::operator>> ( std::istream & is,
nem::quat_t< T > & q )

Definition at line 28 of file quat_io.hpp.

◆ operator>>() [3/3]

template<typename T , size_t N>
std::istream & nem::operator>> ( std::istream & is,
nem::vec< T, N > & vec )

Definition at line 28 of file vec_io.hpp.

◆ orthogonal_3d_basis()

template<typename T >
bool nem::orthogonal_3d_basis ( const nem::vec< T, 3 > & vector,
nem::vec< T, 3 > & b1,
nem::vec< T, 3 > & b2 )

Definition at line 553 of file vec_utils.hpp.

◆ pingpong() [1/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::pingpong ( const nem::vec< T, N > & value,
const nem::vec< T, N > & length )
constexpr

Definition at line 356 of file vec_utils.hpp.

◆ pingpong() [2/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::pingpong ( const nem::vec< T, N > & value,
const nem::vec< T, N > & minIncl,
const nem::vec< T, N > & maxExcl )
constexpr

Definition at line 367 of file vec_utils.hpp.

◆ pingpong() [3/4]

template<nem::scalar_type T>
T nem::pingpong ( T value,
T length )
constexpr

Definition at line 250 of file utils.hpp.

◆ pingpong() [4/4]

template<nem::scalar_type T>
T nem::pingpong ( T value,
T minIncl,
T maxExcl )
constexpr

Definition at line 256 of file utils.hpp.

◆ pow() [1/3]

template<nem::scalar_type T, std::integral E>
T nem::pow ( T base,
E exp )
constexpr

Definition at line 131 of file power.hpp.

◆ pow() [2/3]

template<std::floating_point T, nem::Precision Prec = nem::default_precision>
T nem::pow ( T base,
T exp,
nem::safe_t = nem::safe )
constexpr

Definition at line 144 of file power.hpp.

◆ pow() [3/3]

template<std::floating_point T, nem::Precision Prec = nem::default_precision>
T nem::pow ( T base,
T exp,
nem::unsafe_t  )
constexpr

Definition at line 138 of file power.hpp.

◆ pow2() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::pow2 ( const nem::vec< T, N > & v)
constexpr

Powers

Definition at line 168 of file vec_utils.hpp.

◆ pow2() [2/2]

template<typename T >
T nem::pow2 ( T value)
constexprnoexcept

Powers

Definition at line 69 of file utils.hpp.

◆ pow3() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::pow3 ( const nem::vec< T, N > & v)
constexpr

Definition at line 179 of file vec_utils.hpp.

◆ pow3() [2/2]

template<typename T >
T nem::pow3 ( T value)
constexprnoexcept

Definition at line 70 of file utils.hpp.

◆ pow4() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::pow4 ( const nem::vec< T, N > & v)
constexpr

Definition at line 190 of file vec_utils.hpp.

◆ pow4() [2/2]

template<typename T >
T nem::pow4 ( T value)
constexprnoexcept

Definition at line 71 of file utils.hpp.

◆ radians()

template<nem::scalar_type T>
T nem::radians ( T radians)
constexprnoexcept

Converts radians to radians (passes the argument unchanged). Used to make units explicit.

Definition at line 35 of file trig.hpp.

◆ reflect()

template<typename T , size_t N>
nem::vec< T, N > nem::reflect ( const nem::vec< T, N > & vector,
const nem::vec< T, N > & normal )
inline

Definition at line 489 of file vec_utils.hpp.

◆ rel_error()

template<nem::scalar_type T, nem::Precision Prec = nem::default_precision>
T nem::rel_error ( T x)
constexpr

Definition at line 158 of file config.hpp.

◆ remap() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::remap ( const nem::vec< T, N > & value,
const nem::vec< T, N > & fromMin,
const nem::vec< T, N > & fromMax,
const nem::vec< T, N > & toMin,
const nem::vec< T, N > & toMax )
constexpr

Linear mapping

Definition at line 419 of file vec_utils.hpp.

◆ remap() [2/2]

template<nem::scalar_type T>
T nem::remap ( T value,
T fromMin,
T fromMax,
T toMin,
T toMax )
constexpr

Linear mapping

Definition at line 292 of file utils.hpp.

◆ repeat() [1/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::repeat ( const nem::vec< T, N > & value,
const nem::vec< T, N > & lengthExcl )
constexpr

Repeat, pingpong, clamp

Definition at line 334 of file vec_utils.hpp.

◆ repeat() [2/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::repeat ( const nem::vec< T, N > & value,
const nem::vec< T, N > & minIncl,
const nem::vec< T, N > & maxExcl )
constexpr

Definition at line 345 of file vec_utils.hpp.

◆ repeat() [3/4]

template<nem::scalar_type T>
T nem::repeat ( T value,
T lengthExcl )
constexpr

Unwinds number to 0 when goes past length. Lengh is excluded: when value == lengthExcl, value becomes 0.


Repeat, pingpong, clamp

Definition at line 237 of file utils.hpp.

◆ repeat() [4/4]

template<nem::scalar_type T>
T nem::repeat ( T value,
T minIncl,
T maxExcl )
constexpr

Unwinds number to minimum when goes past maximum. Max value is excluded: when value == maxExcl, value becomes minIncl.

Definition at line 245 of file utils.hpp.

◆ rotate() [1/2]

template<std::floating_point T>
nem::mat< T, 2, 2 > nem::rotate ( T radians)
constexpr

Definition at line 94 of file mat_utils.hpp.

◆ rotate() [2/2]

template<std::floating_point T>
nem::mat< T, 3, 3 > nem::rotate ( T yaw_z,
T pitch_y,
T roll_x )
constexpr

Definition at line 119 of file mat_utils.hpp.

◆ rotate_x()

template<std::floating_point T>
nem::mat< T, 3, 3 > nem::rotate_x ( nem::sincos< T > a)
constexpr

Definition at line 101 of file mat_utils.hpp.

◆ rotate_y()

template<std::floating_point T>
nem::mat< T, 3, 3 > nem::rotate_y ( nem::sincos< T > a)
constexpr

Definition at line 107 of file mat_utils.hpp.

◆ rotate_z()

template<std::floating_point T>
nem::mat< T, 3, 3 > nem::rotate_z ( nem::sincos< T > a)
constexpr

Definition at line 113 of file mat_utils.hpp.

◆ round() [1/4]

template<std::floating_point T, size_t N>
nem::vec< T, N > nem::round ( const nem::vec< T, N > & v)
constexpr

Definition at line 282 of file vec_utils.hpp.

◆ round() [2/4]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::round ( const nem::vec< T, N > & v,
const nem::vec< T, N > & step )
constexpr

Definition at line 319 of file vec_utils.hpp.

◆ round() [3/4]

template<std::floating_point T>
T nem::round ( T value)
constexprnoexcept

Rounds the floating-point number to the closest integer. |0.5| will round up, meaning: 0.3 -> 0.0 0.5 -> 1.0 -0.1 -> 0 -0.6 -> -1.0 -0.5 -> 0

Definition at line 144 of file utils.hpp.

◆ round() [4/4]

template<std::floating_point T>
T nem::round ( T value,
T step )
constexpr

Rounds the value to a uniform linear grid with step {step}. Same as normal round, when step = 1. Step has to always be positive. (v = 0.9, s = 1.0) -> 1.0 (v = 0.2, s = 1.0) -> 0.0 (v = 0.2, s = 0.25) -> 0.25 (v = 0.1, s = 0.25) -> 0.0 (v = -0.1, s = 0.25) -> 0.0 (v = 423.163123, s = 0.1) -> 423.2

Rounds the value to a uniform linear grid with step {step}. Same as normal round, when step = 1. Step has to always be positive. (v = 5, s = 3) -> 6 (v = -4, s = 3) -> -3

Definition at line 213 of file utils.hpp.

◆ scale()

template<std::floating_point T, size_t N>
nem::mat< T, N, N > nem::scale ( const nem::vec< T, N > & value)
constexpr

Definition at line 139 of file mat_utils.hpp.

◆ sec()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::sec ( T x)
constexpr

Definition at line 190 of file trig.hpp.

◆ sign() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::sign ( const nem::vec< T, N > & v)
constexpr

Definition at line 79 of file vec_utils.hpp.

◆ sign() [2/2]

template<nem::scalar_type T>
T nem::sign ( T value)
constexprnoexcept

Definition at line 36 of file utils.hpp.

◆ sin()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::sin ( T x)
constexpr

Definition at line 83 of file trig.hpp.

◆ smoothstep() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::smoothstep ( const nem::vec< T, N > & edge0,
const nem::vec< T, N > & edge1,
const nem::vec< T, N > & x )
constexpr

Interpolation

Definition at line 404 of file vec_utils.hpp.

◆ smoothstep() [2/2]

template<typename T >
T nem::smoothstep ( T edge0,
T edge1,
T x )
constexpr

Interpolation

Definition at line 276 of file utils.hpp.

◆ sqr() [1/2]

template<typename T , size_t N>
nem::vec< T, N > nem::sqr ( const nem::vec< T, N > & v)
constexpr

Definition at line 201 of file vec_utils.hpp.

◆ sqr() [2/2]

template<typename T >
T nem::sqr ( T value)
constexprnoexcept

Definition at line 72 of file utils.hpp.

◆ sqr_length() [1/2]

template<typename T = nem::real>
T nem::sqr_length ( const nem::quat_t< T > & q)
constexpr

Definition at line 13 of file quat_utils.hpp.

◆ sqr_length() [2/2]

template<typename T , size_t N>
T nem::sqr_length ( const nem::vec< T, N > & vec)
constexpr

Definition at line 506 of file vec_utils.hpp.

◆ sqrt()

template<typename T >
T nem::sqrt ( T value)
inline

Roots

Definition at line 180 of file power.hpp.

◆ tan()

template<std::floating_point T, int P = DEFAULT_TRIG_PRECISION>
T nem::tan ( T x)
constexpr

Tangent, cotangent, secant, cosecant

Definition at line 168 of file trig.hpp.

◆ to_str()

template<typename T >
std::string nem::to_str ( const nem::quat_t< T > & q)

Definition at line 38 of file quat_io.hpp.

◆ tostr() [1/2]

template<typename T , size_t C, size_t R>
std::string nem::tostr ( const mat< T, C, R > & matrix)

Definition at line 15 of file mat_io.hpp.

◆ tostr() [2/2]

template<typename T , size_t N>
std::string nem::tostr ( const nem::vec< T, N > & vec)

Definition at line 38 of file vec_io.hpp.

◆ transform()

template<std::floating_point T>
nem::mat< T, 4, 4 > nem::transform ( const nem::vec< T, 3 > & translation,
const nem::quat_t< T > & rotation,
const nem::vec< T, 3 > scaler )
constexpr

Definition at line 150 of file mat_utils.hpp.

◆ transform_items()

template<typename T , size_t C, size_t R, typename F >
nem::mat< T, C, R > nem::transform_items ( nem::mat< T, C, R > m,
F && func )
constexpr

Definition at line 12 of file mat_utils.hpp.

◆ translate_2D()

template<std::floating_point T>
nem::mat< T, 3, 3 > nem::translate_2D ( const nem::vec< T, 2 > & value)
constexpr

Definition at line 127 of file mat_utils.hpp.

◆ translate_3D()

template<std::floating_point T>
nem::mat< T, 4, 4 > nem::translate_3D ( const nem::vec< T, 3 > & value)
constexpr

Definition at line 133 of file mat_utils.hpp.

◆ transpose()

template<typename T , size_t C, size_t R>
nem::mat< T, R, C > nem::transpose ( const nem::mat< T, C, R > & m)
constexpr

Definition at line 25 of file mat_utils.hpp.

◆ truncate() [1/2]

template<nem::scalar_type T, size_t N>
nem::vec< T, N > nem::truncate ( const nem::vec< T, N > & v)
constexpr

Float truncation, fractional part, modulo (remainder), rounding, flooring, ceiling

Definition at line 227 of file vec_utils.hpp.

◆ truncate() [2/2]

template<nem::scalar_type T>
T nem::truncate ( T value)
constexprnoexcept

Float truncation, fractional part, modulo (remainder), rounding, flooring, ceiling

Definition at line 79 of file utils.hpp.

◆ upscale()

template<typename T , size_t C1, size_t R1, size_t C2, size_t R2>
nem::mat< T, C2, R2 > nem::upscale ( const nem::mat< T, C1, R1 > & m)
constexpr

Definition at line 57 of file mat_utils.hpp.

Variable Documentation

◆ default_precision

nem::Precision nem::default_precision = nem::Precision::Fast
inlineconstexpr

Definition at line 72 of file config.hpp.

◆ DEFAULT_TRIG_EPSILON

float nem::DEFAULT_TRIG_EPSILON = 0.01f
staticconstexpr

Definition at line 24 of file trig.hpp.

◆ DEFAULT_TRIG_PRECISION

int nem::DEFAULT_TRIG_PRECISION = 1
staticconstexpr

Definition at line 23 of file trig.hpp.

◆ DEG_TO_RAD

template<std::floating_point T>
T nem::DEG_TO_RAD = nem::TWO_PI<T> / (T)360.0
constexpr

Definition at line 17 of file consts.hpp.

◆ E

template<std::floating_point T>
T nem::E = (T)2.718281828459045
constexpr

Definition at line 14 of file consts.hpp.

◆ ERR_LOG

bool nem::ERR_LOG = true
constexpr

Definition at line 24 of file config.hpp.

◆ ERR_SAFE_FALLBACK

bool nem::ERR_SAFE_FALLBACK = false
constexpr

Definition at line 38 of file config.hpp.

◆ ERR_THROW

bool nem::ERR_THROW = true
constexpr

Definition at line 18 of file config.hpp.

◆ ERR_USE_NAN

bool nem::ERR_USE_NAN = true
constexpr

Definition at line 30 of file config.hpp.

◆ ESQR

template<std::floating_point T>
T nem::ESQR = nem::E<T> * nem::E<T>
constexpr

Definition at line 15 of file consts.hpp.

◆ HALF_PI

template<std::floating_point T>
T nem::HALF_PI = (T)nem::PI<T> * (T)0.5
constexpr

Definition at line 11 of file consts.hpp.

◆ is_subset_of_v

template<class From , class To >
bool nem::is_subset_of_v = is_subset_of<From, To>::value
constexpr

Definition at line 180 of file config.hpp.

◆ LN2

template<std::floating_point T>
T nem::LN2 = (T)0.6931471805599453094
constexpr

Definition at line 19 of file consts.hpp.

◆ LOG2E

template<std::floating_point T>
T nem::LOG2E = (T)1.44269504088896340735992
constexpr

log(2, e)

Definition at line 22 of file consts.hpp.

◆ MATRIX_COLUMN_SEPARATOR

const char* nem::MATRIX_COLUMN_SEPARATOR = ", "
staticconstexpr

Definition at line 9 of file mat_io.hpp.

◆ MATRIX_L_BRACE

const char* nem::MATRIX_L_BRACE = "["
staticconstexpr

Definition at line 11 of file mat_io.hpp.

◆ MATRIX_R_BRACE

const char* nem::MATRIX_R_BRACE = "]"
staticconstexpr

Definition at line 12 of file mat_io.hpp.

◆ MATRIX_ROW_SEPARATOR

const char* nem::MATRIX_ROW_SEPARATOR = "\n"
staticconstexpr

Definition at line 10 of file mat_io.hpp.

◆ PHI

template<std::floating_point T>
T nem::PHI = (T)1.618033988749894
constexpr

Definition at line 16 of file consts.hpp.

◆ PI

template<std::floating_point T>
T nem::PI = (T)3.141592653589793
constexpr

Definition at line 10 of file consts.hpp.

◆ QUARTER_PI

template<std::floating_point T>
T nem::QUARTER_PI = (T)nem::PI<T> * (T)0.25
constexpr

Definition at line 12 of file consts.hpp.

◆ QUAT_L_BRACE

const char* nem::QUAT_L_BRACE = "("
staticconstexpr

Definition at line 12 of file quat_io.hpp.

◆ QUAT_R_BRACE

const char* nem::QUAT_R_BRACE = ")"
staticconstexpr

Definition at line 13 of file quat_io.hpp.

◆ QUAT_SEPARATOR

const char* nem::QUAT_SEPARATOR = " + "
staticconstexpr

Definition at line 11 of file quat_io.hpp.

◆ RAD_TO_DEG

template<std::floating_point T>
T nem::RAD_TO_DEG = (T)1.0 / nem::DEG_TO_RAD<T>
constexpr

Definition at line 18 of file consts.hpp.

◆ safe

safe_t nem::safe {}
inlineconstexpr

Definition at line 63 of file config.hpp.

◆ SQRT2

template<std::floating_point T>
T nem::SQRT2 = (T)1.414213562373095
constexpr

Definition at line 7 of file consts.hpp.

◆ SQRT3

template<std::floating_point T>
T nem::SQRT3 = (T)1.73205080756887
constexpr

Definition at line 8 of file consts.hpp.

◆ SQRT5

template<std::floating_point T>
T nem::SQRT5 = (T)2.236067977499789
constexpr

Definition at line 9 of file consts.hpp.

◆ TWO_PI

template<std::floating_point T>
T nem::TWO_PI = (T)nem::PI<T> * (T)2.0
constexpr

Definition at line 13 of file consts.hpp.

◆ unsafe

unsafe_t nem::unsafe {}
inlineconstexpr

Definition at line 64 of file config.hpp.

◆ USE_C_STRING

bool nem::USE_C_STRING = true
constexpr

Definition at line 48 of file config.hpp.

◆ VECTOR_L_BRACE

const char* nem::VECTOR_L_BRACE = "("
staticconstexpr

Definition at line 12 of file vec_io.hpp.

◆ VECTOR_R_BRACE

const char* nem::VECTOR_R_BRACE = ")"
staticconstexpr

Definition at line 13 of file vec_io.hpp.

◆ VECTOR_SEPARATOR

const char* nem::VECTOR_SEPARATOR = ", "
staticconstexpr

Definition at line 11 of file vec_io.hpp.