Quaternion
A rotation as { w, x, y, z }, with w first in the constructor. Its methods work in radians. Anywhere the API expects a rotation, you can also pass Euler angles in degrees, as { x, y, z } with no w. set, normalize, mul and slerp modify the quaternion and return it.
quaternion.identity()
Quaternion.identity()No rotation: (1, 0, 0, 0).
quaternion.fromEuler()
Quaternion.fromEuler(pitch, yaw, roll)A rotation from Euler angles in radians.
quaternion.fromAxisAngle()
Quaternion.fromAxisAngle(axis, angle)A rotation by an angle around an axis.
quaternion.set()
set(w, x, y, z)Sets the parts.
quaternion.clone()
clone()A copy.
quaternion.dot()
dot(q)The dot product with another quaternion.
quaternion.lengthSquared
lengthSquaredIts length squared.
quaternion.length
lengthIts length (1 for a proper rotation).
quaternion.normalize()
normalize()Scales it to length 1 (all zeros gives the identity).
quaternion.mul()
mul(q)Combines it with another rotation (this, then q, as quaternion product this × q).
quaternion.conjugate()
conjugate()A new quaternion with x, y and z negated: the opposite rotation of a unit quaternion.
quaternion.inverse()
inverse()A new quaternion that undoes this one.
quaternion.slerp()
slerp(target, t)Turns it towards a target along the shortest arc: t = 0 stays, 1 reaches it.
quaternion.rotateVector()
rotateVector(v)A new vector: the given one rotated by this (unit) rotation.
quaternion.toEuler()
toEuler()Its Euler angles in radians, as a Vector3 (pitch, yaw, roll).
quaternion.w
w: numberThe scalar part.
quaternion.x
x: numberThe x part.
quaternion.y
y: numberThe y part.
quaternion.z
z: numberThe z part.