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 with the notion of projectivity. When the fourth component is 1, it describes an 'usual' point and when it is 0, it represents the point at infinity. More...
Public Member Functions | |
Vector4 (T X, T Y, T Z, T W=1.0) | |
Constructs a Vector4 object from its coordinates. More... | |
Vector4 (T X, T Y, const Vector2< T > &vec) | |
Constructs a Vector4 object from two components and a Vector2<T> More... | |
Vector4 (T X, const Vector2< T > &vec, T W) | |
Constructs a Vector4 object from one component, a Vector2<T> and one component. More... | |
Vector4 (T X, const Vector3< T > &vec) | |
Constructs a Vector4 object from one component and a Vector3<T> More... | |
Vector4 (T scale) | |
Constructs explicitely a Vector4 object from its "scale". More... | |
Vector4 (const T vec[4]) | |
Constructs a Vector4 object from an array of four elements. More... | |
Vector4 (const Vector2< T > &vec, T Z=0.0, T W=1.0) | |
Constructs a Vector4 object from a Vector2<T> and two components. More... | |
Vector4 (const Vector3< T > &vec, T W=1.0) | |
Constructs a Vector4 object from one component and a Vector3<T> More... | |
template<typename U > | |
Vector4 (const Vector4< U > &vec) | |
Constructs a Vector4 object from another type of Vector4. More... | |
Vector4 (const Vector4 &vec)=default | |
T | AbsDotProduct (const Vector4 &vec) const |
Calculates the absolute dot (scalar) product with two vectors. More... | |
T | DotProduct (const Vector4 &vec) const |
Calculates the dot (scalar) product with two vectors. More... | |
Vector4 | GetNormal (T *length=nullptr) const |
Gets a copy normalized of the vector. More... | |
Vector4 & | MakeUnitX () |
Makes the vector (1, 0, 0, 1) More... | |
Vector4 & | MakeUnitY () |
Makes the vector (0, 1, 0, 1) More... | |
Vector4 & | MakeUnitZ () |
Makes the vector (0, 0, 1, 1) More... | |
Vector4 & | MakeZero () |
Makes the vector (0, 0, 0, 1) More... | |
Vector4 & | Maximize (const Vector4 &vec) |
Sets this vector's components to the maximum of its own and other components. More... | |
Vector4 & | Minimize (const Vector4 &vec) |
Sets this vector's components to the minimum of its own and other components. More... | |
Vector4 & | Normalize (T *length=nullptr) |
Gives the normalized vector. More... | |
Vector4 & | Set (T X, T Y, T Z, T W=1.0) |
Sets the components of the vector. More... | |
Vector4 & | Set (T X, T Y, const Vector2< T > &vec) |
Sets the components of the vector from two components and a Vector2. More... | |
Vector4 & | Set (T X, const Vector2< T > &vec, T W) |
Sets the components of the vector from one component, a Vector2 and one component. More... | |
Vector4 & | Set (T X, const Vector3< T > &vec) |
Sets the components of the vector from one component and a Vector3. More... | |
Vector4 & | Set (T scale) |
Sets the components of the vector from a "scale". More... | |
Vector4 & | Set (const T vec[4]) |
Sets the components of the vector from an array of four elements. More... | |
Vector4 & | Set (const Vector2< T > &vec, T Z=0.0, T W=1.0) |
Sets the components of the vector from a Vector2 and two components. More... | |
Vector4 & | Set (const Vector3< T > &vec, T W=1.0) |
Sets the components of the vector from a Vector3 and one components. More... | |
Vector4 & | Set (const Vector4< T > &vec) |
Sets the components of the vector from another vector. More... | |
template<typename U > | |
Vector4 & | Set (const Vector4< U > &vec) |
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 Vector4 & | operator+ () const |
Helps to represent the sign of the vector. More... | |
Vector4 | operator- () const |
Negates the components of the vector. More... | |
Vector4 | operator+ (const Vector4 &vec) const |
Adds the components of the vector with other vector. More... | |
Vector4 | operator- (const Vector4 &vec) const |
Substracts the components of the vector with other vector. More... | |
Vector4 | operator* (const Vector4 &vec) const |
Multiplies the components of the vector with other vector. More... | |
Vector4 | operator* (T scale) const |
Multiplies the components of the vector with a scalar. More... | |
Vector4 | operator/ (const Vector4 &vec) const |
Divides the components of the vector with other vector. More... | |
Vector4 | operator/ (T scale) const |
Divides the components of the vector with a scalar. More... | |
Vector4 & | operator= (const Vector4 &other)=default |
Vector4 & | operator+= (const Vector4 &vec) |
Adds the components of other vector to this vector. More... | |
Vector4 & | operator-= (const Vector4 &vec) |
Substracts the components of other vector to this vector. More... | |
Vector4 & | operator*= (const Vector4 &vec) |
Multiplies the components of other vector to this vector. More... | |
Vector4 & | operator*= (T scale) |
Multiplies the components of other vector with a scalar. More... | |
Vector4 & | operator/= (const Vector4 &vec) |
Multiplies the components of other vector to this vector. More... | |
Vector4 & | operator/= (T scale) |
Divides the components of other vector with a scalar. More... | |
bool | operator== (const Vector4 &vec) const |
Compares the vector to other one. More... | |
bool | operator!= (const Vector4 &vec) const |
Compares the vector to other one. More... | |
bool | operator< (const Vector4 &vec) const |
Compares the vector to other one. More... | |
bool | operator<= (const Vector4 &vec) const |
Compares the vector to other one. More... | |
bool | operator> (const Vector4 &vec) const |
Compares the vector to other one. More... | |
bool | operator>= (const Vector4 &vec) const |
Compares the vector to other one. More... | |
template<typename U > | |
Vector4< T > & | Set (const Vector4< U > &vec) |
Sets the components of the vector from another type of Vector4. More... | |
Static Public Member Functions | |
static T | DotProduct (const Vector4 &vec1, const Vector4 &vec2) |
static Vector4 | Lerp (const Vector4 &from, const Vector4 &to, T interpolation) |
Interpolates the vector to other one with a factor of interpolation. More... | |
static Vector4 | Normalize (const Vector4 &vec) |
Gives the normalized vector. More... | |
static Vector4 | UnitX () |
Shorthand for the vector (1, 0, 0, 1) More... | |
static Vector4 | UnitY () |
Shorthand for the vector (0, 1, 0, 1) More... | |
static Vector4 | UnitZ () |
Shorthand for the vector (0, 0, 1, 1) More... | |
static Vector4 | Zero () |
Shorthand for the vector (0, 0, 0, 1) More... | |
Public Attributes | |
T | x |
T | y |
T | z |
T | w |
Math class that represents an element of the three dimensional vector space with the notion of projectivity. When the fourth component is 1, it describes an 'usual' point and when it is 0, it represents the point at infinity.
Nz::Vector4< T >::Vector4 | ( | T | X, |
T | Y, | ||
T | Z, | ||
T | W = 1.0 |
||
) |
Constructs a Vector4 object from its coordinates.
X | X component |
Y | Y component |
Z | Z component |
W | W component |
Nz::Vector4< T >::Vector4 | ( | T | X, |
T | Y, | ||
const Vector2< T > & | vec | ||
) |
Constructs a Vector4 object from two components and a Vector2<T>
X | X component |
Y | Y component |
vec | vec.X = Z component and vec.y = W component |
Nz::Vector4< T >::Vector4 | ( | T | X, |
const Vector2< T > & | vec, | ||
T | W | ||
) |
Constructs a Vector4 object from one component, a Vector2<T> and one component.
X | X component |
vec | vec.X = Y component and vec.y = Z component |
W | W component |
Nz::Vector4< T >::Vector4 | ( | T | X, |
const Vector3< T > & | vec | ||
) |
Constructs a Vector4 object from one component and a Vector3<T>
X | X component |
vec | vec.X = Y component, vec.y = Z component and vec.z = W component |
|
explicit |
Constructs explicitely a Vector4 object from its "scale".
scale | X component = Y component = Z component = W component |
Nz::Vector4< T >::Vector4 | ( | const T | vec[4] | ) |
Constructs a Vector4 object from an array of four elements.
vec[4] | vec[0] is X component, vec[1] is Y component, vec[2] is Z component and vec[3] is W component |
Nz::Vector4< T >::Vector4 | ( | const Vector2< T > & | vec, |
T | Z = 0.0 , |
||
T | W = 1.0 |
||
) |
Constructs a Vector4 object from a Vector2<T> and two components.
vec | vec.X = X component and vec.y = Y component |
Z | Z component |
W | W component |
Nz::Vector4< T >::Vector4 | ( | const Vector3< T > & | vec, |
T | W = 1.0 |
||
) |
Constructs a Vector4 object from one component and a Vector3<T>
vec | vec.X = X component, vec.y = Y component and vec.z = Z component |
W | W component |
|
explicit |
T Nz::Vector4< T >::AbsDotProduct | ( | const Vector4< 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::Vector4< T >::DotProduct | ( | const Vector4< T > & | vec | ) | const |
Calculates the dot (scalar) product with two vectors.
vec | The other vector to calculate the dot product with |
Vector4< T > Nz::Vector4< 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 in this case w |
|
static |
Interpolates the vector to other one with a factor of interpolation.
from | Initial vector |
to | Target vector |
interpolation | Factor of interpolation |
Vector4< T > & Nz::Vector4< T >::MakeUnitX | ( | ) |
Makes the vector (1, 0, 0, 1)
Vector4< T > & Nz::Vector4< T >::MakeUnitY | ( | ) |
Makes the vector (0, 1, 0, 1)
Vector4< T > & Nz::Vector4< T >::MakeUnitZ | ( | ) |
Makes the vector (0, 0, 1, 1)
Vector4< T > & Nz::Vector4< T >::MakeZero | ( | ) |
Makes the vector (0, 0, 0, 1)
Vector4< T > & Nz::Vector4< T >::Maximize | ( | const Vector4< T > & | vec | ) |
Sets this vector's components to the maximum of its own and other components.
vec | Other vector to compare the components with |
Vector4< T > & Nz::Vector4< T >::Minimize | ( | const Vector4< T > & | vec | ) |
Sets this vector's components to the minimum of its own and other components.
vec | Other vector to compare the components with |
Vector4< T > & Nz::Vector4< T >::Normalize | ( | T * | length = nullptr | ) |
Gives the normalized vector.
length | Optional argument to obtain the length's ratio of the vector in this case w |
|
static |
Gives the normalized vector.
vec | Vector to normalize |
Nz::Vector4< T >::operator const T * | ( | ) | const |
Converts vector to const pointer to its own data.
Nz::Vector4< T >::operator T* | ( | ) |
Converts vector to pointer to its own data.
bool Nz::Vector4< T >::operator!= | ( | const Vector4< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
Vector4< T > Nz::Vector4< T >::operator* | ( | const Vector4< T > & | vec | ) | const |
Multiplies the components of the vector with other vector.
vec | The other vector to multiply components with |
Vector4< T > Nz::Vector4< T >::operator* | ( | T | scale | ) | const |
Multiplies the components of the vector with a scalar.
scale | The scalar to multiply components with |
Vector4< T > & Nz::Vector4< T >::operator*= | ( | const Vector4< T > & | vec | ) |
Multiplies the components of other vector to this vector.
vec | The other vector to multiply components with |
Vector4< T > & Nz::Vector4< T >::operator*= | ( | T | scale | ) |
Multiplies the components of other vector with a scalar.
vec | The other vector to multiply components with |
const Vector4< T > & Nz::Vector4< T >::operator+ | ( | ) | const |
Helps to represent the sign of the vector.
Vector4< T > Nz::Vector4< T >::operator+ | ( | const Vector4< T > & | vec | ) | const |
Adds the components of the vector with other vector.
vec | The other vector to add components with |
Vector4< T > & Nz::Vector4< T >::operator+= | ( | const Vector4< T > & | vec | ) |
Adds the components of other vector to this vector.
vec | The other vector to add components with |
Vector4< T > Nz::Vector4< T >::operator- | ( | ) | const |
Negates the components of the vector.
Vector4< T > Nz::Vector4< T >::operator- | ( | const Vector4< T > & | vec | ) | const |
Substracts the components of the vector with other vector.
vec | The other vector to substract components with |
Vector4< T > & Nz::Vector4< T >::operator-= | ( | const Vector4< T > & | vec | ) |
Substracts the components of other vector to this vector.
vec | The other vector to substract components with |
Vector4< T > Nz::Vector4< T >::operator/ | ( | const Vector4< 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 |
Vector4< T > Nz::Vector4< 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 |
Vector4< T > & Nz::Vector4< T >::operator/= | ( | const Vector4< 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 |
Vector4< T > & Nz::Vector4< 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::Vector4< T >::operator< | ( | const Vector4< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector4< T >::operator<= | ( | const Vector4< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector4< T >::operator== | ( | const Vector4< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector4< T >::operator> | ( | const Vector4< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
bool Nz::Vector4< T >::operator>= | ( | const Vector4< T > & | vec | ) | const |
Compares the vector to other one.
vec | Other vector to compare with |
Vector4< T > & Nz::Vector4< T >::Set | ( | T | X, |
T | Y, | ||
T | Z, | ||
T | W = 1.0 |
||
) |
Sets the components of the vector.
X | X component |
Y | Y component |
Z | Z component |
W | W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | T | X, |
T | Y, | ||
const Vector2< T > & | vec | ||
) |
Sets the components of the vector from two components and a Vector2.
X | X component |
Y | Y component |
vec | vec.X = Z component and vec.y = W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | T | X, |
const Vector2< T > & | vec, | ||
T | W | ||
) |
Sets the components of the vector from one component, a Vector2 and one component.
X | X component |
vec | vec.X = Y component and vec.y = Z component |
W | W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | T | X, |
const Vector3< T > & | vec | ||
) |
Sets the components of the vector from one component and a Vector3.
X | X component |
vec | vec.X = Y component, vec.y = Z component and vec.z = W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | T | scale | ) |
Sets the components of the vector from a "scale".
scale | X component = Y component = Z component = W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | const T | vec[4] | ) |
Sets the components of the vector from an array of four elements.
vec[4] | vec[0] is X component, vec[1] is Y component, vec[2] is Z component and vec[3] is W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | const Vector2< T > & | vec, |
T | Z = 0.0 , |
||
T | W = 1.0 |
||
) |
Sets the components of the vector from a Vector2 and two components.
vec | vec.X = X component and vec.y = Y component |
Z | Z component |
W | W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | const Vector3< T > & | vec, |
T | W = 1.0 |
||
) |
Sets the components of the vector from a Vector3 and one components.
vec | vec.X = X component, vec.y = Y component and vec.z = Z component |
W | W component |
Vector4< T > & Nz::Vector4< T >::Set | ( | const Vector4< T > & | vec | ) |
Sets the components of the vector from another vector.
vec | The other vector |
Vector4<T>& Nz::Vector4< T >::Set | ( | const Vector4< U > & | vec | ) |
Sets the components of the vector from another type of Vector4.
vec | Vector of type U to convert its components |
String Nz::Vector4< T >::ToString | ( | ) | const |
Gives a string representation.
|
static |
Shorthand for the vector (1, 0, 0, 1)
|
static |
Shorthand for the vector (0, 1, 0, 1)
|
static |
Shorthand for the vector (0, 0, 1, 1)
|
static |