Vector3

Vector3 class

A vector with three components.

Properties

NameDescription
xThe x component.
yThe y component.
zThe z component.
ORIGINGets the origin position. The origin.
UNIT_SCALEGets the unit scale vector.
X_AXISGets the X axis. The X axis.
Y_AXISGets the Y axis. The Y axis.
Z_AXISGets the Z axis. The Z axis.

Methods

constructor

NameDescription
constructor()

Result:


constructor_overload

NameDescription
constructor_overload(x, y, z)Initializes a new instance of the Vector3 struct.

Parameters:

NameTypeDescription
xNumberThe x coordinate.
yNumberThe y coordinate.
zNumberThe z coordinate.

Result:


constructor_overload$2{#constructor_overload$2}

NameDescription
constructor_overload$2(vec)Initializes a new instance of the Vector3 struct.

Parameters:

NameTypeDescription
vecFVector3The x coordinate.

Result:


constructor_overload$3{#constructor_overload$3}

NameDescription
constructor_overload$3(v)Initializes a new instance of the Vector3 struct.

Parameters:

NameTypeDescription
vNumberV.

Result:


constructor_overload$4{#constructor_overload$4}

NameDescription
constructor_overload$4(vec4)Initializes a new instance of the Vector3 struct.

Parameters:

NameTypeDescription
vec4Vector4Vec4.

Result:


getLength2

NameDescription
getLength2()Gets the square of the length. The length2.

Result:


getLength

NameDescription
getLength()Gets the length of this vector. The length.

Result:


equals

NameDescription
equals(obj)Check if two vector3 equals

Parameters:

NameTypeDescription
objObjectThe object to check equality.

Result: boolean


hashCode

NameDescription
hashCode()Gets the hash code of Vector3

Result: Number


dot

NameDescription
dot(rhs)Gets the dot product of two vectors

Parameters:

NameTypeDescription
rhsVector3Right hand side value.

Result: Number


normalize

NameDescription
normalize()Normalizes this instance.

Result: Vector3


sin

NameDescription
sin()Calculates sine on each component

Result: Vector3


cos

NameDescription
cos()Calculates cosine on each component

Result: Vector3


cross

NameDescription
cross(rhs)Cross product of two vectors

Parameters:

NameTypeDescription
rhsVector3Right hand side value.

Result: Vector3


set

NameDescription
set(newX, newY, newZ)Sets the x/y/z component in one call.

Parameters:

NameTypeDescription
newXNumberThe x component.
newYNumberThe y component.
newZNumberThe z component.

Result: Vector3


toString

NameDescription
toString()Returns a java.lang.String that represents the current Vector3.

Result: String


angleBetween

NameDescription
angleBetween(dir, up)Calculate the inner angle between two direction Two direction can be non-normalized vectors

Parameters:

NameTypeDescription
dirVector3The direction vector to compare with
upVector3The up vector of the two direction’s shared plane

Result: Number


angleBetween

NameDescription
angleBetween(dir)Calculate the inner angle between two direction Two direction can be non-normalized vectors

Parameters:

NameTypeDescription
dirVector3The direction vector to compare with

Result: Number


compareTo

NameDescription
compareTo(other)Compare current vector to another instance.

Parameters:

NameTypeDescription
otheVector3null

Result: Number