stellarlib 0.1.0
Loading...
Searching...
No Matches
stellarlib::lin Namespace Reference

Linear algebra utilities. More...

Typedefs

template<typename T, std::size_t M = 4, std::size_t N = 4>
using matrix = internal::matrix<T, M, N>
 Generic M*N matrix with per-component operations.
template<typename T, std::size_t N = 4>
using vector = matrix<T, 1, N>
 Generic N-dimensional vector with per-component operations.
using bool1 = vector<bool, 1>
 1D boolean vector
using bool2 = vector<bool, 2>
 2D boolean vector
using bool3 = vector<bool, 3>
 3D boolean vector
using bool4 = vector<bool>
 4D boolean vector
using char1 = vector<std::int8_t, 1>
 1D char vector
using char2 = vector<std::int8_t, 2>
 2D char vector
using char3 = vector<std::int8_t, 3>
 3D char vector
using char4 = vector<std::int8_t>
 4D char vector
using uchar1 = vector<std::uint8_t, 1>
 1D unsigned char vector
using uchar2 = vector<std::uint8_t, 2>
 2D unsigned char vector
using uchar3 = vector<std::uint8_t, 3>
 3D unsigned char vector
using uchar4 = vector<std::uint8_t>
 4D unsigned char vector
using short1 = vector<std::int16_t, 1>
 1D short vector
using short2 = vector<std::int16_t, 2>
 2D short vector
using short3 = vector<std::int16_t, 3>
 3D short vector
using short4 = vector<std::int16_t>
 4D short vector
using ushort1 = vector<std::uint16_t, 1>
 1D unsigned short vector
using ushort2 = vector<std::uint16_t, 2>
 2D unsigned short vector
using ushort3 = vector<std::uint16_t, 3>
 3D unsigned short vector
using ushort4 = vector<std::uint16_t>
 4D unsigned short vector
using int1 = vector<std::int32_t, 1>
 1D integer vector
using int2 = vector<std::int32_t, 2>
 2D integer vector
using int3 = vector<std::int32_t, 3>
 3D integer vector
using int4 = vector<std::int32_t>
 4D integer vector
using uint1 = vector<std::uint32_t, 1>
 1D unsigned integer vector
using uint2 = vector<std::uint32_t, 2>
 2D unsigned integer vector
using uint3 = vector<std::uint32_t, 3>
 3D unsigned integer vector
using uint4 = vector<std::uint32_t>
 4D unsigned integer vector
using long1 = vector<std::int64_t, 1>
 1D long vector
using long2 = vector<std::int64_t, 2>
 2D long vector
using long3 = vector<std::int64_t, 3>
 3D long vector
using long4 = vector<std::int64_t>
 4D long vector
using ulong1 = vector<std::uint64_t, 1>
 1D unsigned long vector
using ulong2 = vector<std::uint64_t, 2>
 2D unsigned long vector
using ulong3 = vector<std::uint64_t, 3>
 3D unsigned long vector
using ulong4 = vector<std::uint64_t>
 4D unsigned long vector
using float1 = vector<float, 1>
 1D float vector
using float2 = vector<float, 2>
 2D float vector
using float3 = vector<float, 3>
 3D float vector
using float4 = vector<float>
 4D float vector
using double1 = vector<double, 1>
 1D double vector
using double2 = vector<double, 2>
 2D double vector
using double3 = vector<double, 3>
 3D double vector
using double4 = vector<double>
 4D double vector
using bool1x1 = bool1
 1x1 boolean matrix
using bool2x1 = matrix<bool, 2, 1>
 2x1 boolean matrix
using bool3x1 = matrix<bool, 3, 1>
 3x1 boolean matrix
using bool4x1 = matrix<bool, 4, 1>
 4x1 boolean matrix
using bool1x2 = bool2
 1x2 boolean matrix
using bool2x2 = matrix<bool, 2, 2>
 2x2 boolean matrix
using bool3x2 = matrix<bool, 3, 2>
 3x2 boolean matrix
using bool4x2 = matrix<bool, 4, 2>
 4x2 boolean matrix
using bool1x3 = bool3
 1x3 boolean matrix
using bool2x3 = matrix<bool, 2, 3>
 2x3 boolean matrix
using bool3x3 = matrix<bool, 3, 3>
 3x3 boolean matrix
using bool4x3 = matrix<bool, 4, 3>
 4x3 boolean matrix
using bool1x4 = bool4
 1x4 boolean matrix
using bool2x4 = matrix<bool, 2>
 2x4 boolean matrix
using bool3x4 = matrix<bool, 3>
 3x4 boolean matrix
using bool4x4 = matrix<bool>
 4x4 boolean matrix
using char1x1 = char1
 1x1 char matrix
using char2x1 = matrix<std::int8_t, 2, 1>
 2x1 char matrix
using char3x1 = matrix<std::int8_t, 3, 1>
 3x1 char matrix
using char4x1 = matrix<std::int8_t, 4, 1>
 4x1 char matrix
using char1x2 = char2
 1x2 char matrix
using char2x2 = matrix<std::int8_t, 2, 2>
 2x2 char matrix
using char3x2 = matrix<std::int8_t, 3, 2>
 3x2 char matrix
using char4x2 = matrix<std::int8_t, 4, 2>
 4x2 char matrix
using char1x3 = char3
 1x3 char matrix
using char2x3 = matrix<std::int8_t, 2, 3>
 2x3 char matrix
using char3x3 = matrix<std::int8_t, 3, 3>
 3x3 char matrix
using char4x3 = matrix<std::int8_t, 4, 3>
 4x3 char matrix
using char1x4 = char4
 1x4 char matrix
using char2x4 = matrix<std::int8_t, 2>
 2x4 char matrix
using char3x4 = matrix<std::int8_t, 3>
 3x4 char matrix
using char4x4 = matrix<std::int8_t>
 4x4 char matrix
using uchar1x1 = uchar1
 1x1 unsigned char matrix
using uchar2x1 = matrix<std::uint8_t, 2, 1>
 2x1 unsigned char matrix
using uchar3x1 = matrix<std::uint8_t, 3, 1>
 3x1 unsigned char matrix
using uchar4x1 = matrix<std::uint8_t, 4, 1>
 4x1 unsigned char matrix
using uchar1x2 = uchar2
 1x2 unsigned char matrix
using uchar2x2 = matrix<std::uint8_t, 2, 2>
 2x2 unsigned char matrix
using uchar3x2 = matrix<std::uint8_t, 3, 2>
 3x2 unsigned char matrix
using uchar4x2 = matrix<std::uint8_t, 4, 2>
 4x2 unsigned char matrix
using uchar1x3 = uchar3
 1x3 unsigned char matrix
using uchar2x3 = matrix<std::uint8_t, 2, 3>
 2x3 unsigned char matrix
using uchar3x3 = matrix<std::uint8_t, 3, 3>
 3x3 unsigned char matrix
using uchar4x3 = matrix<std::uint8_t, 4, 3>
 4x3 unsigned char matrix
using uchar1x4 = uchar4
 1x4 unsigned char matrix
using uchar2x4 = matrix<std::uint8_t, 2>
 2x4 unsigned char matrix
using uchar3x4 = matrix<std::uint8_t, 3>
 3x4 unsigned char matrix
using uchar4x4 = matrix<std::uint8_t>
 4x4 unsigned char matrix
using short1x1 = short1
 1x1 short matrix
using short2x1 = matrix<std::int16_t, 2, 1>
 2x1 short matrix
using short3x1 = matrix<std::int16_t, 3, 1>
 3x1 short matrix
using short4x1 = matrix<std::int16_t, 4, 1>
 4x1 short matrix
using short1x2 = short2
 1x2 short matrix
using short2x2 = matrix<std::int16_t, 2, 2>
 2x2 short matrix
using short3x2 = matrix<std::int16_t, 3, 2>
 3x2 short matrix
using short4x2 = matrix<std::int16_t, 4, 2>
 4x2 short matrix
using short1x3 = short3
 1x3 short matrix
using short2x3 = matrix<std::int16_t, 2, 3>
 2x3 short matrix
using short3x3 = matrix<std::int16_t, 3, 3>
 3x3 short matrix
