Quaternion.
``````    [Serializable]
public struct Quat : IEquatable<Quat>
``````

A unit quaternion used for representing 3D rotations.

It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. But due to its compactness and the way it is stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors.

Quaternions need to be (re)normalized.

Static Properties

``````    public static  Identity { get; }
``````

Constructors

``````    public Quat(float x, float y, float z, float w)
``````

Returns a quaternion defined by these values.

``````    public Quat(Quat q)
``````

``````    public Quat(Basis basis)
``````

Returns the rotation matrix corresponding to the given quaternion.

``````    public Quat(Vector3 eulerYXZ)
``````

Returns a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle).

``````    public Quat(Vector3 axis, float angle)
``````

Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.

``````    public Quat()
``````

Fields

``````    public Single w
``````

W component of the quaternion.

``````    public Single x
``````

X component of the quaternion.

``````    public Single y
``````

Y component of the quaternion.

``````    public Single z
``````

Z component of the quaternion.

Properties

``````    public float Length { get; }
``````

``````    public float LengthSquared { get; }
``````

``````    public float this[] { get; set; }
``````

Methods

``````    public Quat CubicSlerp(Quat b, Quat preA, Quat postB, float t)
``````

Performs a cubic spherical-linear interpolation with another quaternion.

``````    public float Dot(Quat b)
``````

Returns the dot product of two quaternions.

``````    public override bool Equals(object obj)
``````

``````    public bool Equals(Quat other)
``````

``````    public Vector3 GetEuler()
``````

Returns Euler angles (in the YXZ convention: first Z, then X, and Y last) corresponding to the rotation represented by the unit quaternion. Returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).

``````    public override int GetHashCode()
``````

``````    public Quat Inverse()
``````

Returns the inverse of the quaternion.

``````    public bool IsNormalized()
``````

Returns whether the quaternion is normalized or not.

``````    public Quat Normalized()
``````

Returns a copy of the quaternion, normalized to unit length.

``````    [Obsolete("Set is deprecated. Use the Quat(real_t, real_t, real_t, real_t) constructor instead.", true)]
public void Set(float x, float y, float z, float w)
``````

``````    [Obsolete("Set is deprecated. Use the Quat(Quat) constructor instead.", true)]
public void Set(Quat q)
``````

``````    [Obsolete("SetAxisAngle is deprecated. Use the Quat(Vector3, real_t) constructor instead.", true)]
public void SetAxisAngle(Vector3 axis, float angle)
``````

``````    [Obsolete("SetEuler is deprecated. Use the Quat(Vector3) constructor instead.", true)]
public void SetEuler(Vector3 eulerYXZ)
``````

``````    public Quat Slerp(Quat b, float t)
``````

Performs a spherical-linear interpolation with another quaternion.

``````    public Quat Slerpni(Quat b, float t)
``````

Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°.

``````    public override string ToString()
``````

``````    public string ToString(string format)
``````

``````    public Vector3 Xform(Vector3 v)
``````

Transforms the vector `v` by this quaternion.

Operators

``````    public static Quat operator +(Quat left, Quat right)
``````

``````    public static Quat operator /(Quat left, float right)
``````

``````    public static bool operator ==(Quat left, Quat right)
``````

``````    public static bool operator !=(Quat left, Quat right)
``````

``````    public static Quat operator *(Quat left, Quat right)
``````

``````    public static Quat operator *(Quat left, Vector3 right)
``````

``````    public static Quat operator *(Vector3 left, Quat right)
``````

``````    public static Quat operator *(Quat left, float right)
``````

``````    public static Quat operator *(float left, Quat right)
``````

``````    public static Quat operator -(Quat left, Quat right)
``````

``````    public static Quat operator -(Quat left)
``````
Tags: