Struct quaternion
A quaternion type for representing rotations.
Inherited Members
Namespace: Unity.Mathematics
Assembly: solution.dll
Syntax
[Serializable]
public struct quaternion : IEquatable<quaternion>, IFormattable
Constructors
Name | Description |
---|---|
quaternion(float, float, float, float) | Constructs a quaternion from four float values. |
quaternion(float3x3) | Constructs a unit quaternion from a float3x3 rotation matrix. The matrix must be orthonormal. |
quaternion(float4) | Constructs a quaternion from float4 vector. |
quaternion(float4x4) | Constructs a unit quaternion from an orthonormal float4x4 matrix. |
Fields
Name | Description |
---|---|
identity | A quaternion representing the identity transform. |
value | The quaternion component values. |
Methods
Name | Description |
---|---|
AxisAngle(float3, float) | Returns a quaternion representing a rotation around a unit axis by an angle in radians. The rotation direction is clockwise when looking along the rotation axis towards the origin. |
Equals(object) | Returns whether true if the quaternion is equal to a given quaternion, false otherwise. |
Equals(quaternion) | Returns true if the quaternion is equal to a given quaternion, false otherwise. |
Euler(float, float, float, RotationOrder) | Returns a quaternion constructed by first performing 3 rotations around the principal axes in a given order. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. When the rotation order is known at compile time, it is recommended for performance reasons to use specific Euler rotation constructors such as EulerZXY(...). |
Euler(float3, RotationOrder) | Returns a quaternion constructed by first performing 3 rotations around the principal axes in a given order. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. When the rotation order is known at compile time, it is recommended for performance reasons to use specific Euler rotation constructors such as EulerZXY(...). |
EulerXYZ(float, float, float) | Returns a quaternion constructed by first performing a rotation around the x-axis, then the y-axis and finally the z-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerXYZ(float3) | Returns a quaternion constructed by first performing a rotation around the x-axis, then the y-axis and finally the z-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerXZY(float, float, float) | Returns a quaternion constructed by first performing a rotation around the x-axis, then the z-axis and finally the y-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerXZY(float3) | Returns a quaternion constructed by first performing a rotation around the x-axis, then the z-axis and finally the y-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerYXZ(float, float, float) | Returns a quaternion constructed by first performing a rotation around the y-axis, then the x-axis and finally the z-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerYXZ(float3) | Returns a quaternion constructed by first performing a rotation around the y-axis, then the x-axis and finally the z-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerYZX(float, float, float) | Returns a quaternion constructed by first performing a rotation around the y-axis, then the z-axis and finally the x-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerYZX(float3) | Returns a quaternion constructed by first performing a rotation around the y-axis, then the z-axis and finally the x-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerZXY(float, float, float) | Returns a quaternion constructed by first performing a rotation around the z-axis, then the x-axis and finally the y-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. This is the default order rotation order in Unity. |
EulerZXY(float3) | Returns a quaternion constructed by first performing a rotation around the z-axis, then the x-axis and finally the y-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. This is the default order rotation order in Unity. |
EulerZYX(float, float, float) | Returns a quaternion constructed by first performing a rotation around the z-axis, then the y-axis and finally the x-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
EulerZYX(float3) | Returns a quaternion constructed by first performing a rotation around the z-axis, then the y-axis and finally the x-axis. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. |
GetHashCode() | Returns a hash code for the quaternion. |
LookRotation(float3, float3) | Returns a quaternion view rotation given a unit length forward vector and a unit length up vector. The two input vectors are assumed to be unit length and not collinear. If these assumptions are not met use float3x3.LookRotationSafe instead. |
LookRotationSafe(float3, float3) | Returns a quaternion view rotation given a forward vector and an up vector. The two input vectors are not assumed to be unit length. If the magnitude of either of the vectors is so extreme that the calculation cannot be carried out reliably or the vectors are collinear, the identity will be returned instead. |
RotateX(float) | Returns a quaternion that rotates around the x-axis by a given number of radians. |
RotateY(float) | Returns a quaternion that rotates around the y-axis by a given number of radians. |
RotateZ(float) | Returns a quaternion that rotates around the z-axis by a given number of radians. |
ToString() | Returns a string representation of the quaternion. |
ToString(string, IFormatProvider) | Returns a string representation of the quaternion using a specified format and culture-specific format information. |
Operators
Name | Description |
---|---|
implicit operator quaternion(float4) | Implicitly converts a float4 vector to a quaternion. |
implicit operator Quaternion(quaternion) | Converts a quaternion to Quaternion. |
implicit operator quaternion(Quaternion) | Converts a Quaternion to quaternion. |