NRE::Math::Vector2D< T > Class Template Reference

A cartesian 2D vector. More...

#include <NRE_Vector2D.hpp>

Inheritance diagram for NRE::Math::Vector2D< T >:

Public Member Functions

constexpr Vector2D ()=default
 
template<class K , class L , typename = UseIfArithmetic<K, L>>
constexpr Vector2D (K nX, L nY)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D (K value)
 
constexpr Vector2D (std::initializer_list< T > list)
 
constexpr Vector2D (Vector2D const &u)=default
 
constexpr Vector2D (Vector2D &&u)=default
 
template<class K >
constexpr Vector2D (Vector2D< K > const &u)
 
template<class K >
constexpr Vector2D (Vector3D< K > const &u)
 
template<class K >
constexpr Vector2D (Vector4D< K > const &u)
 
 ~Vector2D ()=default
 
constexpr T getX () const
 
constexpr T getY () const
 
constexpr T getW () const
 
constexpr T getH () const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setX (K nX)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setY (K nY)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setW (K w)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setH (K h)
 
template<class K , class L , typename = UseIfArithmetic<K, L>>
constexpr void setCoord (K nX, L nY)
 
template<class K , class L , typename = UseIfArithmetic<K, L>>
constexpr void setSize (K w, L h)
 
long double norm () const
 
constexpr T normSquared () const
 
template<class K >
long double distance (Vector2D< K > const &v) const
 
template<class K >
constexpr std::common_type_t< T, K > distanceSquared (Vector2D< K > const &v) const
 
Vector2Dnormalize ()
 
template<class K , typename = UseIfArithmetic<K>>
void limit (K max)
 
template<class K , typename = UseIfArithmetic<K>>
Vector2Dpow (K p)
 
template<class K >
Vector2Dpow (Vector2D< K > const &p)
 
constexpr const T * value () const
 
constexpr T & operator[] (std::size_t index)
 
constexpr T const & operator[] (std::size_t index) const
 
constexpr Vector2Doperator= (Vector2D const &u)=default
 
constexpr Vector2Doperator= (Vector2D &&u)=default
 
template<class K >
constexpr Vector2Doperator= (Vector2D< K > const &u)
 
template<class K >
constexpr Vector2Doperator= (Vector2D< K > &&u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2Doperator+= (K k)
 
template<class K >
constexpr Vector2Doperator+= (Vector2D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2Doperator-= (K k)
 
template<class K >
constexpr Vector2Doperator-= (Vector2D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2Doperator*= (K k)
 
template<class K >
constexpr Vector2Doperator*= (Vector2D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2Doperator/= (K k)
 
template<class K >
constexpr Vector2Doperator/= (Vector2D< K > const &u)
 
template<class K >
constexpr std::common_type_t< T, K > operator|= (Vector2D< K > const &u) const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D< std::common_type_t< T, K > > operator+ (K k) const
 
template<class K >
constexpr Vector2D< std::common_type_t< T, K > > operator+ (Vector2D< K > const &u) const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D< std::common_type_t< T, K > > operator- (K k) const
 
template<class K >
constexpr Vector2D< std::common_type_t< T, K > > operator- (Vector2D< K > const &u) const
 
constexpr Vector2D operator- () const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D< std::common_type_t< T, K > > operator* (K k) const
 
template<class K >
constexpr Vector2D< std::common_type_t< T, K > > operator* (Vector2D< K > const &u) const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D< std::common_type_t< T, K > > operator/ (K k) const
 
template<class K >
constexpr Vector2D< std::common_type_t< T, K > > operator/ (Vector2D< K > const &u) const
 
template<class K >
constexpr std::common_type_t< T, K > operator| (Vector2D< K > const &u) const
 
template<class K >
constexpr bool operator== (Vector2D< K > const &u) const
 
template<class K >
constexpr bool operator!= (Vector2D< K > const &u) const
 
template<class K >
constexpr bool operator< (Vector2D< K > const &u) const
 
template<class K >
constexpr bool operator> (Vector2D< K > const &u) const
 
template<class K >
constexpr bool operator<= (Vector2D< K > const &u) const
 
template<class K >
constexpr bool operator>= (Vector2D< K > const &u) const
 
Utility::String toString () const
 

Detailed Description

template<class T>
class NRE::Math::Vector2D< T >

A cartesian 2D vector.

Constructor & Destructor Documentation

template<class T>
constexpr NRE::Math::Vector2D< T >::Vector2D ( )
default

Construct the null vector

template<class T>
template<class K , class L , typename = UseIfArithmetic<K, L>>
constexpr NRE::Math::Vector2D< T >::Vector2D ( nX,
nY 
)
inline

Construct a vector with passed values

Parameters
nXnew x value
nYnew y value
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr NRE::Math::Vector2D< T >::Vector2D ( value)
inline

Construct a vector with unique values

Parameters
valuethe new x and y values
template<class T>
constexpr NRE::Math::Vector2D< T >::Vector2D ( std::initializer_list< T >  list)

Construct a vector from an initializer list

Parameters
listthe construction list
template<class T>
constexpr NRE::Math::Vector2D< T >::Vector2D ( Vector2D< T > const &  u)
default

Copy u into this

Parameters
uthe object to copy
template<class T>
constexpr NRE::Math::Vector2D< T >::Vector2D ( Vector2D< T > &&  u)
default

Move u into this

Parameters
uthe object to move
template<class T>
template<class K >
constexpr NRE::Math::Vector2D< T >::Vector2D ( Vector2D< K > const &  u)

Convert a K-type vector into a T-type vector

Parameters
uthe K-type vector to convert
template<class T>
template<class K >
constexpr NRE::Math::Vector2D< T >::Vector2D ( Vector3D< K > const &  u)

Convert a K-type 3D vector into a T-type 2D vector

Parameters
uthe K-type 3D vector to convert
template<class T>
template<class K >
constexpr NRE::Math::Vector2D< T >::Vector2D ( Vector4D< K > const &  u)

Convert a K-type 4D vector into a T-type 2D vector

Parameters
uthe K-type 4D vector to convert
template<class T>
NRE::Math::Vector2D< T >::~Vector2D ( )
default

Vector2D Deconstructor

Member Function Documentation

template<class T>
template<class K >
long double NRE::Math::Vector2D< T >::distance ( Vector2D< K > const &  v) const
Returns
the distance to another vector
template<class T>
template<class K >
constexpr std::common_type_t<T, K> NRE::Math::Vector2D< T >::distanceSquared ( Vector2D< K > const &  v) const
Returns
the squared distance to another vector
template<class T>
constexpr T NRE::Math::Vector2D< T >::getH ( ) const
Returns
the y value
template<class T>
constexpr T NRE::Math::Vector2D< T >::getW ( ) const
Returns
the x value
template<class T>
constexpr T NRE::Math::Vector2D< T >::getX ( ) const
Returns
the x value
template<class T>
constexpr T NRE::Math::Vector2D< T >::getY ( ) const
Returns
the x value
template<class T>
template<class K , typename = UseIfArithmetic<K>>
void NRE::Math::Vector2D< T >::limit ( max)
inline

Limit the vector value to the given max, if to high then normalize it

Parameters
maxthe maximum value
template<class T>
long double NRE::Math::Vector2D< T >::norm ( ) const
Returns
the vector's norm
template<class T>
Vector2D& NRE::Math::Vector2D< T >::normalize ( )

Normalize the vector

Returns
the reference of himself
template<class T>
constexpr T NRE::Math::Vector2D< T >::normSquared ( ) const
Returns
the squared vector's norm
template<class T>
template<class K >
constexpr bool NRE::Math::Vector2D< T >::operator!= ( Vector2D< K > const &  u) const

Difference test between this and u

Parameters
uthe vector to test with this
Returns
the test's result
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator* ( k) const
inline

Compute the vector resulting in the multiplication of this by k

Parameters
kthe multiplication factor
Returns
the computed vector
template<class T>
template<class K >
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator* ( Vector2D< K > const &  u) const

Compute the vector resulting in the multiplication of this by u

Parameters
uthe multiplication vector
Returns
the computed vector
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D& NRE::Math::Vector2D< T >::operator*= ( k)
inline

Multiply this by a factor k

Parameters
kthe multiplication factor
Returns
the reference of himself
template<class T>
template<class K >
constexpr Vector2D& NRE::Math::Vector2D< T >::operator*= ( Vector2D< K > const &  u)

Multiply this by a vector u, component by component

Parameters
uthe multiplication vector
Returns
the reference of himself
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator+ ( k) const
inline

Compute the vector resulting in the addition of k into this

Parameters
kthe scalar to add
Returns
the computed vector
template<class T>
template<class K >
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator+ ( Vector2D< K > const &  u) const

Compute the vector resulting in the addition of u into this

Parameters
uthe vector to add
Returns
the computed vector
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D& NRE::Math::Vector2D< T >::operator+= ( k)
inline

Add a scalar to all components

Parameters
kthe scalar to add
Returns
the reference of himself
template<class T>
template<class K >
constexpr Vector2D& NRE::Math::Vector2D< T >::operator+= ( Vector2D< K > const &  u)

Add a vector into this

Parameters
uthe vector to add into this
Returns
the reference of himself
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator- ( k) const
inline

Compute the vector resulting in the subtraction of k into this

Parameters
kthe scalar to add
Returns
the computed vector
template<class T>
template<class K >
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator- ( Vector2D< K > const &  u) const

Compute the vector resulting in the subtraction of u into this

Parameters
uthe vector to subtract
Returns
the computed vector
template<class T>
constexpr Vector2D NRE::Math::Vector2D< T >::operator- ( ) const

Compute the opposite version of this

Returns
the opposite vector
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D& NRE::Math::Vector2D< T >::operator-= ( k)
inline

Subtract a scalar to all components

Parameters
kthe scalar to add
Returns
the reference of himself
template<class T>
template<class K >
constexpr Vector2D& NRE::Math::Vector2D< T >::operator-= ( Vector2D< K > const &  u)

Subtract a vector into this

Parameters
uthe vector to subtract into this
Returns
the reference of himself
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator/ ( k) const
inline

Compute the vector resulting in the division of this by k

Parameters
kthe division factor
Returns
the computed vector
template<class T>
template<class K >
constexpr Vector2D<std::common_type_t<T, K> > NRE::Math::Vector2D< T >::operator/ ( Vector2D< K > const &  u) const

Compute the vector resulting in the division of this by u

Parameters
uthe division vector
Returns
the computed vector
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector2D& NRE::Math::Vector2D< T >::operator/= ( k)
inline

Divide this by a factor k

Parameters
kthe division factor
Returns
the reference of himself
template<class T>
template<class K >
constexpr Vector2D& NRE::Math::Vector2D< T >::operator/= ( Vector2D< K > const &  u)

Divide this by a vector u, component by component

Parameters
uthe division vector
Returns
the reference of himself
template<class T>
template<class K >
constexpr bool NRE::Math::Vector2D< T >::operator< ( Vector2D< K > const &  u) const

Inferior test between this and u

Parameters
uthe vector to test with this
Returns
the test's result
template<class T>
template<class K >
constexpr bool NRE::Math::Vector2D< T >::operator<= ( Vector2D< K > const &  u) const

Inferior or Equal test between this and u

Parameters
uthe vector to test with this
Returns
the test's result
template<class T>
constexpr Vector2D& NRE::Math::Vector2D< T >::operator= ( Vector2D< T > const &  u)
default

Copy u into this

Parameters
uthe object to copy into this
Returns
the reference of himself
template<class T>
constexpr Vector2D& NRE::Math::Vector2D< T >::operator= ( Vector2D< T > &&  u)
default

Move u into this

Parameters
uthe object to move into this
Returns
the reference of himself
template<class T>
template<class K >
constexpr Vector2D& NRE::Math::Vector2D< T >::operator= ( Vector2D< K > const &  u)

Copy u into this

Parameters
uthe object to copy into this
Returns
the reference of himself
template<class T>
template<class K >
constexpr Vector2D& NRE::Math::Vector2D< T >::operator= ( Vector2D< K > &&  u)

Move u into this

Parameters
uthe object to move into this
Returns
the reference of himself
template<class T>
template<class K >
constexpr bool NRE::Math::Vector2D< T >::operator== ( Vector2D< K > const &  u) const

Equality test between this and u

Parameters
uthe vector to test with this
Returns
the test's result
template<class T>
template<class K >
constexpr bool NRE::Math::Vector2D< T >::operator> ( Vector2D< K > const &  u) const

Superior test between this and u

Parameters
uthe vector to test with this
Returns
the test's result
template<class T>
template<class K >
constexpr bool NRE::Math::Vector2D< T >::operator>= ( Vector2D< K > const &  u) const

Superior or Equal test between this and u

Parameters
uthe vector to test with this
Returns
the test's result
template<class T>
constexpr T& NRE::Math::Vector2D< T >::operator[] ( std::size_t  index)

Return a reference on a vector's object

Warning
No range check performed
Parameters
indexthe object's index
Returns
the object's reference
template<class T>
constexpr T const& NRE::Math::Vector2D< T >::operator[] ( std::size_t  index) const

Return a const reference on a vector's object

Warning
No range check performed
Parameters
indexthe object's index
Returns
the object's reference
template<class T>
template<class K >
constexpr std::common_type_t<T, K> NRE::Math::Vector2D< T >::operator| ( Vector2D< K > const &  u) const

Compute the scalar product between this and u

Parameters
uthe vector
Returns
the scalar product
template<class T>
template<class K >
constexpr std::common_type_t<T, K> NRE::Math::Vector2D< T >::operator|= ( Vector2D< K > const &  u) const

Compute the scalar product between this and u

Parameters
uthe vector
Returns
the scalar product
template<class T>
template<class K , typename = UseIfArithmetic<K>>
Vector2D& NRE::Math::Vector2D< T >::pow ( p)
inline

Raise all components to the given power

Parameters
pthe power to which to raise this
Returns
the reference of himself
template<class T>
template<class K >
Vector2D& NRE::Math::Vector2D< T >::pow ( Vector2D< K > const &  p)

Raise all components to the given power vector

Parameters
pthe set of power to which to raise this
Returns
the reference of himself
template<class T>
template<class K , class L , typename = UseIfArithmetic<K, L>>
constexpr void NRE::Math::Vector2D< T >::setCoord ( nX,
nY 
)
inline

Set the values for both x and y

Parameters
nXthe new value for x
nYthe new value for y
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector2D< T >::setH ( h)
inline

Y setter

Parameters
hthe new value for y
template<class T>
template<class K , class L , typename = UseIfArithmetic<K, L>>
constexpr void NRE::Math::Vector2D< T >::setSize ( w,
h 
)
inline

Set the values for both x and y

Parameters
wthe new value for x
hthe new value for y
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector2D< T >::setW ( w)
inline

X setter

Parameters
wthe new value for x
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector2D< T >::setX ( nX)
inline

X setter

Parameters
nXthe new value for x
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector2D< T >::setY ( nY)
inline

Y setter

Parameters
nYthe new value for y
template<class T>
Utility::String NRE::Math::Vector2D< T >::toString ( ) const

Convert the vector into a string

Returns
the converted vector
template<class T>
constexpr const T* NRE::Math::Vector2D< T >::value ( ) const
Returns
a pointer to the vector's data

The documentation for this class was generated from the following files: