B.Math.Vector3()

Represents a 3D vector / point.

To create the object use B.Math.makeVector3().

CONSTANTS:

{B.Math.Vector3} ZERO = {x: 0.0, y: 0.0, z: 0.0}

Zero vector.

{B.Math.Vector3} INF = {x: Infinity, y: Infinity, z: Infinity}

Positive infinity point.

{B.Math.Vector3} N_INF = {x: -Infinity, y: -Infinity, z: -Infinity}

Negative infinity point.

{B.Math.Vector3} X = {x: 1.0, y: 0.0, z: 0.0}

Positive direction along X-axis.

{B.Math.Vector3} Y = {x: 0.0, y: 1.0, z: 0.0}

Positive direction along Y-axis.

{B.Math.Vector3} Z = {x: 0.0, y: 0.0, z: 1.0}

Positive direction along Z-axis.

{B.Math.Vector3} N_X = {x: -1.0, y: 0.0, z: 0.0}

Negative direction along X-axis.

{B.Math.Vector3} N_Y = {x: 0.0, y: -1.0, z: 0.0}

Negative direction along Y-axis.

{B.Math.Vector3} N_Z = {x: 0.0, y: 0.0, z: -1.0}

Negative direction along Z-axis.

PROPERTIES:

{number} x

X component.

{number} y

Y component.

{number} z

Z component.

METHODS:

clone()

Clones this vector to a new vector.

RETURNS:

copy(v)

Copies a given vector into this vector.

PARAMETERS:

RETURNS:

set(x, y, z)

Sets this vector from separated components.

PARAMETERS:

{number} x

{number} y

{number} z

RETURNS:

get(index)

Gets an element by its index.

PARAMETERS:

{number} index

RETURNS:

{number}

THROWS:

{Error}

if the index is out of range

fromArray(array, offset)

Sets this vector from a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

toArray(array, offset)

Sets this vector to a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

length()

Calculates the length of this vector.

RETURNS:

{number}

length

lengthSq()

Calculates the squared length of this vector.

RETURNS:

{number}

squared length

normalize()

Normalizes this vector.

RETURNS:

negate()

Inverts this vector.

RETURNS:

clamp(minVal, maxVal)

Clamps components of this vector.

PARAMETERS:

{number} [minVal] = 0.0

{number} [maxVal] = 1.0

RETURNS:

add(v)

Adds a vector or a scalar to this vector.

PARAMETERS:

{number | B.Math.Vector3} v

RETURNS:

addVectors(a, b)

Adds two given vectors and sets the result to this.

PARAMETERS:

RETURNS:

sub(v)

Subtracts a vector or a scalar from this vector.

PARAMETERS:

{number | B.Math.Vector3} v

RETURNS:

subVectors(a, b)

Subtracts two given vectors and sets the result to this.

PARAMETERS:

RETURNS:

mul(v)

Multiplies this vector by a given vector or a scalar.

PARAMETERS:

{number | B.Math.Vector3} v

RETURNS:

mulVectors(a, b)

Multiplies two given vectors and sets the result to this.

PARAMETERS:

RETURNS:

div(v)

Divides this vector by a given vector or a scalar.

PARAMETERS:

{number | B.Math.Vector3} v

RETURNS:

divVectors(a, b)

Divides two given vectors and sets the result to this.

PARAMETERS:

RETURNS:

dot(v)

Calculates the dot product of this vector and another vector.

PARAMETERS:

RETURNS:

{number}

dot product

cross(v)

Sets this vector to the cross product of itself and another vector.

PARAMETERS:

RETURNS:

crossVectors(a, b)

Calculates the cross product of two given vectors and sets the result to this.

PARAMETERS:

RETURNS:

reflect(normal)

Reflects this vector by a normal vector.

PARAMETERS:

{B.Math.Vector3} normal

RETURNS:

transform3(matrix)

Transforms this vector by a 3x3 matrix.

PARAMETERS:

{B.Math.Matrix3} matrix

RETURNS:

transform4(matrix, w)

Transforms this vector by a 4x4 matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

{number} [w] = 1.0

additional vector's component

RETURNS:

transform(matrix, w)

Transforms this vector by any matrix.

PARAMETERS:

{B.Math.Matrix3 | B.Math.Matrix4} matrix

{number} [w] = 1.0

additional vector's component

RETURNS:

rotate(object)

Rotates this vector by a quaternion or an Euler angles object.

PARAMETERS:

RETURNS:

angleTo(v)

Calculates the angle in radians between this vector and another vector.

PARAMETERS:

RETURNS:

{number}

angle

distanceTo(v)

Calculates the distance between this vector and another vector.

PARAMETERS:

RETURNS:

{number}

distance

distanceToSq(v)

Calculates squared distance between this vector and another vector.

PARAMETERS:

RETURNS:

{number}

squared distance

equal(v)

Checks for strict equality of this vector and another vector.

PARAMETERS:

RETURNS:

{boolean}

CONSTANTS:

PROPERTIES:

METHODS: