mal-math
C++20 mathematics library.
|
#include "vec_math.hpp"
Go to the source code of this file.
Namespaces | |
namespace | mal_math |
Contains mathematical utility functions and classes. | |
Functions | |
template<AnyMat U> | |
constexpr std::istream & | mal_math::operator>> (std::istream &is, U &matrix) |
Reads a matrix from an input stream. | |
template<AnyMat U> | |
constexpr std::ostream & | mal_math::operator<< (std::ostream &os, U const &matrix) |
Writes a matrix to an output stream. | |
template<AnyVec U> | |
constexpr std::ostream & | mal_math::operator<< (std::ostream &os, U &vec) |
Output stream operator overload for vector objects. | |
template<size_t n, Primitive U, AnyVec Vector> requires (n >= 2 && n <= Vector::size) | |
constexpr vec< n, U > | mal_math::as_vec (Vector const &v) noexcept |
Create a new vector of a specified size and type from the given vector. | |
template<size_t n, AnyVec Vector> requires (n >= 2 && n <= Vector::size) | |
constexpr vec< n, std::remove_const_t< typename Vector::type > > | mal_math::as_vec (Vector const &v) noexcept |
Create a new vector of a specified size from the given vector, preserving the type. | |
template<AnyVec Vector> | |
constexpr vec< Vector::size, std::remove_const_t< typename Vector::type > > | mal_math::as_vec (Vector const &v) noexcept |
Create a new vector of the same size from the given vector, preserving the type. | |
template<size_t n, AnyVec Vector> requires (n >= 2 && n <= Vector::size) | |
constexpr vec< n, typename Vector::type > & | mal_math::as_rvec (Vector &v) noexcept |
Convert a given vector to a reference of vec with specified size and type. | |
template<AnyVec Vector> | |
constexpr vec< Vector::size, typename Vector::type > & | mal_math::as_rvec (Vector &v) noexcept |
Convert a given vector to a reference of vec with the same size and type. | |
template<size_t n, AnyVec Vector> requires (n >= 2 && n <= Vector::size) | |
constexpr vec< n, typename Vector::type > const & | mal_math::as_crvec (Vector const &v) noexcept |
Convert a given const vector to a const reference of vec with specified size and type. | |
template<AnyVec Vector> | |
constexpr vec< Vector::size, typename Vector::type > const & | mal_math::as_crvec (Vector const &v) noexcept |
Convert a given const vector to a const reference of vec with the same size and type. | |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator+ (vec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator- (vec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator* (vec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator/ (vec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator* (U const value, vec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator/ (U const value, vec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator+ (U const value, vec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator- (U const value, vec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator+ (vec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator- (vec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator* (vec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator/ (vec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator% (vec< size, T > const &left, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator% (vec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator* (U const value, _detail::rvec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator+ (U const value, _detail::rvec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator- (U const value, _detail::rvec< size, T > const &vector) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator+ (_detail::rvec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator- (_detail::rvec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator* (_detail::rvec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator/ (_detail::rvec< size, T > const &vector, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator+ (_detail::rvec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator- (_detail::rvec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator* (_detail::rvec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator/ (_detail::rvec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator% (_detail::rvec< size, T > const &left, U const value) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator% (_detail::rvec< size, T > const &left, vec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator+ (_detail::rvec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator- (_detail::rvec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator* (_detail::rvec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator/ (_detail::rvec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, std::remove_const_t< T > > | mal_math::operator% (_detail::rvec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator+ (vec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator- (vec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator* (vec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator/ (vec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<size_t size, Primitive T, Primitive U> | |
constexpr vec< size, T > | mal_math::operator% (vec< size, T > const &left, _detail::rvec< size, U > const &right) noexcept |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr bool | mal_math::operator== (T const &left, U const &right) noexcept |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr bool | mal_math::operator!= (T const &left, U const &right) noexcept |
template<AnyVec T> | |
constexpr std::remove_const_t< typename T::type > | mal_math::squared_length (T const &vector) noexcept |
Compute the squared length of the given vector. | |
template<AnyVec T> | |
constexpr auto | mal_math::length (T const &vector) noexcept |
Compute the length (magnitude) of the given vector. | |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::unit_vector (T const &vector) noexcept |
Compute the unit vector (normalized vector) of the given vector. | |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::normalize (T const &vector) noexcept |
Normalize the given vector. | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr std::remove_const_t< typename T::type > | mal_math::dot (T const &left, U const &right) noexcept |
Compute the dot product of two vectors. | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr std::remove_const_t< typename T::type > | mal_math::angle (T const &left, U const &right) noexcept |
Compute the angle between two vectors. | |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::cos (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::sin (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::tan (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::acos (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::asin (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::atan (T const &vector) noexcept |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::atan (T const &left, U const &right) noexcept |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::atan2 (T const &left, U const &right) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::sinh (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::cosh (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::tanh (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::asinh (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::acosh (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::atanh (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::exp (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::exp2 (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::expm1 (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::log (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::log2 (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::log10 (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::log1p (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::logb (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::sqrt (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::inversesqrt (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::abs (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::sign (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::floor (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::ceil (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::trunc (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::round (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::roundEven (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::fract (T const &vector) noexcept |
template<AnyVec T> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::mod (T const &vector, typename T::type const &scalar) noexcept |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::mod (T const &left, U const &right) noexcept |
template<AnyVec T, Primitive U> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::pow (T const &vector, U const pow) noexcept |
template<AnyVec T, AnyVec U> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::pow (T const &vector1, U const &vector2) noexcept |
template<AnyVec T, AnyVec U> requires (T::size == U::size && T::size == 3) | |
constexpr vec< 3, std::remove_const_t< typename T::type > > | mal_math::cross (T const &left, U const &right) noexcept |
Compute the cross product of two 3D vectors. | |
template<Primitive T, Primitive U> | |
constexpr void | mal_math::rclamp (T &left, U const min, U const max) noexcept |
Clamp the value of left between min and max in-place. | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr void | mal_math::rclamp (T &left, U const min, U const max) noexcept |
Clamp the value of left between min and max in-place. | |
template<AnyVec T, Primitive U> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::clamp (T const &left, U const min, U const max) noexcept |
Clamp the value of left between min and max . | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::clamp (T const &left, U const &min, U const &max) noexcept |
Clamp the value of left between min and max . | |
template<Primitive T, Primitive U> | |
constexpr T | mal_math::clamp (T left, U const min, U const max) noexcept |
Clamp the value of left between min and max . | |
template<AnyVec T, Primitive U> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::min (T const &left, U const min) noexcept |
Returns a new vector with each element being the minimum of the corresponding element in left and max . | |
template<AnyVec T, Primitive U> | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::max (T const &left, U const max) noexcept |
Returns a new vector with each element being the maximum of the corresponding element in left and min . | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::min (T const &left, U const &min) noexcept |
Returns a new vector with each element being the minimum of the corresponding elements in left and right . | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr vec< T::size, std::remove_const_t< typename T::type > > | mal_math::max (T const &left, U const &max) noexcept |
Returns a new vector with each element being the maximum of the corresponding elements in left and right . | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr void | mal_math::rmin (T &left, U const &max) noexcept |
Modifies left in-place, setting each element to the minimum of itself and the corresponding element in max . | |
template<AnyVec T, AnyVec U> requires (T::size == U::size) | |
constexpr void | mal_math::rmax (T &left, U const &min) noexcept |
Modifies left in-place, setting each element to the maximum of itself and the corresponding element in min . | |
template<AnyVec T, Primitive U> | |
constexpr void | mal_math::rmin (T &left, U const max) noexcept |
Modifies left in-place, setting each element to the minimum of itself and max . | |
template<AnyVec T, Primitive U> | |
constexpr void | mal_math::rmax (T &left, U const min) noexcept |
Modifies left in-place, setting each element to the maximum of itself and min . | |
template<AnyVec T> | |
constexpr std::remove_const_t< typename T::type > | mal_math::distance (T const &left, T const &right) noexcept |
Compute the distance between two vectors. | |
template<typename T , Primitive U> | |
constexpr auto | mal_math::lerp (T const &from, T const &to, U const param) noexcept |
Linearly interpolate between two values. | |
template<typename T , Primitive U> | |
constexpr auto | mal_math::mix (T const &from, T const &to, U const param) noexcept |
Mix between two values (same as lerp). | |