Vector with 2 floating point components: (x, y).
More...
#include <kanzi/core/math/vector2.hpp>
Vector with 2 floating point components: (x, y).
kanzi::Vector2::Vector2 |
( |
| ) |
|
|
inlineexplicit |
Default constructor. Initializes a vector to (0.0, 0.0).
kanzi::Vector2::Vector2 |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
|
inlineexplicit |
Constructor.
Initializes a vector to (x, y).
- Parameters
-
x | x coefficient of a vector. |
y | y coefficient of a vector. |
kanzi::Vector2::Vector2 |
( |
float |
v | ) |
|
|
inlineexplicit |
Constructor.
Initializes a vector to (v, v).
- Parameters
-
v | x and y coefficients of a vector. |
const float& kanzi::Vector2::operator[] |
( |
size_t |
index | ) |
const |
|
inline |
Access to individual elements of a vector.
- Parameters
-
index | The index of the accessed element. Either 0 or 1. |
- Returns
- If index is 0, the x element. If index is 1, the y element.
float& kanzi::Vector2::operator[] |
( |
size_t |
index | ) |
|
|
inline |
Access to individual elements of the vector.
- Parameters
-
index | Index of the accessed element. Either 0 or 1. |
- Returns
- If index is 0, reference to x element. If index is 1, reference to y element.
Vector2& kanzi::Vector2::operator*= |
( |
float |
scalar | ) |
|
|
inline |
Multiplies each vector element with a scalar.
- Parameters
-
scalar | Multiplier for each vector element. |
- Returns
- This vector.
Vector2& kanzi::Vector2::operator/= |
( |
float |
scalar | ) |
|
|
inline |
Divides each vector element with a scalar.
- Parameters
-
scalar | Divider for each vector element. |
- Returns
- This vector.
Vector2& kanzi::Vector2::operator+= |
( |
float |
scalar | ) |
|
|
inline |
Adds a scalar to each vector element.
- Parameters
-
scalar | Addition to each vector element. |
- Returns
- This vector.
Modifies this vector by adding another vector.
- Parameters
-
- Returns
- This vector.
Modifies this vector by subtracting another vector from this vector.
- Parameters
-
- Returns
- This vector.
Returns the vector with each element being zero.
- Returns
- Vector with zeroed elements.
Returns the vector with each element being one.
- Returns
- Vector with unit element values.
float kanzi::Vector2::getX |
( |
| ) |
const |
|
inline |
Returns the x element of the vector.
- Returns
- The x element.
float kanzi::Vector2::getY |
( |
| ) |
const |
|
inline |
Returns the y element of the vector.
- Returns
- The y element.
void kanzi::Vector2::setX |
( |
float |
value | ) |
|
|
inline |
Sets the x element of the vector.
- Parameters
-
value | The new value of the x element. |
void kanzi::Vector2::setY |
( |
float |
value | ) |
|
|
inline |
Sets the y element of the vector.
- Parameters
-
value | The new value of the y element. |
float kanzi::Vector2::length |
( |
| ) |
const |
|
inline |
Calculates the length a vectors.
- Returns
- sqrt(x*x + y*y)
float kanzi::Vector2::squaredLength |
( |
| ) |
const |
|
inline |
Calculates the squared length a vectors.
- Returns
- x*x + y*y
Normalizes the vector and returns the resulting vector.
- Returns
- The normalized vector.
Vector2 kanzi::Vector2::lowestValue |
( |
| ) |
|
|
inlinestatic |
Returns the vector with each element having the most negative float value.
- Returns
- Vector with the lowest possible value.
Vector2 kanzi::Vector2::highestValue |
( |
| ) |
|
|
inlinestatic |
Returns the vector with each element having the most positive float value.
- Returns
- Vector with the highest possible value.
Returns the vector with each element being NaN.
- Returns
- Vector with NaN elements.
bool kanzi::Vector2::hasNan |
( |
| ) |
const |
|
inline |
Returns true if and only if at least one of the vector values is NaN.
Vector2 kanzi::Vector2::positiveInfinity |
( |
| ) |
|
|
inlinestatic |
Returns the vector with each element being the positive infinity.
- Returns
- Vector with positive infinity elements.
Vector2 kanzi::Vector2::negativeInfinity |
( |
| ) |
|
|
inlinestatic |
Returns the vector with each element being the negative infinity.
- Returns
- Vector with negative infinity elements.
Creates a Vector2 from Vector3 by dropping the z-coordinate.
- Parameters
-
- Returns
- The input vector without z-coordinate.
The documentation for this class was generated from the following file: