Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::Vector3< T > Class Template Reference

Math class that represents an element of the three dimensional vector space. More...

Public Member Functions

 Vector3 (T X, T Y, T Z)
 Constructs a Vector3 object from its coordinates. More...
 
 Vector3 (T X, const Vector2< T > &vec)
 Constructs a Vector3 object from a component and a Vector2<T> More...
 
 Vector3 (T scale)
 Constructs explicitely a Vector3 object from its "scale". More...
 
 Vector3 (const T vec[3])
 Constructs a Vector3 object from an array of three elements. More...
 
 Vector3 (const Vector2< T > &vec, T Z=0.0)
 Constructs a Vector3 object from a Vector2<T> and a component. More...
 
template<typename U >
 Vector3 (const Vector3< U > &vec)
 Constructs a Vector3 object from another type of Vector3. More...
 
 Vector3 (const Vector3 &vec)=default
 
 Vector3 (const Vector4< T > &vec)
 Constructs a Vector3 object from a Vector4. More...
 
AbsDotProduct (const Vector3 &vec) const
 Calculates the absolute dot (scalar) product with two vectors. More...
 
AngleBetween (const Vector3 &vec) const
 Calculates the angle between two vectors in orthonormal basis. More...
 
Vector3 CrossProduct (const Vector3 &vec) const
 Calculates the cross (scalar) product with two vectors. More...
 
Distance (const Vector3 &vec) const
 Calculates the distance between two vectors. More...
 
float Distancef (const Vector3 &vec) const
 Calculates the distance between two vectors. More...
 
DotProduct (const Vector3 &vec) const
 Calculates the dot (scalar) product with two vectors. More...
 
GetLength () const
 Calculates the length (magnitude) of the vector. More...
 
float GetLengthf () const
 Calculates the length (magnitude) of the vector. More...
 
Vector3 GetNormal (T *length=nullptr) const
 Gets a copy normalized of the vector. More...
 
GetSquaredLength () const
 Calculates the squared length (magnitude) of the vector. More...
 
Vector3MakeBackward ()
 Makes the vector (0, 0, 1) More...
 
Vector3MakeDown ()
 Makes the vector (0, -1, 0) More...
 
Vector3MakeForward ()
 Makes the vector (0, 0, -1) More...
 
Vector3MakeLeft ()
 Makes the vector (-1, 0, 0) More...
 
Vector3MakeRight ()
 Makes the vector (1, 0, 0) More...
 
Vector3MakeUnit ()
 Makes the vector (1, 1, 1) More...
 
Vector3MakeUnitX ()
 Makes the vector (1, 0, 0) More...
 
Vector3MakeUnitY ()
 Makes the vector (0, 1, 0) More...
 
Vector3MakeUnitZ ()
 Makes the vector (0, 0, 1) More...
 
Vector3MakeUp ()
 Makes the vector (0, 1, 0) More...
 
Vector3MakeZero ()
 Makes the vector (0, 0, 0) More...
 
Vector3Maximize (const Vector3 &vec)
 Sets this vector's components to the maximum of its own and other components. More...
 
Vector3Minimize (const Vector3 &vec)
 Sets this vector's components to the minimum of its own and other components. More...
 
Vector3Normalize (T *length=nullptr)
 Normalizes the current vector. More...
 
Vector3Set (T X, T Y, T Z)
 Sets the components of the vector. More...
 
Vector3Set (T X, const Vector2< T > &vec)
 Sets the components of the vector from a component and a Vector2. More...
 
Vector3Set (T scale)
 Sets the components of the vector from a "scale". More...
 
Vector3Set (const T vec[3])
 Sets the components of the vector from an array of three elements. More...
 
Vector3Set (const Vector2< T > &vec, T Z=0.0)
 Sets the components of the vector from a Vector2 and a component. More...
 
Vector3Set (const Vector3< T > &vec)
 Sets the components of the vector from another vector. More...
 
template<typename U >
Vector3Set (const Vector3< U > &vec)
 
Vector3Set (const Vector4< T > &vec)
 Sets the components of the vector from a Vector4. More...
 
SquaredDistance (const Vector3 &vec) const
 Calculates the squared distance between two vectors. More...
 
String ToString () const
 Gives a string representation. More...
 
 operator T* ()
 Converts vector to pointer to its own data. More...
 
 operator const T * () const
 Converts vector to const pointer to its own data. More...
 
const Vector3operator+ () const
 Helps to represent the sign of the vector. More...
 
Vector3 operator- () const
 Negates the components of the vector. More...
 
Vector3 operator+ (const Vector3 &vec) const
 Adds the components of the vector with other vector. More...
 
Vector3 operator- (const Vector3 &vec) const
 Substracts the components of the vector with other vector. More...
 
Vector3 operator* (const Vector3 &vec) const
 Multiplies the components of the vector with other vector. More...
 
Vector3 operator* (T scale) const
 Multiplies the components of the vector with a scalar. More...
 
Vector3 operator/ (const Vector3 &vec) const
 Divides the components of the vector with other vector. More...
 
Vector3 operator/ (T scale) const
 Divides the components of the vector with a scalar. More...
 
Vector3operator= (const Vector3 &vec)=default
 
Vector3operator+= (const Vector3 &vec)
 Adds the components of other vector to this vector. More...
 
Vector3operator-= (const Vector3 &vec)
 Substracts the components of other vector to this vector. More...
 
Vector3operator*= (const Vector3 &vec)
 Multiplies the components of other vector to this vector. More...
 
Vector3operator*= (T scale)
 Multiplies the components of other vector with a scalar. More...
 
Vector3operator/= (const Vector3 &vec)
 Multiplies the components of other vector to this vector. More...
 
Vector3operator/= (T scale)
 Divides the components of other vector with a scalar. More...
 
bool operator== (const Vector3 &vec) const
 Compares the vector to other one. More...
 
bool operator!= (const Vector3 &vec) const
 Compares the vector to other one. More...
 
bool operator< (const Vector3 &vec) const
 Compares the vector to other one. More...
 
bool operator<= (const Vector3 &vec) const
 Compares the vector to other one. More...
 
bool operator> (const Vector3 &vec) const
 Compares the vector to other one. More...
 
bool operator>= (const Vector3 &vec) const
 Compares the vector to other one. More...
 
template<typename U >
Vector3< T > & Set (const Vector3< U > &vec)
 Sets the components of the vector from another type of Vector3. More...
 

Static Public Member Functions

static Vector3 Backward ()
 Shorthand for the vector (0, 0, 1) More...
 
static Vector3 CrossProduct (const Vector3 &vec1, const Vector3 &vec2)
 Calculates the cross product with two vectors. More...
 
static T DotProduct (const Vector3 &vec1, const Vector3 &vec2)
 Calculates the dot (scalar) product with two vectors. More...
 
static T Distance (const Vector3 &vec1, const Vector3 &vec2)
 Measure the distance between two points Shorthand for vec1.Distance(vec2) More...
 
static float Distancef (const Vector3 &vec1, const Vector3 &vec2)
 Measure the distance between two points as a float Shorthand for vec1.Distancef(vec2) More...
 
static Vector3 Down ()
 Shorthand for the vector (0, -1, 0) More...
 
static Vector3 Forward ()
 Shorthand for the vector (0, 0, -1) More...
 
static Vector3 Left ()
 Shorthand for the vector (-1, 0, 0) More...
 
static Vector3 Lerp (const Vector3 &from, const Vector3 &to, T interpolation)
 Interpolates the vector to other one with a factor of interpolation. More...
 
static Vector3 Normalize (const Vector3 &vec)
 Gives the normalized vector. More...
 
static Vector3 Right ()
 Shorthand for the vector (1, 0, 0) More...
 
static T SquaredDistance (const Vector3 &vec1, const Vector3 &vec2)
 Calculates the squared distance between two vectors. More...
 
static Vector3 Unit ()
 Shorthand for the vector (1, 1, 1) More...
 
static Vector3 UnitX ()
 Shorthand for the vector (1, 0, 0) More...
 
static Vector3 UnitY ()
 Shorthand for the vector (0, 1, 0) More...
 
static Vector3 UnitZ ()
 Shorthand for the vector (0, 0, 1) More...
 
static Vector3 Up ()
 Shorthand for the vector (0, 1, 0) More...
 
static Vector3 Zero ()
 Shorthand for the vector (0, 0, 0) More...
 

Public Attributes

x
 
y
 
z
 

Detailed Description

template<typename T>
class Nz::Vector3< T >

