Quaternion

Description

class Quaternion

Constructor

new Quaternion(x, y, z, w)

Creates a new Quaternion from the passed floats.

Parameters

Name Type Description
optional x number
optional y number
optional z number

Members

x : number

y : number

z : number

w : number

Methods

toString() string

Returns a string with the Quaternion coordinates.

getClassName() string

Returns the string "Quaternion".

getHashCode() number

Returns the Quaternion hash code.

asArray() number[]

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

equals(otherQuaternion) boolean

Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.

Parameters

Name Type Description
otherQuaternion Quaternion

clone() Quaternion

Returns a new Quaternion copied from the current one.

copyFrom(other) Quaternion

Updates the current Quaternion from the passed one coordinates.

Returns the updated Quaterion.

Parameters

Name Type Description
other Quaternion

copyFromFloats(x, y, z, w) Quaternion

Updates the current Quaternion from the passed float coordinates.

Returns the updated Quaterion.

Parameters

Name Type Description
x number
y number
z number

set(x, y, z, w) Quaternion

Updates the current Quaternion from the passed float coordinates.

Returns the updated Quaterion.

Parameters

Name Type Description
x number
y number
z number

add(other) Quaternion

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

Parameters

Name Type Description
other Quaternion

subtract(other) Quaternion

Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.

Parameters

Name Type Description
other Quaternion

scale(value) Quaternion

Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".

Parameters

Name Type Description
value number

multiply(q1) Quaternion

Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".

Parameters

Name Type Description
q1 Quaternion

multiplyToRef(q1, result) Quaternion

Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".

Returns the current Quaternion.

Parameters

Name Type Description
q1 Quaternion
result Quaternion

multiplyInPlace(q1) Quaternion

Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".

Returns the updated Quaternion.

Parameters

Name Type Description
q1 Quaternion

conjugateToRef(ref) Quaternion

Sets the passed "ref" with the conjugation of the current Quaternion.

Returns the current Quaternion.

Parameters

Name Type Description
ref Quaternion

conjugateInPlace() Quaternion

Conjugates in place the current Quaternion.

Returns the updated Quaternion.

conjugate() Quaternion

Returns a new Quaternion as the conjugate of the current Quaternion.

length() number

Returns the Quaternion length (float).

normalize() Quaternion

Normalize in place the current Quaternion.

Returns the updated Quaternion.

toEulerAngles(order) Vector3

Returns a new Vector3 set with the Euler angles translated from the current Quaternion.

Parameters

Name Type Description
optional order string

toEulerAnglesToRef(result, order) Quaternion

Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion.

Returns the current Quaternion.

Parameters

Name Type Description
result Vector3
optional order string

toRotationMatrix(result) Quaternion

Updates the passed rotation matrix with the current Quaternion values.

Returns the current Quaternion.

Parameters

Name Type Description
result Matrix

fromRotationMatrix(matrix) Quaternion

Updates the current Quaternion from the passed rotation matrix values.

Returns the updated Quaternion.

Parameters

Name Type Description
matrix Matrix

static FromRotationMatrix(matrix) Quaternion

Returns a new Quaternion set from the passed rotation matrix values.

Parameters

Name Type Description
matrix Matrix

static FromRotationMatrixToRef(matrix, result) void

Updates the passed quaternion "result" with the passed rotation matrix values.

Parameters

Name Type Description
matrix Matrix
result Quaternion

static Zero() Quaternion

Returns a new Quaternion set to (0.0, 0.0, 0.0).

static Inverse(q) Quaternion

Returns a new Quaternion as the inverted current Quaternion.

Parameters

Name Type Description
q Quaternion

static Identity() Quaternion

Returns the identity Quaternion.

static IsIdentity(quaternion) boolean

Parameters

Name Type Description
quaternion Quaternion

static RotationAxis(axis, angle) Quaternion

Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).

Parameters

Name Type Description
axis Vector3
angle number

static RotationAxisToRef(axis, angle, result) Quaternion

Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).

Parameters

Name Type Description
axis Vector3
angle number
result Quaternion

static FromArray(array, offset) Quaternion

Retuns a new Quaternion set from the starting index of the passed array.

Parameters

Name Type Description
array ArrayLike<number>
optional offset number

static RotationYawPitchRoll(yaw, pitch, roll) Quaternion

Returns a new Quaternion set from the passed Euler float angles (y, x, z).

Parameters

Name Type Description
yaw number
pitch number
roll number

static RotationYawPitchRollToRef(yaw, pitch, roll, result) void

Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).

Parameters

Name Type Description
yaw number
pitch number
roll number

static RotationAlphaBetaGamma(alpha, beta, gamma) Quaternion

Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation

Parameters

Name Type Description
alpha number
beta number
gamma number

static RotationAlphaBetaGammaToRef(alpha, beta, gamma, result) void

Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation

Parameters

Name Type Description
alpha number
beta number
gamma number

static RotationQuaternionFromAxis(axis1, axis2, axis3, ref) Quaternion

Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.

cf to Vector3.RotationFromAxis() documentation.

Note : axis1, axis2 and axis3 are normalized during this operation.

Parameters

Name Type Description
axis1 Vector3
axis2 Vector3
axis3 Vector3

static RotationQuaternionFromAxisToRef(axis1, axis2, axis3, ref) void

Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.

cf to Vector3.RotationFromAxis() documentation.

Note : axis1, axis2 and axis3 are normalized during this operation.

Parameters

Name Type Description
axis1 Vector3
axis2 Vector3
axis3 Vector3

static Slerp(left, right, amount) Quaternion

Parameters

Name Type Description
left Quaternion
right Quaternion
amount number

static SlerpToRef(left, right, amount, result) void

Parameters

Name Type Description
left Quaternion
right Quaternion
amount number

static Hermite(value1, tangent1, value2, tangent2, amount) Quaternion

Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".

Parameters

Name Type Description
value1 Quaternion
tangent1 Quaternion
value2 Quaternion
tangent2 Quaternion