Antkeeper  0.0.1
Namespaces | Classes | Enumerations | Functions
math Namespace Reference

Mathematical functions and data types. More...

Namespaces

 compile
 Compile-time mathematical functions.
 
 hash
 Hash functions.
 
 literals
 User-defined math literals.
 
 matrix_types
 Matrix types.
 
 noise
 Noise functions.
 
 numbers
 Mathematical constants.
 
 operators
 Mathematical operators.
 
 polynomial
 Polynomial functions.
 
 quadrature
 Numerical integration functions.
 
 quaternion_types
 Quaternion types.
 
 types
 Linear algebra data types.
 
 vector_types
 Vector types.
 

Classes

struct  matrix
 n by m column-major matrix. More...
 
class  moving_average
 Calculates a moving average. More...
 
struct  quaternion
 Quaternion composed of a real scalar part and imaginary vector part. More...
 
struct  se3
 SE(3) proper rigid transformation (rototranslation). More...
 
struct  transform
 SRT transformation. More...
 
struct  vector
 n-dimensional vector. More...
 

Enumerations

enum class  rotation_sequence : std::uint8_t {
  zxz = 0b100010 , xyx = 0b000100 , yzy = 0b011001 , zyz = 0b100110 ,
  xzx = 0b001000 , yxy = 0b010001 , xyz = 0b100100 , yzx = 0b001001 ,
  zxy = 0b010010 , xzy = 0b011000 , zyx = 0b000110 , yxz = 0b100001
}
 Rotation sequences of proper Euler and Tait-Bryan angles. More...
 

Functions

template<class T >
constexpr T degrees (T radians) noexcept
 Converts an angle from radians to degrees. More...
 
template<class T >
constexpr T radians (T degrees) noexcept
 Converts an angle given in degrees to radians. More...
 
template<class T >
constexpr T wrap_degrees (T degrees)
 Wraps an angle to [-180, 180]. More...
 
template<class T >
constexpr T wrap_radians (T radians)
 Wraps an angle to [-pi, pi]. More...
 
template<std::integral T>
constexpr vec3< T > rotation_axes (rotation_sequence sequence) noexcept
 Returns the indices of the axes of a rotation sequence. More...
 
template<std::floating_point T>
fract (T x)
 Returns the fractional part of a floating-point number. More...
 
template<typename T , typename S = float>
constexpr T lerp (const T &x, const T &y, S a) noexcept
 Linearly interpolates between x and y. More...
 
template<typename T >
constexpr T lerp_angle (T x, T y, T a)
 Linearly interpolates between two angles, x and y. More...
 
template<typename T , typename S = float>
log_lerp (const T &x, const T &y, S a)
 Logarithmically interpolates between x and y. More...
 
template<class T >
constexpr T map (T x, T from_min, T from_max, T to_min, T to_max) noexcept
 Remaps a number from one range to another. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > add (const matrix< T, N, M > &a, const matrix< T, N, M > &b) noexcept
 Adds two matrices. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > add (const matrix< T, N, M > &a, T b) noexcept
 Adds a matrix and a scalar. More...
 
template<class T , std::size_t N>
constexpr T determinant (const matrix< T, N, N > &m) noexcept
 Calculates the determinant of a square matrix. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > componentwise_mul (const matrix< T, N, M > &a, const matrix< T, N, M > &b) noexcept
 Performs a component-wise multiplication of two matrices. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > div (const matrix< T, N, M > &a, const matrix< T, N, M > &b) noexcept
 Divides a matrix by a matrix. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > div (const matrix< T, N, M > &a, T b) noexcept
 Divides a matrix by a scalar. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > div (T a, const matrix< T, N, M > &b) noexcept
 Divides a scalar by a matrix. More...
 
template<class T , std::size_t N>
constexpr matrix< T, N, N > inverse (const matrix< T, N, N > &m) noexcept
 Calculates the inverse of a square matrix. More...
 
template<class T >
constexpr mat4< T > look_at_rh (const vec3< T > &position, const vec3< T > &target, const vec3< T > &up)
 Constructs a right-handed viewing transformation matrix. More...
 
template<class T >
constexpr std::tuple< mat4< T >, mat4< T > > look_at_rh_inv (const vec3< T > &position, const vec3< T > &target, const vec3< T > &up)
 Constructs a right-handed viewing transformation matrix and its inverse. More...
 
template<class T , std::size_t N, std::size_t M, std::size_t P>
constexpr matrix< T, P, M > mul (const matrix< T, N, M > &a, const matrix< T, P, N > &b) noexcept
 Multiplies two matrices. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > mul (const matrix< T, N, M > &a, T b) noexcept
 Multiplies a matrix by a scalar. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::column_vector_type mul (const matrix< T, N, M > &a, const typename matrix< T, N, M >::row_vector_type &b) noexcept
 Calculates the product of a matrix and a row vector. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::row_vector_type mul (const typename matrix< T, N, M >::column_vector_type &a, const matrix< T, N, M > &b) noexcept
 Calculates the product of a column vector and a matrix. More...
 
template<class T >
mat3< T > rotate (T angle, const vector< T, 3 > &axis)
 Constructs a rotation matrix. More...
 
template<class T >
mat3< T > rotate_x (T angle)
 Produces a matrix which rotates Cartesian coordinates about the x-axis by a given angle. More...
 
template<class T >
mat3< T > rotate_y (T angle)
 Produces a matrix which rotates Cartesian coordinates about the y-axis by a given angle. More...
 
template<class T >
mat3< T > rotate_z (T angle)
 Produces a matrix which rotates Cartesian coordinates about the z-axis by a given angle. More...
 
template<class T >
constexpr mat4< T > scale (const vec3< T > &v)
 Constructs a scale matrix. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > sub (const matrix< T, N, M > &a, const matrix< T, N, M > &b) noexcept
 Subtracts a matrix from another matrix. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > sub (const matrix< T, N, M > &a, T b) noexcept
 Subtracts a scalar from matrix. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > sub (T a, const matrix< T, N, M > &b) noexcept
 Subtracts a matrix from a scalar. More...
 
template<class T , std::size_t N>
constexpr T trace (const matrix< T, N, N > &m) noexcept
 Calculates the trace of a square matrix. More...
 
template<class T >
constexpr mat4< T > translate (const vec3< T > &v)
 Constructs a translation matrix. More...
 
template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, M, N > transpose (const matrix< T, N, M > &m) noexcept
 Calculates the transpose of a matrix. More...
 
template<class T >
horizontal_fov (T v, T r)
 Calculates a horizontal FoV given a vertical FoV and aspect ratio. More...
 
template<class T >
vertical_fov (T h, T r)
 Calculates a vertical FoV given a horizontal FoV and aspect ratio. More...
 
template<class T >
constexpr mat4< T > ortho (T left, T right, T bottom, T top, T near, T far) noexcept
 Constructs an orthographic projection matrix which will transform the near and far clipping planes to [-1, 1], respectively. More...
 
template<class T >
constexpr std::tuple< mat4< T >, mat4< T > > ortho_inv (T left, T right, T bottom, T top, T near, T far) noexcept
 Constructs an orthographic projection matrix which will transform the near and far clipping planes to [-1, 1], respectively, along with its inverse. More...
 
template<class T >
constexpr mat4< T > ortho_half_z (T left, T right, T bottom, T top, T near, T far) noexcept
 Constructs an orthographic projection matrix which will transform the near and far clipping planes to [0, 1], respectively. More...
 
template<class T >
constexpr std::tuple< mat4< T >, mat4< T > > ortho_half_z_inv (T left, T right, T bottom, T top, T near, T far) noexcept
 Constructs an orthographic projection matrix which will transform the near and far clipping planes to [0, 1], respectively, along with its inverse. More...
 
template<class T >
mat4< T > perspective (T vertical_fov, T aspect_ratio, T near, T far)
 Constructs a perspective projection matrix which will transform the near and far clipping planes to [-1, 1], respectively. More...
 
template<class T >
std::tuple< mat4< T >, mat4< T > > perspective_inv (T vertical_fov, T aspect_ratio, T near, T far)
 Constructs a perspective projection matrix which will transform the near and far clipping planes to [-1, 1], respectively, along with its inverse. More...
 
template<class T >
mat4< T > perspective_half_z (T vertical_fov, T aspect_ratio, T near, T far)
 Constructs a perspective projection matrix which will transform the near and far clipping planes to [0, 1], respectively. More...
 
template<class T >
std::tuple< mat4< T >, mat4< T > > perspective_half_z_inv (T vertical_fov, T aspect_ratio, T near, T far)
 Constructs a perspective projection matrix which will transform the near and far clipping planes to [0, 1], respectively, along with its inverse. More...
 
template<class T >
mat4< T > inf_perspective_half_z_reverse (T vertical_fov, T aspect_ratio, T near)
 Constructs a perspective projection matrix, with an infinite far plane, which will transform the near and far clipping planes to [1, 0], respectively. More...
 
template<class T >
std::tuple< mat4< T >, mat4< T > > inf_perspective_half_z_reverse_inv (T vertical_fov, T aspect_ratio, T near)
 Constructs a perspective projection matrix, with an infinite far plane, which will transform the near and far clipping planes to [1, 0], respectively, along with its inverse. More...
 
