Vector with 2 floating point components: (x, y). More...
#include <kanzi/core/math/vector2.hpp>
Public Member Functions | |
| constexpr float | getX () const |
| Returns the x element of the vector. | |
| constexpr float | getY () const |
| Returns the y element of the vector. | |
| bool | hasNan () const |
| Returns true if and only if at least one of the vector values is NaN. | |
| float | length () const |
| Calculates the length a vectors. | |
| KZ_NO_DISCARD Vector2 | normalized () const |
| Normalizes the vector and returns the resulting vector. | |
| constexpr Vector2 & | operator*= (float scalar) |
| Multiplies each vector element with a scalar. | |
| constexpr Vector2 & | operator+= (float scalar) |
| Adds a scalar to each vector element. | |
| constexpr Vector2 & | operator+= (Vector2 v) |
| Modifies this vector by adding another vector. | |
| constexpr Vector2 & | operator-= (Vector2 v) |
| Modifies this vector by subtracting another vector from this vector. | |
| constexpr Vector2 & | operator/= (float scalar) |
| Divides each vector element with a scalar. | |
| constexpr float & | operator[] (size_t index) |
| Access to individual elements of the vector. | |
| constexpr const float & | operator[] (size_t index) const |
| Access to individual elements of a vector. | |
| constexpr void | setX (float value) |
| Sets the x element of the vector. | |
| constexpr void | setY (float value) |
| Sets the y element of the vector. | |
| constexpr float | squaredLength () const |
| Calculates the squared length a vectors. | |
| constexpr | Vector2 () |
| Default constructor. | |
| constexpr | Vector2 (float v) |
| Constructor. | |
| constexpr | Vector2 (float x, float y) |
| Constructor. | |
Static Public Member Functions | |
| static constexpr Vector2 | createFromVector3 (Vector3 v) |
| Creates a Vector2 from Vector3 by dropping the z-coordinate. | |
| static constexpr Vector2 | highestValue () |
| Returns the vector with each element having the most positive float value. | |
| static constexpr Vector2 | lowestValue () |
| Returns the vector with each element having the most negative float value. | |
| static constexpr Vector2 | nan () |
| Returns the vector with each element being NaN. | |
| static constexpr Vector2 | negativeInfinity () |
| Returns the vector with each element being the negative infinity. | |
| static KZ_NO_DISCARD constexpr Vector2 | one () |
| Returns the vector with each element being one. | |
| static constexpr Vector2 | positiveInfinity () |
| Returns the vector with each element being the positive infinity. | |
| static KZ_NO_DISCARD constexpr Vector2 | zero () |
| Returns the vector with each element being zero. | |
Vector with 2 floating point components: (x, y).
|
inlineexplicitconstexpr |
Default constructor.
Initializes a vector to (0.0, 0.0).
Constructor.
Initializes a vector to (x, y).
| x | X coefficient of a vector. |
| y | Y coefficient of a vector. |
Constructor.
Initializes a vector to (v, v).
| v | X and Y coefficients of a vector. |
Access to individual elements of a vector.
| index | The index of the accessed element. Either 0 or 1. |
Access to individual elements of the vector.
| index | Index of the accessed element. Either 0 or 1. |
Multiplies each vector element with a scalar.
| scalar | Multiplier for each vector element. |
Divides each vector element with a scalar.
| scalar | Divider for each vector element. |
Adds a scalar to each vector element.
| scalar | Addition to each vector element. |
Modifies this vector by adding another vector.
| v | Another vector. |
Modifies this vector by subtracting another vector from this vector.
| v | Another vector. |
|
inlinestaticconstexpr |
Returns the vector with each element being zero.
|
inlinestaticconstexpr |
Returns the vector with each element being one.
Returns the x element of the vector.
Returns the y element of the vector.
Sets the x element of the vector.
| value | The new value of the x element. |
Sets the y element of the vector.
| value | The new value of the y element. |
|
inline |
Calculates the length a vectors.
Calculates the squared length a vectors.
|
inline |
Normalizes the vector and returns the resulting vector.
Returns the vector with each element having the most negative float value.
Returns the vector with each element having the most positive float value.
Returns the vector with each element being NaN.
|
inline |
Returns true if and only if at least one of the vector values is NaN.
Returns the vector with each element being the positive infinity.
Returns the vector with each element being the negative infinity.