Kanzi Java API
Vector2 Class Reference

Vector with 2 floating point components: (x, y). More...

Public Member Functions

 Vector2 (long cPtr, boolean cMemoryOwn)
 
 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)
 
float get (long index)
 
float getX ()
 Returns the x element of the vector. More...
 
float getY ()
 Returns the y element of the vector. 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 (long index, float value)
 
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)
 
static Vector2 componentAdd (Vector2 v, float scalar)
 
static boolean componentAllGreaterThan (Vector2 a, Vector2 b)
 
static boolean componentAllGreaterThanOrEqual (Vector2 a, Vector2 b)
 
static boolean componentAllLessThan (Vector2 a, Vector2 b)
 
static boolean componentAllLessThanOrEqual (Vector2 a, Vector2 b)
 
static Vector2 componentCeil (Vector2 v)
 
static Vector2 componentFloor (Vector2 v)
 
static Vector2 componentRound (Vector2 v)
 
static Vector2 componentSqrt (Vector2 v)
 
static Vector2 componentSubtract (Vector2 v, float scalar)
 
static Vector2 componentWiseDivide (Vector2 v1, Vector2 v2)
 
static Vector2 componentWiseMax (Vector2 v1, Vector2 v2)
 
static Vector2 componentWiseMin (Vector2 v1, Vector2 v2)
 
static Vector2 componentWiseMultiply (Vector2 v1, Vector2 v2)
 
static Vector2 componentWiseRemainder (Vector2 v1, Vector2 v2)
 
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)
 
static long getCPtr (Vector2 obj)
 
static Vector2 highestValue ()
 Returns the vector with each element having the most positive float value. More...
 
static boolean isfinite (Vector2 v)
 
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)
 
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 ()
 

Protected Attributes

transient boolean swigCMemOwn
 

Detailed Description

Vector with 2 floating point components: (x, y).

Constructor & Destructor Documentation

Vector2 ( )

Default constructor.

Initializes a vector to (0.0, 0.0).

Vector2 ( float  x,
float  y 
)

Constructor.

Initializes a vector to (x, y).

Parameters
xx coefficient of a vector.
yy coefficient of a vector.
Vector2 ( float  v)

Constructor.

Initializes a vector to (v, v).

Parameters
vx and y coefficients of a vector.

Member Function Documentation

Vector2 add ( float  scalar)

Adds a scalar to each vector element.


Parameters
scalarAddition to each vector element.
Returns
This vector.
Vector2 add ( Vector2  v)

Modifies this vector by adding another vector.


Parameters
vAnother vector.
Returns
This vector.
static Vector2 add ( float  scalar,
Vector2  v 
)
static

Adds a scalar and a vector and returns the sum.

Parameters
scalarLeft hand side scalar.
vRight hand side vector.
Returns
The result vector.
static Vector2 add ( Vector2  v,
float  scalar 
)
static

Adds a vector and a scalar and returns the sum.

Parameters
vLeft hand side vector.
scalarRight hand side scalar.
Returns
The result vector.
static Vector2 add ( Vector2  v1,
Vector2  v2 
)
static

Adds two vectors and returns the sum.

Parameters
v1Left hand side vector.
v2Right hand side vector.
Returns
The result vector.
static Vector2 createFromVector3 ( Vector3  v)
static

Creates a Vector2 from Vector3 by dropping the z-coordinate.


Parameters
vInput vector.
Returns
The input vector without z-coordinate.
Vector2 divide ( float  scalar)

Divides each vector element with a scalar.


Parameters
scalarDivider for each vector element.
Returns
This vector.
static Vector2 divide ( Vector2  v,
float  scalar 
)
static

Divides all vector elements with a scalar and returns the resulting vector.

Parameters
vA vector.
scalarA scalar.
Returns
The result vector.
float getX ( )

Returns the x element of the vector.


Returns
The x element.
float getY ( )

Returns the y element of the vector.


Returns
The y element.
static Vector2 highestValue ( )
static

Returns the vector with each element having the most positive float value.


Returns
Vector with the highest possible value.
float length ( )

Calculates the length a vectors.


Returns
sqrt(x*x + y*y)
static Vector2 lowestValue ( )
static

Returns the vector with each element having the most negative float value.


Returns
Vector with the lowest possible value.
Vector2 multiply ( float  scalar)

Multiplies each vector element with a scalar.


Parameters
scalarMultiplier for each vector element.
Returns
This vector.
static Vector2 multiply ( float  scalar,
Vector2  v 
)
static

Multiplies all vector elements with a scalar and returns the resulting vector.

Parameters
scalarA scalar.
vA vector.
Returns
The result vector.
static Vector2 multiply ( Vector2  v,
float  scalar 
)
static

Multiplies all vector elements with a scalar and returns the resulting vector.

Parameters
vA vector.
scalarA scalar.
Returns
The result vector.
static Vector2 nan ( )
static

Returns the vector with each element being NaN.


Returns
Vector with NaN elements.
static Vector2 negate ( Vector2  v)
static

Negates all vector elements and returns the resulting vector.

Parameters
vA vector.
Returns
The result vector.
static Vector2 negativeInfinity ( )
static

Returns the vector with each element being the negative infinity.


Returns
Vector with negative infinity elements.
Vector2 normalized ( )

Normalizes the vector and returns the resulting vector.


Returns
The normalized vector.
static Vector2 one ( )
static

Returns the vector with each element being one.


Returns
Vector with unit element values.
static Vector2 positiveInfinity ( )
static

Returns the vector with each element being the positive infinity.


Returns
Vector with positive infinity elements.
void setX ( float  value)

Sets the x element of the vector.


Parameters
valueThe new value of the x element.
void setY ( float  value)

Sets the y element of the vector.


Parameters
valueThe new value of the y element.
float squaredLength ( )

Calculates the squared length a vectors.


Returns
x*x + y*y
Vector2 subtract ( Vector2  v)

Modifies this vector by subtracting another vector from this vector.


Parameters
vAnother vector.
Returns
This vector.
static Vector2 subtract ( Vector2  v1,
Vector2  v2 
)
static

Subtracts two vectors and returns the difference.

Parameters
v1Left hand side vector.
v2Right hand side vector.
Returns
The result vector.
static Vector2 zero ( )
static

Returns the vector with each element being zero.


Returns
Vector with zeroed elements.