Vector with 2 floating point components: (x, y). More...
Public Member Functions | |
Vector2 () | |
Default constructor. More... | |
Vector2 (float x, float y) | |
Constructor. More... | |
Vector2 (float v) | |
Constructor. More... | |
Vector2 | add (float scalar) |
Adds a scalar to each vector element. More... | |
Vector2 | add (Vector2 v) |
Modifies this vector by adding another vector. More... | |
synchronized void | delete () |
Vector2 | divide (float scalar) |
Divides each vector element with a scalar. More... | |
boolean | equals (Object obj) |
Indicates whether some other object is "equal to" this one. More... | |
float | get (int index) |
Returns the vector element value at index. More... | |
float | getX () |
Returns the x element of the vector. More... | |
float | getY () |
Returns the y element of the vector. More... | |
int | hashCode () |
Returns a hash code value for the object. More... | |
boolean | hasNan () |
Returns true if and only if at least one of the vector values is NaN. | |
float | length () |
Calculates the length a vectors. More... | |
Vector2 | multiply (float scalar) |
Multiplies each vector element with a scalar. More... | |
Vector2 | normalized () |
Normalizes the vector and returns the resulting vector. More... | |
void | set (int index, float value) |
Sets the vector element at index to value. More... | |
void | setX (float value) |
Sets the x element of the vector. More... | |
void | setY (float value) |
Sets the y element of the vector. More... | |
float | squaredLength () |
Calculates the squared length a vectors. More... | |
Vector2 | subtract (Vector2 v) |
Modifies this vector by subtracting another vector from this vector. More... | |
Static Public Member Functions | |
static Vector2 | add (float scalar, Vector2 v) |
Adds a scalar and a vector and returns the sum. More... | |
static Vector2 | add (Vector2 v, float scalar) |
Adds a vector and a scalar and returns the sum. More... | |
static Vector2 | add (Vector2 v1, Vector2 v2) |
Adds two vectors and returns the sum. More... | |
static Vector2 | componentAbs (Vector2 v) |
Calculates component-wise absolute value for all elements and returns resulting vector. More... | |
static Vector2 | componentAdd (Vector2 v, float scalar) |
Adds a value to all elements of a vector and returns the result. More... | |
static boolean | componentAllGreaterThan (Vector2 a, Vector2 b) |
Returns whether each component of the first vector is greater than the corresponding component of the second vector. More... | |
static boolean | componentAllGreaterThanOrEqual (Vector2 a, Vector2 b) |
Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector. More... | |
static boolean | componentAllLessThan (Vector2 a, Vector2 b) |
Returns whether each component of the first vector is less than the corresponding component of the second vector. More... | |
static boolean | componentAllLessThanOrEqual (Vector2 a, Vector2 b) |
Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector. More... | |
static Vector2 | componentCeil (Vector2 v) |
Calculates component-wise ceil value for all elements and returns resulting vector. More... | |
static Vector2 | componentFloor (Vector2 v) |
Calculates component-wise floor value for all elements and returns resulting vector. More... | |
static Vector2 | componentRound (Vector2 v) |
Calculates component-wise rounded value for all elements and returns resulting vector. More... | |
static Vector2 | componentSqrt (Vector2 v) |
Calculates component-wise square root all elements and returns resulting vector. More... | |
static Vector2 | componentSubtract (Vector2 v, float scalar) |
Subtracts a value from all elements of a vector and returns the result. More... | |
static Vector2 | componentWiseDivide (Vector2 v1, Vector2 v2) |
Divides all vector elements component-wise and returns the resulting vector. More... | |
static Vector2 | componentWiseMax (Vector2 v1, Vector2 v2) |
Calculates the component-wise maximum for all vector elements and returns the resulting vector. More... | |
static Vector2 | componentWiseMin (Vector2 v1, Vector2 v2) |
Calculates the component-wise minimum for all vector elements and returns the resulting vector. More... | |
static Vector2 | componentWiseMultiply (Vector2 v1, Vector2 v2) |
Multiplies all vector elements component-wise and returns the resulting vector. More... | |
static Vector2 | componentWiseRemainder (Vector2 v1, Vector2 v2) |
Calculates component-wise the remainder for all vector elements and returns the resulting vector. More... | |
static Vector2 | createFromVector3 (Vector3 v) |
Creates a Vector2 from Vector3 by dropping the z-coordinate. More... | |
static Vector2 | divide (Vector2 v, float scalar) |
Divides all vector elements with a scalar and returns the resulting vector. More... | |
static float | dotProduct (Vector2 v1, Vector2 v2) |
Calculates the dot product of two vectors. More... | |
static Vector2 | highestValue () |
Returns the vector with each element having the most positive float value. More... | |
static boolean | isfinite (Vector2 v) |
Overloading of std::isfinite for kanzi::Vector2. More... | |
static Vector2 | lowestValue () |
Returns the vector with each element having the most negative float value. More... | |
static Vector2 | multiply (float scalar, Vector2 v) |
Multiplies all vector elements with a scalar and returns the resulting vector. More... | |
static Vector2 | multiply (Vector2 v, float scalar) |
Multiplies all vector elements with a scalar and returns the resulting vector. More... | |
static Vector2 | nan () |
Returns the vector with each element being NaN. More... | |
static Vector2 | negate (Vector2 v) |
Negates all vector elements and returns the resulting vector. More... | |
static Vector2 | negativeInfinity () |
Returns the vector with each element being the negative infinity. More... | |
static Vector2 | one () |
Returns the vector with each element being one. More... | |
static Vector2 | positiveInfinity () |
Returns the vector with each element being the positive infinity. More... | |
static float | pseudoCrossProduct (Vector2 left, Vector2 right) |
Calculates pseudo-cross product of two 2D vectors. More... | |
static Vector2 | subtract (Vector2 v1, Vector2 v2) |
Subtracts two vectors and returns the difference. More... | |
static Vector2 | zero () |
Returns the vector with each element being zero. More... | |
Protected Member Functions | |
void | finalize () |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. More... | |
Protected Attributes | |
transient boolean | swigCMemOwn |
Does this object own its native object. More... | |
Vector with 2 floating point components: (x, y).
Vector2 | ( | ) |
Default constructor.
Initializes a vector to (0.0, 0.0).
Vector2 | ( | float | x, |
float | y | ||
) |
Constructor.
Initializes a vector to (x, y).
x | x coefficient of a vector. |
y | y coefficient of a vector. |
Vector2 | ( | float | v | ) |
Constructor.
Initializes a vector to (v, v).
v | x and y coefficients of a vector. |
Vector2 add | ( | float | scalar | ) |
Adds a scalar to each vector element.
scalar | Addition to each vector element. |
Modifies this vector by adding another vector.
v | Another vector. |
Adds a scalar and a vector and returns the sum.
scalar | Left hand side scalar. |
v | Right hand side vector. |
Adds a vector and a scalar and returns the sum.
v | Left hand side vector. |
scalar | Right hand side scalar. |
Adds two vectors and returns the sum.
v1 | Left hand side vector. |
v2 | Right hand side vector. |
Calculates component-wise absolute value for all elements and returns resulting vector.
v | Vector input. |
Adds a value to all elements of a vector and returns the result.
v | A vector. |
scalar | A scalar. |
Returns whether each component of the first vector is greater than the corresponding component of the second vector.
a | First vector. |
b | Second vector. |
Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector.
a | First vector. |
b | Second vector. |
Returns whether each component of the first vector is less than the corresponding component of the second vector.
a | First vector. |
b | Second vector. |
Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector.
a | First vector. |
b | Second vector. |
Calculates component-wise ceil value for all elements and returns resulting vector.
v | Vector input. |
Calculates component-wise floor value for all elements and returns resulting vector.
v | Vector input. |
Calculates component-wise rounded value for all elements and returns resulting vector.
v | Vector input. |
Calculates component-wise square root all elements and returns resulting vector.
v | Vector input. |
Subtracts a value from all elements of a vector and returns the result.
v | A vector. |
scalar | A scalar. |
Divides all vector elements component-wise and returns the resulting vector.
v1 | The first vector. |
v2 | The second vector. |
Calculates the component-wise maximum for all vector elements and returns the resulting vector.
v1 | The first vector. |
v2 | The second vector. |
Calculates the component-wise minimum for all vector elements and returns the resulting vector.
v1 | The first vector. |
v2 | The second vector. |
Multiplies all vector elements component-wise and returns the resulting vector.
v1 | The first vector. |
v2 | The second vector. |
Calculates component-wise the remainder for all vector elements and returns the resulting vector.
v1 | The first vector. |
v2 | The second vector. |
Vector2 divide | ( | float | scalar | ) |
Divides each vector element with a scalar.
scalar | Divider for each vector element. |
Divides all vector elements with a scalar and returns the resulting vector.
v | A vector. |
scalar | A scalar. |
Calculates the dot product of two vectors.
v1 | The first vector. |
v2 | The second vector. |
boolean equals | ( | Object | obj | ) |
Indicates whether some other object is "equal to" this one.
obj | The reference object with which to compare. |
|
protected |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
Finalization is deprecated and subject to removal in future.
float get | ( | int | index | ) |
Returns the vector element value at index.
float getX | ( | ) |
Returns the x element of the vector.
float getY | ( | ) |
Returns the y element of the vector.
int hashCode | ( | ) |
Returns a hash code value for the object.
|
static |
Returns the vector with each element having the most positive float value.
|
static |
Overloading of std::isfinite for kanzi::Vector2.
float length | ( | ) |
Calculates the length a vectors.
|
static |
Returns the vector with each element having the most negative float value.
Vector2 multiply | ( | float | scalar | ) |
Multiplies each vector element with a scalar.
scalar | Multiplier for each vector element. |
Multiplies all vector elements with a scalar and returns the resulting vector.
scalar | A scalar. |
v | A vector. |
Multiplies all vector elements with a scalar and returns the resulting vector.
v | A vector. |
scalar | A scalar. |
|
static |
Returns the vector with each element being NaN.
Negates all vector elements and returns the resulting vector.
v | A vector. |
|
static |
Returns the vector with each element being the negative infinity.
Vector2 normalized | ( | ) |
Normalizes the vector and returns the resulting vector.
|
static |
Returns the vector with each element being one.
|
static |
Returns the vector with each element being the positive infinity.
Calculates pseudo-cross product of two 2D vectors.
U x V = Uy * Vx - Ux * Vy.
left | The first vector. |
right | The second vector. |
void set | ( | int | index, |
float | value | ||
) |
Sets the vector element at index to value.
index | Vector element index to set. |
value | Value to set. |
void setX | ( | float | value | ) |
Sets the x element of the vector.
value | The new value of the x element. |
void setY | ( | float | value | ) |
Sets the y element of the vector.
value | The new value of the y element. |
float squaredLength | ( | ) |
Calculates the squared length a vectors.
Modifies this vector by subtracting another vector from this vector.
v | Another vector. |
Subtracts two vectors and returns the difference.
v1 | Left hand side vector. |
v2 | Right hand side vector. |
|
static |
Returns the vector with each element being zero.
|
protected |
Does this object own its native object.