using short4x3 = matrix<std::int16_t, 4, 3>
 4x3 short matrix
using short1x4 = short4
 1x4 short matrix
using short2x4 = matrix<std::int16_t, 2>
 2x4 short matrix
using short3x4 = matrix<std::int16_t, 3>
 3x4 short matrix
using short4x4 = matrix<std::int16_t>
 4x4 short matrix
using ushort1x1 = ushort1
 1x1 unsigned short matrix
using ushort2x1 = matrix<std::uint16_t, 2, 1>
 2x1 unsigned short matrix
using ushort3x1 = matrix<std::uint16_t, 3, 1>
 3x1 unsigned short matrix
using ushort4x1 = matrix<std::uint16_t, 4, 1>
 4x1 unsigned short matrix
using ushort1x2 = ushort2
 1x2 unsigned short matrix
using ushort2x2 = matrix<std::uint16_t, 2, 2>
 2x2 unsigned short matrix
using ushort3x2 = matrix<std::uint16_t, 3, 2>
 3x2 unsigned short matrix
using ushort4x2 = matrix<std::uint16_t, 4, 2>
 4x2 unsigned short matrix
using ushort1x3 = ushort3
 1x3 unsigned short matrix
using ushort2x3 = matrix<std::uint16_t, 2, 3>
 2x3 unsigned short matrix
using ushort3x3 = matrix<std::uint16_t, 3, 3>
 3x3 unsigned short matrix
using ushort4x3 = matrix<std::uint16_t, 4, 3>
 4x3 unsigned short matrix
using ushort1x4 = ushort4
 1x4 unsigned short matrix
using ushort2x4 = matrix<std::uint16_t, 2>
 2x4 unsigned short matrix
using ushort3x4 = matrix<std::uint16_t, 3>
 3x4 unsigned short matrix
using ushort4x4 = matrix<std::uint16_t>
 4x4 unsigned short matrix
using int1x1 = int1
 1x1 integer matrix
using int2x1 = matrix<std::int32_t, 2, 1>
 2x1 integer matrix
using int3x1 = matrix<std::int32_t, 3, 1>
 3x1 integer matrix
using int4x1 = matrix<std::int32_t, 4, 1>
 4x1 integer matrix
using int1x2 = int2
 1x2 integer matrix
using int2x2 = matrix<std::int32_t, 2, 2>
 2x2 integer matrix
using int3x2 = matrix<std::int32_t, 3, 2>
 3x2 integer matrix
using int4x2 = matrix<std::int32_t, 4, 2>
 4x2 integer matrix
using int1x3 = int3
 1x3 integer matrix
using int2x3 = matrix<std::int32_t, 2, 3>
 2x3 integer matrix
using int3x3 = matrix<std::int32_t, 3, 3>
 3x3 integer matrix
using int4x3 = matrix<std::int32_t, 4, 3>
 4x3 integer matrix
using int1x4 = int4
 1x4 integer matrix
using int2x4 = matrix<std::int32_t, 2>
 2x4 integer matrix
using int3x4 = matrix<std::int32_t, 3>
 3x4 integer matrix
using int4x4 = matrix<std::int32_t>
 4x4 integer matrix
using uint1x1 = uint1
 1x1 unsigned integer matrix
using uint2x1 = matrix<std::uint32_t, 2, 1>
 2x1 unsigned integer matrix
using uint3x1 = matrix<std::uint32_t, 3, 1>
 3x1 unsigned integer matrix
using uint4x1 = matrix<std::uint32_t, 4, 1>
 4x1 unsigned integer matrix
using uint1x2 = uint2
 1x2 unsigned integer matrix
using uint2x2 = matrix<std::uint32_t, 2, 2>
 2x2 unsigned integer matrix
using uint3x2 = matrix<std::uint32_t, 3, 2>
 3x2 unsigned integer matrix
using uint4x2 = matrix<std::uint32_t, 4, 2>
 4x2 unsigned integer matrix
using uint1x3 = uint3
 1x3 unsigned integer matrix
using uint2x3 = matrix<std::uint32_t, 2, 3>
 2x3 unsigned integer matrix
using uint3x3 = matrix<std::uint32_t, 3, 3>
 3x3 unsigned integer matrix
using uint4x3 = matrix<std::uint32_t, 4, 3>
 4x3 unsigned integer matrix
using uint1x4 = uint4
 1x4 unsigned integer matrix
using uint2x4 = matrix<std::uint32_t, 2>
 2x4 unsigned integer matrix
using uint3x4 = matrix<std::uint32_t, 3>
 3x4 unsigned integer matrix
using uint4x4 = matrix<std::uint32_t>
 4x4 unsigned integer matrix
using long1x1 = long1
 1x1 long matrix
using long2x1 = matrix<std::int64_t, 2, 1>
 2x1 long matrix
using long3x1 = matrix<std::int64_t, 3, 1>
 3x1 long matrix
using long4x1 = matrix<std::int64_t, 4, 1>
 4x1 long matrix
using long1x2 = long2
 1x2 long matrix
using long2x2 = matrix<std::int64_t, 2, 2>
 2x2 long matrix
using long3x2 = matrix<std::int64_t, 3, 2>
 3x2 long matrix
using long4x2 = matrix<std::int64_t, 4, 2>
 4x2 long matrix
using long1x3 = long3
 1x3 long matrix
using long2x3 = matrix<std::int64_t, 2, 3>
 2x3 long matrix
using long3x3 = matrix<std::int64_t, 3, 3>
 3x3 long matrix
using long4x3 = matrix<std::int64_t, 4, 3>
 4x3 long matrix
using long1x4 = long4
 1x4 long matrix
using long2x4 = matrix<std::int64_t, 2>
 2x4 long matrix
using long3x4 = matrix<std::int64_t, 3>
 3x4 long matrix
using long4x4 = matrix<std::int64_t>
 4x4 long matrix
using ulong1x1 = ulong1
 1x1 unsigned long matrix
using ulong2x1 = matrix<std::uint64_t, 2, 1>
 2x1 unsigned long matrix
using ulong3x1 = matrix<std::uint64_t, 3, 1>
 3x1 unsigned long matrix
using ulong4x1 = matrix<std::uint64_t, 4, 1>
 4x1 unsigned long matrix
using ulong1x2 = ulong2
 1x2 unsigned long matrix
using ulong2x2 = matrix<std::uint64_t, 2, 2>
 2x2 unsigned long matrix
using ulong3x2 = matrix<std::uint64_t, 3, 2>
 3x2 unsigned long matrix
using ulong4x2 = matrix<std::uint64_t, 4, 2>
 4x2 unsigned long matrix
using ulong1x3 = ulong3
 1x3 unsigned long matrix
using ulong2x3 = matrix<std::uint64_t, 2, 3>
 2x3 unsigned long matrix
using ulong3x3 = matrix<std::uint64_t, 3, 3>
 3x3 unsigned long matrix
using ulong4x3 = matrix<std::uint64_t, 4, 3>
 4x3 unsigned long matrix
using ulong1x4 = ulong4
 1x4 unsigned long matrix
using ulong2x4 = matrix<std::uint64_t, 2>
 2x4 unsigned long matrix
using ulong3x4 = matrix<std::uint64_t, 3>
 3x4 unsigned long matrix
using ulong4x4 = matrix<std::uint64_t>
 4x4 unsigned long matrix
using float1x1 = float1
 1x1 float matrix
using float2x1 = matrix<float, 2, 1>
 2x1 float matrix
using float3x1 = matrix<float, 3, 1>
 3x1 float matrix
using float4x1 = matrix<float, 4, 1>
 4x1 float matrix
using float1x2 = float2
 1x2 float matrix
using float2x2 = matrix<float, 2, 2>
 2x2 float matrix
using float3x2 = matrix<float, 3, 2>
 3x2 float matrix
using float4x2 = matrix<float, 4, 2>
 4x2 float matrix
using float1x3 = float3
 1x3 float matrix
using float2x3 = matrix<float, 2, 3>
 2x3 float matrix
using float3x3 = matrix<float, 3, 3>
 3x3 float matrix
using float4x3 = matrix<float, 4, 3>
 4x3 float matrix
using float1x4 = float4
 1x4 float matrix
using float2x4 = matrix<float, 2>
 2x4 float matrix
using float3x4 = matrix<float, 3>
 3x4 float matrix
using float4x4 = matrix<float>
 4x4 float matrix
using double1x1 = double1
 1x1 double matrix
using double2x1 = matrix<double, 2, 1>
 2x1 double matrix
using double3x1 = matrix<double, 3, 1>
 3x1 double matrix
using double4x1 = matrix<double, 4, 1>
 4x1 double matrix
using double1x2 = double2
 1x2 double matrix
using double2x2 = matrix<double, 2, 2>
 2x2 double matrix
using double3x2 = matrix<double, 3, 2>
 3x2 double matrix
using double4x2 = matrix<double, 4, 2>
 4x2 double matrix
using double1x3 = double3
 1x3 double matrix
using double2x3 = matrix<double, 2, 3>
 2x3 double matrix
using double3x3 = matrix<double, 3, 3>
 3x3 double matrix
using double4x3 = matrix<double, 4, 3>
 4x3 double matrix
using double1x4 = double4
 1x4 double matrix
using double2x4 = matrix<double, 2>
 2x4 double matrix
using double3x4 = matrix<double, 3>
 3x4 double matrix
using double4x4 = matrix<double>
 4x4 double matrix

Functions

template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 2)
constexpr auto translate (const internal::matrix< T, 3, 3 > &m, const internal::matrix< U, M, N > &v) noexcept -> internal::matrix< std::common_type_t< T, U >, 3, 3 >
 Translates a 3x3 transformation matrix using a 2D vector.
template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 3)
constexpr auto translate (const internal::matrix< T, 4, 4 > &m, const internal::matrix< U, M, N > &v) noexcept -> internal::matrix< std::common_type_t< T, U >, 4, 4 >
 Translates a 4x4 transformation matrix using a 3D vector.
template<typename T, typename U>
requires (std::is_arithmetic_v<U>)
constexpr auto rotate (const internal::matrix< T, 3, 3 > &m, const U angle) noexcept -> internal::matrix< std::common_type_t< T, U >, 3, 3 >
 Rotates a 3x3 transformation matrix using radians.
template<typename T, typename U, typename V, std::size_t M, std::size_t N>
requires (std::is_arithmetic_v<U> && M * N == 3)
constexpr auto rotate (const internal::matrix< T, 4, 4 > &m, const U angle, const internal::matrix< V, M, N > &axis) noexcept -> internal::matrix< std::common_type_t< T, U, V >, 4, 4 >
 Rotates a 4x4 transformation matrix using radians and a 3D axis.
template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 2)
constexpr auto scale (const internal::matrix< T, 3, 3 > &m, const internal::matrix< U, M, N > &v) noexcept -> internal::matrix< std::common_type_t< T, U >, 3, 3 >
 Scales a 3x3 transformation matrix using a 2D vector.
template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 3)
constexpr auto scale (const internal::matrix< T, 4, 4 > &m, const internal::matrix< U, M, N > &v) noexcept -> internal::matrix< std::common_type_t< T, U >, 4, 4 >
 Scales a 4x4 transformation matrix using a 3D vector.
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto perspective (const T fovy, const U aspect, const V near) noexcept
 Constructs a 4x4 perspective matrix.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto abs (const T x) noexcept
 Returns the absolute value of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto acos (const T x) noexcept
 Returns the arccosine of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto all (const T x) noexcept
 Determines if all components of x are truthy.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto any (const T x) noexcept
 Determines if any components of x are truthy.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto asin (const T x) noexcept
 Returns the arcsine of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto atan (const T x) noexcept
 Returns the arctangent of x (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto atan2 (const T y, const U x) noexcept
 Returns the arctangent of y and x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto ceil (const T x) noexcept
 Returns the smallest integer value that is greater than or equal to x (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto clamp (const T x, const U min, const V max) noexcept
 Clamps x to the range [min, max] (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto cos (const T x) noexcept
 Returns the cosine of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto cosh (const T x) noexcept
 Returns the hyperbolic cosine of x (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto cross (const T x, const U y) noexcept
 Returns the cross product of two 3D vectors.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto degrees (const T x) noexcept
 Converts x from radians to degrees (per-component).
template<typename T>
constexpr auto determinant (const matrix< T, 1, 1 > &m) noexcept
 Returns the determinant of the specified square matrix.
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto distance (const T x, const U y) noexcept
 Returns a distance scalar between two vectors.
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto dot (const T x, const U y) noexcept
 Returns the dot product of two vectors.
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto dst (const T src0, const U src1) noexcept
 Calculates a distance vector for lighting.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto exp (const T x) noexcept
 Returns the base-e exponential of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto exp2 (const T x) noexcept
 Returns the base 2 exponential of x (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto faceforward (const T n, const U i, const V ng) noexcept
 Flips the surface-normal (if needed) to face in a direction opposite to i; returns the result in n.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto floor (const T x) noexcept
 Returns the largest integer that is less than or equal to x (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto fma (const T a, const U b, const V c) noexcept
 Returns the fused multiply-addition of a*b+c (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto fmod (const T x, const U y) noexcept
 Returns the floating-point remainder of x/y (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto frac (const T x) noexcept
 Returns the fractional part of x; which is greater than or equal to 0 and less than 1 (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto ldexp (const T x, const U exp) noexcept
 Returns the result of multiplying x by two, raised to the power of exp (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto length (const T x) noexcept
 Returns the length of the specified vector.
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto lerp (const T x, const U y, const V s) noexcept
 Performs a linear interpolation (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto lit (const T n_dot_l, const U n_dot_h, const V m) noexcept
 Returns a lighting coefficient vector.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto log (const T x) noexcept
 Returns the base-e logarithm of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto log10 (const T x) noexcept
 Returns the base-10 logarithm of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto log2 (const T x) noexcept
 Returns the base-2 logarithm of x (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto mad (const T mvalue, const U avalue, const V bvalue) noexcept
 Performs an arithmetic multiply/add operation on a, b and c (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto max (const T x, const U y) noexcept
 Selects the greater of x and y (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto min (const T x, const U y) noexcept
 Selects the lesser of x and y (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto modf (const T x, U &ip) noexcept
 Splits the value x into fractional and integer parts, each of which has the same sign as x (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto mul (const T x, const U y) noexcept
 Multiplies x and y using matrix math; the inner dimension x-columns and y-rows must be equal.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto normalize (const T x) noexcept
 Normalizes the specified vector according to x/length(x).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto pow (const T x, const U y) noexcept
 Returns x raised to y (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto radians (const T x) noexcept
 Converts x from degrees to radians (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto rcp (const T x) noexcept
 Returns the reciprocal of x (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto reflect (const T i, const U n) noexcept
 Returns a reflection vector using an incident ray and a surface normal.
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto refract (const T i, const U n, const V eta) noexcept
 Returns a refraction vector using an entering ray, a surface normal, and a refraction index.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto round (const T x) noexcept
 Rounds x to the nearest integer; halfway cases are rounded away from zero (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto rsqrt (const T x) noexcept
 Returns the reciprocal of the square root of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto saturate (const T x) noexcept
 Clamps x within the range [0, 1] (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto sign (const T x) noexcept
 Returns the sign of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto sin (const T x) noexcept
 Returns the sine of x (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr void sincos (const T x, U &s, V &c) noexcept
 Returns the sine and cosine of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto sinh (const T x) noexcept
 Returns the hyperbolic sine of x (per-component).
template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
constexpr auto smoothstep (const T min, const U max, const V x) noexcept
 Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max] (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto sqrt (const T x) noexcept
 Returns the square root of x (per-component).
template<typename T, typename U>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
constexpr auto step (const T y, const U x) noexcept
 Compares y and x, returning 0 or 1 based on which value is greater (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto tan (const T x) noexcept
 Returns the tangent of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto tanh (const T x) noexcept
 Returns the hyperbolic tangent of x (per-component).
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto transpose (const T x) noexcept
 Transposes the specified input matrix.
template<typename T>
requires (std::is_arithmetic_v<T>)
constexpr auto trunc (const T x) noexcept
 Truncates x to the integer component (per-component).

Detailed Description

Linear algebra utilities.

Typedef Documentation

◆ matrix

template<typename T, std::size_t M = 4, std::size_t N = 4>
using stellarlib::lin::matrix = internal::matrix<T, M, N>

Generic M*N matrix with per-component operations.

Template Parameters
TArithmetic type of the components
MNumber of rows in the matrix
NNumber of columns in the matrix

◆ vector

template<typename T, std::size_t N = 4>
using stellarlib::lin::vector = matrix<T, 1, N>

Generic N-dimensional vector with per-component operations.

Template Parameters
TArithmetic type of the components
NDimension of the vector

Function Documentation

◆ translate() [1/2]

template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 2)
auto stellarlib::lin::translate ( const internal::matrix< T, 3, 3 > & m,
const internal::matrix< U, M, N > & v ) -> internal::matrix< std::common_type_t< T, U >, 3, 3 >
nodiscardconstexprnoexcept

Translates a 3x3 transformation matrix using a 2D vector.

Parameters
m3x3 transformation matrix to be translated
v2D translation vector
Returns
Translated 3x3 transformation matrix

◆ translate() [2/2]

template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 3)
auto stellarlib::lin::translate ( const internal::matrix< T, 4, 4 > & m,
const internal::matrix< U, M, N > & v ) -> internal::matrix< std::common_type_t< T, U >, 4, 4 >
nodiscardconstexprnoexcept

Translates a 4x4 transformation matrix using a 3D vector.

Parameters
m4x4 transformation matrix to be translated
v3D translation vector
Returns
Translated 4x4 transformation matrix

◆ rotate() [1/2]

template<typename T, typename U>
requires (std::is_arithmetic_v<U>)
auto stellarlib::lin::rotate ( const internal::matrix< T, 3, 3 > & m,
const U angle ) -> internal::matrix< std::common_type_t< T, U >, 3, 3 >
nodiscardconstexprnoexcept

Rotates a 3x3 transformation matrix using radians.

Parameters
m3x3 transformation matrix to be rotated
angleRotation angle in radians
Returns
Rotated 3x3 transformation matrix

◆ rotate() [2/2]

template<typename T, typename U, typename V, std::size_t M, std::size_t N>
requires (std::is_arithmetic_v<U> && M * N == 3)
auto stellarlib::lin::rotate ( const internal::matrix< T, 4, 4 > & m,
const U angle,
const internal::matrix< V, M, N > & axis ) -> internal::matrix< std::common_type_t< T, U, V >, 4, 4 >
nodiscardconstexprnoexcept

Rotates a 4x4 transformation matrix using radians and a 3D axis.

Parameters
m4x4 transformation matrix to be rotated
angleRotation angle in radians
axis3D rotation axis
Returns
Rotated 4x4 transformation matrix

◆ scale() [1/2]

template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 2)
auto stellarlib::lin::scale ( const internal::matrix< T, 3, 3 > & m,
const internal::matrix< U, M, N > & v ) -> internal::matrix< std::common_type_t< T, U >, 3, 3 >
nodiscardconstexprnoexcept

Scales a 3x3 transformation matrix using a 2D vector.

Parameters
m3x3 transformation matrix to be scaled
v2D scaling vector
Returns
Scaled 3x3 transformation matrix

◆ scale() [2/2]

template<typename T, typename U, std::size_t M, std::size_t N>
requires (M * N == 3)
auto stellarlib::lin::scale ( const internal::matrix< T, 4, 4 > & m,
const internal::matrix< U, M, N > & v ) -> internal::matrix< std::common_type_t< T, U >, 4, 4 >
nodiscardconstexprnoexcept

Scales a 4x4 transformation matrix using a 3D vector.

Parameters
m4x4 transformation matrix to be scaled
v3D scaling vector
Returns
Scaled 4x4 transformation matrix

◆ perspective()

template<typename T, typename U, typename V>
requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && std::is_arithmetic_v<V>)
auto stellarlib::lin::perspective ( const T fovy,
const U aspect,
const V near )
nodiscardconstexprnoexcept

Constructs a 4x4 perspective matrix.

Parameters
fovyVertical field of view of the camera
aspectAspect ratio of the viewport
nearDistance of the near clipping plane
Returns
Constructed 4x4 perspective matrix