Quat

    Quaternion.

    Properties

    Quat ( from )
    Quat ( Vector3 euler )
    Quat ( axis, float angle )
    Quat ( x, float y, z, float w )
    cubic_slerp ( b, Quat pre_a, post_b, float t )
    dot ( b )
    Vector3 ( )
    Quat ( )
    bool ( )
    float ( )
    float ( )
    Quat ( )
    voidset_axis_angle ( axis, float angle )
    void ( Vector3 euler )
    slerp ( b, float t )
    slerpni ( b, float t )
    xform ( v )

    Constants

    • IDENTITY = Quat( 0, 0, 0, 1 )

    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.

    Tutorials

    • w

    W component of the quaternion. Default value:


    X component of the quaternion. Default value:


    • y

    Y component of the quaternion. Default value:


    Method Descriptions

    Returns the rotation matrix corresponding to the given quaternion.


    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).


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


    Returns a quaternion defined by these values.


    • cubic_slerp ( Quat b, pre_a, Quat post_b, t )

    Performs a cubic spherical-linear interpolation with another quaternion.


    Returns the dot product of two quaternions.


    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).


    • inverse ( )

    • bool is_normalized ( )

    Returns whether the quaternion is normalized or not.


    • length ( )

    Returns the length of the quaternion.


    • float length_squared ( )

    Returns the length of the quaternion, squared.


    • normalized ( )

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


    • void set_axis_angle ( Vector3 axis, angle )

    Set the quaternion to a rotation which rotates around axis by the specified angle, in radians. The axis must be a normalized vector.


    Set the quaternion to 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).


    • slerp ( Quat b, t )

    Performs a spherical-linear interpolation with another quaternion.



    Transforms the vector by this quaternion.