Kanzi 3.9.10
Vector3 Class Reference

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

Public Member Functions

 Vector3 ()
 Default constructor, initializes the vector to (0.0, 0.0, 0.0).
 
 Vector3 (float v)
 Constructor, initializes the vector to (v, v, v).
 
 Vector3 (float x, float y, float z)
 Constructor, initializes the vector to (x, y, z).
 
Vector3 add (float scalar)
 Adds a scalar to each vector element.
 
Vector3 add (Vector3 v)
 Modifies this vector by adding another vector.
 
synchronized void delete ()
 
Vector3 divide (float scalar)
 Divides each vector element with a scalar.
 
boolean equals (Object obj)
 Indicates whether some other object is "equal to" this one.
 
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.
 
float getZ ()
 Returns the z element of the vector.
 
int hashCode ()
 Returns a hash code value for the object.
 
boolean hasNan ()
 Returns true if and only if at least one of the vector values is NaN.
 
float length ()
 Calculates the length a vectors.
 
Vector3 maximumAxis ()
 Returns axis based on the largest component of Vector3.
 
Vector3 minimumAxis ()
 Returns axis based on the minimum component of Vector3.
 
Vector3 multiply (float scalar)
 Multiplies each vector element with a scalar.
 
Vector3 normalized ()
 Normalizes the vector and returns the resulting vector.
 
void set (int index, float value)
 Sets the vector element at index to value.
 
void setX (float value)
 Sets the x element of the vector.
 
void setY (float value)
 Sets the y element of the vector.
 
void setZ (float value)
 Sets the z element of the vector.
 
float squaredLength ()
 Calculates the squared length a vectors.
 
Vector3 subtract (Vector3 v)
 Modifies this vector by subtracting another vector from this vector.
 

Static Public Member Functions

static Vector3 add (float scalar, Vector3 v)
 Adds a scalar and a vector and returns the sum.
 
static Vector3 add (Vector3 v, float scalar)
 Adds a vector and a scalar and returns the sum.
 
static Vector3 add (Vector3 v1, Vector3 v2)
 Adds two vectors and returns the sum.
 
static Vector3 componentAbs (Vector3 v)
 Calculates component-wise absolute value for all elements and returns resulting vector.
 
static Vector3 componentAdd (Vector3 v, float scalar)
 Adds a value to all elements of a vector and returns the result.
 
static boolean componentAllGreaterThan (Vector3 a, Vector3 b)
 Returns whether each component of the first vector is greater than the corresponding component of the second vector.
 
static boolean componentAllGreaterThanOrEqual (Vector3 a, Vector3 b)
 Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector.
 
static boolean componentAllLessThan (Vector3 a, Vector3 b)
 Returns whether each component of the first vector is less than the corresponding component of the second vector.
 
static boolean componentAllLessThanOrEqual (Vector3 a, Vector3 b)
 Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector.
 
static Vector3 componentCeil (Vector3 v)
 Calculates component-wise ceil value for all elements and returns resulting vector.
 
static Vector3 componentFloor (Vector3 v)
 Calculates component-wise floor value for all elements and returns resulting vector.
 
static Vector3 componentRound (Vector3 v)
 Calculates component-wise rounded value for all elements and returns resulting vector.
 
static Vector3 componentSqrt (Vector3 v)
 Calculates component-wise square root all elements and returns resulting vector.
 
static Vector3 componentSubtract (Vector3 v, float scalar)
 Subtracts a value from all elements of a vector and returns the result.
 
static Vector3 componentWiseDivide (Vector3 v1, Vector3 v2)
 Divides component-wise all vector elements and returns the resulting vector.
 
static Vector3 componentWiseMax (Vector3 v1, Vector3 v2)
 Calculates the component-wise maximum for all vector elements and returns the resulting vector.
 
static Vector3 componentWiseMin (Vector3 v1, Vector3 v2)
 Calculates the component-wise minimum for all vector elements and returns the resulting vector.
 
static Vector3 componentWiseMultiply (Vector3 v1, Vector3 v2)
 Multiplies component-wise all vector elements and returns the resulting vector.
 
static Vector3 componentWiseRemainder (Vector3 v1, Vector3 v2)
 Calculates component-wise the remainder for all vector elements and returns the resulting vector.
 
static Vector3 crossProduct (Vector3 v1, Vector3 v2)
 Calculates the cross product of two vectors.
 
static Vector3 divide (Vector3 v, float scalar)
 Divides all vector elements with a scalar and returns the resulting vector.
 
static float dotProduct (Vector3 v1, Vector3 v2)
 Calculates the dot product of two vectors.
 
