B.Math.Quaternion()

Represents a unit quaternion.

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

Note: the order of transformations coincides with the order in which the quaternions are multiplied (from left to right).

CONSTANTS:

{B.Math.Quaternion} IDENTITY = {w: 1.0, x: 0.0, y: 0.0, z: 0.0}

Identity quaternion.

METHODS:

clone()

Clones this quaternion to a new quaternion object.

RETURNS:

copy(q)

Copies a given quaternion object into this quaternion.

PARAMETERS:

RETURNS:

set(w, x, y, z)

Sets all elements and performs normalization.

PARAMETERS:

{number} w

{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 quaternion from a part of array and performs normalization.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

toArray(array, offset)

Sets this quaternion to a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

fromAxisAngle(axis, angle)

Sets this quaternion from an axis vector and an angle.

PARAMETERS:

{B.Math.Vector3} axis

{number} angle

RETURNS:

fromRotationMatrix(matrix)

Sets this quaternion from any rotation matrix.

PARAMETERS:

RETURNS:

fromAngles(angles)

Sets this quaternion from Euler angles.

PARAMETERS:

{B.Math.Angles} angles

RETURNS:

axis(result)

Returns the axis vector (or zero-vector for identity quaternion).

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector.

RETURNS:

angle()

Returns the angle.

RETURNS:

{number}

mulQuaternions(a, b)

Multiplies two given quaternions and sets the result to this.

PARAMETERS:

RETURNS:

mul(q)

Multiplies this quaternion by a given quaternion.

PARAMETERS:

RETURNS:

dot(q)

Calculates the dot product of this quaternion and another quaternion.

PARAMETERS:

RETURNS:

{number}

this

invert()

Inverts this quaternion.

RETURNS:

slerp(q, t, result)

Spherically interpolates between this quaternion and another quaternion by t.

PARAMETERS:

{B.Math.Quaternion} q

{number} t

[0.0, 1.0]

{B.Math.Quaternion} [result]

omit if you want to return newly created quaternion.

RETURNS:

equal(q)

Checks for strict equality of this quaternion and another quaternion.

PARAMETERS:

RETURNS:

{boolean}

CONSTANTS:

METHODS: