SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::math::Vector4< T > Class Template Referencefinal

A vector with four components. More...

#include <Vector4.h>

Inheritance diagram for spark::math::Vector4< T >:
spark::math::details::Vector< Vector4, T, 4 >

Public Member Functions

constexpr Vector4 ()
 Initializes a new Vector4 with all components to their default value.
 
constexpr Vector4 (T value_x, T value_y, T value_z, T value_w) noexcept
 Initializes a new Vector4 with components set to the given values.
 
constexpr Vector4 (const Vector4 &other)
 
constexpr Vector4 (Vector4 &&other) noexcept
 
constexpr Vector4operator= (const Vector4 &other)
 
constexpr Vector4operator= (Vector4 &&other) noexcept
 
template<typename To >
constexpr Vector4< To > castTo () const noexcept
 Casts all components of the Vector4 to the type To.
 
- Public Member Functions inherited from spark::math::details::Vector< Vector4, T, 4 >
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 Vector4< T > operator+ (const Vector4< T > &other) const noexcept
 Adds two Vector.
 
constexpr Vector4< T > operator- (const Vector4< T > &other) const noexcept
 Subtracts two Vector.
 
constexpr Vector4< T > operator- () const noexcept
 Negates all components of the current Vector.
 
constexpr Vector4< T > operator* (const Vector4< T > &other) const noexcept
 Multiplies two Vector.
 
constexpr Vector4< T > operator* (const T &value) const noexcept
 Multiplies a Vector by a value of type T.
 
constexpr Vector4< T > operator/ (const Vector4< T > &other) const noexcept
 Divides two Vector.
 
constexpr Vector4< T > operator/ (const T &value) const noexcept
 Divides a Vector by a value of type T.
 
constexpr Vector4< T > & operator+= (const Vector &other) noexcept
 Adds the value of other to the current vector.
 
constexpr Vector4< T > & operator-= (const Vector &other) noexcept
 Subtracts the value of other to the current vector.
 
constexpr Vector4< T > & operator*= (const Vector &other) noexcept
 Multiplies the value of other to the current vector.
 
constexpr Vector4< T > & operator/= (const T &value) noexcept
 Divides the value of other from the current vector.
 
constexpr T norm () const noexcept
 Computes the norm of the Vector. (||v|| = sqrt(v1^2 + v2^2 + ... + vn^2))
 
constexpr Vector4< T > normalized () const noexcept
 Gets the normalized Vector. (v / ||v||)
 
constexpr T dot (const Vector4< T > &other) const noexcept
 Computes the dot product between the current Vector and other.
 

Public Attributes

x {}
 
y {}
 
z {}
 
w {}
 

Detailed Description

template<typename T>
class spark::math::Vector4< T >

A vector with four components.

Template Parameters
TThe type of the four components.

Constructor & Destructor Documentation

◆ Vector4()

template<typename T >
spark::math::Vector4< T >::Vector4 ( T value_x,
T value_y,
T value_z,
T value_w )
constexprnoexcept

Initializes a new Vector4 with components set to the given values.

Parameters
value_wThe value of the w component.
value_xThe value of the x component.
value_yThe value of the y component.
value_zThe value of the z component.

Member Function Documentation

◆ castTo()

template<typename T >
template<typename To >
Vector4< To > spark::math::Vector4< T >::castTo ( ) const
nodiscardconstexprnoexcept

Casts all components of the Vector4 to the type To.

Template Parameters
ToType of the components of the new Vector4.
Returns
A Vector4 of type To.