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

A vector with two components. More...

#include <Vector2.h>

Inheritance diagram for spark::math::Vector2< T >:
spark::math::details::Vector< Vector2, T, 2 >

Public Member Functions

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

Public Attributes

x {}
 
y {}
 

Detailed Description

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

A vector with two components.

Template Parameters
TThe type of the components.

Constructor & Destructor Documentation

◆ Vector2()

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

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

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

Member Function Documentation

◆ castTo()

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

Casts all components of the Vector2 to the type To.

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