Simple-Vector v1.3.0
Vector

Classes

class  sl::vec::Vector< T, VDimensions >
 A mathematically vector implementation. More...
 

Functions

template<class... T>
 sl::vec::Vector (T &&...) -> Vector< std::common_type_t< T... >, sizeof...(T)>
 Vector deduction guide to make aggregate-like construction easier. More...
 
template<vectorial TVector, add_assignable< TVector > T2>
constexpr TVector sl::vec::operator+ (TVector lhs, T2 &&rhs)
 Sum operator. More...
 
template<vectorial TVector, sub_assignable< TVector > T2>
constexpr TVector sl::vec::operator- (TVector lhs, T2 &&rhs)
 Minus operator. More...
 
template<vectorial TVector, mul_assignable< TVector > T2>
constexpr TVector sl::vec::operator* (TVector lhs, T2 &&rhs)
 Multiplication operator. More...
 
template<vectorial TVector, mul_assignable< TVector > T2>
constexpr TVector sl::vec::operator* (T2 &&lhs, TVector rhs)
 Commutative multiplication operator. More...
 
template<vectorial TVector, div_assignable< TVector > T2>
constexpr TVector sl::vec::operator/ (TVector lhs, T2 &&rhs)
 Division operator. More...
 
template<vectorial TVector, mod_assignable< TVector > T2>
constexpr TVector sl::vec::operator% (TVector lhs, T2 &&rhs)
 Modulo operator. More...
 
template<vectorial TVector1, vectorial TVector2>
requires mulable<vector_value_t<TVector2>, vector_value_t<TVector1>>
constexpr vector_value_t< TVector1 > sl::vec::dot_product (const TVector1 &lhs, const TVector2 &rhs)
 Calculates the dot product of to Vectors. More...
 
template<vectorial TVector>
constexpr vector_value_t< TVector > sl::vec::length_squared (const TVector &vector)
 Calculates the squared length of a Vector. More...
 
template<vectorial TVector>
constexpr auto sl::vec::length (const TVector &vector)
 Calculates the length of a Vector. More...
 
template<vectorial TVector>
requires std::floating_point<vector_value_t<TVector>>
constexpr TVector sl::vec::normalized (TVector vec)
 Calculates the normalization of a Vector. More...
 
template<vectorial TVector>
constexpr TVector sl::vec::projected (const TVector &vector, TVector target)
 Projects vector onto the target Vector. More...
 
template<vectorial TVector, class T >
requires std::is_arithmetic_v<T>
constexpr TVector sl::vec::lerp (TVector vector1, const TVector &vector2, T t)
 Computes the linear interpolation between both vectors for the parameter t (or extrapolation, when t is outside the range [0,1]). More...
 
template<vectorial TVector>
requires std::floating_point<vector_value_t<TVector>>
constexpr TVector sl::vec::inversed (TVector vector)
 Computes the inverse of the vector (1./v[0], 1./v[1], ...). More...
 

Detailed Description

Function Documentation

◆ dot_product()

template<vectorial TVector1, vectorial TVector2>
requires mulable<vector_value_t<TVector2>, vector_value_t<TVector1>>
constexpr vector_value_t< TVector1 > sl::vec::dot_product ( const TVector1 &  lhs,
const TVector2 &  rhs 
)
constexpr

Calculates the dot product of to Vectors.

Template Parameters
TVector1A vectorial type
TVector2Another vectorial type
Parameters
lhsleft-hand-side of calculation
rhsleft-hand-side of calculation
Returns
scalar value

◆ inversed()

template<vectorial TVector>
requires std::floating_point<vector_value_t<TVector>>
constexpr TVector sl::vec::inversed ( TVector  vector)
constexpr

Computes the inverse of the vector (1./v[0], 1./v[1], ...).

Template Parameters
TVectorType of Vector
Parameters
vectorThe Vector to be inversed
Returns
newly constructed Vector

◆ length()

template<vectorial TVector>
constexpr auto sl::vec::length ( const TVector &  vector)
constexpr

Calculates the length of a Vector.

Template Parameters
TVectorA vectorial type
Parameters
vectorVector to be calculated from
Returns
scalar value
Remarks
Due to std::sqrt, this function will always return a floating point type.

◆ length_squared()

template<vectorial TVector>
constexpr vector_value_t< TVector > sl::vec::length_squared ( const TVector &  vector)
constexpr

