Vector2
¶
Vector with 2 floating point components: (x, y).
Functions which can be used to create new instances of Vector2.
Default constructor. Initializes a vector to (0.0, 0.0).
local vector2 = Vector2()
Constructor. Initializes a vector to (x, y).
local vector2 = Vector2(x, y)
x | (float) | x coefficient of a vector. |
y | (float) | y coefficient of a vector. |
Constructor. Initializes a vector to (v, v).
local vector2 = Vector2(v)
v | (float) | x and y coefficients of a vector. |
Methods of Vector2 class.
Vector2.zero() | Returns the vector with each element being zero |
Vector2.one() | Returns the vector with each element being one |
Vector2:getX() | Returns the x element of the vector |
Vector2:getY() | Returns the y element of the vector |
Vector2:setX() | Sets the x element of the vector |
Vector2:setY() | Sets the y element of the vector |
Vector2:hasNan() | Returns true if and only if at least one of the vector values is NaN |
Vector2.createFromVector3() | Creates a Vector2 from Vector3 by dropping the z-coordinate |
Vector2:length() | Calculates the length a vectors |
Vector2:squaredLength() | Calculates the squared length a vectors |
Vector2:normalized() | Normalizes the vector and returns the resulting vector |
Vector2.lowestValue() | Returns the vector with each element having the most negative float value |
Vector2.highestValue() | Returns the vector with each element having the most positive float value |
Vector2.nan() | Returns the vector with each element being NaN |
Vector2.positiveInfinity() | Returns the vector with each element being the positive infinity |
Vector2.negativeInfinity() | Returns the vector with each element being the negative infinity |
Returns the vector with each element being zero.
(Vector2) | Vector with zeroed elements. |
Returns the vector with each element being one.
(Vector2) | Vector with unit element values. |
Returns the x element of the vector.
(float) | The x element. |
Returns the y element of the vector.
(float) | The y element. |
Sets the x element of the vector.
value | (float) | The new value of the x element. |
Sets the y element of the vector.
value | (float) | The new value of the y element. |
Returns true if and only if at least one of the vector values is NaN.
Creates a Vector2 from Vector3 by dropping the z-coordinate.
v | (Vector3) | Input vector. |
(Vector2) | The input vector without z-coordinate. |
Calculates the length a vectors.
(float) | sqrt(xx + yy) |
Calculates the squared length a vectors.
(float) | xx + yy |
Normalizes the vector and returns the resulting vector.
(Vector2) | The normalized vector. |
Returns the vector with each element having the most negative float value.
(Vector2) | Vector with the lowest possible value. |
Returns the vector with each element having the most positive float value.
(Vector2) | Vector with the highest possible value. |
Returns the vector with each element being NaN.
(Vector2) | Vector with NaN elements. |
Returns the vector with each element being the positive infinity.
(Vector2) | Vector with positive infinity elements. |
Returns the vector with each element being the negative infinity.
(Vector2) | Vector with negative infinity elements. |
Vector2 specific standalone functions, which are not a part of the Vector2 class.
componentAbs() | Calculates component-wise absolute value for all elements and returns resulting vector |
componentCeil() | Calculates component-wise ceil value for all elements and returns resulting vector |
componentFloor() | Calculates component-wise floor value for all elements and returns resulting vector |
componentRound() | Calculates component-wise rounded value for all elements and returns resulting vector |
componentSqrt() | Calculates component-wise square root all elements and returns resulting vector |
componentWiseMax() | Calculates the component-wise maximum for all vector elements and returns the resulting vector |
componentWiseMin() | Calculates the component-wise minimum for all vector elements and returns the resulting vector |
componentWiseMultiply() | Multiplies all vector elements component-wise and returns the resulting vector |
componentWiseDivide() | Divides all vector elements component-wise and returns the resulting vector |
componentWiseRemainder() | Calculates component-wise the remainder for all vector elements and returns the resulting vector |
componentAdd() | Adds a value to all elements of a vector and returns the result |
componentSubtract() | Subtracts a value from all elements of a vector and returns the result |
componentAllLessThan() | Returns whether each component of the first vector is less than the corresponding component of the second vector |
componentAllLessThanOrEqual() | Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector |
componentAllGreaterThan() | Returns whether each component of the first vector is greater than the corresponding component of the second vector |
componentAllGreaterThanOrEqual() | Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector |
dotProduct() | Calculates the dot product of two vectors |
pseudoCrossProduct() | Calculates pseudo-cross product of two 2D vectors |
isfinite() | Overloading of std::isfinite for kanzi::Vector2 |
Calculates component-wise absolute value for all elements and returns resulting vector.
v | (Vector2) | Vector input. |
(Vector2) | The result vector. |
Calculates component-wise ceil value for all elements and returns resulting vector.
v | (Vector2) | Vector input. |
(Vector2) | The result vector. |
Calculates component-wise floor value for all elements and returns resulting vector.
v | (Vector2) | Vector input. |
(Vector2) | The result vector. |
Calculates component-wise rounded value for all elements and returns resulting vector.
v | (Vector2) | Vector input. |
(Vector2) | The result vector. |
Calculates component-wise square root all elements and returns resulting vector.
v | (Vector2) | Vector input. |
(Vector2) | The result vector. |
Calculates the component-wise maximum for all vector elements and returns the resulting vector.
v1 | (Vector2) | The first vector. |
v2 | (Vector2) | The second vector. |
(Vector2) | The result vector. |
Calculates the component-wise minimum for all vector elements and returns the resulting vector.
v1 | (Vector2) | The first vector. |
v2 | (Vector2) | The second vector. |
(Vector2) | The result vector. |
Multiplies all vector elements component-wise and returns the resulting vector.
v1 | (Vector2) | The first vector. |
v2 | (Vector2) | The second vector. |
(Vector2) | The result vector. |
Divides all vector elements component-wise and returns the resulting vector.
v1 | (Vector2) | The first vector. |
v2 | (Vector2) | The second vector. |
(Vector2) | The result vector. |
Calculates component-wise the remainder for all vector elements and returns the resulting vector.
v1 | (Vector2) | The first vector. |
v2 | (Vector2) | The second vector. |
(Vector2) | The result vector. |
Adds a value to all elements of a vector and returns the result.
v | (Vector2) | A vector. |
scalar | (float) | A scalar. |
(Vector2) | The result vector. |
Subtracts a value from all elements of a vector and returns the result.
v | (Vector2) | A vector. |
scalar | (float) | A scalar. |
(Vector2) | The result vector. |
Returns whether each component of the first vector is less than the corresponding component of the second vector.
a | (Vector2) | First vector. |
b | (Vector2) | Second vector. |
(bool) | If each component of the first vector is less than the corresponding component of the second vector, true, otherwise false. |
Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector.
a | (Vector2) | First vector. |
b | (Vector2) | Second vector. |
(bool) | If each component of the first vector is less than or equal to the corresponding component of the second vector, true, otherwise false. |
Returns whether each component of the first vector is greater than the corresponding component of the second vector.
a | (Vector2) | First vector. |
b | (Vector2) | Second vector. |
(bool) | If each component of the first vector is greater than the corresponding component of the second vector, true, otherwise false. |
Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector.
a | (Vector2) | First vector. |
b | (Vector2) | Second vector. |
(bool) | If each component of the first vector is greater than or equal to the corresponding component of the second vector, true, otherwise false. |
Calculates the dot product of two vectors.
v1 | (Vector2) | The first vector. |
v2 | (Vector2) | The second vector. |
(float) | The dot product of the vectors. |
Calculates pseudo-cross product of two 2D vectors. U x V = Uy * Vx - Ux * Vy.
left | (Vector2) | The first vector. |
right | (Vector2) | The second vector. |
(float) | The pseudo-cross product of the vectors. |
Overloading of std::isfinite for kanzi::Vector2.
vec | (Vector2) | Vector2 value. |
(bool) | If both elements of the Vector2 have finite value, true, otherwise false. |