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

A cartesian 3D vector, 2D homogeneous. More...

#include <NRE_Vector3D.hpp>

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

Public Member Functions

constexpr Vector3D ()=default
 
template<class K , class L , class N , typename = UseIfArithmetic<K, L, N>>
constexpr Vector3D (K nX, L nY, N nZ)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3D (K value)
 
constexpr Vector3D (std::initializer_list< T > list)
 
constexpr Vector3D (Vector3D const &u)=default
 
constexpr Vector3D (Vector3D &&u)=default
 
template<class K >
constexpr Vector3D (Vector3D< K > const &u)
 
template<class K >
constexpr Vector3D (Vector2D< K > const &u)
 
template<class K >
constexpr Vector3D (Vector4D< K > const &u)
 
template<class K , class L , typename = UseIfArithmetic<L>>
constexpr Vector3D (Vector2D< K > const &u, L nZ)
 
 ~Vector3D ()=default
 
constexpr T getX () const
 
constexpr T getY () const
 
constexpr T getZ () const
 
constexpr T getR () const
 
constexpr T getG () const
 
constexpr T getB () 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 setZ (K nZ)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setR (K r)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setG (K g)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr void setB (K b)
 
template<class K , class L , class N , typename = UseIfArithmetic<K, L, N>>
constexpr void setCoord (K nX, L nY, N nZ)
 
template<class K , class L , typename = UseIfArithmetic<L>>
constexpr void setCoord (Vector2D< K > const &u, L nZ)
 
template<class K , class L , class N , typename = UseIfArithmetic<K, L, N>>
constexpr void setRGB (K r, L g, N b)
 
long double norm () const
 
constexpr T normSquared () const
 
template<class K >
long double distance (Vector3D< K > const &v) const
 
template<class K >
constexpr std::common_type_t< T, K > distanceSquared (Vector3D< K > const &v) const
 
Vector3Dnormalize ()
 
template<class K , typename = UseIfArithmetic<K>>
void limit (K max)
 
template<class K , typename = UseIfArithmetic<K>>
Vector3Dpow (K p)
 
template<class K >
Vector3Dpow (Vector3D< 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 Vector3Doperator= (Vector3D const &u)=default
 
constexpr Vector3Doperator= (Vector3D &&u)=default
 
template<class K >
constexpr Vector3Doperator= (Vector3D< K > const &u)
 
template<class K >
constexpr Vector3Doperator= (Vector3D< K > &&u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3Doperator+= (K k)
 
template<class K >
constexpr Vector3Doperator+= (Vector3D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3Doperator-= (K k)
 
template<class K >
constexpr Vector3Doperator-= (Vector3D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3Doperator*= (K k)
 
template<class K >
constexpr Vector3Doperator*= (Vector3D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3Doperator/= (K k)
 
template<class K >
constexpr Vector3Doperator/= (Vector3D< K > const &u)
 
template<class K >
constexpr std::common_type_t< T, K > operator|= (Vector3D< K > const &u) const
 
template<class K >
constexpr Vector3Doperator^= (Vector3D< K > const &u)
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3D< std::common_type_t< T, K > > operator+ (K k) const
 
template<class K >
constexpr Vector3D< std::common_type_t< T, K > > operator+ (Vector3D< K > const &u) const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3D< std::common_type_t< T, K > > operator- (K k) const
 
template<class K >
constexpr Vector3D< std::common_type_t< T, K > > operator- (Vector3D< K > const &u) const
 
constexpr Vector3D operator- () const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3D< std::common_type_t< T, K > > operator* (K k) const
 
template<class K >
constexpr Vector3D< std::common_type_t< T, K > > operator* (Vector3D< K > const &u) const
 
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3D< std::common_type_t< T, K > > operator/ (K k) const
 
template<class K >
constexpr Vector3D< std::common_type_t< T, K > > operator/ (Vector3D< K > const &u) const
 
template<class K >
constexpr std::common_type_t< T, K > operator| (Vector3D< K > const &u) const
 
template<class K >
constexpr Vector3D< std::common_type_t< T, K > > operator^ (Vector3D< K > const &u) const
 
template<class K >
constexpr bool operator== (Vector3D< K > const &u) const
 
template<class K >
constexpr bool operator!= (Vector3D< K > const &u) const
 
template<class K >
constexpr bool operator< (Vector3D< K > const &u) const
 
template<class K >
constexpr bool operator> (Vector3D< K > const &u) const
 
template<class K >
constexpr bool operator<= (Vector3D< K > const &u) const
 
template<class K >
constexpr bool operator>= (Vector3D< K > const &u) const
 
Utility::String toString () const
 

Detailed Description

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

A cartesian 3D vector, 2D homogeneous.

Constructor & Destructor Documentation

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

Construct the null vector

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

Construct a vector with passed values

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

Construct a vector with an unique value for all coordinates

Parameters
valuenew x, y and z values
template<class T>
constexpr NRE::Math::Vector3D< T >::Vector3D ( std::initializer_list< T >  list)

Construct a vector from an initializer list

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

Copy u into this

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

Move u into this

Parameters
uthe object to move
template<class T>
template<class K >
constexpr NRE::Math::Vector3D< T >::Vector3D ( Vector3D< 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::Vector3D< T >::Vector3D ( Vector2D< K > const &  u)

Convert a 2D vector into a 3D vector with a default z value

Parameters
uthe 2D vector to convert
template<class T>
template<class K >
constexpr NRE::Math::Vector3D< T >::Vector3D ( Vector4D< K > const &  u)

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

Parameters
uthe K-type 4D vector to convert
template<class T>
template<class K , class L , typename = UseIfArithmetic<L>>
constexpr NRE::Math::Vector3D< T >::Vector3D ( Vector2D< K > const &  u,
nZ 
)
inline

Convert a 2D vector into a 3D point with a passed z value

Parameters
uthe 2D vector to convert
nZthe new z value
template<class T>
NRE::Math::Vector3D< T >::~Vector3D ( )
default

Vector3D Deconstructor

Member Function Documentation

template<class T>
template<class K >
long double NRE::Math::Vector3D< T >::distance ( Vector3D< 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::Vector3D< T >::distanceSquared ( Vector3D< K > const &  v) const
Returns
the squared distance to another vector
template<class T>
constexpr T NRE::Math::Vector3D< T >::getB ( ) const
Returns
the z value
template<class T>
constexpr T NRE::Math::Vector3D< T >::getG ( ) const
Returns
the y value
template<class T>
constexpr T NRE::Math::Vector3D< T >::getR ( ) const
Returns
the x value
template<class T>
constexpr T NRE::Math::Vector3D< T >::getX ( ) const
Returns
the x value
template<class T>
constexpr T NRE::Math::Vector3D< T >::getY ( ) const
Returns
the y value
template<class T>
constexpr T NRE::Math::Vector3D< T >::getZ ( ) const
Returns
the z value
template<class T>
template<class K , typename = UseIfArithmetic<K>>
void NRE::Math::Vector3D< 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::Vector3D< T >::norm ( ) const
Returns
the vector's norm
template<class T>
Vector3D& NRE::Math::Vector3D< T >::normalize ( )

Normalize the vector

Returns
the reference of himself
template<class T>
constexpr T NRE::Math::Vector3D< T >::normSquared ( ) const
Returns
the squared vector's norm
template<class T>
template<class K >
constexpr bool NRE::Math::Vector3D< T >::operator!= ( Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< T >::operator* ( Vector3D< 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 Vector3D& NRE::Math::Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator*= ( Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< T >::operator+ ( Vector3D< 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 Vector3D& NRE::Math::Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator+= ( Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< T >::operator- ( Vector3D< 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 Vector3D NRE::Math::Vector3D< T >::operator- ( ) const

Compute the opposite version of this

Returns
the opposite vector
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr Vector3D& NRE::Math::Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator-= ( Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< T >::operator/ ( Vector3D< 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 Vector3D& NRE::Math::Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator/= ( Vector3D< 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::Vector3D< T >::operator< ( Vector3D< 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::Vector3D< T >::operator<= ( Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator= ( Vector3D< T > const &  u)
default

Copy u into this

Parameters
uthe object to copy into this
Returns
the reference of himself
template<class T>
constexpr Vector3D& NRE::Math::Vector3D< T >::operator= ( Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator= ( Vector3D< 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 Vector3D& NRE::Math::Vector3D< T >::operator= ( Vector3D< 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::Vector3D< T >::operator== ( Vector3D< 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::Vector3D< T >::operator> ( Vector3D< 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::Vector3D< T >::operator>= ( Vector3D< 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::Vector3D< 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::Vector3D< 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 Vector3D<std::common_type_t<T, K> > NRE::Math::Vector3D< T >::operator^ ( Vector3D< K > const &  u) const

Compute the vector resulting in the cross product of this and u

Parameters
uthe vector
Returns
the computed vector
template<class T>
template<class K >
constexpr Vector3D& NRE::Math::Vector3D< T >::operator^= ( Vector3D< K > const &  u)

Replace this by the cross product between this and u

Parameters
uthe vector
Returns
the reference of himself
template<class T>
template<class K >
constexpr std::common_type_t<T, K> NRE::Math::Vector3D< T >::operator| ( Vector3D< 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::Vector3D< T >::operator|= ( Vector3D< 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>>
Vector3D& NRE::Math::Vector3D< 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 >
Vector3D& NRE::Math::Vector3D< T >::pow ( Vector3D< 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 , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector3D< T >::setB ( b)
inline

Z setter

Parameters
bthe new value for z
template<class T>
template<class K , class L , class N , typename = UseIfArithmetic<K, L, N>>
constexpr void NRE::Math::Vector3D< T >::setCoord ( nX,
nY,
nZ 
)
inline

Set the values for x, y and z

Parameters
nXthe new value for x
nYthe new value for y
nZthe new value for z
template<class T>
template<class K , class L , typename = UseIfArithmetic<L>>
constexpr void NRE::Math::Vector3D< T >::setCoord ( Vector2D< K > const &  u,
nZ 
)
inline

Set the values for x, y and z with a base 2D vector

Parameters
uthe base 2D vector for x and y values
nZthe new value for z
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector3D< T >::setG ( g)
inline

Y setter

Parameters
gthe new value for y
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector3D< T >::setR ( r)
inline

X setter

Parameters
rthe new value for x
template<class T>
template<class K , class L , class N , typename = UseIfArithmetic<K, L, N>>
constexpr void NRE::Math::Vector3D< T >::setRGB ( r,
g,
b 
)
inline

Set the values for x, y and z

Parameters
rthe new value for x
gthe new value for y
bthe new value for z
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector3D< 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::Vector3D< T >::setY ( nY)
inline

Y setter

Parameters
nYthe new value for y
template<class T>
template<class K , typename = UseIfArithmetic<K>>
constexpr void NRE::Math::Vector3D< T >::setZ ( nZ)
inline

Z setter

Parameters
nZthe new value for z
template<class T>
Utility::String NRE::Math::Vector3D< T >::toString ( ) const

Convert the vector into a string

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

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