StaticidentityReturns the identity quaternion (0, 0, 0, 1).
StaticfromBuilds a quaternion representing a rotation of rad radians around axis (axis is normalized internally).
StaticfromBuilds a quaternion from intrinsic Euler angles (radians) applied in XYZ order.
rotation around the X axis (pitch)
rotation around the Y axis (yaw)
rotation around the Z axis (roll)
StaticfromExtracts the rotation of a matrix as a unit quaternion. Only the upper-left 3×3 (the rotation/basis part) is read, so a TRS or look-at matrix works directly provided its basis is orthonormal (no non-uniform scale). Uses the numerically-stable branch-by-largest-diagonal method.
Handy for deriving an orientation from a constructed basis — e.g. a chase
camera does Quaternion.fromRotationMatrix(Mat4.lookAt(eye, target, up).invert()).
Column-major matrix whose 3×3 rotation part is orthonormal.
StaticfromBuilds the rotation that aims an object's local forward axis
(Vec3.FORWARD, i.e. -Z) along forward in world space. The inverse
of Vec3.FORWARD-relative worldDirection() readers like
DirectionalLight / SpotLight: set
go.rotation = Quaternion.fromForward(dir) and the light then shines down dir.
up only resolves the roll about forward (irrelevant for a directional or
spot light); it defaults to world up, swapping to world right when forward
is nearly vertical so the basis stays well-conditioned.
Desired world-space forward direction (normalized internally).
Optionalup: Vec3Optional reference up; defaults to Vec3.UP (or Vec3.RIGHT near-vertical).
Returns a copy of this quaternion.
Sets this quaternion to represent a rotation of rad radians around axis (axis is normalized internally).
The axis of rotation.
The angle of rotation in radians.
Sets this quaternion from intrinsic Euler angles (radians) applied in XYZ order.
rotation around the X axis (pitch)
rotation around the Y axis (yaw)
rotation around the Z axis (roll)
Sets this quaternion to the identity rotation (0, 0, 0, 1). Useful for reusing an existing quaternion instance instead of creating a new one.
Returns the squared length.
Returns the Euclidean length.
Returns a unit-length copy, or the identity quaternion if length is 0.
Returns the conjugate (-x, -y, -z, w), which is the inverse for unit quaternions.
Returns the Hamilton product this * b, which composes rotations (this applied after b).
Converts this quaternion to its equivalent column-major 4x4 rotation matrix.
Spherical linear interpolation from this to b at parameter t in [0, 1].
Picks the shorter arc (negates b if the dot product is negative) and falls back to normalized linear interpolation when the angle between the quaternions is tiny.
Unit quaternion representing a 3D rotation, stored as (x, y, z, w) with w as the scalar part.