Antkeeper  0.0.1
Classes | Namespaces | Typedefs | Functions
vector.hpp File Reference
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <cmath>
#include <concepts>
#include <format>
#include <iterator>
#include <limits>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

struct  math::vector< T, N >
 n-dimensional vector. More...
 
struct  std::tuple_size< math::vector< T, N > >
 Provides access to the number of elements in a math::vector as a compile-time constant expression. More...
 
struct  std::tuple_element< I, math::vector< T, N > >
 Provides compile-time indexed access to the type of the elements in a math::vector using a tuple-like interface. More...
 
struct  std::formatter< math::vector< T, N > >
 Specialization of std::formatter for math::vector. More...
 

Namespaces

 math
 Mathematical functions and data types.
 
 math::vector_types
 Vector types.
 
 math::types
 Linear algebra data types.
 
 math::operators
 Mathematical operators.
 

Typedefs

template<class T >
using math::vector_types::vec2 = vector< T, 2 >
 2-dimensional vector. More...
 
template<class T >
using math::vector_types::vec3 = vector< T, 3 >
 3-dimensional vector. More...
 
template<class T >
using math::vector_types::vec4 = vector< T, 4 >
 4-dimensional vector. More...
 
template<std::size_t N>
using math::vector_types::bvec = vector< bool, N >
 n-dimensional vector of Boolean values. More...
 
using math::vector_types::bvec2 = bvec< 2 >
 n-dimensional vector of Boolean values. More...
 
using math::vector_types::bvec3 = bvec< 3 >
 n-dimensional vector of Boolean values. More...
 
using math::vector_types::bvec4 = bvec< 4 >
 n-dimensional vector of Boolean values. More...
 
template<std::size_t N>
using math::vector_types::ivec = vector< int, N >
 n-dimensional vector of signed integers. More...
 
using math::vector_types::ivec2 = ivec< 2 >
 n-dimensional vector of signed integers. More...
 
using math::vector_types::ivec3 = ivec< 3 >
 n-dimensional vector of signed integers. More...
 
using math::vector_types::ivec4 = ivec< 4 >
 n-dimensional vector of signed integers. More...
 
template<std::size_t N>
using math::vector_types::uvec = vector< unsigned int, N >
 n-dimensional vector of unsigned integers. More...
 
using math::vector_types::uvec2 = uvec< 2 >
 n-dimensional vector of unsigned integers. More...
 
using math::vector_types::uvec3 = uvec< 3 >
 n-dimensional vector of unsigned integers. More...
 
using math::vector_types::uvec4 = uvec< 4 >
 n-dimensional vector of unsigned integers. More...
 
template<std::size_t N>
using math::vector_types::fvec = vector< float, N >
 n-dimensional vector of single-precision floating-point numbers. More...
 
using math::vector_types::fvec2 = fvec< 2 >
 n-dimensional vector of single-precision floating-point numbers. More...
 
using math::vector_types::fvec3 = fvec< 3 >
 n-dimensional vector of single-precision floating-point numbers. More...
 
using math::vector_types::fvec4 = fvec< 4 >
 n-dimensional vector of single-precision floating-point numbers. More...
 
template<std::size_t N>
using math::vector_types::dvec = vector< double, N >
 n-dimensional vector of double-precision floating-point numbers. More...
 
using math::vector_types::dvec2 = dvec< 2 >
 n-dimensional vector of double-precision floating-point numbers. More...
 
using math::vector_types::dvec3 = dvec< 3 >
 n-dimensional vector of double-precision floating-point numbers. More...
 
using math::vector_types::dvec4 = dvec< 4 >
 n-dimensional vector of double-precision floating-point numbers. More...
 

Functions

template<class T , std::size_t N>
constexpr vector< T, N > math::abs (const vector< T, N > &x)
 Returns the absolute values of each element. More...
 
template<std::size_t N>
constexpr bool math::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>
math::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 math::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 > math::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 > math::clamp_length (const vector< T, N > &x, T max_length)
 Clamps the length of a vector. More...
 
template<class T >
constexpr vector< T, 3 > math::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>
math::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 math::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 > math::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 > math::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 > math::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 > math::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 > math::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>
math::inv_length (const vector< T, N > &x)
 Calculates the inverse length of a vector. More...
 
template<std::floating_point T, std::size_t N>
math::length (const vector< T, N > &x)
 Calculates the length of a vector. More...
 
template<class T , std::size_t N>
constexpr vector< bool, N > math::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 > math::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 > math::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 math::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 > math::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 math::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 > math::negate (const vector< T, N > &x) noexcept
 Negates a vector. More...
 
template<std::floating_point T, std::size_t N>
vector< T, N > math::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 > math::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 > math::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 > math::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 > math::sign (const vector< T, N > &x)
 Returns a vector containing the signs of each element. More...
 
template<std::floating_point 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. More...
 
template<class T , std::size_t N>
constexpr T math::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 math::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 > math::sqrt (const vector< T, N > &x)
 Takes the square root of each element. More...
 
template<class T , std::size_t N>
constexpr T math::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)> math::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 math::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 > math::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 > math::sqrt (const vector< T, N > &x, const vector< T, N > &y)
 
template<class T , std::size_t N>
constexpr vector< T, N > math::operators::operator+ (const vector< T, N > &x, const vector< T, N > &y) noexcept
 
template<class T , std::size_t N>
constexpr vector< T, N > math::operators::operator/ (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 > math::operators::operator/ (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 > math::operators::operator/ (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 > math::operators::operator* (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 > math::operators::operator- (const vector< T, N > &x) noexcept
 Negates a vector. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > math::operators::operator- (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 > math::operators::operator- (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 > math::operators::operator- (T x, const vector< T, N > &y) noexcept
 Subtracts a value by another value. More...
 
template<class T , std::size_t N>
constexpr bool math::operators::operator== (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Tests two vector for equality. More...
 
template<class T , std::size_t N>
constexpr bool math::operators::operator!= (const vector< T, N > &x, const vector< T, N > &y) noexcept
 Tests two vector for inequality. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > math::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 > math::add (const vector< T, N > &x, T y) noexcept
 Adds two values. More...
 
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)
 Clamps the values of a vector's elements. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > math::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 > math::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 > math::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 > math::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 > math::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 > math::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 & math::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 && math::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 & math::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 && math::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 > math::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 > math::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 > math::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 > math::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 > math::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 > math::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 > math::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 > math::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 > math::sub (T 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 > math::operators::operator+ (const vector< T, N > &x, T y) noexcept
 
template<class T , std::size_t N>
constexpr vector< T, N > math::operators::operator+ (T x, const vector< T, N > &y) noexcept
 
template<class T , std::size_t N>
constexpr vector< T, N > math::operators::operator* (const vector< T, N > &x, T y) noexcept
 Multiplies two values. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > math::operators::operator* (T x, const vector< T, N > &y) noexcept
 Multiplies two values. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator+= (vector< T, N > &x, const vector< T, N > &y) noexcept
 Adds two values and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator+= (vector< T, N > &x, T y) noexcept
 Adds two values and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator-= (vector< T, N > &x, const vector< T, N > &y) noexcept
 Subtracts the first value by the second value and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator-= (vector< T, N > &x, T y) noexcept
 Subtracts the first value by the second value and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator*= (vector< T, N > &x, const vector< T, N > &y) noexcept
 Multiplies two values and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator*= (vector< T, N > &x, T y) noexcept
 Multiplies two values and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator/= (vector< T, N > &x, const vector< T, N > &y) noexcept
 Divides the first value by the second value and stores the result in the first value. More...
 
template<class T , std::size_t N>
constexpr vector< T, N > & math::operators::operator/= (vector< T, N > &x, T y) noexcept
 Divides the first value by the second value and stores the result in the first value. More...