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

A vector with three components. More...

#include <Vector3.h>

Inheritance diagram for spark::math::Vector3< T >:
spark::math::details::Vector< Vector3, T, 3 >

Public Member Functions

constexpr Vector3 ()
 Initializes a new Vector3 with all components to their default value.
 
constexpr Vector3 (T x_value, T y_value, T z_value) noexcept
 Initializes a new Vector3 with components set to the given values.
 
constexpr Vector3 (const Vector3 &other)
 
constexpr Vector3 (Vector3 &&other) noexcept
 
constexpr Vector3operator= (const Vector3 &other)
 
constexpr Vector3operator= (Vector3 &&other) noexcept
 
template<typename To >
constexpr Vector3< To > castTo () const noexcept
 Casts all components of the Vector3 to the type To.
 
- Public Member Functions inherited from spark::math::details::Vector< Vector3, T, 3 >
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 Vector3< T > operator+ (const Vector3< T > &other) const noexcept
 Adds two Vector.
 
constexpr Vector3< T > operator- (const Vector3< T > &other) const noexcept
 Subtracts two Vector.
 
constexpr Vector3< T > operator- () const noexcept
 Negates all components of the current Vector.
 
constexpr Vector3< T > operator* (const Vector3< T > &other) const noexcept
 Multiplies two Vector.
 
constexpr Vector3< T > operator* (const T &value) const noexcept
 Multiplies a Vector by a value of type T.
 
constexpr Vector3< T > operator/ (const Vector3< T > &other) const noexcept
 Divides two Vector.
 
constexpr Vector3< T > operator/ (const T &value) const noexcept
 Divides a Vector by a value of type T.
 
constexpr Vector3< T > & operator+= (const Vector &other) noexcept
 Adds the value of other to the current vector.
 
constexpr Vector3< T > & operator-= (const Vector &other) noexcept
 Subtracts the value of other to the current vector.
 
constexpr Vector3< T > & operator*= (const Vector &other) noexcept
 Multiplies the value of other to the current vector.
 
constexpr Vector3< 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 Vector3< T > normalized () const noexcept
 Gets the normalized Vector. (v / ||v||)
 
constexpr T dot (const Vector3< T > &other) const noexcept
 Computes the dot product between the current Vector and other.
 

Public Attributes

x {}
 
y {}
 
z {}
 

Detailed Description

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

A vector with three components.

Template Parameters
TThe type of three components.

Constructor & Destructor Documentation

◆ Vector3()

template<typename T >
spark::math::Vector3< T >::Vector3 ( T x_value,
T y_value,
T z_value )
constexprnoexcept

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

Parameters
x_valueThe value of the x component.
y_valueThe value of the y component.
z_valueThe value of the z component.

Member Function Documentation

◆ castTo()

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

Casts all components of the Vector3 to the type To.

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