Math class that represents an element of the three dimensional vector space.

Remarks
The basis is said to be "right-hand". It means that with your right hand, the thumb is X positive, the index finger Y positive and the middle finger (pointing to you) Z positive

Constructor & Destructor Documentation

◆ Vector3() [1/7]

template<typename T>
Nz::Vector3< T >::Vector3 ( X,
Y,
Z 
)

Constructs a Vector3 object from its coordinates.

Parameters
XX component
YY component
ZZ component

◆ Vector3() [2/7]

template<typename T>
Nz::Vector3< T >::Vector3 ( X,
const Vector2< T > &  vec 
)

Constructs a Vector3 object from a component and a Vector2<T>

Parameters
XX component
vecvec.X = Y component and vec.y = Z component

◆ Vector3() [3/7]

template<typename T>
Nz::Vector3< T >::Vector3 ( scale)
explicit

Constructs explicitely a Vector3 object from its "scale".

Parameters
scaleX component = Y component = Z component

◆ Vector3() [4/7]

template<typename T>
Nz::Vector3< T >::Vector3 ( const T  vec[3])

Constructs a Vector3 object from an array of three elements.

Parameters
vec[3]vec[0] is X component, vec[1] is Y component and vec[2] is Z component

◆ Vector3() [5/7]

template<typename T>
Nz::Vector3< T >::Vector3 ( const Vector2< T > &  vec,
Z = 0.0 
)

Constructs a Vector3 object from a Vector2<T> and a component.

Parameters
vecvec.X = X component and vec.y = Y component
ZZ component

◆ Vector3() [6/7]

template<typename T >
template<typename U >
Nz::Vector3< T >::Vector3 ( const Vector3< U > &  vec)
explicit

Constructs a Vector3 object from another type of Vector3.

Parameters
vecVector of type U to convert to type T

◆ Vector3() [7/7]

template<typename T>
Nz::Vector3< T >::Vector3 ( const Vector4< T > &  vec)
explicit

Constructs a Vector3 object from a Vector4.

Parameters
vecVector4 where only the first three components are taken

Member Function Documentation

◆ AbsDotProduct()

template<typename T >
T Nz::Vector3< T >::AbsDotProduct ( const Vector3< T > &  vec) const

Calculates the absolute dot (scalar) product with two vectors.

Returns
The dot product with absolutes values on each component
Parameters
vecThe other vector to calculate the absolute dot product with
See also
DotProduct

◆ AngleBetween()

template<typename T >
T Nz::Vector3< T >::AngleBetween ( const Vector3< T > &  vec) const

Calculates the angle between two vectors in orthonormal basis.

Returns
The angle unit depends of NAZARA_MATH_ANGLE_RADIAN in the range 0..pi
Parameters
vecThe other vector to measure the angle with
Remarks
The vectors do not need to be normalised
Produce a NazaraError if one of the vec components is null with NAZARA_MATH_SAFE defined
Exceptions
std::domain_errorif NAZARA_MATH_SAFE is defined and one of the vec components is null
See also
NormalizeAngle

◆ Backward()

template<typename T >
Vector3< T > Nz::Vector3< T >::Backward ( )
static

Shorthand for the vector (0, 0, 1)

Returns
A vector with components (0, 0, 1)
See also
MakeBackward

◆ CrossProduct() [1/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::CrossProduct ( const Vector3< T > &  vec) const

Calculates the cross (scalar) product with two vectors.

Returns
The vector of the cross product according to "right-hand" rule
Parameters
vecThe other vector to calculate the cross product with
See also
CrossProduct

◆ CrossProduct() [2/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::CrossProduct ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)
static

Calculates the cross product with two vectors.

Returns
A vector which is the cross product according to "right-hand" rule
Parameters
vec1The first vector to calculate the cross product with
vec2The second vector to calculate the cross product with
See also
CrossProduct

◆ Distance() [1/2]

template<typename T >
T Nz::Vector3< T >::Distance ( const Vector3< T > &  vec) const

Calculates the distance between two vectors.

Returns
The metric distance between two vectors with euclidean norm
Parameters
vecThe other vector to measure the distance with
See also
SquaredDistance

◆ Distance() [2/2]

template<typename T >
T Nz::Vector3< T >::Distance ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)
static

Measure the distance between two points Shorthand for vec1.Distance(vec2)

param vec1 the first point param vec2 the second point

Returns
The distance between the two vectors
See also
SquaredDistance

◆ Distancef() [1/2]

template<typename T >
float Nz::Vector3< T >::Distancef ( const Vector3< T > &  vec) const

Calculates the distance between two vectors.

Returns
The metric distance in float between two vectors with euclidean norm
Parameters
vecThe other vector to measure the distance with

◆ Distancef() [2/2]

template<typename T >
float Nz::Vector3< T >::Distancef ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)
static

Measure the distance between two points as a float Shorthand for vec1.Distancef(vec2)

param vec1 the first point param vec2 the second point

Returns
The distance between the two vectors as a float
See also
SquaredDistancef

◆ DotProduct() [1/2]

template<typename T >
T Nz::Vector3< T >::DotProduct ( const Vector3< T > &  vec) const

Calculates the dot (scalar) product with two vectors.

Returns
The value of the dot product
Parameters
vecThe other vector to calculate the dot product with
See also
AbsDotProduct, DotProduct

◆ DotProduct() [2/2]

template<typename T >
T Nz::Vector3< T >::DotProduct ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)
static

Calculates the dot (scalar) product with two vectors.

Returns
The value of the dot product
Parameters
vec1The first vector to calculate the dot product with
vec2The second vector to calculate the dot product with
See also
AbsDotProduct, DotProduct

◆ Down()

template<typename T >
Vector3< T > Nz::Vector3< T >::Down ( )
static

Shorthand for the vector (0, -1, 0)

Returns
A vector with components (0, -1, 0)
See also
MakeDown

◆ Forward()

template<typename T >
Vector3< T > Nz::Vector3< T >::Forward ( )
static

Shorthand for the vector (0, 0, -1)

Returns
A vector with components (0, 0, -1)
See also
Forward

◆ GetLength()

template<typename T >
T Nz::Vector3< T >::GetLength ( ) const

Calculates the length (magnitude) of the vector.

Returns
The length of the vector
See also
GetSquaredLength

◆ GetLengthf()

template<typename T >
float Nz::Vector3< T >::GetLengthf ( ) const

Calculates the length (magnitude) of the vector.

Returns
The length in float of the vector

◆ GetNormal()

template<typename T>
Vector3< T > Nz::Vector3< T >::GetNormal ( T *  length = nullptr) const

Gets a copy normalized of the vector.

Returns
A new vector which is the vector normalized
Parameters
lengthOptional argument to obtain the length's ratio of the vector and the unit-length
Remarks
If ths vector is (0, 0, 0), then it returns (0, 0, 0) and length is 0
See also
Normalize

◆ GetSquaredLength()

template<typename T >
T Nz::Vector3< T >::GetSquaredLength ( ) const

Calculates the squared length (magnitude) of the vector.

Returns
The squared length of the vector
See also
GetLength

◆ Left()

template<typename T >
Vector3< T > Nz::Vector3< T >::Left ( )
static

Shorthand for the vector (-1, 0, 0)

Returns
A vector with components (-1, 0, 0)
See also
MakeLeft

◆ Lerp()

template<typename T>
Vector3< T > Nz::Vector3< T >::Lerp ( const Vector3< T > &  from,
const Vector3< T > &  to,
interpolation 
)
static

Interpolates the vector to other one with a factor of interpolation.

Returns
A new vector which is the interpolation of two vectors
Parameters
fromInitial vector
toTarget vector
interpolationFactor of interpolation
Remarks
interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
See also
Lerp

◆ MakeBackward()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeBackward ( )

Makes the vector (0, 0, 1)

Returns
A reference to this vector with components (0, 0, 1)
See also
Backward

◆ MakeDown()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeDown ( )

Makes the vector (0, -1, 0)

Returns
A reference to this vector with components (0, -1, 0)
See also
Down

◆ MakeForward()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeForward ( )

Makes the vector (0, 0, -1)

Returns
A reference to this vector with components (0, 0, -1)
See also
Forward

◆ MakeLeft()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeLeft ( )

Makes the vector (-1, 0, 0)

Returns
A reference to this vector with components (-1, 0, 0)
See also
Left

◆ MakeRight()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeRight ( )

Makes the vector (1, 0, 0)

Returns
A reference to this vector with components (1, 0, 0)
See also
Right

