A cartesian 2D vector. More...
#include <NRE_Vector2D.hpp>
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 |
Vector2D & | normalize () |
template<class K , typename = UseIfArithmetic<K>> | |
void | limit (K max) |
template<class K , typename = UseIfArithmetic<K>> | |
Vector2D & | pow (K p) |
template<class K > | |
Vector2D & | pow (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 Vector2D & | operator= (Vector2D const &u)=default |
constexpr Vector2D & | operator= (Vector2D &&u)=default |
template<class K > | |
constexpr Vector2D & | operator= (Vector2D< K > const &u) |
template<class K > | |
constexpr Vector2D & | operator= (Vector2D< K > &&u) |
template<class K , typename = UseIfArithmetic<K>> | |
constexpr Vector2D & | operator+= (K k) |
template<class K > | |
constexpr Vector2D & | operator+= (Vector2D< K > const &u) |
template<class K , typename = UseIfArithmetic<K>> | |
constexpr Vector2D & | operator-= (K k) |
template<class K > | |
constexpr Vector2D & | operator-= (Vector2D< K > const &u) |
template<class K , typename = UseIfArithmetic<K>> | |
constexpr Vector2D & | operator*= (K k) |
template<class K > | |
constexpr Vector2D & | operator*= (Vector2D< K > const &u) |
template<class K , typename = UseIfArithmetic<K>> | |
constexpr Vector2D & | operator/= (K k) |
template<class K > | |
constexpr Vector2D & | operator/= (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 |
A cartesian 2D vector.
|
default |
Construct the null vector
|
inline |
Construct a vector with passed values
nX | new x value |
nY | new y value |
|
inline |
Construct a vector with unique values
value | the new x and y values |
constexpr NRE::Math::Vector2D< T >::Vector2D | ( | std::initializer_list< T > | list | ) |
Construct a vector from an initializer list
list | the construction list |
|
default |
Copy u into this
u | the object to copy |
|
default |
Move u into this
u | the object to move |
constexpr NRE::Math::Vector2D< T >::Vector2D | ( | Vector2D< K > const & | u | ) |
Convert a K-type vector into a T-type vector
u | the K-type vector to convert |
constexpr NRE::Math::Vector2D< T >::Vector2D | ( | Vector3D< K > const & | u | ) |
Convert a K-type 3D vector into a T-type 2D vector
u | the K-type 3D vector to convert |
constexpr NRE::Math::Vector2D< T >::Vector2D | ( | Vector4D< K > const & | u | ) |
Convert a K-type 4D vector into a T-type 2D vector
u | the K-type 4D vector to convert |
|
default |
Vector2D Deconstructor
long double NRE::Math::Vector2D< T >::distance | ( | Vector2D< K > const & | v | ) | const |
constexpr std::common_type_t<T, K> NRE::Math::Vector2D< T >::distanceSquared | ( | Vector2D< K > const & | v | ) | const |
constexpr T NRE::Math::Vector2D< T >::getH | ( | ) | const |
constexpr T NRE::Math::Vector2D< T >::getW | ( | ) | const |
constexpr T NRE::Math::Vector2D< T >::getX | ( | ) | const |
constexpr T NRE::Math::Vector2D< T >::getY | ( | ) | const |
|
inline |
Limit the vector value to the given max, if to high then normalize it
max | the maximum value |
long double NRE::Math::Vector2D< T >::norm | ( | ) | const |
Vector2D& NRE::Math::Vector2D< T >::normalize | ( | ) |
Normalize the vector
constexpr T NRE::Math::Vector2D< T >::normSquared | ( | ) | const |
constexpr bool NRE::Math::Vector2D< T >::operator!= | ( | Vector2D< K > const & | u | ) | const |
Difference test between this and u
u | the vector to test with this |
|
inline |
Compute the vector resulting in the multiplication of this by k
k | the multiplication factor |
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
u | the multiplication vector |
|
inline |
Multiply this by a factor k
k | the multiplication factor |
constexpr Vector2D& NRE::Math::Vector2D< T >::operator*= | ( | Vector2D< K > const & | u | ) |
Multiply this by a vector u, component by component
u | the multiplication vector |
|
inline |
Compute the vector resulting in the addition of k into this
k | the scalar to add |
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
u | the vector to add |
|
inline |
Add a scalar to all components
k | the scalar to add |
constexpr Vector2D& NRE::Math::Vector2D< T >::operator+= | ( | Vector2D< K > const & | u | ) |
Add a vector into this
u | the vector to add into this |
|
inline |
Compute the vector resulting in the subtraction of k into this
k | the scalar to add |
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
u | the vector to subtract |
constexpr Vector2D NRE::Math::Vector2D< T >::operator- | ( | ) | const |
Compute the opposite version of this
|
inline |
Subtract a scalar to all components
k | the scalar to add |
constexpr Vector2D& NRE::Math::Vector2D< T >::operator-= | ( | Vector2D< K > const & | u | ) |
Subtract a vector into this
u | the vector to subtract into this |
|
inline |
Compute the vector resulting in the division of this by k
k | the division factor |
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
u | the division vector |
|
inline |
Divide this by a factor k
k | the division factor |
constexpr Vector2D& NRE::Math::Vector2D< T >::operator/= | ( | Vector2D< K > const & | u | ) |
Divide this by a vector u, component by component
u | the division vector |
constexpr bool NRE::Math::Vector2D< T >::operator< | ( | Vector2D< K > const & | u | ) | const |
Inferior test between this and u
u | the vector to test with this |
constexpr bool NRE::Math::Vector2D< T >::operator<= | ( | Vector2D< K > const & | u | ) | const |
Inferior or Equal test between this and u
u | the vector to test with this |
|
default |
Copy u into this
u | the object to copy into this |
|
default |
Move u into this
u | the object to move into this |
constexpr Vector2D& NRE::Math::Vector2D< T >::operator= | ( | Vector2D< K > const & | u | ) |
Copy u into this
u | the object to copy into this |
constexpr Vector2D& NRE::Math::Vector2D< T >::operator= | ( | Vector2D< K > && | u | ) |
Move u into this
u | the object to move into this |
constexpr bool NRE::Math::Vector2D< T >::operator== | ( | Vector2D< K > const & | u | ) | const |
Equality test between this and u
u | the vector to test with this |
constexpr bool NRE::Math::Vector2D< T >::operator> | ( | Vector2D< K > const & | u | ) | const |
Superior test between this and u
u | the vector to test with this |
constexpr bool NRE::Math::Vector2D< T >::operator>= | ( | Vector2D< K > const & | u | ) | const |
Superior or Equal test between this and u
u | the vector to test with this |
constexpr T& NRE::Math::Vector2D< T >::operator[] | ( | std::size_t | index | ) |
Return a reference on a vector's object
index | the object's index |
constexpr T const& NRE::Math::Vector2D< T >::operator[] | ( | std::size_t | index | ) | const |
Return a const reference on a vector's object
index | the object's index |
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
u | the vector |
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
u | the vector |
|
inline |
Raise all components to the given power
p | the power to which to raise this |
Vector2D& NRE::Math::Vector2D< T >::pow | ( | Vector2D< K > const & | p | ) |
Raise all components to the given power vector
p | the set of power to which to raise this |
|
inline |
Set the values for both x and y
nX | the new value for x |
nY | the new value for y |
|
inline |
Y setter
h | the new value for y |
|
inline |
Set the values for both x and y
w | the new value for x |
h | the new value for y |
|
inline |
X setter
w | the new value for x |
|
inline |
X setter
nX | the new value for x |
|
inline |
Y setter
nY | the new value for y |
Utility::String NRE::Math::Vector2D< T >::toString | ( | ) | const |
Convert the vector into a string
constexpr const T* NRE::Math::Vector2D< T >::value | ( | ) | const |