![]() |
Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Math class that represents an element of the two dimensional vector space. More...
Public Member Functions | |
| Vector2 (T X, T Y) | |
| Constructs a Vector2 object from its coordinates. More... | |
| Vector2 (T scale) | |
| Constructs explicitely a Vector2 object from its "scale". More... | |
| Vector2 (const T vec[2]) | |
| Constructs a Vector2 object from an array of two elements. More... | |
| template<typename U > | |
| Vector2 (const Vector2< U > &vec) | |
| Constructs a Vector2 object from another type of Vector2. More... | |
| Vector2 (const Vector2 &vec)=default | |
| Vector2 (const Vector3< T > &vec) | |
| Constructs a Vector2 object from a Vector3. More... | |
| Vector2 (const Vector4< T > &vec) | |
| Constructs a Vector2 object from a Vector4. More... | |
| T | AbsDotProduct (const Vector2 &vec) const |
| Calculates the absolute dot (scalar) product with two vectors. More... | |
| T | AngleBetween (const Vector2 &vec) const |
| Calculates the angle between two vectors in orthonormal basis. More... | |
| T | Distance (const Vector2 &vec) const |
| Calculates the distance between two vectors. More... | |
| float | Distancef (const Vector2 &vec) const |
| Calculates the distance between two vectors. More... | |
| T | DotProduct (const Vector2 &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... | |
| Vector2 | 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... | |
| Vector2 & | MakeUnit () |
| Makes the vector (1, 1) More... | |
| Vector2 & | MakeUnitX () |
| Makes the vector (1, 0) More... | |
| Vector2 & | MakeUnitY () |
| Makes the vector (0, 1) More... | |
| Vector2 & | MakeZero () |
| Makes the vector (0, 0) More... | |
| Vector2 & | Maximize (const Vector2 &vec) |
| Sets this vector's components to the maximum of its own and other components. More... | |
| Vector2 & | Minimize (const Vector2 &vec) |
| Sets this vector's components to the minimum of its own and other components. More... | |
| Vector2 & | Normalize (T *length=nullptr) |
| Normalizes the current vector. More... | |
| Vector2 & | Set (T X, T Y) |
| Sets the components of the vector. More... | |
| Vector2 & | Set (T scale) |
| Sets the components of the vector from a "scale". More... | |
| Vector2 & | Set (const T vec[2]) |
| Sets the components of the vector from an array of two elements. More... | |
| Vector2 & | Set (const Vector2 &vec) |
| Sets the components of the vector from another vector. More... | |
| Vector2 & | Set (const Vector3< T > &vec) |
| Sets the components of the vector from a Vector3. More... | |
| Vector2 & | Set (const Vector4< T > &vec) |
| Sets the components of the vector from a Vector4. More... | |
| template<typename U > | |
| Vector2 & | Set (const Vector2< U > &vec) |
| T | SquaredDistance (const Vector2 &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 Vector2 & | operator+ () const |
| Helps to represent the sign of the vector. More... | |
| Vector2 | operator- () const |
| Negates the components of the vector. More... | |
| Vector2 | operator+ (const Vector2 &vec) const |
| Adds the components of the vector with other vector. More... | |
| Vector2 | operator- (const Vector2 &vec) const |
| Substracts the components of the vector with other vector. More... | |
| Vector2 | operator* (const Vector2 &vec) const |
| Multiplies the components of the vector with other vector. More... | |
| Vector2 | operator* (T scale) const |
| Multiplies the components of the vector with a scalar. More... | |
| Vector2 | operator/ (const Vector2 &vec) const |
| Divides the components of the vector with other vector. More... | |
| Vector2 | operator/ (T scale) const |
| Divides the components of the vector with a scalar. More... | |
| Vector2 & | operator= (const Vector2 &other)=default |
| Vector2 & | operator+= (const Vector2 &vec) |
| Adds the components of other vector to this vector. More... | |
| Vector2 & | operator-= (const Vector2 &vec) |
| Substracts the components of other vector to this vector. More... | |
| Vector2 & | operator*= (const Vector2 &vec) |
| Multiplies the components of other vector to this vector. More... | |
| Vector2 & | operator*= (T scale) |
| Multiplies the components of other vector with a scalar. More... | |
| Vector2 & | operator/= (const Vector2 &vec) |
| Multiplies the components of other vector to this vector. More... | |
| Vector2 & | operator/= (T scale) |
| Divides the components of other vector with a scalar. More... | |
| bool | operator== (const Vector2 &vec) const |
| Compares the vector to other one. More... | |
| bool | operator!= (const Vector2 &vec) const |
| Compares the vector to other one. More... | |
| bool | operator< (const Vector2 &vec) const |
| Compares the vector to other one. More... | |
| bool | operator<= (const Vector2 &vec) const |
| Compares the vector to other one. More... | |
| bool | operator> (const Vector2 &vec) const |
| Compares the vector to other one. More... | |
| bool | operator>= (const Vector2 &vec) const |
| Compares the vector to other one. More... | |
| template<typename U > | |
| Vector2< T > & | Set (const Vector2< U > &vec) |
| Sets the components of the vector from another type of Vector2. More... | |
Static Public Member Functions | |
| static T | DotProduct (const Vector2 &vec1, const Vector2 &vec2) |
| Calculates the dot (scalar) product with two vectors. More... | |
| static Vector2 | Lerp (const Vector2 &from, const Vector2 &to, T interpolation) |
| Interpolates the vector to other one with a factor of interpolation. More... | |
| static Vector2 | Normalize (const Vector2 &vec) |
| Gives the normalized vector. More... | |
| static Vector2 | Unit () |
| Shorthand for the vector (1, 1) More... | |
| static Vector2 | UnitX () |
| Shorthand for the vector (1, 0) More... | |
| static Vector2 | UnitY () |
| Shorthand for the vector (0, 1) More... | |
| static Vector2 | Zero () |
| Shorthand for the vector (0, 0) More... | |
Public Attributes | |
| T | x |
| T | y |
Math class that represents an element of the two dimensional vector space.
| Nz::Vector2< T >::Vector2 | ( | T | X, |
| T | Y | ||
| ) |
Constructs a Vector2 object from its coordinates.
| X | X component |
| Y | Y component |
|
explicit |
Constructs explicitely a Vector2 object from its "scale".
| scale | X component = Y component |
| Nz::Vector2< T >::Vector2 | ( | const T | vec[2] | ) |
Constructs a Vector2 object from an array of two elements.
| vec[2] | vec[0] is X component and vec[1] is Y component |
|
explicit |
|
explicit |
|
explicit |
| T Nz::Vector2< T >::AbsDotProduct | ( | const Vector2< 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::Vector2< T >::AngleBetween | ( | const Vector2< T > & | vec | ) | const |
Calculates the angle between two vectors in orthonormal basis.
| vec | The other vector to measure the angle with |
| T Nz::Vector2< T >::Distance | ( | const Vector2< T > & | vec | ) | const |
Calculates the distance between two vectors.
| vec | The other vector to measure the distance with |
| float Nz::Vector2< T >::Distancef | ( | const Vector2< T > & | vec | ) | const |
Calculates the distance between two vectors.
| vec | The other vector to measure the distance with |
| T Nz::Vector2< T >::DotProduct | ( | const Vector2< 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 |
| T Nz::Vector2< T >::GetLength | ( | ) | const |
Calculates the length (magnitude) of the vector.
| float Nz::Vector2< T >::GetLengthf | ( | ) | const |
Calculates the length (magnitude) of the vector.
| Vector2< T > Nz::Vector2< 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::Vector2< T >::GetSquaredLength | ( | ) | const |
Calculates the squared length (magnitude) of the vector.
|
static |
Interpolates the vector to other one with a factor of interpolation.
| from | Initial vector |
| to | Target vector |
| interpolation | Factor of interpolation |
| Vector2< T > & Nz::Vector2< T >::MakeUnit | ( | ) |
| Vector2< T > & Nz::Vector2< T >::MakeUnitX | ( | ) |
| Vector2< T > & Nz::Vector2< T >::MakeUnitY | ( | ) |
| Vector2< T > & Nz::Vector2< T >::MakeZero | ( | ) |
| Vector2< T > & Nz::Vector2< T >::Maximize | ( | const Vector2< T > & | vec | ) |
Sets this vector's components to the maximum of its own and other components.
| vec | Other vector to compare the components with |
| Vector2< T > & Nz::Vector2< T >::Minimize | ( | const Vector2< T > & | vec | ) |
Sets this vector's components to the minimum of its own and other components.
| vec | Other vector to compare the components with |
| Vector2< T > & Nz::Vector2< 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::Vector2< T >::operator const T * | ( | ) | const |
Converts vector to const pointer to its own data.
| Nz::Vector2< T >::operator T* | ( | ) |
Converts vector to pointer to its own data.
| bool Nz::Vector2< T >::operator!= | ( | const Vector2< T > & | vec | ) | const |
Compares the vector to other one.
| vec | Other vector to compare with |
| Vector2< T > Nz::Vector2< T >::operator* | ( | const Vector2< T > & | vec | ) | const |
Multiplies the components of the vector with other vector.
| vec | The other vector to multiply components with |
| Vector2< T > Nz::Vector2< T >::operator* | ( | T | scale | ) | const |
Multiplies the components of the vector with a scalar.
| scale | The scalar to multiply components with |
| Vector2< T > & Nz::Vector2< T >::operator*= | ( | const Vector2< T > & | vec | ) |
Multiplies the components of other vector to this vector.
| vec | The other vector to multiply components with |
| Vector2< T > & Nz::Vector2< T >::operator*= | ( | T | scale | ) |
Multiplies the components of other vector with a scalar.
| vec | The other vector to multiply components with |
| const Vector2< T > & Nz::Vector2< T >::operator+ | ( | ) | const |
Helps to represent the sign of the vector.
| Vector2< T > Nz::Vector2< T >::operator+ | ( | const Vector2< T > & | vec | ) | const |
Adds the components of the vector with other vector.
| vec | The other vector to add components with |
| Vector2< T > & Nz::Vector2< T >::operator+= | ( | const Vector2< T > & | vec | ) |
Adds the components of other vector to this vector.
| vec | The other vector to add components with |
| Vector2< T > Nz::Vector2< T >::operator- | ( | ) | const |
Negates the components of the vector.
| Vector2< T > Nz::Vector2< T >::operator- | ( | const Vector2< T > & | vec | ) | const |
Substracts the components of the vector with other vector.
| vec | The other vector to substract components with |
| Vector2< T > & Nz::Vector2< T >::operator-= | ( | const Vector2< T > & | vec | ) |
Substracts the components of other vector to this vector.
| vec | The other vector to substract components with |
| Vector2< T > Nz::Vector2< T >::operator/ | ( | const Vector2< 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 |
| Vector2< T > Nz::Vector2< 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 |
| Vector2< T > & Nz::Vector2< T >::operator/= | ( | const Vector2< 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 |
| Vector2< T > & Nz::Vector2< 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::Vector2< T >::operator< | ( | const Vector2< T > & | vec | ) | const |
Compares the vector to other one.
| vec | Other vector to compare with |
| bool Nz::Vector2< T >::operator<= | ( | const Vector2< T > & | vec | ) | const |
Compares the vector to other one.
| vec | Other vector to compare with |
| bool Nz::Vector2< T >::operator== | ( | const Vector2< T > & | vec | ) | const |
Compares the vector to other one.
| vec | Other vector to compare with |
| bool Nz::Vector2< T >::operator> | ( | const Vector2< T > & | vec | ) | const |
Compares the vector to other one.
| vec | Other vector to compare with |
| bool Nz::Vector2< T >::operator>= | ( | const Vector2< T > & | vec | ) | const |
Compares the vector to other one.
| vec | Other vector to compare with |
| Vector2< T > & Nz::Vector2< T >::Set | ( | T | X, |
| T | Y | ||
| ) |
Sets the components of the vector.
| X | X component |
| Y | Y component |
| Vector2< T > & Nz::Vector2< T >::Set | ( | T | scale | ) |
Sets the components of the vector from a "scale".
| scale | X component = Y component |
| Vector2< T > & Nz::Vector2< T >::Set | ( | const T | vec[2] | ) |
Sets the components of the vector from an array of two elements.
| vec[2] | vec[0] is X component and vec[1] is Y component |
| Vector2< T > & Nz::Vector2< T >::Set | ( | const Vector2< T > & | vec | ) |
Sets the components of the vector from another vector.
| vec | The other vector |
| Vector2< T > & Nz::Vector2< T >::Set | ( | const Vector3< T > & | vec | ) |
| Vector2< T > & Nz::Vector2< T >::Set | ( | const Vector4< T > & | vec | ) |
| Vector2<T>& Nz::Vector2< T >::Set | ( | const Vector2< U > & | vec | ) |
Sets the components of the vector from another type of Vector2.
| vec | Vector of type U to convert its components |
| T Nz::Vector2< T >::SquaredDistance | ( | const Vector2< T > & | vec | ) | const |
Calculates the squared distance between two vectors.
| vec | The other vector to measure the distance with |
| String Nz::Vector2< T >::ToString | ( | ) | const |
Gives a string representation.
|
static |
|
static |
|
static |
|
static |