SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::math::details::Vector< Impl, T, N > Class Template Reference

Public Member Functions

constexpr Vector (std::array< std::reference_wrapper< T >, N > values)
 Initializes a new Vector.
 
constexpr bool operator== (const Vector &other) const noexcept
 Compares two Vector for equality.
 
constexpr bool operator!= (const Vector &other) const noexcept
 Compares two Vector for inequality.
 
constexpr Impl< T > operator+ (const Impl< T > &other) const noexcept
 Adds two Vector.
 
constexpr Impl< T > operator- (const Impl< T > &other) const noexcept
 Subtracts two Vector.
 
constexpr Impl< T > operator* (const Impl< T > &other) const noexcept
 Multiplies two Vector.
 
constexpr Impl< T > operator/ (const Impl< T > &other) const noexcept
 Divides two Vector.
 
constexpr Impl< T > operator* (const T &value) const noexcept
 Multiplies a Vector by a value of type T.
 
constexpr Impl< T > operator/ (const T &value) const noexcept
 Divides a Vector by a value of type T.
 
constexpr Impl< T > & operator+= (const Vector &other) noexcept
 Adds the value of other to the current vector.
 
constexpr Impl< T > & operator-= (const Vector &other) noexcept
 Subtracts the value of other to the current vector.
 
constexpr Impl< T > & operator*= (const Vector &other) noexcept
 Multiplies the value of other to the current vector.
 
constexpr Impl< T > & operator/= (const T &value) noexcept
 Divides the value of other from the current vector.
 
constexpr Impl< T > operator- () const noexcept
 Negates all components of the current Vector.
 
constexpr T norm () const noexcept
 Computes the norm of the Vector. (||v|| = sqrt(v1^2 + v2^2 + ... + vn^2))
 
constexpr Impl< T > normalized () const noexcept
 Gets the normalized Vector. (v / ||v||)
 
constexpr T dot (const Impl< T > &other) const noexcept
 Computes the dot product between the current Vector and other.
 

Friends

constexpr void swap (Vector &lhs, Vector &rhs) noexcept
 Swaps two Vector.
 

Member Function Documentation

◆ dot()

template<template< typename > typename Impl, typename T , std::size_t N>
T spark::math::details::Vector< Impl, T, N >::dot ( const Impl< T > & other) const
inlinenodiscardconstexprnoexcept

Computes the dot product between the current Vector and other.

Parameters
otherThe Vector to compute the dot product with.
Returns
The value of the dot product between this and other.

◆ norm()

template<template< typename > typename Impl, typename T , std::size_t N>
T spark::math::details::Vector< Impl, T, N >::norm ( ) const
inlinenodiscardconstexprnoexcept

Computes the norm of the Vector. (||v|| = sqrt(v1^2 + v2^2 + ... + vn^2))

Returns
The norm of the Vector.

◆ normalized()

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::normalized ( ) const
inlinenodiscardconstexprnoexcept

Gets the normalized Vector. (v / ||v||)

Returns
The normalized Vector.

◆ operator!=()

template<template< typename > typename Impl, typename T , std::size_t N>
bool spark::math::details::Vector< Impl, T, N >::operator!= ( const Vector< Impl, T, N > & other) const
inlineconstexprnoexcept

Compares two Vector for inequality.

Parameters
otherA Vector to compare with.
Returns
true if this is not equal to other false otherwise.

◆ operator*() [1/2]

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator* ( const Impl< T > & other) const
inlineconstexprnoexcept

Multiplies two Vector.

Parameters
otherThe Vector to multiply with.
Returns
A Vector resulting of the multiplication of the two vectors.

◆ operator*() [2/2]

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator* ( const T & value) const
inlineconstexprnoexcept

Multiplies a Vector by a value of type T.

Parameters
valueThe value of type T to multiply the vector with
Returns
A Vector resulting of the multiplication with value.

◆ operator*=()

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > & spark::math::details::Vector< Impl, T, N >::operator*= ( const Vector< Impl, T, N > & other)
inlineconstexprnoexcept

Multiplies the value of other to the current vector.

Parameters
otherThe Vector to take values to multiply with.
Returns
A reference to the modified Vector.

◆ operator+()

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator+ ( const Impl< T > & other) const
inlineconstexprnoexcept

Adds two Vector.

Parameters
otherThe Vector to add.
Returns
A Vector resulting of the sum of the two vectors.

◆ operator+=()

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > & spark::math::details::Vector< Impl, T, N >::operator+= ( const Vector< Impl, T, N > & other)
inlineconstexprnoexcept

Adds the value of other to the current vector.

Parameters
otherThe Vector to take values to add.
Returns
A reference to the modified Vector.

◆ operator-() [1/2]

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator- ( ) const
inlineconstexprnoexcept

Negates all components of the current Vector.

Returns
A Vector with all components negated.

◆ operator-() [2/2]

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator- ( const Impl< T > & other) const
inlineconstexprnoexcept

Subtracts two Vector.

Parameters
otherThe Vector to subtract.
Returns
A Vector resulting of the subtraction of the two vectors.

◆ operator-=()

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > & spark::math::details::Vector< Impl, T, N >::operator-= ( const Vector< Impl, T, N > & other)
inlineconstexprnoexcept

Subtracts the value of other to the current vector.

Parameters
otherThe Vector to take values to subtract.
Returns
A reference to the modified Vector.

◆ operator/() [1/2]

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator/ ( const Impl< T > & other) const
inlineconstexprnoexcept

Divides two Vector.

Parameters
otherThe Vector to divide with.
Returns
A Vector resulting of the division of the two vectors.

◆ operator/() [2/2]

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > spark::math::details::Vector< Impl, T, N >::operator/ ( const T & value) const
inlineconstexprnoexcept

Divides a Vector by a value of type T.

Parameters
valueThe value of type T to divide the vector with
Returns
A Vector resulting of the division with value.

◆ operator/=()

template<template< typename > typename Impl, typename T , std::size_t N>
Impl< T > & spark::math::details::Vector< Impl, T, N >::operator/= ( const T & value)
inlineconstexprnoexcept

Divides the value of other from the current vector.

Parameters
valueThe value to divide each component with.
Returns
A reference to the modified Vector.

◆ operator==()

template<template< typename > typename Impl, typename T , std::size_t N>
bool spark::math::details::Vector< Impl, T, N >::operator== ( const Vector< Impl, T, N > & other) const
inlineconstexprnoexcept

Compares two Vector for equality.

Parameters
otherA Vector to compare with.
Returns
true if this is equal to other false otherwise.

Friends And Related Symbol Documentation

◆ swap

template<template< typename > typename Impl, typename T , std::size_t N>
void swap ( Vector< Impl, T, N > & lhs,
Vector< Impl, T, N > & rhs )
friend

Swaps two Vector.

Parameters
lhsThe first vector.
rhsThe second vector.