static Vector3 getOrthogonalVector (Vector3 v)
 Finds a vector that is orthogonal to the given vector.
 
static Vector3 highestValue ()
 Returns the vector with each element having the most positive float value.
 
static Vector3 linearTosRGB (Vector3 vec)
 Converts to whole Vector3 from linear to sRGB.
 
static Vector3 lowestValue ()
 Returns the vector with each element having the most negative float value.
 
static Vector3 multiply (float scalar, Vector3 v)
 Multiplies all vector elements with a scalar and returns the resulting vector.
 
static Vector3 multiply (Vector3 v, float scalar)
 Multiplies all vector elements with a scalar and returns the resulting vector.
 
static Vector3 nan ()
 Returns the vector with each element being NaN.
 
static Vector3 negate (Vector3 v)
 Negates all vector elements and returns the resulting vector.
 
static Vector3 negativeInfinity ()
 Returns the vector with each element being the negative infinity.
 
static Vector3 negativeX ()
 Returns the unit vector pointing left.
 
static Vector3 negativeY ()
 Returns the unit vector pointing down.
 
static Vector3 negativeZ ()
 Returns the unit vector pointing forward.
 
static Vector3 one ()
 Returns the vector with each element being one.
 
static Vector3 positiveInfinity ()
 Returns the vector with each element being the positive infinity.
 
static Vector3 positiveX ()
 Returns the unit vector pointing right.
 
static Vector3 positiveY ()
 Returns the unit vector pointing up.
 
static Vector3 positiveZ ()
 Returns the unit vector pointing backward.
 
static Vector3 sRGBToLinear (Vector3 vec)
 Converts to whole Vector3 from sRGB to linear.
 
static Vector3 subtract (Vector3 v1, Vector3 v2)
 Subtracts two vectors and returns the difference.
 
static Vector3 zero ()
 Returns the vector with each element being zero.
 

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.
 

Protected Attributes

transient boolean swigCMemOwn
 Does this object own its native object.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Vector3() [1/2]

Vector3 ( float x,
float y,
float z )

Constructor, initializes the vector to (x, y, z).


Parameters
xx component of the vector.
yy component of the vector.
zz component of the vector.

◆ Vector3() [2/2]

Vector3 ( float v)

Constructor, initializes the vector to (v, v, v).


Parameters
vx, y and z components of the vector.

Member Function Documentation

◆ add() [1/5]

Vector3 add ( float scalar)

Adds a scalar to each vector element.


Parameters
scalarAddition to each vector element.
Returns
This vector.

◆ add() [2/5]

static Vector3 add ( float scalar,
Vector3 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.

◆ add() [3/5]

Vector3 add ( Vector3 v)

Modifies this vector by adding another vector.


Parameters
vAnother vector.
Returns
This vector.

◆ add() [4/5]

static Vector3 add ( Vector3 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.

◆ add() [5/5]

static Vector3 add ( Vector3 v1,
Vector3 v2 )
static

Adds two vectors and returns the sum.

Parameters
v1Left hand side vector.
v2Right hand side vector.
Returns
The result vector.

◆ componentAbs()

static Vector3 componentAbs ( Vector3 v)
static

Calculates component-wise absolute value for all elements and returns resulting vector.


Parameters
vVector input.
Returns
The result vector.

◆ componentAdd()

static Vector3 componentAdd ( Vector3 v,
float scalar )
static

Adds a value to all elements of a vector and returns the result.


Parameters
vA vector.
scalarA scalar.
Returns
The result vector.

◆ componentAllGreaterThan()

static boolean componentAllGreaterThan ( Vector3 a,
Vector3 b )
static

Returns whether each component of the first vector is greater than the corresponding component of the second vector.


Parameters
aFirst vector.
bSecond vector.
Returns
If each component of the first vector is greater than the corresponding component of the second vector, true, otherwise false.

◆ componentAllGreaterThanOrEqual()

static boolean componentAllGreaterThanOrEqual ( Vector3 a,
Vector3 b )
static

Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector.


Parameters
aFirst vector.
bSecond vector.
Returns
If each component of the first vector is greater than or equal to the corresponding component of the second vector, true, otherwise false.

◆ componentAllLessThan()

static boolean componentAllLessThan ( Vector3 a,
Vector3 b )
static

Returns whether each component of the first vector is less than the corresponding component of the second vector.


Parameters
aFirst vector.
bSecond vector.
Returns
If each component of the first vector is less than the corresponding component of the second vector, true, otherwise false.

◆ componentAllLessThanOrEqual()

static boolean componentAllLessThanOrEqual ( Vector3 a,
Vector3 b )
static

Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector.


Parameters
aFirst vector.
bSecond vector.
Returns
If each component of the first vector is less than or equal to the corresponding component of the second vector, true, otherwise false.

◆ componentCeil()

static Vector3 componentCeil ( Vector3 v)
static

Calculates component-wise ceil value for all elements and returns resulting vector.


Parameters
vVector input.
Returns
The result vector.

◆ componentFloor()

static Vector3 componentFloor ( Vector3 v)
static

Calculates component-wise floor value for all elements and returns resulting vector.


Parameters
vVector input.
Returns
The result vector.

◆ componentRound()

static Vector3 componentRound ( Vector3 v)
static

Calculates component-wise rounded value for all elements and returns resulting vector.


Parameters
vVector input.
Returns
The result vector.

◆ componentSqrt()

static Vector3 componentSqrt ( Vector3 v)
static

Calculates component-wise square root all elements and returns resulting vector.


Parameters
vVector input.
Returns
The result vector.

◆ componentSubtract()

static Vector3 componentSubtract ( Vector3 v,
float scalar )
static

Subtracts a value from all elements of a vector and returns the result.


Parameters
vA vector.
scalarA scalar.
Returns
The result vector.

◆ componentWiseDivide()

static Vector3 componentWiseDivide ( Vector3 v1,
Vector3 v2 )
static

Divides component-wise all vector elements and returns the resulting vector.


Parameters
v1The first vector.
v2The second vector.
Returns
The result vector.

◆ componentWiseMax()

static Vector3 componentWiseMax ( Vector3 v1,
Vector3 v2 )
static

Calculates the component-wise maximum for all vector elements and returns the resulting vector.


Parameters
v1The first vector.
v2The second vector.
Returns
The result vector.

◆ componentWiseMin()

static Vector3 componentWiseMin ( Vector3 v1,
Vector3 v2 )
static

Calculates the component-wise minimum for all vector elements and returns the resulting vector.


Parameters
v1The first vector.
v2The second vector.
Returns
The result vector.

◆ componentWiseMultiply()

static Vector3 componentWiseMultiply ( Vector3 v1,
Vector3 v2 )
static

Multiplies component-wise all vector elements and returns the resulting vector.


Parameters
v1The first vector.
v2The second vector.
Returns
The result vector.

◆ componentWiseRemainder()

static Vector3 componentWiseRemainder ( Vector3 v1,
Vector3 v2 )
static

Calculates component-wise the remainder for all vector elements and returns the resulting vector.


Parameters
v1The first vector.
v2The second vector.
Returns
The result vector.

◆ crossProduct()

static Vector3 crossProduct ( Vector3 v1,
Vector3 v2 )
static

Calculates the cross product of two vectors.


Parameters
v1The first vector.
v2The second vector.
Returns
The cross product of the vectors.

◆ divide() [1/2]

Vector3 divide ( float scalar)

Divides each vector element with a scalar.


Parameters
scalarDivider for each vector element.
Returns
This vector.

◆ divide() [2/2]

static Vector3 divide ( Vector3 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.

◆ dotProduct()

static float dotProduct ( Vector3 v1,
Vector3 v2 )
static

Calculates the dot product of two vectors.


Parameters
v1The first vector.
v2The second vector.
Returns
The dot product of the vectors.

◆ equals()

boolean equals ( Object obj)

Indicates whether some other object is "equal to" this one.

Parameters
objThe reference object with which to compare.
Returns
True if this object is the same as the obj argument, otherwise false.

◆ finalize()

void finalize ( )
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.

◆ get()

float get ( int index)

Returns the vector element value at index.


Returns
The vector element value at index.

◆ getOrthogonalVector()

static Vector3 getOrthogonalVector ( Vector3 v)
static

Finds a vector that is orthogonal to the given vector.


Parameters
vSource vector. Length must be 1.
Returns
Vector orthogonal to the source vector. Not necessarily of unit length.

◆ getX()

float getX ( )

Returns the x element of the vector.


Returns
The x element.

◆ getY()

float getY ( )

Returns the y element of the vector.


Returns
The y element.

◆ getZ()

float getZ ( )

Returns the z element of the vector.


Returns
The z element.

◆ hashCode()

int hashCode ( )

Returns a hash code value for the object.

Returns
A hash code value for this object.

◆ highestValue()

static Vector3 highestValue ( )
static

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


Returns
Vector with the highest possible value.

◆ length()

float length ( )

Calculates the length a vectors.


Returns
sqrt(x*x + y*y + z*z)

◆ linearTosRGB()

static Vector3 linearTosRGB ( Vector3 vec)
static

Converts to whole Vector3 from linear to sRGB.


Since linear-to-sRGB conversion does not take alpha into account, it is possible to interpret Vector3 as just the RGB components.

Parameters
vecVector3 representing color in linear format.
Returns
Vector3 representing color in sRGB format.

◆ lowestValue()

static Vector3 lowestValue ( )
static

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


Returns
Vector with the lowest possible value.

◆ maximumAxis()

Vector3 maximumAxis ( )

Returns axis based on the largest component of Vector3.


Returns
If X component is largest, (1, 0, 0), else if Y component is largest, (0, 1, 0), else (0, 0, 1).

◆ minimumAxis()

Vector3 minimumAxis ( )

Returns axis based on the minimum component of Vector3.


Returns
If X component is smallest, (1, 0, 0), else if Y component is smallest, (0, 1, 0), else (0, 0, 1).

◆ multiply() [1/3]

Vector3 multiply ( float scalar)

Multiplies each vector element with a scalar.


Parameters
scalarMultiplier for each vector element.
Returns
This vector.

◆ multiply() [2/3]

static Vector3 multiply ( float scalar,
Vector3 v )
static

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

Parameters
scalarA scalar.
vA vector.
Returns
The result vector.

◆ multiply() [3/3]

static Vector3 multiply ( Vector3 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.

◆ nan()

static Vector3 nan ( )
static

Returns the vector with each element being NaN.


Returns
Vector with NaN elements.

◆ negate()

static Vector3 negate ( Vector3 v)
static

Negates all vector elements and returns the resulting vector.

Parameters
vA vector.
Returns
The result vector.

◆ negativeInfinity()

static Vector3 negativeInfinity ( )
static

Returns the vector with each element being the negative infinity.


Returns
Vector with negative infinity elements.

◆ negativeX()

static Vector3 negativeX ( )
static

Returns the unit vector pointing left.


Returns
Vector3(-1.0f, 0.0f, 0.0f).

◆ negativeY()

static Vector3 negativeY ( )
static

Returns the unit vector pointing down.


Returns
Vector3(0.0f, -1.0f, 0.0f).

◆ negativeZ()

static Vector3 negativeZ ( )
static

Returns the unit vector pointing forward.


Returns
Vector3(0.0f, 0.0f, -1.0f).

◆ normalized()

Vector3 normalized ( )

Normalizes the vector and returns the resulting vector.


Returns
The normalized vector.

◆ one()

static Vector3 one ( )
static

Returns the vector with each element being one.


Returns
Vector with unit element values.

◆ positiveInfinity()

static Vector3 positiveInfinity ( )
static

Returns the vector with each element being the positive infinity.


Returns
Vector with positive infinity elements.

◆ positiveX()

static Vector3 positiveX ( )
static

Returns the unit vector pointing right.


Returns
Vector3(1.0f, 0.0f, 0.0f).

◆ positiveY()

static Vector3 positiveY ( )
static

Returns the unit vector pointing up.


Returns
Vector3(0.0f, 1.0f, 0.0f).

◆ positiveZ()

static Vector3 positiveZ ( )
static

Returns the unit vector pointing backward.


Returns
Vector3(0.0f, 0.0f, 1.0f).

◆ set()

void set ( int index,
float value )

Sets the vector element at index to value.


Parameters
indexVector element index to set.
valueValue to set.

◆ setX()

void setX ( float value)

Sets the x element of the vector.


Parameters
valueThe new value of the x element.

◆ setY()

void setY ( float value)

Sets the y element of the vector.


Parameters
valueThe new value of the y element.

◆ setZ()

void setZ ( float value)

Sets the z element of the vector.


Parameters
valueThe new value of the z element.

◆ squaredLength()

float squaredLength ( )

Calculates the squared length a vectors.


Returns
x*x + y*y + z*z

◆ sRGBToLinear()

static Vector3 sRGBToLinear ( Vector3 vec)
static

Converts to whole Vector3 from sRGB to linear.


Since sRGB-to-linear conversion does not take alpha into account, it is possible to interpret Vector3 as just the RGB components.

Parameters
vecVector3 representing color in sRGB format.
Returns
Vector3 representing color in linear format.

◆ subtract() [1/2]

Vector3 subtract ( Vector3 v)

Modifies this vector by subtracting another vector from this vector.


Parameters
vAnother vector.
Returns
This vector.

◆ subtract() [2/2]

static Vector3 subtract ( Vector3 v1,
Vector3 v2 )
static

Subtracts two vectors and returns the difference.

Parameters
v1Left hand side vector.
v2Right hand side vector.
Returns
The result vector.

◆ zero()

static Vector3 zero ( )
static

Returns the vector with each element being zero.


Returns
Vector with zeroed elements.