◆ MakeUnit()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeUnit ( )

Makes the vector (1, 1, 1)

Returns
A reference to this vector with components (1, 1, 1)
See also
Unit

◆ MakeUnitX()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeUnitX ( )

Makes the vector (1, 0, 0)

Returns
A reference to this vector with components (1, 0, 0)
See also
UnitX

◆ MakeUnitY()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeUnitY ( )

Makes the vector (0, 1, 0)

Returns
A reference to this vector with components (0, 1, 0)
See also
UnitY

◆ MakeUnitZ()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeUnitZ ( )

Makes the vector (0, 0, 1)

Returns
A reference to this vector with components (0, 0, 1)
See also
UnitZ

◆ MakeUp()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeUp ( )

Makes the vector (0, 1, 0)

Returns
A reference to this vector with components (0, 1, 0)
See also
Up

◆ MakeZero()

template<typename T >
Vector3< T > & Nz::Vector3< T >::MakeZero ( )

Makes the vector (0, 0, 0)

Returns
A reference to this vector with components (0, 0, 0)
See also
Zero

◆ Maximize()

template<typename T >
Vector3< T > & Nz::Vector3< T >::Maximize ( const Vector3< T > &  vec)

Sets this vector's components to the maximum of its own and other components.

Returns
A reference to this vector with replaced values with the corresponding max value
Parameters
vecOther vector to compare the components with
See also
Minimize

◆ Minimize()

template<typename T >
Vector3< T > & Nz::Vector3< T >::Minimize ( const Vector3< T > &  vec)

Sets this vector's components to the minimum of its own and other components.

Returns
A reference to this vector with replaced values with the corresponding min value
Parameters
vecOther vector to compare the components with
See also
Maximize

◆ Normalize() [1/2]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Normalize ( T *  length = nullptr)

Normalizes the current vector.

Returns
A reference to this vector
Parameters
lengthOptional argument to obtain the length's ratio of the vector and the unit-length
Remarks
If the vector is (0, 0, 0), then it returns (0, 0, 0) and length is 0
See also
GetNormal

◆ Normalize() [2/2]

template<typename T>
Vector3< T > Nz::Vector3< T >::Normalize ( const Vector3< T > &  vec)
static

Gives the normalized vector.

Returns
A normalized vector from the vec
Parameters
vecVector to normalize
Remarks
If the vector is (0, 0, 0), then it returns (0, 0, 0)
See also
GetNormal

◆ operator const T *()

template<typename T >
Nz::Vector3< T >::operator const T * ( ) const

Converts vector to const pointer to its own data.

Returns
A constant pointer to the own data
Remarks
Access to index greather than 2 is undefined behavior

◆ operator T*()

template<typename T >
Nz::Vector3< T >::operator T* ( )

Converts vector to pointer to its own data.

Returns
A pointer to the own data
Remarks
Access to index greather than 2 is undefined behavior

◆ operator!=()

template<typename T >
bool Nz::Vector3< T >::operator!= ( const Vector3< T > &  vec) const

Compares the vector to other one.

Returns
false if the vectors are the same
Parameters
vecOther vector to compare with

◆ operator*() [1/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::operator* ( const Vector3< T > &  vec) const

Multiplies the components of the vector with other vector.

Returns
A vector where components are the product of this vector and the other one
Parameters
vecThe other vector to multiply components with

◆ operator*() [2/2]

template<typename T>
Vector3< T > Nz::Vector3< T >::operator* ( scale) const

Multiplies the components of the vector with a scalar.

Returns
A vector where components are the product of this vector and the scalar
Parameters
scaleThe scalar to multiply components with

◆ operator*=() [1/2]

template<typename T >
Vector3< T > & Nz::Vector3< T >::operator*= ( const Vector3< T > &  vec)

Multiplies the components of other vector to this vector.

Returns
A reference to this vector where components are the product of this vector and the other one
Parameters
vecThe other vector to multiply components with

◆ operator*=() [2/2]

template<typename T>
Vector3< T > & Nz::Vector3< T >::operator*= ( scale)

Multiplies the components of other vector with a scalar.

Returns
A reference to this vector where components are the product of this vector and the scalar
Parameters
vecThe other vector to multiply components with

◆ operator+() [1/2]

template<typename T >
const Vector3< T > & Nz::Vector3< T >::operator+ ( ) const

Helps to represent the sign of the vector.

Returns
A constant reference to this vector

◆ operator+() [2/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::operator+ ( const Vector3< T > &  vec) const

Adds the components of the vector with other vector.

Returns
A vector where components are the sum of this vector and the other one
Parameters
vecThe other vector to add components with

◆ operator+=()

template<typename T >
Vector3< T > & Nz::Vector3< T >::operator+= ( const Vector3< T > &  vec)

Adds the components of other vector to this vector.

Returns
A reference to this vector where components are the sum of this vector and the other one
Parameters
vecThe other vector to add components with

◆ operator-() [1/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::operator- ( ) const

Negates the components of the vector.

Returns
A constant reference to this vector with negate components

◆ operator-() [2/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::operator- ( const Vector3< T > &  vec) const

Substracts the components of the vector with other vector.

Returns
A vector where components are the difference of this vector and the other one
Parameters
vecThe other vector to substract components with

◆ operator-=()

template<typename T >
Vector3< T > & Nz::Vector3< T >::operator-= ( const Vector3< T > &  vec)

Substracts the components of other vector to this vector.

Returns
A reference to this vector where components are the difference of this vector and the other one
Parameters
vecThe other vector to substract components with

◆ operator/() [1/2]

template<typename T >
Vector3< T > Nz::Vector3< T >::operator/ ( const Vector3< T > &  vec) const

Divides the components of the vector with other vector.

Returns
A vector where components are the quotient of this vector and the other one
Parameters
vecThe other vector to divide components with
Remarks
Produce a NazaraError if one of the vec components is null with NAZARA_MATH_SAFE defined
Exceptions
std::domain_errorif NAZARA_MATH_SAFE is defined and one of the vec components is null

◆ operator/() [2/2]

template<typename T>
Vector3< T > Nz::Vector3< T >::operator/ ( scale) const

Divides the components of the vector with a scalar.

Returns
A vector where components are the quotient of this vector and the scalar
Parameters
scaleThe scalar to divide components with
Remarks
Produce a NazaraError if scale is null with NAZARA_MATH_SAFE defined
Exceptions
std::domain_errorif NAZARA_MATH_SAFE is defined and scale is null

◆ operator/=() [1/2]

template<typename T >
Vector3< T > & Nz::Vector3< T >::operator/= ( const Vector3< T > &  vec)

Multiplies the components of other vector to this vector.

Returns
A reference to this vector where components are the quotient of this vector and the other one
Parameters
vecThe other vector to multiply components with
Remarks
Produce a NazaraError if one of the vec components is null with NAZARA_MATH_SAFE defined
Exceptions
std::domain_errorif NAZARA_MATH_SAFE is defined and one of the vec components is null

◆ operator/=() [2/2]

template<typename T>
Vector3< T > & Nz::Vector3< T >::operator/= ( scale)

Divides the components of other vector with a scalar.

Returns
A reference to this vector where components are the quotient of this vector and the scalar
Parameters
vecThe other vector to divide components with
Remarks
Produce a NazaraError if scale is null with NAZARA_MATH_SAFE defined
Exceptions
std::domain_errorif NAZARA_MATH_SAFE is defined and scale is null

◆ operator<()

template<typename T >
bool Nz::Vector3< T >::operator< ( const Vector3< T > &  vec) const

Compares the vector to other one.

Returns
true if this vector has its first components inferior to the other ones
Parameters
vecOther vector to compare with

◆ operator<=()

template<typename T >
bool Nz::Vector3< T >::operator<= ( const Vector3< T > &  vec) const

Compares the vector to other one.

Returns
true if this vector has its first components inferior or equal to the other ones
Parameters
vecOther vector to compare with

◆ operator==()

template<typename T >
bool Nz::Vector3< T >::operator== ( const Vector3< T > &  vec) const

Compares the vector to other one.

Returns
true if the vectors are the same
Parameters
vecOther vector to compare with

◆ operator>()

template<typename T >
bool Nz::Vector3< T >::operator> ( const Vector3< T > &  vec) const

Compares the vector to other one.

Returns
true if this vector has its first components superior to the other ones
Parameters
vecOther vector to compare with

◆ operator>=()

template<typename T >
bool Nz::Vector3< T >::operator>= ( const Vector3< T > &  vec) const

Compares the vector to other one.

Returns
true if this vector has its first components superior or equal to the other ones
Parameters
vecOther vector to compare with

◆ Right()

template<typename T >
Vector3< T > Nz::Vector3< T >::Right ( )
static

Shorthand for the vector (1, 0, 0)

Returns
A vector with components (1, 0, 0)
See also
MakeRight

◆ Set() [1/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( X,
Y,
Z 
)

Sets the components of the vector.

Returns
A reference to this vector
Parameters
XX component
YY component
ZZ component

◆ Set() [2/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( X,
const Vector2< T > &  vec 
)

Sets the components of the vector from a component and a Vector2.

Parameters
XX component
vecvec.X = Y component and vec.y = Z component

◆ Set() [3/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( scale)

Sets the components of the vector from a "scale".

Returns
A reference to this vector
Parameters
scaleX component = Y component = Z component

◆ Set() [4/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( const T  vec[3])

Sets the components of the vector from an array of three elements.

Returns
A reference to this vector
Parameters
vec[3]vec[0] is X component, vec[1] is Y component and vec[2] is Z component

◆ Set() [5/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( const Vector2< T > &  vec,
Z = 0.0 
)

Sets the components of the vector from a Vector2 and a component.

Parameters
vecvec.X = X component and vec.y = Y component
ZZ component

◆ Set() [6/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( const Vector3< T > &  vec)

Sets the components of the vector from another vector.

Returns
A reference to this vector
Parameters
vecThe other vector

◆ Set() [7/8]

template<typename T>
Vector3< T > & Nz::Vector3< T >::Set ( const Vector4< T > &  vec)

Sets the components of the vector from a Vector4.

Returns
A reference to this vector
Parameters
vecVector4 where only the first three components are taken

◆ Set() [8/8]

template<typename T>
template<typename U >
Vector3<T>& Nz::Vector3< T >::Set ( const Vector3< U > &  vec)

Sets the components of the vector from another type of Vector3.

Returns
A reference to this vector
Parameters
vecVector of type U to convert its components

◆ SquaredDistance() [1/2]

template<typename T >
T Nz::Vector3< T >::SquaredDistance ( const Vector3< T > &  vec) const

Calculates the squared distance between two vectors.

Returns
The metric distance between two vectors with the squared euclidean norm
Parameters
vecThe other vector to measure the distance with
See also
Distance

◆ SquaredDistance() [2/2]

template<typename T >
T Nz::Vector3< T >::SquaredDistance ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)
static

Calculates the squared distance between two vectors.

Returns
The metric distance between two vectors with the squared euclidean norm
Parameters
vec1The first point to measure the distance with
vec2The second point to measure the distance with
See also
Distance

◆ ToString()

template<typename T >
String Nz::Vector3< T >::ToString ( ) const

Gives a string representation.

Returns
A string representation of the object: "Vector3(x, y, z)"

◆ Unit()

template<typename T >
Vector3< T > Nz::Vector3< T >::Unit ( )
static

Shorthand for the vector (1, 1, 1)

Returns
A vector with components (1, 1, 1)
See also
MakeUnit

◆ UnitX()

template<typename T >
Vector3< T > Nz::Vector3< T >::UnitX ( )
static

Shorthand for the vector (1, 0, 0)

Returns
A vector with components (1, 0, 0)
See also
MakeUnitX

◆ UnitY()

template<typename T >
Vector3< T > Nz::Vector3< T >::UnitY ( )
static

Shorthand for the vector (0, 1, 0)

Returns
A vector with components (0, 1, 0)
See also
MakeUnitY

◆ UnitZ()

template<typename T >
Vector3< T > Nz::Vector3< T >::UnitZ ( )
static

Shorthand for the vector (0, 0, 1)

Returns
A vector with components (0, 0, 1)
See also
MakeUnitZ

◆ Up()

template<typename T >
Vector3< T > Nz::Vector3< T >::Up ( )
static

Shorthand for the vector (0, 1, 0)

Returns
A vector with components (0, 1, 0)
See also
MakeUp

◆ Zero()

template<typename T >
Vector3< T > Nz::Vector3< T >::Zero ( )
static

Shorthand for the vector (0, 0, 0)

Returns
A vector with components (0, 0, 0)
See also
MakeZero

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