Calculates the squared length of a Vector.

Template Parameters
TVectorA vectorial type
Parameters
vectorVector to be calculated from
Returns
scalar value

◆ lerp()

template<vectorial TVector, class T >
requires std::is_arithmetic_v<T>
constexpr TVector sl::vec::lerp ( TVector  vector1,
const TVector &  vector2,
t 
)
constexpr

Computes the linear interpolation between both vectors for the parameter t (or extrapolation, when t is outside the range [0,1]).

Template Parameters
TVectorType of Vector
TType of interpolation distance
Parameters
vector1The first Vector
vector2The second Vector
tThe interpolation distance (usually between [0, 1])
Returns
newly constructed Vector
Remarks
Vector with integral value_type may work as expected if difference between both vectors is very small.

◆ normalized()

template<vectorial TVector>
requires std::floating_point<vector_value_t<TVector>>
constexpr TVector sl::vec::normalized ( TVector  vec)
constexpr

Calculates the normalization of a Vector.

Template Parameters
TVectorA vectorial type
Parameters
vecVector to be calculated from
Returns
newly constructed Vector

◆ operator%()

template<vectorial TVector, mod_assignable< TVector > T2>
constexpr TVector sl::vec::operator% ( TVector  lhs,
T2 &&  rhs 
)
constexpr

Modulo operator.

Template Parameters
TVectorA vectorial type
T2A type, which is modulo-assignable to TVector
Parameters
lhsleft-hand-side of modulo
rhsright-hand-side of modulo
Returns
newly constructed Vector

◆ operator*() [1/2]

template<vectorial TVector, mul_assignable< TVector > T2>
constexpr TVector sl::vec::operator* ( T2 &&  lhs,
TVector  rhs 
)
constexpr

Commutative multiplication operator.

Template Parameters
TVectorA vectorial type
T2A type, which is multiplication-assignable to TVector
Parameters
lhsleft-hand-side of multiplication
rhsright-hand-side of multiplication
Returns
newly constructed Vector

◆ operator*() [2/2]

template<vectorial TVector, mul_assignable< TVector > T2>
constexpr TVector sl::vec::operator* ( TVector  lhs,
T2 &&  rhs 
)
constexpr

Multiplication operator.

Template Parameters
TVectorA vectorial type
T2A type, which is multiplication-assignable to TVector
Parameters
lhsleft-hand-side of multiplication
rhsright-hand-side of multiplication
Returns
newly constructed Vector

◆ operator+()

template<vectorial TVector, add_assignable< TVector > T2>
constexpr TVector sl::vec::operator+ ( TVector  lhs,
T2 &&  rhs 
)
constexpr

Sum operator.

Template Parameters
TVectorA vectorial type
T2A type, which is add-assignable to TVector
Parameters
lhsleft-hand-side of sum
rhsright-hand-side of sum
Returns
newly constructed Vector

◆ operator-()

template<vectorial TVector, sub_assignable< TVector > T2>
constexpr TVector sl::vec::operator- ( TVector  lhs,
T2 &&  rhs 
)
constexpr

Minus operator.

Template Parameters
TVectorA vectorial type
T2A type, which is subtract-assignable to TVector
Parameters
lhsleft-hand-side of subtraction
rhsright-hand-side of subtraction
Returns
newly constructed Vector

◆ operator/()

template<vectorial TVector, div_assignable< TVector > T2>
constexpr TVector sl::vec::operator/ ( TVector  lhs,
T2 &&  rhs 
)
constexpr

Division operator.

Template Parameters
TVectorA vectorial type
T2A type, which is division-assignable to TVector
Parameters
lhsleft-hand-side of division
rhsright-hand-side of division
Returns
newly constructed Vector

◆ projected()

template<vectorial TVector>
constexpr TVector sl::vec::projected ( const TVector &  vector,
TVector  target 
)
constexpr

Projects vector onto the target Vector.

Template Parameters
TVectorType of Vector
Parameters
vectorThe Vector to be projected
targetThe Vector to be projected onto
Returns
newly constructed Vector

◆ Vector()

template<class... T>
sl::vec::Vector ( T &&  ...) -> Vector< std::common_type_t< T... >, sizeof...(T)>

Vector deduction guide to make aggregate-like construction easier.

Template Parameters
TVariadic types