CLASSES
TagsA - Z

Vector4

Objects

Description

class Vector4

Constructor

new Vector4(x, y, z, w)

Creates a Vector4 object from the passed floats.

Parameters

Name Type Description
x number
y number
z number

Members

x : number

y : number

z : number

w : number

Methods

toString() string

Returns the string with the Vector4 coordinates.

getClassName() string

Returns the string "Vector4".

getHashCode() number

Returns the Vector4 hash code.

asArray() number[]

Returns a new array populated with 4 elements : the Vector4 coordinates.

toArray(array, Float32Array, index) Vector4

Populates the passed array from the passed index with the Vector4 coordinates.

Returns the Vector4.

Parameters

Name Type Description
array number[] or Float32Array
optional index number

addInPlace(otherVector) Vector4

Adds the passed vector to the current Vector4.

Returns the updated Vector4.

Parameters

Name Type Description
otherVector Vector4

add(otherVector) Vector4

Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.

Parameters

Name Type Description
otherVector Vector4

addToRef(otherVector, result) Vector4

Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.

Returns the current Vector4.

Parameters

Name Type Description
otherVector Vector4
result Vector4

subtractInPlace(otherVector) Vector4

Subtract in place the passed vector from the current Vector4.

Returns the updated Vector4.

Parameters

Name Type Description
otherVector Vector4

subtract(otherVector) Vector4

Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.

Parameters

Name Type Description
otherVector Vector4

subtractToRef(otherVector, result) Vector4

Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.

Returns the current Vector4.

Parameters

Name Type Description
otherVector Vector4
result Vector4

subtractFromFloats(x, y, z, w) Vector4

Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.

Parameters

Name Type Description
x number
y number
z number

subtractFromFloatsToRef(x, y, z, w, result) Vector4

Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.

Returns the current Vector4.

Parameters

Name Type Description
x number
y number
z number
w number

negate() Vector4

Returns a new Vector4 set with the current Vector4 negated coordinates.

scaleInPlace(scale) Vector4

Multiplies the current Vector4 coordinates by scale (float).

Returns the updated Vector4.

Parameters

Name Type Description
scale number

scale(scale) Vector4

Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).

Parameters

Name Type Description
scale number

scaleToRef(scale, result) Vector4

Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).

Returns the current Vector4.

Parameters

Name Type Description
scale number
result Vector4

equals(otherVector) boolean

Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.

Parameters

Name Type Description
otherVector Vector4

equalsWithEpsilon(otherVector, epsilon) boolean

Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.

Parameters

Name Type Description
otherVector Vector4
optional epsilon number

equalsToFloats(x, y, z, w) boolean

Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.

Parameters

Name Type Description
x number
y number
z number

multiplyInPlace(otherVector) Vector4

Multiplies in place the current Vector4 by the passed one.

Returns the updated Vector4.

Parameters

Name Type Description
otherVector Vector4

multiply(otherVector) Vector4

Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.

Parameters

Name Type Description
otherVector Vector4

multiplyToRef(otherVector, result) Vector4

Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.

Returns the current Vector4.

Parameters

Name Type Description
otherVector Vector4
result Vector4

multiplyByFloats(x, y, z, w) Vector4

Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.

Parameters

Name Type Description
x number
y number
z number

divide(otherVector) Vector4

Returns a new Vector4 set with the division result of the current Vector4 by the passed one.

Parameters

Name Type Description
otherVector Vector4

divideToRef(otherVector, result) Vector4

Updates the passed vector "result" with the division result of the current Vector4 by the passed one.

Returns the current Vector4.

Parameters

Name Type Description
otherVector Vector4
result Vector4

MinimizeInPlace(other) Vector4

Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones.

Parameters

Name Type Description
other Vector4

MaximizeInPlace(other) Vector4

Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones.

Parameters

Name Type Description
other Vector4

length() number

Returns the Vector4 length (float).

lengthSquared() number

Returns the Vector4 squared length (float).

normalize() Vector4

Normalizes in place the Vector4.

Returns the updated Vector4.

toVector3() Vector3

Returns a new Vector3 from the Vector4 (x, y, z) coordinates.

clone() Vector4

Returns a new Vector4 copied from the current one.

copyFrom(source) Vector4

Updates the current Vector4 with the passed one coordinates.

Returns the updated Vector4.

Parameters

Name Type Description
source Vector4

copyFromFloats(x, y, z, w) Vector4

Updates the current Vector4 coordinates with the passed floats.

Returns the updated Vector4.

Parameters

Name Type Description
x number
y number
z number

set(x, y, z, w) Vector4

Updates the current Vector4 coordinates with the passed floats.

Returns the updated Vector4.

Parameters

Name Type Description
x number
y number
z number

static FromArray(array, offset) Vector4

Returns a new Vector4 set from the starting index of the passed array.

Parameters

Name Type Description
array ArrayLike<number>
optional offset number

static FromArrayToRef(array, offset, result) void

Updates the passed vector "result" from the starting index of the passed array.

Parameters

Name Type Description
array ArrayLike<number>
offset number
result Vector4

static FromFloatArrayToRef(array, offset, result) void

Updates the passed vector "result" from the starting index of the passed Float32Array.

Parameters

Name Type Description
array Float32Array
offset number
result Vector4

static FromFloatsToRef(x, y, z, w, result) void

Updates the passed vector "result" coordinates from the passed floats.

Parameters

Name Type Description
x number
y number
z number
w number

static Zero() Vector4

Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)

static One() Vector4

Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)

static Normalize(vector) Vector4

Returns a new normalized Vector4 from the passed one.

Parameters

Name Type Description
vector Vector4

static NormalizeToRef(vector, result) void

Updates the passed vector "result" from the normalization of the passed one.

Parameters

Name Type Description
vector Vector4
result Vector4

static Minimize(left, right) Vector4

Parameters

Name Type Description
left Vector4
right Vector4

static Maximize(left, right) Vector4

Parameters

Name Type Description
left Vector4
right Vector4

static Distance(value1, value2) number

Returns the distance (float) between the vectors "value1" and "value2".

Parameters

Name Type Description
value1 Vector4
value2 Vector4

static DistanceSquared(value1, value2) number

Returns the squared distance (float) between the vectors "value1" and "value2".

Parameters

Name Type Description
value1 Vector4
value2 Vector4

static Center(value1, value2) Vector4

Returns a new Vector4 located at the center between the vectors "value1" and "value2".

Parameters

Name Type Description
value1 Vector4
value2 Vector4

static TransformNormal(vector, transformation) Vector4

Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.

This methods computes transformed normalized direction vectors only.

Parameters

Name Type Description
vector Vector4
transformation Matrix

static TransformNormalToRef(vector, transformation, result) void

Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.

This methods computes transformed normalized direction vectors only.

Parameters

Name Type Description
vector Vector4
transformation Matrix
result Vector4

static TransformNormalFromFloatsToRef(x, y, z, w, transformation, result) void

Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).

This methods computes transformed normalized direction vectors only.

Parameters

Name Type Description
x number
y number
z number
w number
transformation Matrix