template<class T >
constexpr quaternion< T > add (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Adds two quaternions. More...
 
template<class T >
constexpr quaternion< T > add (const quaternion< T > &a, T b) noexcept
 Adds a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > conjugate (const quaternion< T > &q) noexcept
 Calculates the conjugate of a quaternion. More...
 
template<class T >
constexpr T dot (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Calculates the dot product of two quaternions. More...
 
template<class T >
constexpr quaternion< T > div (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Divides a quaternion by another quaternion. More...
 
template<class T >
constexpr quaternion< T > div (const quaternion< T > &a, T b) noexcept
 Divides a quaternion by a scalar. More...
 
template<class T >
constexpr quaternion< T > div (T a, const quaternion< T > &b) noexcept
 Divides a scalar by a quaternion. More...
 
template<class T >
inv_length (const quaternion< T > &q)
 Calculates the inverse length of a quaternion. More...
 
template<class T >
length (const quaternion< T > &q)
 Calculates the length of a quaternion. More...
 
template<class T >
constexpr quaternion< T > lerp (const quaternion< T > &a, const quaternion< T > &b, T t) noexcept
 Performs linear interpolation between two quaternions. More...
 
template<class T >
quaternion< T > look_rotation (const vec3< T > &forward, vec3< T > up)
 Creates a unit quaternion rotation using forward and up vectors. More...
 
template<class T >
constexpr quaternion< T > mul (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Multiplies two quaternions. More...
 
template<class T >
constexpr quaternion< T > mul (const quaternion< T > &a, T b) noexcept
 Multiplies a quaternion by a scalar. More...
 
template<class T >
constexpr vec3< T > mul (const quaternion< T > &q, const vec3< T > &v) noexcept
 Rotates a vector by a unit quaternion. More...
 
template<class T >
constexpr vec3< T > mul (const vec3< T > &v, const quaternion< T > &q) noexcept
 Rotates a vector by the inverse of a unit quaternion. More...
 
template<class T >
constexpr quaternion< T > negate (const quaternion< T > &q) noexcept
 Negates a quaternion. More...
 
template<class T >
quaternion< T > nlerp (const quaternion< T > &a, const quaternion< T > &b, T t)
 Performs normalized linear interpolation between two quaternions. More...
 
template<class T >
quaternion< T > normalize (const quaternion< T > &q)
 Normalizes a quaternion. More...
 
template<class T >
quaternion< T > angle_axis (T angle, const vec3< T > &axis)
 Creates a rotation from an angle and axis. More...
 
template<class T >
quaternion< T > rotation (const vec3< T > &from, const vec3< T > &to, T tolerance=T{1e-6})
 Constructs a quaternion representing the minimum rotation from one direction to another direction. More...
 
template<class T >
quaternion< T > rotate_towards (const vec3< T > &from, const vec3< T > &to, T max_angle)
 Constructs a quaternion representing an angle-limited rotation from one direction towards another direction. More...
 
template<class T >
quaternion< T > slerp (const quaternion< T > &a, const quaternion< T > &b, T t, T tolerance=T{1e-6})
 Performs spherical linear interpolation between two quaternions. More...
 
template<class T >
constexpr T sqr_length (const quaternion< T > &q) noexcept
 Calculates the square length of a quaternion. More...
 
template<class T >
constexpr quaternion< T > sub (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Subtracts a quaternion from another quaternion. More...
 
template<class T >
std::array< quaternion< T >, 2 > swing_twist (const quaternion< T > &q, const vec3< T > &twist_axis, T tolerance=T{1e-6})
 Decomposes a quaternion into swing and twist rotation components. More...
 
template<class T >
quaternion< T > quaternion_cast (const mat3< T > &m)
 Converts a 3x3 rotation matrix to a quaternion. More...
 
template<typename T = float>
random (T start, T end)
 Generates a pseudo-random floating point number on [start, end) using std::rand(). More...
 
template<class T >
transform< T > inverse (const transform< T > &t) noexcept
 Calculates the inverse of a transform. More...
 
template<class T >
transform< T > mul (const transform< T > &x, const transform< T > &y)
 Combines two transforms. More...
 
template<class T >
constexpr vector< T, 3 > mul (const transform< T > &t, const vector< T, 3 > &v) noexcept
 Transforms a vector by a transform. More...
 
template<class T >
constexpr vector< T, 3 > mul (const vector< T, 3 > &v, const transform< T > &t) noexcept
 Transforms a vector by the inverse of a transform. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > abs (const vector< T, N > &x)
 Returns the absolute values of each element. More...
 
template<std::size_t N>
constexpr bool all (const vector< bool, N > &x) noexcept
 Checks if all elements of a boolean vector are true. More...
 
template<std::floating_point T, std::size_t N>
angle (const vector< T, N > &from, const vector< T, N > &to)
 Calculates the angle between two direction vectors. More...
 
template<std::size_t N>
constexpr bool any (const vector< bool, N > &x) noexcept
 Checks if any elements of a boolean vector are true. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > ceil (const vector< T, N > &x)
 Performs an element-wise ceil operation. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > clamp_length (const vector< T, N > &x, T max_length)
 Clamps the length of a vector. More...
 
template<class T >
constexpr vector< T, 3 > cross (const vector< T, 3 > &x, const vector< T, 3 > &y) noexcept
 Calculates the cross product of two vectors. More...
 
template<std::floating_point T, std::size_t N>
distance (const vector< T, N > &p0, const vector< T, N > &p1)
 Calculates the distance between two points. More...
 
template<class T , std::size_t N>
constexpr T dot (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Calculates the dot product of two vectors. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > equal (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Compares two vectors for equality. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > floor (const vector< T, N > &x)
 Performs a element-wise floor operation. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > fract (const vector< T, N > &x)
 Returns a vector containing the fractional part of each element. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > greater_than (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Performs a element-wise greater-than comparison of two vectors. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > greater_than_equal (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Performs a element-wise greater-than or equal-to comparison of two vectors. More...
 
template<std::floating_point T, std::size_t N>
inv_length (const vector< T, N > &x)
 Calculates the inverse length of a vector. More...
 
template<std::floating_point T, std::size_t N>
length (const vector< T, N > &x)
 Calculates the length of a vector. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > less_than (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Performs a element-wise less-than comparison of two vectors. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > less_than_equal (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Performs a element-wise less-than or equal-to comparison of two vectors. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > max (const vector< T, N > &x, const vector< T, N > &y)
 Returns a vector containing the maximum elements of two vectors. More...
 
template<class T , std::size_t N>
constexpr T max (const vector< T, N > &x)
 Returns the value of the greatest element in a vector. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > min (const vector< T, N > &x, const vector< T, N > &y)
 Returns a vector containing the minimum elements of two vectors. More...
 
template<class T , std::size_t N>
constexpr T min (const vector< T, N > &x)
 Returns the value of the smallest element in a vector. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > negate (const vector< T, N > &x) noexcept
 Negates a vector. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > normalize (const vector< T, N > &x)
 Calculates the unit vector in the same direction as the original vector. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > logical_not (const vector< T, N > &x) noexcept
 Logically inverts a boolean vector. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > not_equal (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Compares two vectors for inequality. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > round (const vector< T, N > &x)
 Performs a element-wise round operation. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > sign (const vector< T, N > &x)
 Returns a vector containing the signs of each element. More...
 
template<std::floating_point T>
signed_angle (const vector< T, 3 > &x, const vector< T, 3 > &y, const vector< T, 3 > &n)
 Calculates the signed angle between two direction vectors about axis. More...
 
template<class T , std::size_t N>
constexpr T sqr_distance (const vector< T, N > &p0, const vector< T, N > &p1) noexcept
 Calculates the square distance between two points. More...
 
template<class T , std::size_t N>
constexpr T sqr_length (const vector< T, N > &x) noexcept
 Calculates the square length of a vector. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > sqrt (const vector< T, N > &x)
 Takes the square root of each element. More...
 
template<class T , std::size_t N>
constexpr T sum (const vector< T, N > &x) noexcept
 Calculates the sum of all elements in a vector. More...
 
template<std::size_t... Indices, class T , std::size_t N>
constexpr vector< T, sizeof...(Indices)> swizzle (const vector< T, N > &x) noexcept
 Makes an m-dimensional vector by rearranging and/or duplicating elements of an n-dimensional vector. More...
 
template<class T >
constexpr T triple (const vector< T, 3 > &x, const vector< T, 3 > &y, const vector< T, 3 > &z) noexcept
 Calculates the triple product of three vectors. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > trunc (const vector< T, N > &x)
 Performs a element-wise trunc operation. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > sqrt (const vector< T, N > &x, const vector< T, N > &y)
 
template<rotation_sequence Sequence, class T >
vec3< T > euler_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_zxz_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_xyx_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_yzy_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_zyz_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_xzx_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_yxy_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_xyz_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_yzx_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_zxy_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_xzy_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_zyx_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_yxz_from_quat (const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<class T >
vec3< T > euler_from_quat (rotation_sequence sequence, const quat< T > &q, T tolerance=T{1e-6})
 Derives Euler angles from a unit quaternion. More...
 
template<rotation_sequence Sequence, class T >
quat< T > euler_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_zxz_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_xyx_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_yzy_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_zyz_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_xzx_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_yxy_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_xyz_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_yzx_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_zxy_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_xzy_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_zyx_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_yxz_to_quat (const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<class T >
quat< T > euler_to_quat (rotation_sequence sequence, const vec3< T > &angles)
 Constructs a quaternion from Euler angles. More...
 
template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::column_vector_type & get (matrix< T, N, M > &m) noexcept
 Extracts the Ith column from a matrix. More...
 
template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::column_vector_type && get (matrix< T, N, M > &&m) noexcept
 Extracts the Ith column from a matrix. More...
 
template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr const matrix< T, N, M >::column_vector_type & get (const matrix< T, N, M > &m) noexcept
 Extracts the Ith column from a matrix. More...
 
template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr const matrix< T, N, M >::column_vector_type && get (const matrix< T, N, M > &&m) noexcept
 Extracts the Ith column from a matrix. More...
 
template<class T >
constexpr quaternion< T > sub (const quaternion< T > &a, T b) noexcept
 Subtracts a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > sub (T a, const quaternion< T > &b) noexcept
 Subtracts a quaternion and a scalar. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > add (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Adds two values. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > add (const vector< T, N > &x, T y) noexcept
 Adds two values. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > clamp (const vector< T, N > &x, const vector< T, N > &min, const vector< T, N > &max)
 Clamps the values of a vector's elements. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > clamp (const vector< T, N > &x, T min, T max)
 Clamps the values of a vector's elements. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > div (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Divides a vector by a value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > div (const vector< T, N > &x, T y) noexcept
 Divides a vector by a value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > div (T x, const vector< T, N > &y) noexcept
 Divides a vector by a value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > fma (const vector< T, N > &x, const vector< T, N > &y, const vector< T, N > &z)
 Performs a multiply-add operation. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > fma (const vector< T, N > &x, T y, T z)
 Performs a multiply-add operation. More...
 
template<std::size_t I, class T , std::size_t N>
constexpr T & get (math::vector< T, N > &v) noexcept
 Extracts the Ith element from a vector. More...
 
template<std::size_t I, class T , std::size_t N>
constexpr T && get (math::vector< T, N > &&v) noexcept
 Extracts the Ith element from a vector. More...
 
template<std::size_t I, class T , std::size_t N>
constexpr const T & get (const math::vector< T, N > &v) noexcept
 Extracts the Ith element from a vector. More...
 
template<std::size_t I, class T , std::size_t N>
constexpr const T && get (const math::vector< T, N > &&v) noexcept
 Extracts the Ith element from a vector. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > mod (const vector< T, N > &x, const vector< T, N > &y)
 Calculates the element-wise remainder of the division operation x / y. More...
 
template<std::floating_point T, std::size_t N>
constexpr vector< T, N > mod (const vector< T, N > &x, T y)
 Calculates the element-wise remainder of the division operation x / y. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > mul (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Multiplies two values. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > mul (const vector< T, N > &x, T y) noexcept
 Multiplies two values. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > pow (const vector< T, N > &x, const vector< T, N > &y)
 Raises each element to a power. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > pow (const vector< T, N > &x, T y)
 Raises each element to a power. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > sub (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Subtracts a value by another value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > sub (const vector< T, N > &x, T y) noexcept
 Subtracts a value by another value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > sub (T x, const vector< T, N > &y) noexcept
 Subtracts a value by another value. More...
 

Detailed Description

Mathematical functions and data types.

Enumeration Type Documentation

◆ rotation_sequence

enum math::rotation_sequence : std::uint8_t
strong

Rotation sequences of proper Euler and Tait-Bryan angles.

Indices of the first, second, and third rotation axes are encoded in bits 0-1, 2-3, and 4-5, respectively.

Enumerator
zxz 

z-x-z rotation sequence (proper Euler angles).

xyx 

x-y-x rotation sequence (proper Euler angles).

yzy 

y-z-y rotation sequence (proper Euler angles).

zyz 

z-y-z rotation sequence (proper Euler angles).

xzx 

x-z-x rotation sequence (proper Euler angles).

yxy 

y-x-y rotation sequence (proper Euler angles).

xyz 

x-y-z rotation sequence (Tait-Bryan angles).

yzx 

y-z-x rotation sequence (Tait-Bryan angles).

zxy 

z-x-y rotation sequence (Tait-Bryan angles).

xzy 

x-z-y rotation sequence (Tait-Bryan angles).

zyx 

z-y-x rotation sequence (Tait-Bryan angles).

yxz 

y-x-z rotation sequence (Tait-Bryan angles).

Definition at line 38 of file euler-angles.hpp.

Function Documentation

◆ abs()

template<class T , std::size_t N>
constexpr vector< T, N > math::abs ( const vector< T, N > &  x)
inlineconstexpr

Returns the absolute values of each element.

Parameters
xInput vector.
Returns
Absolute values of input vector elements.

Definition at line 985 of file vector.hpp.

◆ add() [1/6]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::add ( const matrix< T, N, M > &  a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Adds two matrices.

Parameters
aFirst matrix.
bSecond matrix.
Returns
Sum of the two matrices.

Definition at line 776 of file math/matrix.hpp.

◆ add() [2/6]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::add ( const matrix< T, N, M > &  a,
b 
)
constexprnoexcept

Adds a matrix and a scalar.

Parameters
aMatrix.
bscalar.
Returns
Sum of the matrix and scalar.

Definition at line 789 of file math/matrix.hpp.

◆ add() [3/6]

template<class T >
constexpr quaternion< T > math::add ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inlineconstexprnoexcept

Adds two quaternions.

Parameters
aFirst quaternion.
bSecond quaternion.
Returns
Sum of the two quaternions.

Definition at line 554 of file quaternion.hpp.

◆ add() [4/6]

template<class T >
constexpr quaternion< T > math::add ( const quaternion< T > &  a,
b 
)
inlineconstexprnoexcept

Adds a quaternion and a scalar.

Parameters
aFirst value.
bSecond second value.
Returns
Sum of the quaternion and scalar.

Definition at line 560 of file quaternion.hpp.

◆ add() [5/6]

template<class T , std::size_t N>
constexpr vector< T, N > math::add ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Adds two values.

Parameters
xFirst value.
ySecond value.
Returns
Sum of the two values.

Definition at line 998 of file vector.hpp.

◆ add() [6/6]

template<class T , std::size_t N>
constexpr vector< T, N > math::add ( const vector< T, N > &  x,
y 
)
inlineconstexprnoexcept

Adds two values.

Parameters
xFirst value.
ySecond value.
Returns
Sum of the two values.

Definition at line 1011 of file vector.hpp.

◆ all()

template<std::size_t N>
constexpr bool math::all ( const vector< bool, N > &  x)
inlineconstexprnoexcept

Checks if all elements of a boolean vector are true.

Parameters
xVector to be tested for truth.
Returns
true if all elements are true, false otherwise.

Definition at line 1024 of file vector.hpp.

◆ angle()

template<std::floating_point T, std::size_t N>
T math::angle ( const vector< T, N > &  from,
const vector< T, N > &  to 
)

Calculates the angle between two direction vectors.

Parameters
fromFirst direction vector.
toSecond direction vector.
Returns
Angle between the two direction vectors, in radians.

Definition at line 1030 of file vector.hpp.

◆ angle_axis()

template<class T >
quaternion< T > math::angle_axis ( angle,
const vec3< T > &  axis 
)

Creates a rotation from an angle and axis.

Parameters
angleAngle of rotation (in radians).
axisAxis of rotation
Returns
Quaternion representing the rotation.

Definition at line 685 of file quaternion.hpp.

◆ any()

template<std::size_t N>
constexpr bool math::any ( const vector< bool, N > &  x)
inlineconstexprnoexcept

Checks if any elements of a boolean vector are true.

Parameters
xVector to be tested for truth.
Returns
true if any elements are true, false otherwise.

Definition at line 1043 of file vector.hpp.

◆ ceil()

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::ceil ( const vector< T, N > &  x)
inlineconstexpr

Performs an element-wise ceil operation.

Parameters
xInput vector.
Returns
Component-wise ceil of input vector.

Definition at line 1056 of file vector.hpp.

◆ clamp() [1/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::clamp ( const vector< T, N > &  x,
const vector< T, N > &  min,
const vector< T, N > &  max 
)
inlineconstexpr

Clamps the values of a vector's elements.

Parameters
xVector to clamp.
minMinimum value.
maxMaximum value.
Returns
Clamped vector.

Definition at line 1069 of file vector.hpp.

◆ clamp() [2/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::clamp ( const vector< T, N > &  x,
min,
max 
)
inlineconstexpr

Clamps the values of a vector's elements.

Parameters
xVector to clamp.
minMinimum value.
maxMaximum value.
Returns
Clamped vector.

Definition at line 1082 of file vector.hpp.

◆ clamp_length()

template<std::floating_point T, std::size_t N>
vector< T, N > math::clamp_length ( const vector< T, N > &  x,
max_length 
)

Clamps the length of a vector.

Parameters
xVector to clamp.
max_lengthMaximum length.
Returns
Length-clamped vector.

Definition at line 1088 of file vector.hpp.

◆ componentwise_mul()

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::componentwise_mul ( const matrix< T, N, M > &  a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Performs a component-wise multiplication of two matrices.

Parameters
xFirst matrix multiplicand.
ySecond matrix multiplicand.
Returns
Product of the component-wise multiplcation.

Definition at line 843 of file math/matrix.hpp.

◆ conjugate()

template<class T >
constexpr quaternion< T > math::conjugate ( const quaternion< T > &  q)
inlineconstexprnoexcept

Calculates the conjugate of a quaternion.

Parameters
qQuaternion from which the conjugate will be calculated.
Returns
Conjugate of the quaternion.

Definition at line 566 of file quaternion.hpp.

◆ cross()

template<class T >
constexpr vector< T, 3 > math::cross ( const vector< T, 3 > &  x,
const vector< T, 3 > &  y 
)
inlineconstexprnoexcept

Calculates the cross product of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Cross product of the two vectors.

Definition at line 1095 of file vector.hpp.

◆ degrees()

template<class T >
constexpr T math::degrees ( radians)
inlineconstexprnoexcept

Converts an angle from radians to degrees.

Parameters
radiansAngle in radians.
Returns
Angle in degrees.

Definition at line 36 of file angles.hpp.

◆ determinant()

template<class T , std::size_t N>
constexpr T math::determinant ( const matrix< T, N, N > &  m)
constexprnoexcept

Calculates the determinant of a square matrix.

Parameters
mMatrix of which to take the determinant.
Returns
Determinant of m.
Warning
Currently only implemented for 2x2, 3x3, and 4x4 matrices.

◆ distance()

template<std::floating_point T, std::size_t N>
T math::distance ( const vector< T, N > &  p0,
const vector< T, N > &  p1 
)
inline

Calculates the distance between two points.

Parameters
p0First of two points.
p1Second of two points.
Returns
Distance between the two points.

Definition at line 1106 of file vector.hpp.

◆ div() [1/9]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::div ( const matrix< T, N, M > &  a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Divides a matrix by a matrix.

Parameters
aFirst matrix.
bSecond matrix.
Returns
Result of the division.

Definition at line 856 of file math/matrix.hpp.

◆ div() [2/9]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::div ( const matrix< T, N, M > &  a,
b 
)
constexprnoexcept

Divides a matrix by a scalar.

Parameters
aMatrix.
bScalar.
Returns
Result of the division.

Definition at line 869 of file math/matrix.hpp.

◆ div() [3/9]

template<class T >
constexpr quaternion< T > math::div ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inlineconstexprnoexcept

Divides a quaternion by another quaternion.

Parameters
aFirst value.
bSecond value.
Returns
Result of the division.

Definition at line 578 of file quaternion.hpp.

◆ div() [4/9]

template<class T >
constexpr quaternion< T > math::div ( const quaternion< T > &  a,
b 
)
inlineconstexprnoexcept

Divides a quaternion by a scalar.

Parameters
aQuaternion.
bScalar.
Returns
Result of the division.

Definition at line 584 of file quaternion.hpp.

◆ div() [5/9]

template<class T , std::size_t N>
constexpr vector< T, N > math::div ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Divides a vector by a value.

Parameters
xFirst value.
ySecond value.
Returns
Result of the division.

Definition at line 1119 of file vector.hpp.

◆ div() [6/9]

template<class T , std::size_t N>
constexpr vector< T, N > math::div ( const vector< T, N > &  x,
y 
)
inlineconstexprnoexcept

Divides a vector by a value.

Parameters
xFirst value.
ySecond value.
Returns
Result of the division.

Definition at line 1132 of file vector.hpp.

◆ div() [7/9]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::div ( a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Divides a scalar by a matrix.

Parameters
aScalar.
bMatrix.
Returns
Result of the division.

Definition at line 882 of file math/matrix.hpp.

◆ div() [8/9]

template<class T >
constexpr quaternion< T > math::div ( a,
const quaternion< T > &  b 
)
inlineconstexprnoexcept

Divides a scalar by a quaternion.

Parameters
aScalar.
bQuaternion.
Returns
Result of the division.

Definition at line 590 of file quaternion.hpp.

◆ div() [9/9]

template<class T , std::size_t N>
constexpr vector< T, N > math::div ( x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Divides a vector by a value.

Parameters
xFirst value.
ySecond value.
Returns
Result of the division.

Definition at line 1145 of file vector.hpp.

◆ dot() [1/2]

template<class T >
constexpr T math::dot ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inlineconstexprnoexcept

Calculates the dot product of two quaternions.

Parameters
aFirst quaternion.
bSecond quaternion.
Returns
Dot product of the two quaternions.

Definition at line 572 of file quaternion.hpp.

◆ dot() [2/2]

template<class T , std::size_t N>
constexpr T math::dot ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Calculates the dot product of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Dot product of the two vectors.

Definition at line 1158 of file vector.hpp.

◆ equal()

template<class T , std::size_t N>
constexpr vector< bool, N > math::equal ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Compares two vectors for equality.

Parameters
xFirst vector.
ySecond vector.
Returns
Boolean vector containing the result of the element comparisons.

Definition at line 1171 of file vector.hpp.

◆ euler_from_quat() [1/2]

template<rotation_sequence Sequence, class T >
vec3<T> math::euler_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 109 of file euler-angles.hpp.

◆ euler_from_quat() [2/2]

template<class T >
vec3<T> math::euler_from_quat ( rotation_sequence  sequence,
const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 235 of file euler-angles.hpp.

◆ euler_to_quat() [1/2]

template<rotation_sequence Sequence, class T >
quat<T> math::euler_to_quat ( const vec3< T > &  angles)

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 283 of file euler-angles.hpp.

◆ euler_to_quat() [2/2]

template<class T >
quat<T> math::euler_to_quat ( rotation_sequence  sequence,
const vec3< T > &  angles 
)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 488 of file euler-angles.hpp.

◆ euler_xyx_from_quat()

template<class T >
vec3<T> math::euler_xyx_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 169 of file euler-angles.hpp.

◆ euler_xyx_to_quat()

template<class T >
quat<T> math::euler_xyx_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 422 of file euler-angles.hpp.

◆ euler_xyz_from_quat()

template<class T >
vec3<T> math::euler_xyz_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 199 of file euler-angles.hpp.

◆ euler_xyz_to_quat()

template<class T >
quat<T> math::euler_xyz_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 452 of file euler-angles.hpp.

◆ euler_xzx_from_quat()

template<class T >
vec3<T> math::euler_xzx_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 187 of file euler-angles.hpp.

◆ euler_xzx_to_quat()

template<class T >
quat<T> math::euler_xzx_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 440 of file euler-angles.hpp.

◆ euler_xzy_from_quat()

template<class T >
vec3<T> math::euler_xzy_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 217 of file euler-angles.hpp.

◆ euler_xzy_to_quat()

template<class T >
quat<T> math::euler_xzy_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 470 of file euler-angles.hpp.

◆ euler_yxy_from_quat()

template<class T >
vec3<T> math::euler_yxy_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 193 of file euler-angles.hpp.

◆ euler_yxy_to_quat()

template<class T >
quat<T> math::euler_yxy_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 446 of file euler-angles.hpp.

◆ euler_yxz_from_quat()

template<class T >
vec3<T> math::euler_yxz_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 229 of file euler-angles.hpp.

◆ euler_yxz_to_quat()

template<class T >
quat<T> math::euler_yxz_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 482 of file euler-angles.hpp.

◆ euler_yzx_from_quat()

template<class T >
vec3<T> math::euler_yzx_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 205 of file euler-angles.hpp.

◆ euler_yzx_to_quat()

template<class T >
quat<T> math::euler_yzx_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 458 of file euler-angles.hpp.

◆ euler_yzy_from_quat()

template<class T >
vec3<T> math::euler_yzy_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 175 of file euler-angles.hpp.

◆ euler_yzy_to_quat()

template<class T >
quat<T> math::euler_yzy_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 428 of file euler-angles.hpp.

◆ euler_zxy_from_quat()

template<class T >
vec3<T> math::euler_zxy_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 211 of file euler-angles.hpp.

◆ euler_zxy_to_quat()

template<class T >
quat<T> math::euler_zxy_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 464 of file euler-angles.hpp.

◆ euler_zxz_from_quat()

template<class T >
vec3<T> math::euler_zxz_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 163 of file euler-angles.hpp.

◆ euler_zxz_to_quat()

template<class T >
quat<T> math::euler_zxz_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 416 of file euler-angles.hpp.

◆ euler_zyx_from_quat()

template<class T >
vec3<T> math::euler_zyx_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 223 of file euler-angles.hpp.

◆ euler_zyx_to_quat()

template<class T >
quat<T> math::euler_zyx_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 476 of file euler-angles.hpp.

◆ euler_zyz_from_quat()

template<class T >
vec3<T> math::euler_zyz_from_quat ( const quat< T > &  q,
tolerance = T{1e-6} 
)
inline

Derives Euler angles from a unit quaternion.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
sequenceRotation sequence of the Euler angles.
qQuaternion to convert.
toleranceFloating-point tolerance, in radians, for handling singularities.
Returns
Euler angles representing the rotation described by the quaternion, in radians.
See also
Bernardes, Evandro & Viollet, Stéphane. (2022). Quaternion to Euler angles conversion: A direct, general and computationally efficient method. PLoS ONE. 17. 10.1371/journal.pone.0276302.

Definition at line 181 of file euler-angles.hpp.

◆ euler_zyz_to_quat()

template<class T >
quat<T> math::euler_zyz_to_quat ( const vec3< T > &  angles)
inline

Constructs a quaternion from Euler angles.

Template Parameters
SequenceRotation sequence of the Euler angles.
TScalar type.
Parameters
anglesVector of Euler angles.
Returns
Quaternion.
See also
Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Matrix, 58(15-16), 1-35.

Definition at line 434 of file euler-angles.hpp.

◆ floor()

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::floor ( const vector< T, N > &  x)
inlineconstexpr

Performs a element-wise floor operation.

Parameters
xInput vector.
Returns
Component-wise floor of input vector.

Definition at line 1184 of file vector.hpp.

◆ fma() [1/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::fma ( const vector< T, N > &  x,
const vector< T, N > &  y,
const vector< T, N > &  z 
)
inlineconstexpr

Performs a multiply-add operation.

Parameters
xInput vector
yValue to multiply.
zValue to add.
Returns
Vector containing the multiply-add results.

Definition at line 1197 of file vector.hpp.

◆ fma() [2/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::fma ( const vector< T, N > &  x,
y,
z 
)
inlineconstexpr

Performs a multiply-add operation.

Parameters
xInput vector
yValue to multiply.
zValue to add.
Returns
Vector containing the multiply-add results.

Definition at line 1210 of file vector.hpp.

◆ fract() [1/2]

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::fract ( const vector< T, N > &  x)
inlineconstexpr

Returns a vector containing the fractional part of each element.

Parameters
xInput vector.
Returns
Fractional parts of input vector.

Definition at line 1223 of file vector.hpp.

◆ fract() [2/2]

template<std::floating_point T>
T math::fract ( x)
inline

Returns the fractional part of a floating-point number.

Template Parameters
TFloating-point type.
Parameters
xFloating-point number.
Returns
Fractional part of x.

Definition at line 38 of file fract.hpp.

◆ get() [1/8]

template<std::size_t I, class T , std::size_t N>
constexpr const T && math::get ( const math::vector< T, N > &&  v)
inlineconstexprnoexcept

Extracts the Ith element from a vector.

Template Parameters
IIndex of an element.
TElement type.
NNumber of elements.
Parameters
vVector from which to extract an element.
Returns
Reference to the Ith element of v.

Definition at line 1250 of file vector.hpp.

◆ get() [2/8]

template<std::size_t I, class T , std::size_t N>
constexpr const T & math::get ( const math::vector< T, N > &  v)
inlineconstexprnoexcept

Extracts the Ith element from a vector.

Template Parameters
IIndex of an element.
TElement type.
NNumber of elements.
Parameters
vVector from which to extract an element.
Returns
Reference to the Ith element of v.

Definition at line 1243 of file vector.hpp.

◆ get() [3/8]

template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr const matrix< T, N, M >::column_vector_type && math::get ( const matrix< T, N, M > &&  m)
inlineconstexprnoexcept

Extracts the Ith column from a matrix.

Template Parameters
IIndex of a column.
TElement type.
NNumber of columns.
MNumber of rows.
Parameters
mMatrix from which to extract a column.
Returns
Reference to the Ith column of m.

Definition at line 909 of file math/matrix.hpp.

◆ get() [4/8]

template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr const matrix< T, N, M >::column_vector_type & math::get ( const matrix< T, N, M > &  m)
inlineconstexprnoexcept

Extracts the Ith column from a matrix.

Template Parameters
IIndex of a column.
TElement type.
NNumber of columns.
MNumber of rows.
Parameters
mMatrix from which to extract a column.
Returns
Reference to the Ith column of m.

Definition at line 902 of file math/matrix.hpp.

◆ get() [5/8]

template<std::size_t I, class T , std::size_t N>
constexpr T && math::get ( math::vector< T, N > &&  v)
inlineconstexprnoexcept

Extracts the Ith element from a vector.

Template Parameters
IIndex of an element.
TElement type.
NNumber of elements.
Parameters
vVector from which to extract an element.
Returns
Reference to the Ith element of v.

Definition at line 1236 of file vector.hpp.

◆ get() [6/8]

template<std::size_t I, class T , std::size_t N>
constexpr T & math::get ( math::vector< T, N > &  v)
inlineconstexprnoexcept

Extracts the Ith element from a vector.

Template Parameters
IIndex of an element.
TElement type.
NNumber of elements.
Parameters
vVector from which to extract an element.
Returns
Reference to the Ith element of v.

Definition at line 1229 of file vector.hpp.

◆ get() [7/8]

template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::column_vector_type && math::get ( matrix< T, N, M > &&  m)
inlineconstexprnoexcept

Extracts the Ith column from a matrix.

Template Parameters
IIndex of a column.
TElement type.
NNumber of columns.
MNumber of rows.
Parameters
mMatrix from which to extract a column.
Returns
Reference to the Ith column of m.

Definition at line 895 of file math/matrix.hpp.

◆ get() [8/8]

template<std::size_t I, class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::column_vector_type & math::get ( matrix< T, N, M > &  m)
inlineconstexprnoexcept

Extracts the Ith column from a matrix.

Template Parameters
IIndex of a column.
TElement type.
NNumber of columns.
MNumber of rows.
Parameters
mMatrix from which to extract a column.
Returns
Reference to the Ith column of m.

Definition at line 888 of file math/matrix.hpp.

◆ greater_than()

template<class T , std::size_t N>
constexpr vector< bool, N > math::greater_than ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Performs a element-wise greater-than comparison of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Boolean vector containing the result of the element comparisons.

Definition at line 1264 of file vector.hpp.

◆ greater_than_equal()

template<class T , std::size_t N>
constexpr vector< bool, N > math::greater_than_equal ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Performs a element-wise greater-than or equal-to comparison of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Boolean vector containing the result of the element comparisons.

Definition at line 1277 of file vector.hpp.

◆ horizontal_fov()

template<class T >
T math::horizontal_fov ( v,
r 
)

Calculates a horizontal FoV given a vertical FoV and aspect ratio.

Parameters
vVertical FoV, in radians.
rRatio of width to height.
Returns
Horizontal FoV, in radians.
See also
https://en.wikipedia.org/wiki/Field_of_view_in_video_games

Definition at line 40 of file math/projection.hpp.

◆ inf_perspective_half_z_reverse()

template<class T >
mat4<T> math::inf_perspective_half_z_reverse ( vertical_fov,
aspect_ratio,
near 
)

Constructs a perspective projection matrix, with an infinite far plane, which will transform the near and far clipping planes to [1, 0], respectively.

Parameters
vertical_fovVertical field of view angle, in radians.
aspect_ratioAspect ratio which determines the horizontal field of view.
nearDistance to the near clipping plane.
Returns
Perspective projection matrix.

Definition at line 319 of file math/projection.hpp.

◆ inf_perspective_half_z_reverse_inv()

template<class T >
std::tuple<mat4<T>, mat4<T> > math::inf_perspective_half_z_reverse_inv ( vertical_fov,
aspect_ratio,
near 
)

Constructs a perspective projection matrix, with an infinite far plane, which will transform the near and far clipping planes to [1, 0], respectively, along with its inverse.

Parameters
vertical_fovVertical field of view angle, in radians.
aspect_ratioAspect ratio which determines the horizontal field of view.
nearDistance to the near clipping plane.
Returns
Tuple containing the perspective projection matrix, followed by its inverse.
Note
Constructing the inverse perspective projection matrix from projection parameters is faster and more precise than inverting matrix.

Definition at line 345 of file math/projection.hpp.

◆ inv_length() [1/2]

template<class T >
T math::inv_length ( const quaternion< T > &  q)
inline

Calculates the inverse length of a quaternion.

Parameters
qQuaternion to calculate the inverse length of.
Returns
Inverse length of the quaternion.

Definition at line 596 of file quaternion.hpp.

◆ inv_length() [2/2]

template<std::floating_point T, std::size_t N>
T math::inv_length ( const vector< T, N > &  x)
inline

Calculates the inverse length of a vector.

Parameters
xVector of which to calculate the inverse length.
Returns
Inverse length of the vector.

Definition at line 1283 of file vector.hpp.

◆ inverse() [1/2]

template<class T , std::size_t N>
constexpr matrix<T, N, N> math::inverse ( const matrix< T, N, N > &  m)
constexprnoexcept

Calculates the inverse of a square matrix.

Parameters
mSquare matrix.
Returns
Inverse of matrix m.
Warning
Currently only implemented for 2x2, 3x3, and 4x4 matrices.

◆ inverse() [2/2]

template<class T >
transform< T > math::inverse ( const transform< T > &  t)
noexcept

Calculates the inverse of a transform.

Parameters
tTransform of which to take the inverse.

Definition at line 155 of file transform.hpp.

◆ length() [1/2]

template<class T >
T math::length ( const quaternion< T > &  q)
inline

Calculates the length of a quaternion.

Parameters
qQuaternion to calculate the length of.
Returns
Length of the quaternion.

Definition at line 602 of file quaternion.hpp.

◆ length() [2/2]

template<std::floating_point T, std::size_t N>
T math::length ( const vector< T, N > &  x)
inline

Calculates the length of a vector.

Parameters
xVector of which to calculate the length.
Returns
Length of the vector.

Definition at line 1289 of file vector.hpp.

◆ lerp() [1/2]

template<class T >
constexpr quaternion< T > math::lerp ( const quaternion< T > &  a,
const quaternion< T > &  b,
t 
)
inlineconstexprnoexcept

Performs linear interpolation between two quaternions.

Parameters
aFirst quaternion.
bSecond quaternion.
tInterpolation factor.
Returns
Interpolated quaternion.

Definition at line 608 of file quaternion.hpp.

◆ lerp() [2/2]

template<typename T , typename S = float>
constexpr T math::lerp ( const T &  x,
const T &  y,
a 
)
constexprnoexcept

Linearly interpolates between x and y.

Requires the following operators to be defined:

T operator+(const T&, const T&);
T operator-(const T&, const T&);
T operator*(const T&, S);
Template Parameters
TValue type.
SScalar type.

Definition at line 41 of file interpolation.hpp.

◆ lerp_angle()

template<typename T >
constexpr T math::lerp_angle ( x,
y,
a 
)
constexpr

Linearly interpolates between two angles, x and y.

Template Parameters
TValue type.
Parameters
xStart angle, in radians.
yEnd angle, in radians.
aInterpolation ratio.
Returns
Interpolated angle, in radians.

Definition at line 56 of file interpolation.hpp.

◆ less_than()

template<class T , std::size_t N>
constexpr vector< bool, N > math::less_than ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Performs a element-wise less-than comparison of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Boolean vector containing the result of the element comparisons.

Definition at line 1302 of file vector.hpp.

◆ less_than_equal()

template<class T , std::size_t N>
constexpr vector< bool, N > math::less_than_equal ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Performs a element-wise less-than or equal-to comparison of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Boolean vector containing the result of the element comparisons.

Definition at line 1315 of file vector.hpp.

◆ log_lerp()

template<typename T , typename S = float>
T math::log_lerp ( const T &  x,
const T &  y,
a 
)

Logarithmically interpolates between x and y.

Warning
Undefined behavior when x is zero.
Template Parameters
TValue type.
SScalar type.

Definition at line 70 of file interpolation.hpp.

◆ logical_not()

template<class T , std::size_t N>
constexpr vector< bool, N > math::logical_not ( const vector< T, N > &  x)
inlineconstexprnoexcept

Logically inverts a boolean vector.

Parameters
xVector to be inverted.
Returns
Logically inverted vector.

Definition at line 1437 of file vector.hpp.

◆ look_at_rh()

template<class T >
constexpr mat4< T > math::look_at_rh ( const vec3< T > &  position,
const vec3< T > &  target,
const vec3< T > &  up 
)
constexpr

Constructs a right-handed viewing transformation matrix.

Parameters
positionPosition of the view point.
targetPosition of the target.
upUnit vector pointing in the up direction.
Returns
Viewing transformation matrix.

Definition at line 983 of file math/matrix.hpp.

◆ look_at_rh_inv()

template<class T >
constexpr std::tuple< mat4< T >, mat4< T > > math::look_at_rh_inv ( const vec3< T > &  position,
const vec3< T > &  target,
const vec3< T > &  up 
)
constexpr

Constructs a right-handed viewing transformation matrix and its inverse.

Parameters
positionPosition of the view point.
targetPosition of the target.
upUnit vector pointing in the up direction.
Returns
Tuple containing the viewing transformation matrix, followed by its inverse.
Note
Constructing the inverse viewing transformation matrix from viewing parameters is faster and more precise than inverting matrix.

Definition at line 1000 of file math/matrix.hpp.

◆ look_rotation()

template<class T >
quaternion< T > math::look_rotation ( const vec3< T > &  forward,
vec3< T >  up 
)

Creates a unit quaternion rotation using forward and up vectors.

Parameters
forwardUnit forward vector.
upUnit up vector.
Returns
Unit rotation quaternion.

Definition at line 618 of file quaternion.hpp.

◆ map()

template<class T >
constexpr T math::map ( x,
from_min,
from_max,
to_min,
to_max 
)
constexprnoexcept

Remaps a number from one range to another.

Parameters
xValue to remap.
from_minStart of the first range.
from_maxEnd of the first range.
to_minStart of the second range.
to_maxEnd of the second range.
Returns
Unclamped remapped value.

Definition at line 37 of file map.hpp.

◆ max() [1/2]

template<class T , std::size_t N>
constexpr T math::max ( const vector< T, N > &  x)
inlineconstexpr

Returns the value of the greatest element in a vector.

Parameters
xInput vector.
Returns
Value of the greatest element in the input vector.

Definition at line 1334 of file vector.hpp.

◆ max() [2/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::max ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
constexpr

Returns a vector containing the maximum elements of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Maximum elements of the two vectors.

Definition at line 1328 of file vector.hpp.

◆ min() [1/2]

template<class T , std::size_t N>
constexpr T math::min ( const vector< T, N > &  x)
inlineconstexpr

Returns the value of the smallest element in a vector.

Parameters
xInput vector.
Returns
Value of the smallest element in the input vector.

Definition at line 1353 of file vector.hpp.

◆ min() [2/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::min ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
constexpr

Returns a vector containing the minimum elements of two vectors.

Parameters
xFirst vector.
ySecond vector.
Returns
Minimum elements of the two vectors.

Definition at line 1347 of file vector.hpp.

◆ mod() [1/2]

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::mod ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexpr

Calculates the element-wise remainder of the division operation x / y.

Parameters
xFirst vector.
ySecond vector.
Returns
Remainders of x / y.

Definition at line 1366 of file vector.hpp.

◆ mod() [2/2]

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::mod ( const vector< T, N > &  x,
y 
)
inlineconstexpr

Calculates the element-wise remainder of the division operation x / y.

Parameters
xFirst vector.
ySecond vector.
Returns
Remainders of x / y.

Definition at line 1379 of file vector.hpp.

◆ mul() [1/13]

template<class T , std::size_t N, std::size_t M, std::size_t P>
constexpr matrix< T, P, M > math::mul ( const matrix< T, N, M > &  a,
const matrix< T, P, N > &  b 
)
constexprnoexcept

Multiplies two matrices.

Template Parameters
TMatrix element type.
NNumber of columns in matrix a, and rows in matrix b.
MNumber of rows in matrix a.
PNumber of columns in matrix b.
Parameters
aFirst matrix.
bSecond matrix.
Returns
Product of a * b.

Definition at line 1027 of file math/matrix.hpp.

◆ mul() [2/13]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::column_vector_type math::mul ( const matrix< T, N, M > &  a,
const typename matrix< T, N, M >::row_vector_type &  b 
)
constexprnoexcept

Calculates the product of a matrix and a row vector.

Parameters
aMatrix.
bRow vector
Returns
Product of the matrix and the row vector.

Definition at line 1066 of file math/matrix.hpp.

◆ mul() [3/13]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::mul ( const matrix< T, N, M > &  a,
b 
)
constexprnoexcept

Multiplies a matrix by a scalar.

Parameters
aMatrix.
bScalar.
Returns
Product of the matrix and the scalar.

Definition at line 1053 of file math/matrix.hpp.

◆ mul() [4/13]

template<class T >
constexpr quaternion< T > math::mul ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
constexprnoexcept

Multiplies two quaternions.

Parameters
aFirst quaternion.
bSecond quaternion.
Returns
Product of the two quaternions.

Definition at line 635 of file quaternion.hpp.

◆ mul() [5/13]

template<class T >
constexpr quaternion< T > math::mul ( const quaternion< T > &  a,
b 
)
inlineconstexprnoexcept

Multiplies a quaternion by a scalar.

Parameters
aFirst value.
bSecond value.
Returns
Product of the quaternion and scalar.

Definition at line 647 of file quaternion.hpp.

◆ mul() [6/13]

template<class T >
constexpr vec3< T > math::mul ( const quaternion< T > &  q,
const vec3< T > &  v 
)
constexprnoexcept

Rotates a vector by a unit quaternion.

Parameters
qUnit quaternion.
vVector to rotate.
Returns
Rotated vector.
Warning
q must be a unit quaternion.
See also
https://fgiesen.wordpress.com/2019/02/09/rotating-a-single-vector-using-a-quaternion/

Definition at line 653 of file quaternion.hpp.

◆ mul() [7/13]

template<class T >
constexpr vector< T, 3 > math::mul ( const transform< T > &  t,
const vector< T, 3 > &  v 
)
constexprnoexcept

Transforms a vector by a transform.

Parameters
tTransform.
vVector.
Returns
Transformed vector.

Definition at line 172 of file transform.hpp.

◆ mul() [8/13]

template<class T >
transform< T > math::mul ( const transform< T > &  x,
const transform< T > &  y 
)

Combines two transforms.

Parameters
xFirst transform.
ySecond transform.
Returns
Product of the two transforms.

Definition at line 161 of file transform.hpp.

◆ mul() [9/13]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M >::row_vector_type math::mul ( const typename matrix< T, N, M >::column_vector_type &  a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Calculates the product of a column vector and a matrix.

Parameters
aColumn vector.
bMatrix.
Returns
Product of the column vector and the matrix.

Definition at line 1079 of file math/matrix.hpp.

◆ mul() [10/13]

template<class T >
constexpr vec3< T > math::mul ( const vec3< T > &  v,
const quaternion< T > &  q 
)
inlineconstexprnoexcept

Rotates a vector by the inverse of a unit quaternion.

Parameters
vVector to rotate.
qUnit quaternion.
Returns
Rotated vector.
Warning
q must be a unit quaternion.

Definition at line 660 of file quaternion.hpp.

◆ mul() [11/13]

template<class T >
constexpr vector< T, 3 > math::mul ( const vector< T, 3 > &  v,
const transform< T > &  t 
)
inlineconstexprnoexcept

Transforms a vector by the inverse of a transform.

Parameters
vVector.
tTransform.
Returns
Transformed vector.

Definition at line 178 of file transform.hpp.

◆ mul() [12/13]

template<class T , std::size_t N>
constexpr vector< T, N > math::mul ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Multiplies two values.

Parameters
xFirst value.
ySecond value.
Returns
Product of the two values.

Definition at line 1392 of file vector.hpp.

◆ mul() [13/13]

template<class T , std::size_t N>
constexpr vector< T, N > math::mul ( const vector< T, N > &  x,
y 
)
inlineconstexprnoexcept

Multiplies two values.

Parameters
xFirst value.
ySecond value.
Returns
Product of the two values.

Definition at line 1405 of file vector.hpp.

◆ negate() [1/2]

template<class T >
constexpr quaternion< T > math::negate ( const quaternion< T > &  q)
inlineconstexprnoexcept

Negates a quaternion.

Parameters
qQuaternion to negate.
Returns
Negated quaternion.

Definition at line 667 of file quaternion.hpp.

◆ negate() [2/2]

template<class T , std::size_t N>
constexpr vector< T, N > math::negate ( const vector< T, N > &  x)
inlineconstexprnoexcept

Negates a vector.

Parameters
xVector to negate.
Returns
Negated vector.

Definition at line 1418 of file vector.hpp.

◆ nlerp()

template<class T >
quaternion< T > math::nlerp ( const quaternion< T > &  a,
const quaternion< T > &  b,
t 
)

Performs normalized linear interpolation between two quaternions.

Parameters
aFirst quaternion.
bSecond quaternion.
tInterpolation factor.
Returns
Interpolated quaternion.

Definition at line 673 of file quaternion.hpp.

◆ normalize() [1/2]

template<class T >
quaternion< T > math::normalize ( const quaternion< T > &  q)
inline

Normalizes a quaternion.

Parameters
qQuaternion to normalize.
Returns
Unit quaternion.

Definition at line 679 of file quaternion.hpp.

◆ normalize() [2/2]

template<std::floating_point T, std::size_t N>
vector< T, N > math::normalize ( const vector< T, N > &  x)
inline

Calculates the unit vector in the same direction as the original vector.

Parameters
xVector to normalize.
Returns
Unit vector.

Definition at line 1424 of file vector.hpp.

◆ not_equal()

template<class T , std::size_t N>
constexpr vector< bool, N > math::not_equal ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Compares two vectors for inequality.

Parameters
xFirst vector.
ySecond vector.
Returns
Boolean vector containing the result of the element comparisons.

Definition at line 1450 of file vector.hpp.

◆ ortho()

template<class T >
constexpr mat4<T> math::ortho ( left,
right,
bottom,
top,
near,
far 
)
constexprnoexcept

Constructs an orthographic projection matrix which will transform the near and far clipping planes to [-1, 1], respectively.

Parameters
leftSigned distance to the left clipping plane.
rightSigned distance to the right clipping plane.
bottomSigned distance to the bottom clipping plane.
topSigned distance to the top clipping plane.
nearSigned distance to the near clipping plane.
farSigned distance to the far clipping plane.
Returns
Orthographic projection matrix.

Definition at line 74 of file math/projection.hpp.

◆ ortho_half_z()

template<class T >
constexpr mat4<T> math::ortho_half_z ( left,
right,
bottom,
top,
near,
far 
)
constexprnoexcept

Constructs an orthographic projection matrix which will transform the near and far clipping planes to [0, 1], respectively.

Parameters
leftSigned distance to the left clipping plane.
rightSigned distance to the right clipping plane.
bottomSigned distance to the bottom clipping plane.
topSigned distance to the top clipping plane.
nearSigned distance to the near clipping plane.
farSigned distance to the far clipping plane.
Returns
Orthographic projection matrix.

Definition at line 135 of file math/projection.hpp.

◆ ortho_half_z_inv()

template<class T >
constexpr std::tuple<mat4<T>, mat4<T> > math::ortho_half_z_inv ( left,
right,
bottom,
top,
near,
far 
)
constexprnoexcept

Constructs an orthographic projection matrix which will transform the near and far clipping planes to [0, 1], respectively, along with its inverse.

Parameters
leftSigned distance to the left clipping plane.
rightSigned distance to the right clipping plane.
bottomSigned distance to the bottom clipping plane.
topSigned distance to the top clipping plane.
nearSigned distance to the near clipping plane.
farSigned distance to the far clipping plane.
Returns
Tuple containing the orthographic projection matrix, followed by its inverse.
Note
Constructing the inverse orthographic projection matrix from projection parameters is faster and more precise than inverting matrix.

Definition at line 161 of file math/projection.hpp.

◆ ortho_inv()

template<class T >
constexpr std::tuple<mat4<T>, mat4<T> > math::ortho_inv ( left,
right,
bottom,
top,
near,
far 
)
constexprnoexcept

Constructs an orthographic projection matrix which will transform the near and far clipping planes to [-1, 1], respectively, along with its inverse.

Parameters
leftSigned distance to the left clipping plane.
rightSigned distance to the right clipping plane.
bottomSigned distance to the bottom clipping plane.
topSigned distance to the top clipping plane.
nearSigned distance to the near clipping plane.
farSigned distance to the far clipping plane.
Returns
Tuple containing the orthographic projection matrix, followed by its inverse.
Note
Constructing the inverse orthographic projection matrix from projection parameters is faster and more precise than inverting matrix.

Definition at line 100 of file math/projection.hpp.

◆ perspective()

template<class T >
mat4<T> math::perspective ( vertical_fov,
aspect_ratio,
near,
far 
)

Constructs a perspective projection matrix which will transform the near and far clipping planes to [-1, 1], respectively.

Parameters
vertical_fovVertical field of view angle, in radians.
aspect_ratioAspect ratio which determines the horizontal field of view.
nearDistance to the near clipping plane.
farDistance to the far clipping plane.
Returns
Perspective projection matrix.

Definition at line 194 of file math/projection.hpp.

◆ perspective_half_z()

template<class T >
mat4<T> math::perspective_half_z ( vertical_fov,
aspect_ratio,
near,
far 
)

Constructs a perspective projection matrix which will transform the near and far clipping planes to [0, 1], respectively.

Parameters
vertical_fovVertical field of view angle, in radians.
aspect_ratioAspect ratio which determines the horizontal field of view.
nearDistance to the near clipping plane.
farDistance to the far clipping plane.
Returns
Perspective projection matrix.

Definition at line 257 of file math/projection.hpp.

◆ perspective_half_z_inv()

template<class T >
std::tuple<mat4<T>, mat4<T> > math::perspective_half_z_inv ( vertical_fov,
aspect_ratio,
near,
far 
)

Constructs a perspective projection matrix which will transform the near and far clipping planes to [0, 1], respectively, along with its inverse.

Parameters
vertical_fovVertical field of view angle, in radians.
aspect_ratioAspect ratio which determines the horizontal field of view.
nearDistance to the near clipping plane.
farDistance to the far clipping plane.
Returns
Tuple containing the perspective projection matrix, followed by its inverse.
Note
Constructing the inverse perspective projection matrix from projection parameters is faster and more precise than inverting matrix.

Definition at line 284 of file math/projection.hpp.

◆ perspective_inv()

template<class T >
std::tuple<mat4<T>, mat4<T> > math::perspective_inv ( vertical_fov,
aspect_ratio,
near,
far 
)

Constructs a perspective projection matrix which will transform the near and far clipping planes to [-1, 1], respectively, along with its inverse.

Parameters
vertical_fovVertical field of view angle, in radians.
aspect_ratioAspect ratio which determines the horizontal field of view.
nearDistance to the near clipping plane.
farDistance to the far clipping plane.
Returns
Arraay containing the perspective projection matrix, followed by its inverse.
Note
Constructing the inverse perspective projection matrix from projection parameters is faster and more precise than inverting matrix.

Definition at line 221 of file math/projection.hpp.

◆ pow() [1/2]

template<std::floating_point T, std::size_t N>
vector< T, N > math::pow ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inline

Raises each element to a power.

Parameters
xInput vector
yExponent.
Returns
Vector with its elements raised to the given power.

Definition at line 1463 of file vector.hpp.

◆ pow() [2/2]

template<std::floating_point T, std::size_t N>
vector< T, N > math::pow ( const vector< T, N > &  x,
y 
)
inline

Raises each element to a power.

Parameters
xInput vector
yExponent.
Returns
Vector with its elements raised to the given power.

Definition at line 1476 of file vector.hpp.

◆ quaternion_cast()

template<class T >
quaternion< T > math::quaternion_cast ( const mat3< T > &  m)

Converts a 3x3 rotation matrix to a quaternion.

Parameters
mRotation matrix.
Returns
Unit quaternion representing the rotation described by m.

Definition at line 803 of file quaternion.hpp.

◆ radians()

template<class T >
constexpr T math::radians ( degrees)
inlineconstexprnoexcept

Converts an angle given in degrees to radians.

Parameters
radiansAngle in radians.
Returns
Angle in degrees.

Definition at line 48 of file angles.hpp.

◆ random()

template<typename T = float>
T math::random ( start,
end 
)

Generates a pseudo-random floating point number on [start, end) using std::rand().

Warning
Don't forget to seed with std::srand() before using!
Parameters
startStart of the range (inclusive).
endEnd of the range (exclusive).
Returns
Pseudo-random floating point number.

Definition at line 38 of file random.hpp.

◆ rotate()

template<class T >
mat3< T > math::rotate ( angle,
const vector< T, 3 > &  axis 
)

Constructs a rotation matrix.

Parameters
angleAngle of rotation, in radians.
axisAxis of rotation.
Returns
Rotation matrix.

Definition at line 1085 of file math/matrix.hpp.

◆ rotate_towards()

template<class T >
quaternion< T > math::rotate_towards ( const vec3< T > &  from,
const vec3< T > &  to,
max_angle 
)

Constructs a quaternion representing an angle-limited rotation from one direction towards another direction.

Parameters
fromUnit vector pointing in the source direction.
toUnit vector pointing in the target direction.
max_angleMaximum angle of rotation, in radians.
Returns
Unit quaternion representing a rotation from direction from towards direction to.
Warning
from and to must be unit vectors.

Definition at line 716 of file quaternion.hpp.

◆ rotate_x()

template<class T >
mat3< T > math::rotate_x ( angle)

Produces a matrix which rotates Cartesian coordinates about the x-axis by a given angle.

Parameters
angleAngle of rotation, in radians.
Returns
Rotation matrix.

Definition at line 1106 of file math/matrix.hpp.

◆ rotate_y()

template<class T >
mat3< T > math::rotate_y ( angle)

Produces a matrix which rotates Cartesian coordinates about the y-axis by a given angle.

Parameters
angleAngle of rotation, in radians.
Returns
Rotation matrix.

Definition at line 1120 of file math/matrix.hpp.

◆ rotate_z()

template<class T >
mat3< T > math::rotate_z ( angle)

Produces a matrix which rotates Cartesian coordinates about the z-axis by a given angle.

Parameters
angleAngle of rotation, in radians.
Returns
Rotation matrix.

Definition at line 1134 of file math/matrix.hpp.

◆ rotation()

template<class T >
quaternion< T > math::rotation ( const vec3< T > &  from,
const vec3< T > &  to,
tolerance = T{1e-6} 
)

Constructs a quaternion representing the minimum rotation from one direction to another direction.

Parameters
fromUnit vector pointing in the source direction.
toUnit vector pointing in the target direction.
toleranceFloating-point tolerance.
Returns
Unit quaternion representing the minimum rotation from direction from to direction to.
Warning
from and to must be unit vectors.

Definition at line 691 of file quaternion.hpp.

◆ rotation_axes()

template<std::integral T>
constexpr vec3<T> math::rotation_axes ( rotation_sequence  sequence)
inlineconstexprnoexcept

Returns the indices of the axes of a rotation sequence.

Template Parameters
TIndex type.
Parameters
sequenceRotation sequence.
Returns
Vector containing the indices of the axes of sequence.

Definition at line 87 of file euler-angles.hpp.

◆ round()

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::round ( const vector< T, N > &  x)
inlineconstexpr

Performs a element-wise round operation.

Parameters
xInput vector
Returns
Component-wise round of input vector.

Definition at line 1489 of file vector.hpp.

◆ scale()

template<class T >
constexpr mat4< T > math::scale ( const vec3< T > &  v)
constexpr

Constructs a scale matrix.

Parameters
vScale vector.
Returns
Scale matrix.

Definition at line 1148 of file math/matrix.hpp.

◆ sign()

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::sign ( const vector< T, N > &  x)
inlineconstexpr

Returns a vector containing the signs of each element.

Parameters
xInput vector
Returns
Signs of input vector elements.

Definition at line 1502 of file vector.hpp.

◆ signed_angle()

template<std::floating_point T>
T math::signed_angle ( const vector< T, 3 > &  x,
const vector< T, 3 > &  y,
const vector< T, 3 > &  n 
)

Calculates the signed angle between two direction vectors about axis.

Parameters
fromFirst direction vector.
toSecond direction vector.
axisAxis direction vector.
Returns
Signed angle between from and to about axis, in radians.

Definition at line 1508 of file vector.hpp.

◆ slerp()

template<class T >
quaternion< T > math::slerp ( const quaternion< T > &  a,
const quaternion< T > &  b,
t,
tolerance = T{1e-6} 
)

Performs spherical linear interpolation between two quaternions.

Parameters
aFirst quaternion.
bSecond quaternion.
tInterpolation factor.
toleranceFloating-point tolerance.
Returns
Interpolated quaternion.

Definition at line 724 of file quaternion.hpp.

◆ sqr_distance()

template<class T , std::size_t N>
constexpr T math::sqr_distance ( const vector< T, N > &  p0,
const vector< T, N > &  p1 
)
inlineconstexprnoexcept

Calculates the square distance between two points.

The square distance can be calculated faster than the distance because a call to std::sqrt is saved.

Parameters
p0First of two points.
p1Second of two points.
Returns
Square distance between the two points.

Definition at line 1514 of file vector.hpp.

◆ sqr_length() [1/2]

template<class T >
constexpr T math::sqr_length ( const quaternion< T > &  q)
inlineconstexprnoexcept

Calculates the square length of a quaternion.

The square length can be calculated faster than the length because a call to std::sqrt is saved.

Parameters
qQuaternion to calculate the square length of.
Returns
Square length of the quaternion.

Definition at line 744 of file quaternion.hpp.

◆ sqr_length() [2/2]

template<class T , std::size_t N>
constexpr T math::sqr_length ( const vector< T, N > &  x)
inlineconstexprnoexcept

Calculates the square length of a vector.

The square length can be calculated faster than the length because a call to std::sqrt is saved.

Parameters
xVector of which to calculate the square length.
Returns
Square length of the vector.

Definition at line 1520 of file vector.hpp.

◆ sqrt() [1/2]

template<std::floating_point T, std::size_t N>
vector<T, N> math::sqrt ( const vector< T, N > &  x)

Takes the square root of each element.

Parameters
xInput vector
Returns
Square roots of the input vector elements.

◆ sqrt() [2/2]

template<std::floating_point T, std::size_t N>
vector<T, N> math::sqrt ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inline

Definition at line 1533 of file vector.hpp.

◆ sub() [1/9]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::sub ( const matrix< T, N, M > &  a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Subtracts a matrix from another matrix.

Parameters
aFirst matrix.
bSecond matrix.
Returns
Difference between the two matrices.

Definition at line 1167 of file math/matrix.hpp.

◆ sub() [2/9]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::sub ( const matrix< T, N, M > &  a,
b 
)
constexprnoexcept

Subtracts a scalar from matrix.

Parameters
aMatrix.
bScalar.
Returns
Difference between the matrix and scalar.

Definition at line 1180 of file math/matrix.hpp.

◆ sub() [3/9]

template<class T >
constexpr quaternion< T > math::sub ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inlineconstexprnoexcept

Subtracts a quaternion from another quaternion.

Parameters
aFirst quaternion.
bSecond quaternion.
Returns
Difference between the quaternions.

Definition at line 750 of file quaternion.hpp.

◆ sub() [4/9]

template<class T >
constexpr quaternion< T > math::sub ( const quaternion< T > &  a,
b 
)
inlineconstexprnoexcept

Subtracts a quaternion and a scalar.

Parameters
aFirst value.
bSecond second.
Returns
Difference between the quaternion and scalar.

Definition at line 756 of file quaternion.hpp.

◆ sub() [5/9]

template<class T , std::size_t N>
constexpr vector< T, N > math::sub ( const vector< T, N > &  x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Subtracts a value by another value.

Parameters
xFirst value.
ySecond value.
Returns
Difference between the two values.

Definition at line 1546 of file vector.hpp.

◆ sub() [6/9]

template<class T , std::size_t N>
constexpr vector< T, N > math::sub ( const vector< T, N > &  x,
y 
)
inlineconstexprnoexcept

Subtracts a value by another value.

Parameters
xFirst value.
ySecond value.
Returns
Difference between the two values.

Definition at line 1559 of file vector.hpp.

◆ sub() [7/9]

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, N, M > math::sub ( a,
const matrix< T, N, M > &  b 
)
constexprnoexcept

Subtracts a matrix from a scalar.

Parameters
aScalar.
bMatrix.
Returns
Difference between the scalar and matrix.

Definition at line 1193 of file math/matrix.hpp.

◆ sub() [8/9]

template<class T >
constexpr quaternion< T > math::sub ( a,
const quaternion< T > &  b 
)
inlineconstexprnoexcept

Subtracts a quaternion and a scalar.

Parameters
aFirst value.
bSecond second.
Returns
Difference between the quaternion and scalar.

Definition at line 762 of file quaternion.hpp.

◆ sub() [9/9]

template<class T , std::size_t N>
constexpr vector< T, N > math::sub ( x,
const vector< T, N > &  y 
)
inlineconstexprnoexcept

Subtracts a value by another value.

Parameters
xFirst value.
ySecond value.
Returns
Difference between the two values.

Definition at line 1572 of file vector.hpp.

◆ sum()

template<class T , std::size_t N>
constexpr T math::sum ( const vector< T, N > &  x)
inlineconstexprnoexcept

Calculates the sum of all elements in a vector.

Parameters
xVector to sum.
Returns
Sum of the vector's elements.

Definition at line 1585 of file vector.hpp.

◆ swing_twist()

template<class T >
std::array< quaternion< T >, 2 > math::swing_twist ( const quaternion< T > &  q,
const vec3< T > &  twist_axis,
tolerance = T{1e-6} 
)

Decomposes a quaternion into swing and twist rotation components.

Parameters
[in]qUnit quaternion to decompose.
[in]twist_axisAxis of twist rotation.
[out]swingSwing rotation component.
[out]twistTwist rotation component.
[in]toleranceFloating-point tolerance.
Returns
Array containing the swing rotation component, followed by the twist rotation component.
Warning
q must be a unit quaternion.
twist_axis must be a unit vector.
See also
https://www.euclideanspace.com/maths/geometry/rotations/for/decomposition/

Definition at line 768 of file quaternion.hpp.

◆ swizzle()

template<std::size_t... Indices, class T , std::size_t N>
constexpr vector< T, sizeof...(Indices)> math::swizzle ( const vector< T, N > &  x)
inlineconstexprnoexcept

Makes an m-dimensional vector by rearranging and/or duplicating elements of an n-dimensional vector.

Template Parameters
IndicesList of indices of elements in x.
TVector element type.
NNumber of dimensions in x.
Parameters
xVector to swizzle.
Returns
Vector containing elements from x in the order specified by Indices. The size of the returned vector is equivalent to the number of indices in Indices.

Definition at line 1591 of file vector.hpp.

◆ trace()

template<class T , std::size_t N>
constexpr T math::trace ( const matrix< T, N, N > &  m)
constexprnoexcept

Calculates the trace of a square matrix.

Parameters
mSquare matrix.
Returns
Sum of elements on the main diagonal.

Definition at line 1206 of file math/matrix.hpp.

◆ translate()

template<class T >
constexpr mat4< T > math::translate ( const vec3< T > &  v)
constexpr

Constructs a translation matrix.

Parameters
vTranslation vector.
Returns
Translation matrix.

Definition at line 1212 of file math/matrix.hpp.

◆ transpose()

template<class T , std::size_t N, std::size_t M>
constexpr matrix< T, M, N > math::transpose ( const matrix< T, N, M > &  m)
constexprnoexcept

Calculates the transpose of a matrix.

Parameters
mMatrix to transpose.
Returns
Transposed matrix.

Definition at line 1238 of file math/matrix.hpp.

◆ triple()

template<class T >
constexpr T math::triple ( const vector< T, 3 > &  x,
const vector< T, 3 > &  y,
const vector< T, 3 > &  z 
)
inlineconstexprnoexcept

Calculates the triple product of three vectors.

Parameters
xFirst vector.
ySecond vector.
zThird vector.
Returns
Triple product of the three vectors (dot(x, cross(y, z)).

Definition at line 1597 of file vector.hpp.

◆ trunc()

template<std::floating_point T, std::size_t N>
constexpr vector< T, N > math::trunc ( const vector< T, N > &  x)
inlineconstexpr

Performs a element-wise trunc operation.

Parameters
xInput vector
Returns
Component-wise trunc of input vector.

Definition at line 1610 of file vector.hpp.

◆ vertical_fov()

template<class T >
T math::vertical_fov ( h,
r 
)

Calculates a vertical FoV given a horizontal FoV and aspect ratio.

Parameters
hHorizontal FoV, in radians.
rRatio of width to height.
Returns
Vertical FoV, in radians.
See also
https://en.wikipedia.org/wiki/Field_of_view_in_video_games

Definition at line 56 of file math/projection.hpp.

◆ wrap_degrees()

template<class T >
constexpr T math::wrap_degrees ( degrees)
inlineconstexpr

Wraps an angle to [-180, 180].

Parameters
degreesAngle in degrees.
Returns
Wrapped angle.

Definition at line 60 of file angles.hpp.

◆ wrap_radians()

template<class T >
constexpr T math::wrap_radians ( radians)
inlineconstexpr

Wraps an angle to [-pi, pi].

Parameters
radiansAngle in radians.
Returns
Wrapped angle.

Definition at line 72 of file angles.hpp.