Class Quat

Quat metatype, wrapper for godot_quat.

Constructed using the idiom Quat(...), which calls __new.

The X, Y, Z and W components may be accessed through elements or individually with x/y/z/w. Vector2 with two adjacent components may be get/set with the pairs xy/yz/zw. Vector3 with three adjacent components may be get/set with the triplets xyz/yzw:

typedef union godot_quat {
    float elements[4];
    struct { float x, y, z, w; };
    struct { Vector2 xy; Vector2 zw; };
    struct { float _; Vector2 yz; float _; };
    struct { Vector3 xyz; float _; };
    struct { float _; Vector3 yzw; };
} godot_quat;

Methods

Quat:cubic_slerp (b, preA, postB, t) Performs a cubic spherical interpolation between quaternions preA, this vector, b, and postB, by the given amount t.
Quat:dot (b) Returns the dot product of two quaternions.
Quat:inverse () Returns the inverse of the quaternion.
Quat:is_normalized () Returns whether the quaternion is normalized or not.
Quat:length () Returns the length of the quaternion.
Quat:length_squared () Returns the length of the quaternion, squared.
Quat:normalized () Returns a copy of the quaternion, normalized to unit length.
Quat:slerp (to, weight) Returns the result of the spherical linear interpolation between this quaternion and to by amount weight.
Quat:slerpni (to, weight) Returns the result of the spherical linear interpolation between this quaternion and to by amount weight, but without checking if the rotation path is not bigger than 90 degrees.
Quat:unpack () Returns all elements.
Quat:xform (v) Returns a vector transformed (multiplied) by this quaternion.

Metamethods

Quat:__add (a, b) Addition operation
Quat:__concat (a, b) Concatenates values.
Quat:__div (a, s) Division operation
Quat:__eq (a, b) Equality operation If either a or b are not of type Quat, always return false.
Quat:__mul (a, b) Multiplication operation
Quat:__new (...) Quat constructor, called by the idiom Quat(...).
Quat:__sub (a, b) Subtraction operation
Quat:__tostring () Returns a Lua string representation of this quaternion.
Quat:__unm () Unary minus operation

Constants

Quat.IDENTITY The identity quaternion, representing no rotation.


Methods

Quat:cubic_slerp (b, preA, postB, t)
Performs a cubic spherical interpolation between quaternions preA, this vector, b, and postB, by the given amount t.

Parameters:

Returns:

    Quat
Quat:dot (b)
Returns the dot product of two quaternions.

Parameters:

Returns:

    number
Quat:inverse ()
Returns the inverse of the quaternion.

Returns:

    Quat
Quat:is_normalized ()
Returns whether the quaternion is normalized or not.

Returns:

    bool
Quat:length ()
Returns the length of the quaternion.

Returns:

    number
Quat:length_squared ()
Returns the length of the quaternion, squared.

Returns:

    number
Quat:normalized ()
Returns a copy of the quaternion, normalized to unit length.

Returns:

    Quat
Quat:slerp (to, weight)
Returns the result of the spherical linear interpolation between this quaternion and to by amount weight. Note: Both quaternions must be normalized.

Parameters:

  • to Quat
  • weight number

Returns:

    Quat

See also:

Quat:slerpni (to, weight)
Returns the result of the spherical linear interpolation between this quaternion and to by amount weight, but without checking if the rotation path is not bigger than 90 degrees. Note: Both quaternions must be normalized.

Parameters:

  • to Quat
  • weight number

Returns:

    Quat

See also:

Quat:unpack ()
Returns all elements.

Returns:

  1. number X
  2. number Y
  3. number Z
  4. number W
Quat:xform (v)
Returns a vector transformed (multiplied) by this quaternion.

Parameters:

Returns:

    Vector3

Metamethods

Quat:__add (a, b)
Addition operation

Parameters:

Returns:

    Quat
Quat:__concat (a, b)
Concatenates values.

Parameters:

  • a First value, stringified with GD.str
  • b First value, stringified with GD.str

Returns:

    String
Quat:__div (a, s)
Division operation

Parameters:

Returns:

    Quat
Quat:__eq (a, b)
Equality operation If either a or b are not of type Quat, always return false.

Parameters:

Returns:

    bool
Quat:__mul (a, b)
Multiplication operation

Parameters:

  • a Quat
  • b Vector3 or number If a Vector3 is passed, calls xform. Otherwise, returns a Quat with each component multiplied by b.

Returns:

    Quat or Vector3
Quat:__new (...)

Quat constructor, called by the idiom Quat(...).

  • Quat(): IDENTITY quaternion (Quat() == Quat(0, 0, 0, 1))
  • Quat(number x[, number y = 0[, number z = 0[, number w = 1]]]): set XYZW
  • Quat(Basis basis): construct from basis
  • Quat(Vector3 euler): rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last)
  • Quat(Vector3 axis, number angle): rotates around the given axis by the specified angle. The axis must be a normalized vector.
  • Quat(Quat other): copy values from other

Parameters:

  • ...

Returns:

    Quat
Quat:__sub (a, b)
Subtraction operation

Parameters:

Returns:

    Quat
Quat:__tostring ()
Returns a Lua string representation of this quaternion.

Returns:

    string
Quat:__unm ()
Unary minus operation

Returns:

    Quat

Constants

Quat.IDENTITY
The identity quaternion, representing no rotation. Equivalent to an identity Basis matrix. If a vector is transformed by an identity quaternion, it will not change.
  • IDENTITY Quat(0, 0, 0, 1)
generated by LDoc 1.4.6 Last updated 2023-01-04 08:52:34