Skip to content

API > Quaternion


Quaternion⚓︎

Quaternions are used to represent rotations. They are compact, don't suffer from gimbal lock and can easily be interpolated. Unity internally uses Quaternions to represent all rotations.

Members⚓︎

Properties⚓︎

Name Description
Quaternion.eulerAnglesProperty Returns or sets the euler angle representation of the rotation.
Quaternion.normalizedProperty Returns this quaternion with a magnitude of 1 (Read Only).
Quaternion.wProperty W component of the Quaternion. Do not directly modify quaternions.
Quaternion.xProperty X component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
Quaternion.yProperty Y component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
Quaternion.zProperty

Static Properties⚓︎

Name Description
Quaternion.identity Static fieldProperty The identity rotation (Read Only).

Constructor⚓︎

Name Description
Quaternion(x, y, z, w)Constructor Constructs new Quaternion with given x,y,z,w components.

Methods⚓︎

Name Description
Quaternion.LerpUnclamped(a, b, t) Method Interpolates between a and b by t and normalizes the result afterwards. The parameter t is not clamped.
Quaternion.Set(newX, newY, newZ, newW) Method Set x, y, z and w components of an existing Quaternion.
Quaternion.SetFromToRotation(fromDirection, toDirection) Method Creates a rotation which rotates from fromDirection to toDirection.
Quaternion.SetLookRotation(view, up=Vector3.up) Method Creates a rotation with the specified forward and upwards directions.
Quaternion.ToAngleAxis() Method Converts a rotation to angle-axis representation (angles in degrees).

Static Methods⚓︎

Name Description
Quaternion.Angle(a, b) Static fieldMethod Returns the angle in degrees between two rotations a and b.
Quaternion.AngleAxis(angle, axis) Static fieldMethod Creates a rotation which rotates angle degrees around axis.
Quaternion.Dot(a, b) Static fieldMethod The dot product between two rotations.
Quaternion.Euler(x, y, z) Static fieldMethod Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis; applied in that order.
Quaternion.FromToRotation(fromDirection, toDirection) Static fieldMethod Creates a rotation which rotates from fromDirection to toDirection.
Quaternion.Inverse(rotation) Static fieldMethod Returns the Inverse of rotation.
Quaternion.Lerp(a, b, t) Static fieldMethod Interpolates between a and b by t and normalizes the result afterwards. The parameter t is clamped to the range [0, 1].
Quaternion.LookRotation(forward, upwards =Vector3.up) Static fieldMethod Creates a rotation with the specified forward and upwards directions.
Quaternion.Normalize(q) Static fieldMethod Converts this quaternion to one with the same orientation but with a magnitude of 1.
Quaternion.RotateTowards(from, to, maxDegreesDelta) Static fieldMethod Rotates a rotation from towards to.
Quaternion.Slerp(a, b, t) Static fieldMethod Spherically interpolates between a and b by t. The parameter t is clamped to the range [0, 1].
Quaternion.SlerpUnclamped(a, b, t) Static fieldMethod Spherically interpolates between a and b by t. The parameter t is not clamped.

Operators⚓︎

Name Description
Operator (Quaternion*Quaternion)Operator Combines rotations lhs and rhs.

| Operator (Quaternion*Vector3)Operator | Rotates the point rhs with rotation lhs. |

| Operator (Quaternion==Quaternion)Operator | Are two quaternions equal to each other? This function tests whether dot product of two quaternions is close to 1.0. Note that because quaternions can represent rotations that are up to two full revolutions (720 degrees), this comparison can return false even if resulting rotations look the same. |