Skip to content

REVO / API version 0.0.10

Quaternion

Immutable quaternion. Constructor arguments are not normalized.

new Quaternion(): Quaternion

Creates the identity quaternion (0, 0, 0, 1).

Quaternion

new Quaternion(x, y, z, w): Quaternion

Parameter Type Description
x number -
y number -
z number -
w number Scalar component.

Quaternion

new Quaternion(value): Quaternion

Parameter Type
value [number, number, number, number]

Quaternion

new Quaternion(value): Quaternion

Parameter Type
value IQuaternion

Quaternion

new Quaternion(value): Quaternion

Sets every component to value.

Parameter Type
value number

Quaternion

Property Type Details
length
readonly
number —
lengthSquared
readonly
number —
w
readonly
number Implements IQuaternion.w
x
readonly
number Implements IQuaternion.x
y
readonly
number Implements IQuaternion.y
z
readonly
number Implements IQuaternion.z
one
static readonly
Quaternion —
zero
static readonly
Quaternion —

equals(value, epsilon?): boolean

Compares components: q and -q are unequal despite representing the same rotation.

Parameter Type Description
value IQuaternion -
epsilon? number Finite, non-negative tolerance per component. Defaults to 0.

boolean


inverse(): Quaternion

Returns the inverse. Throws RangeError for a zero or infinite quaternion, or if the result overflows.

Quaternion


mul(value): Quaternion

Hamilton product: this quaternion multiplied by value.

Parameter Type
value IQuaternion

Quaternion


normalize(): Quaternion

Throws RangeError for a zero or infinite quaternion.

Quaternion


rotate(value): Vector3

Rotates a vector. This quaternion must have unit length.

Parameter Type
value IVector3

Vector3


toArray(): [number, number, number, number]

Returns [x, y, z, w].

[number, number, number, number]


toFixed(precision?): Quaternion

Parameter Type Description
precision? number Number of decimal places. Must be an integer from 0 to 100. Defaults to 4.

Quaternion


toString(): string

Returns a string representation of an object.

string