Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
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... | |
T | AbsDotProduct (const Vector3 &vec) const |
Calculates the absolute dot (scalar) product with two vectors. More... | |
T | 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... | |
T | 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... | |
T | DotProduct (const Vector3 &vec) const |
Calculates the dot (scalar) product with two vectors. More... | |
T | 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... | |
T | GetSquaredLength () const |
Calculates the squared length (magnitude) of the vector. More... | |
Vector3 & | MakeBackward () |
Makes the vector (0, 0, 1) More... | |
Vector3 & | MakeDown () |
Makes the vector (0, -1, 0) More... | |
Vector3 & | MakeForward () |
Makes the vector (0, 0, -1) More... | |
Vector3 & | MakeLeft () |
Makes the vector (-1, 0, 0) More... | |
Vector3 & | MakeRight () |
Makes the vector (1, 0, 0) More... | |
Vector3 & | MakeUnit () |
Makes the vector (1, 1, 1) More... | |
Vector3 & | MakeUnitX () |
Makes the vector (1, 0, 0) More... | |
Vector3 & | MakeUnitY () |
Makes the vector (0, 1, 0) More... | |
Vector3 & | MakeUnitZ () |
Makes the vector (0, 0, 1) More... | |
Vector3 & | MakeUp () |
Makes the vector (0, 1, 0) More... | |
Vector3 & | MakeZero () |
Makes the vector (0, 0, 0) More... | |
Vector3 & | Maximize (const Vector3 &vec) |
Sets this vector's components to the maximum of its own and other components. More... | |
Vector3 & | Minimize (const Vector3 &vec) |
Sets this vector's components to the minimum of its own and other components. More... | |
Vector3 & | Normalize (T *length=nullptr) |
Normalizes the current vector. More... | |
Vector3 & | Set (T X, T Y, T Z) |
Sets the components of the vector. More... | |
Vector3 & | Set (T X, const Vector2< T > &vec) |
Sets the components of the vector from a component and a Vector2. More... | |
Vector3 & | Set (T scale) |
Sets the components of the vector from a "scale". More... | |
Vector3 & | Set (const T vec[3]) |
Sets the components of the vector from an array of three elements. More... | |
Vector3 & | Set (const Vector2< T > &vec, T Z=0.0) |
Sets the components of the vector from a Vector2 and a component. More... | |
Vector3 & | Set (const Vector3< T > &vec) |
Sets the components of the vector from another vector. More... | |
template<typename U > | |
Vector3 & | Set (const Vector3< U > &vec) |
Vector3 & | Set (const Vector4< T > &vec) |
Sets the components of the vector from a Vector4. More... | |
T | 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 Vector3 & | operator+ () 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... | |
Vector3 & | operator= (const Vector3 &vec)=default |
Vector3 & | operator+= (const Vector3 &vec) |
Adds the components of other vector to this vector. More... | |
Vector3 & | operator-= (const Vector3 &vec) |
Substracts the components of other vector to this vector. More... | |
Vector3 & | operator*= (const Vector3 &vec) |
Multiplies the components of other vector to this vector. More... | |
Vector3 & | operator*= (T scale) |
Multiplies the components of other vector with a scalar. More... | |
Vector3 & | operator/= (const Vector3 &vec) |
Multiplies the components of other vector to this vector. More... | |
Vector3 & | operator/= (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 | |
T | x |
T | y |
T | z |
Math class that represents an element of the three dimensional vector space.
Nz::Vector3< T >::Vector3 | ( | T | X, |
T | Y, | ||
T | Z | ||
) |
Constructs a Vector3 object from its coordinates.
X | X component |
Y | Y component |
Z | Z component |
Nz::Vector3< T >::Vector3 | ( | T | X, |
const Vector2< T > & | vec | ||
) |
Constructs a Vector3 object from a component and a Vector2<T>
X | X component |
vec | vec.X = Y component and vec.y = Z component |
|
explicit |
Constructs explicitely a Vector3 object from its "scale".
scale | X component = Y component = Z component |
Nz::Vector3< T >::Vector3 | ( | const T | vec[3] | ) |
Constructs a Vector3 object from an array of three elements.
vec[3] | vec[0] is X component, vec[1] is Y component and vec[2] is Z component |
Nz::Vector3< T >::Vector3 | ( | const Vector2< T > & | vec, |
T | Z = 0.0 |
||
) |
Constructs a Vector3 object from a Vector2<T> and a component.
vec | vec.X = X component and vec.y = Y component |
Z | Z component |
|
explicit |
|
explicit |
T Nz::Vector3< T >::AbsDotProduct | ( | const Vector3< T > & | vec | ) | const |
Calculates the absolute dot (scalar) product with two vectors.
vec | The other vector to calculate the absolute dot product with |
T Nz::Vector3< T >::AngleBetween | ( | const Vector3< T > & | vec | ) | const |
Calculates the angle between two vectors in orthonormal basis.
vec | The other vector to measure the angle with |
std::domain_error | if NAZARA_MATH_SAFE is defined and one of the vec components is null |
|
static |
Vector3< T > Nz::Vector3< T >::CrossProduct | ( | const Vector3< T > & | vec | ) | const |
Calculates the cross (scalar) product with two vectors.
vec | The other vector to calculate the cross product with |
|
static |
Calculates the cross product with two vectors.
vec1 | The first vector to calculate the cross product with |
vec2 | The second vector to calculate the cross product with |
T Nz::Vector3< T >::Distance | ( | const Vector3< T > & | vec | ) | const |
Calculates the distance between two vectors.
vec | The other vector to measure the distance with |
|
static |
Measure the distance between two points Shorthand for vec1.Distance(vec2)
param vec1 the first point param vec2 the second point
float Nz::Vector3< T >::Distancef | ( | const Vector3< T > & | vec | ) | const |
Calculates the distance between two vectors.
vec | The other vector to measure the distance with |
|
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
T Nz::Vector3< T >::DotProduct | ( | const Vector3< T > & | vec | ) | const |
Calculates the dot (scalar) product with two vectors.
vec | The other vector to calculate the dot product with |
|
static |
Calculates the dot (scalar) product with two vectors.
vec1 | The first vector to calculate the dot product with |
vec2 | The second vector to calculate the dot product with |
|
static |
|
static |
T Nz::Vector3< T >::GetLength | ( | ) | const |
Calculates the length (magnitude) of the vector.
float Nz::Vector3< T >::GetLengthf | ( | ) | const |
Calculates the length (magnitude) of the vector.
Vector3< T > Nz::Vector3< T >::GetNormal | ( | T * | length = nullptr | ) | const |
Gets a copy normalized of the vector.
length | Optional argument to obtain the length's ratio of the vector and the unit-length |
T Nz::Vector3< T >::GetSquaredLength | ( | ) | const |
Calculates the squared length (magnitude) of the vector.
|
static |
|
static |
Interpolates the vector to other one with a factor of interpolation.
from | Initial vector |
to | Target vector |
interpolation | Factor of interpolation |
Vector3< T > & Nz::Vector3< T >::MakeBackward | ( | ) |
Makes the vector (0, 0, 1)
Vector3< T > & Nz::Vector3< T >::MakeDown | ( | ) |
Makes the vector (0, -1, 0)
Vector3< T > & Nz::Vector3< T >::MakeForward | ( | ) |
Makes the vector (0, 0, -1)
Vector3< T > & Nz::Vector3< T >::MakeLeft | ( | ) |
Makes the vector (-1, 0, 0)
Vector3< T > & Nz::Vector3< T >::MakeRight | ( | ) |
Makes the vector (1, 0, 0)
Vector3< T > & Nz::Vector3< T >::MakeUnit | ( | ) |
Vector3< T > & Nz::Vector3< T >::MakeUnitX | ( | ) |
Makes the vector (1, 0, 0)
Vector3< T > & Nz::Vector3< T >::MakeUnitY | ( | ) |
Makes the vector (0, 1, 0)
Vector3< T > & Nz::Vector3< T >::MakeUnitZ | ( | ) |
Makes the vector (0, 0, 1)
Vector3< T > & Nz::Vector3< T >::MakeUp | ( | ) |
Vector3< T > & Nz::Vector3< T >::MakeZero | ( | ) |
Vector3< T > & Nz::Vector3< T >::Maximize | ( | const Vector3< T > & | vec | ) |
Sets this vector's components to the maximum of its own and other components.
vec | Other vector to compare the components with |
Vector3< T > & Nz::Vector3< T >::Minimize | ( | const Vector3< T > & | vec | ) |
Sets this vector's components to the minimum of its own and other components.
vec | Other vector to compare the components with |
Vector3< T > & Nz::Vector3< T >::Normalize | ( | T * | length = nullptr | ) |
Normalizes the current vector.
length | Optional argument to obtain the length's ratio of the vector and the unit-length |
|
static |
Gives the normalized vector.
vec | Vector to normalize |
Nz::Vector3< T >::operator const T * | ( | ) | const |
Converts vector to const pointer to its own data.
Nz::Vector3< T >::operator T* | ( | ) |
Converts vector to pointer to its own data.
bool Nz::Vector3< T >::operator!= | ( | const Vector3< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
Vector3< T > Nz::Vector3< T >::operator* | ( | const Vector3< T > & | vec | ) | const |
Multiplies the components of the vector with other vector.
vec | The other vector to multiply components with |
Vector3< T > Nz::Vector3< T >::operator* | ( | T | scale | ) | const |
Multiplies the components of the vector with a scalar.
scale | The scalar to multiply components with |
Vector3< T > & Nz::Vector3< T >::operator*= | ( | const Vector3< T > & | vec | ) |
Multiplies the components of other vector to this vector.
vec | The other vector to multiply components with |
Vector3< T > & Nz::Vector3< T >::operator*= | ( | T | scale | ) |
Multiplies the components of other vector with a scalar.
vec | The other vector to multiply components with |
const Vector3< T > & Nz::Vector3< T >::operator+ | ( | ) | const |
Helps to represent the sign of the vector.
Vector3< T > Nz::Vector3< T >::operator+ | ( | const Vector3< T > & | vec | ) | const |
Adds the components of the vector with other vector.
vec | The other vector to add components with |
Vector3< T > & Nz::Vector3< T >::operator+= | ( | const Vector3< T > & | vec | ) |
Adds the components of other vector to this vector.
vec | The other vector to add components with |
Vector3< T > Nz::Vector3< T >::operator- | ( | ) | const |
Negates the components of the vector.
Vector3< T > Nz::Vector3< T >::operator- | ( | const Vector3< T > & | vec | ) | const |
Substracts the components of the vector with other vector.
vec | The other vector to substract components with |
Vector3< T > & Nz::Vector3< T >::operator-= | ( | const Vector3< T > & | vec | ) |
Substracts the components of other vector to this vector.
vec | The other vector to substract components with |
Vector3< T > Nz::Vector3< T >::operator/ | ( | const Vector3< T > & | vec | ) | const |
Divides the components of the vector with other vector.
vec | The other vector to divide components with |
std::domain_error | if NAZARA_MATH_SAFE is defined and one of the vec components is null |
Vector3< T > Nz::Vector3< T >::operator/ | ( | T | scale | ) | const |
Divides the components of the vector with a scalar.
scale | The scalar to divide components with |
std::domain_error | if NAZARA_MATH_SAFE is defined and scale is null |
Vector3< T > & Nz::Vector3< T >::operator/= | ( | const Vector3< T > & | vec | ) |
Multiplies the components of other vector to this vector.
vec | The other vector to multiply components with |
std::domain_error | if NAZARA_MATH_SAFE is defined and one of the vec components is null |
Vector3< T > & Nz::Vector3< T >::operator/= | ( | T | scale | ) |
Divides the components of other vector with a scalar.
vec | The other vector to divide components with |
std::domain_error | if NAZARA_MATH_SAFE is defined and scale is null |
bool Nz::Vector3< T >::operator< | ( | const Vector3< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector3< T >::operator<= | ( | const Vector3< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector3< T >::operator== | ( | const Vector3< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector3< T >::operator> | ( | const Vector3< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector3< T >::operator>= | ( | const Vector3< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
|
static |
Vector3< T > & Nz::Vector3< T >::Set | ( | T | X, |
T | Y, | ||
T | Z | ||
) |
Sets the components of the vector.
X | X component |
Y | Y component |
Z | Z component |
Vector3< T > & Nz::Vector3< T >::Set | ( | T | X, |
const Vector2< T > & | vec | ||
) |
Sets the components of the vector from a component and a Vector2.
X | X component |
vec | vec.X = Y component and vec.y = Z component |
Vector3< T > & Nz::Vector3< T >::Set | ( | T | scale | ) |
Sets the components of the vector from a "scale".
scale | X component = Y component = Z component |
Vector3< T > & Nz::Vector3< T >::Set | ( | const T | vec[3] | ) |
Sets the components of the vector from an array of three elements.
vec[3] | vec[0] is X component, vec[1] is Y component and vec[2] is Z component |
Vector3< T > & Nz::Vector3< T >::Set | ( | const Vector2< T > & | vec, |
T | Z = 0.0 |
||
) |
Sets the components of the vector from a Vector2 and a component.
vec | vec.X = X component and vec.y = Y component |
Z | Z component |
Vector3< T > & Nz::Vector3< T >::Set | ( | const Vector3< T > & | vec | ) |
Sets the components of the vector from another vector.
vec | The other vector |
Vector3< T > & Nz::Vector3< T >::Set | ( | const Vector4< T > & | vec | ) |
Vector3<T>& Nz::Vector3< T >::Set | ( | const Vector3< U > & | vec | ) |
Sets the components of the vector from another type of Vector3.
vec | Vector of type U to convert its components |
T Nz::Vector3< T >::SquaredDistance | ( | const Vector3< T > & | vec | ) | const |
Calculates the squared distance between two vectors.
vec | The other vector to measure the distance with |
|
static |
Calculates the squared distance between two vectors.
vec1 | The first point to measure the distance with |
vec2 | The second point to measure the distance with |
String Nz::Vector3< T >::ToString | ( | ) | const |
Gives a string representation.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |