Struct quaternion
- Namespace
- Misaki.HighPerformance.Mathematics
- Assembly
- Misaki.HighPerformance.Mathematics.dll
public struct quaternion : IEquatable<quaternion>
- Implements
- Inherited Members
Constructors
quaternion(float3x3)
Constructs a unit quaternion from a float3x3 rotation matrix. The matrix must be orthonormal.
public quaternion(float3x3 m)
Parameters
mfloat3x3The float3x3 orthonormal rotation matrix.
quaternion(float4)
Constructs a quaternion from float4 vector.
public quaternion(float4 value)
Parameters
valuefloat4The quaternion xyzw component values.
quaternion(float4x4)
Constructs a unit quaternion from an orthonormal float4x4 matrix.
public quaternion(float4x4 m)
Parameters
mfloat4x4The float4x4 orthonormal rotation matrix.
quaternion(float, float, float, float)
Constructs a quaternion from four float values.
public quaternion(float x, float y, float z, float w)
Parameters
xfloatThe quaternion x component.
yfloatThe quaternion y component.
zfloatThe quaternion z component.
wfloatThe quaternion w component.
Fields
identity
A quaternion representing the identity transform.
public static readonly quaternion identity
Field Value
value
The quaternion component values.
public float4 value
Field Value
Methods
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.
public static quaternion AxisAngle(float3 axis, float angle)
Parameters
Returns
- quaternion
The quaternion representing a rotation around an axis.
Equals(quaternion)
Returns true if the quaternion is equal to a given quaternion, false otherwise.
public bool Equals(quaternion x)
Parameters
xquaternionThe quaternion to compare with.
Returns
- bool
True if the quaternion is equal to the input, false otherwise.
Equals(object?)
Returns whether true if the quaternion is equal to a given quaternion, false otherwise.
public override bool Equals(object? x)
Parameters
xobjectThe object to compare with.
Returns
- bool
True if the quaternion is equal to the input, false otherwise.
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(...).
public static quaternion Euler(float3 xyz, math.RotationOrder order = RotationOrder.Default)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
ordermath.RotationOrderThe order in which the rotations are applied.
Returns
- quaternion
The quaternion representing the Euler angle rotation in the specified order.
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(...).
public static quaternion Euler(float x, float y, float z, math.RotationOrder order = RotationOrder.Default)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
ordermath.RotationOrderThe order in which the rotations are applied.
Returns
- quaternion
The quaternion representing the Euler angle rotation in the specified order.
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.
public static quaternion EulerXYZ(float3 xyz)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in x-y-z order.
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.
public static quaternion EulerXYZ(float x, float y, float z)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in x-y-z order.
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.
public static quaternion EulerXZY(float3 xyz)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in x-z-y order.
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.
public static quaternion EulerXZY(float x, float y, float z)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in x-z-y order.
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.
public static quaternion EulerYXZ(float3 xyz)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in y-x-z order.
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.
public static quaternion EulerYXZ(float x, float y, float z)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in y-x-z order.
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.
public static quaternion EulerYZX(float3 xyz)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in y-z-x order.
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.
public static quaternion EulerYZX(float x, float y, float z)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in y-z-x order.
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.
public static quaternion EulerZXY(float3 xyz)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in z-x-y order.
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.
public static quaternion EulerZXY(float x, float y, float z)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in z-x-y order.
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.
public static quaternion EulerZYX(float3 xyz)
Parameters
xyzfloat3A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in z-y-x order.
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.
public static quaternion EulerZYX(float x, float y, float z)
Parameters
xfloatThe rotation angle around the x-axis in radians.
yfloatThe rotation angle around the y-axis in radians.
zfloatThe rotation angle around the z-axis in radians.
Returns
- quaternion
The quaternion representing the Euler angle rotation in z-y-x order.
GetHashCode()
Returns a hash code for the quaternion.
public override int GetHashCode()
Returns
- int
The hash code of 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.
public static quaternion LookRotation(float3 forward, float3 up)
Parameters
Returns
- quaternion
The quaternion view rotation.
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.
public static quaternion LookRotationSafe(float3 forward, float3 up)
Parameters
Returns
- quaternion
The quaternion view rotation or the identity quaternion.
RotateX(float)
Returns a quaternion that rotates around the x-axis by a given number of radians.
public static quaternion RotateX(float angle)
Parameters
anglefloatThe clockwise rotation angle when looking along the x-axis towards the origin in radians.
Returns
- quaternion
The quaternion representing a rotation around the x-axis.
RotateY(float)
Returns a quaternion that rotates around the y-axis by a given number of radians.
public static quaternion RotateY(float angle)
Parameters
anglefloatThe clockwise rotation angle when looking along the y-axis towards the origin in radians.
Returns
- quaternion
The quaternion representing a rotation around the y-axis.
RotateZ(float)
Returns a quaternion that rotates around the z-axis by a given number of radians.
public static quaternion RotateZ(float angle)
Parameters
anglefloatThe clockwise rotation angle when looking along the z-axis towards the origin in radians.
Returns
- quaternion
The quaternion representing a rotation around the z-axis.
ToString()
Returns a string representation of the quaternion.
public override string ToString()
Returns
- string
The string representation of the quaternion.
Operators
implicit operator quaternion(float4)
Implicitly converts a float4 vector to a quaternion.
public static implicit operator quaternion(float4 v)
Parameters
vfloat4The quaternion xyzw component values.
Returns
- quaternion
The quaternion constructed from a float4 vector.