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 .eulerAngles | Returns or sets the euler angle representation of the rotation. |
Quaternion .normalized | Returns this quaternion with a magnitude of 1 (Read Only). |
Quaternion .w | W component of the Quaternion. Do not directly modify quaternions. |
Quaternion .x | X component of the Quaternion. Don't modify this directly unless you know quaternions inside out. |
Quaternion .y | Y component of the Quaternion. Don't modify this directly unless you know quaternions inside out. |
Quaternion .z |
Static Properties
Name | Description |
---|---|
Quaternion .identity | The identity rotation (Read Only). |
Constructor
Name | Description |
---|---|
Quaternion(x, y, z, w) | Constructs new Quaternion with given x,y,z,w components. |
Methods
Name | Description |
---|---|
Quaternion .LerpUnclamped(a, b, t) | Interpolates between a and b by t and normalizes the result afterwards. The parameter t is not clamped. |
Quaternion .Set(newX, newY, newZ, newW) | Set x, y, z and w components of an existing Quaternion. |
Quaternion .SetFromToRotation(fromDirection, toDirection) | Creates a rotation which rotates from fromDirection to toDirection. |
Quaternion .SetLookRotation(view, up=Vector3.up) | Creates a rotation with the specified forward and upwards directions. |
Quaternion .ToAngleAxis() | Converts a rotation to angle-axis representation (angles in degrees). |
Static Methods
Name | Description |
---|---|
Quaternion .Angle(a, b) | Returns the angle in degrees between two rotations a and b. |
Quaternion .AngleAxis(angle, axis) | Creates a rotation which rotates angle degrees around axis. |
Quaternion .Dot(a, b) | The dot product between two rotations. |
Quaternion .Euler(x, y, z) | 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) | Creates a rotation which rotates from fromDirection to toDirection. |
Quaternion .Inverse(rotation) | Returns the Inverse of rotation. |
Quaternion .Lerp(a, b, t) | 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) | Creates a rotation with the specified forward and upwards directions. |
Quaternion .Normalize(q) | Converts this quaternion to one with the same orientation but with a magnitude of 1. |
Quaternion .RotateTowards(from, to, maxDegreesDelta) | Rotates a rotation from towards to. |
Quaternion .Slerp(a, b, t) | Spherically interpolates between a and b by t. The parameter t is clamped to the range [0, 1]. |
Quaternion .SlerpUnclamped(a, b, t) | Spherically interpolates between a and b by t. The parameter t is not clamped. |
Operators
Name | Description |
---|---|
Operator (Quaternion*Quaternion) | Combines rotations lhs and rhs. |
| Operator (Quaternion*Vector3) | Rotates the point rhs
with rotation lhs
. |
| Operator (Quaternion==Quaternion) | 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. |