Quaternion
A quaternion, used to represent rotations.
Iterating through an instance yields its components (x, y, z, w) in order.
Rotation methods expect a normalized (unit length) quaternion.
Instances are mutable and not thread-safe. Use each instance from one thread only.
Reading x/y/z/w has no side effect. Writing any of them, or calling a mutating method, fires the registered onChange callback (see that method).
Functions
Returns the angle between this quaternion and q in radians.
Returns a new quaternion with copied values from this instance.
Sets this quaternion to its conjugate: the same rotation in the opposite direction about the same axis.
Copies the values of quaternion into this instance.
Returns the dot product of this quaternion and v.
Sets this quaternion to the identity quaternion (no rotation).
Inverts this quaternion via conjugate. The quaternion is assumed to have unit length.
Multiplies this quaternion by q.
Normalizes this quaternion. It computes the quaternion that performs the same rotation but has length 1. A zero-length quaternion becomes the identity.
Registers callback to run whenever this quaternion's state changes (via a component setter or a mutating method). Reads never fire it.
Pre-multiplies this quaternion by q.
Sets this quaternion to a uniformly random, normalized quaternion.
Sets this quaternion from the rotation specified by the given Euler angles.
Sets this quaternion from the given rotation matrix m (the upper 3x3 of which must be an unscaled rotation).
Serialization result: the components of this quaternion as [x, y, z, w].