:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Quat.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Quat: Quat ==== **Category:** Built-In Types Brief Description ----------------- Quaternion. Properties ---------- +---------------------------+---------------------------------+ | :ref:`float` | :ref:`w` | +---------------------------+---------------------------------+ | :ref:`float` | :ref:`x` | +---------------------------+---------------------------------+ | :ref:`float` | :ref:`y` | +---------------------------+---------------------------------+ | :ref:`float` | :ref:`z` | +---------------------------+---------------------------------+ Methods ------- +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`Quat` **(** :ref:`Basis` from **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`Quat` **(** :ref:`Vector3` euler **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`Quat` **(** :ref:`Vector3` axis, :ref:`float` angle **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`Quat` **(** :ref:`float` x, :ref:`float` y, :ref:`float` z, :ref:`float` w **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`cubic_slerp` **(** :ref:`Quat` b, :ref:`Quat` pre_a, :ref:`Quat` post_b, :ref:`float` t **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`dot` **(** :ref:`Quat` b **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_euler` **(** **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`inverse` **(** **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_normalized` **(** **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`length` **(** **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`length_squared` **(** **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`normalized` **(** **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_axis_angle` **(** :ref:`Vector3` axis, :ref:`float` angle **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_euler` **(** :ref:`Vector3` euler **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`slerp` **(** :ref:`Quat` b, :ref:`float` t **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Quat` | :ref:`slerpni` **(** :ref:`Quat` b, :ref:`float` t **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`xform` **(** :ref:`Vector3` v **)** | +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Constants --------- .. _class_Quat_constant_IDENTITY: - **IDENTITY** = **Quat( 0, 0, 0, 1 )** Description ----------- A unit quaternion used for representing 3D rotations. It is similar to :ref:`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 --------- - `#interpolating-with-quaternions <../tutorials/3d/using_transforms.html#interpolating-with-quaternions>`_ in :doc:`../tutorials/3d/using_transforms` Property Descriptions --------------------- .. _class_Quat_property_w: - :ref:`float` **w** W component of the quaternion. Default value: ``1`` ---- .. _class_Quat_property_x: - :ref:`float` **x** X component of the quaternion. Default value: ``0`` ---- .. _class_Quat_property_y: - :ref:`float` **y** Y component of the quaternion. Default value: ``0`` ---- .. _class_Quat_property_z: - :ref:`float` **z** Z component of the quaternion. Default value: ``0`` Method Descriptions ------------------- .. _class_Quat_method_Quat: - :ref:`Quat` **Quat** **(** :ref:`Basis` from **)** Returns the rotation matrix corresponding to the given quaternion. ---- - :ref:`Quat` **Quat** **(** :ref:`Vector3` euler **)** 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). ---- - :ref:`Quat` **Quat** **(** :ref:`Vector3` axis, :ref:`float` angle **)** Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector. ---- - :ref:`Quat` **Quat** **(** :ref:`float` x, :ref:`float` y, :ref:`float` z, :ref:`float` w **)** Returns a quaternion defined by these values. ---- .. _class_Quat_method_cubic_slerp: - :ref:`Quat` **cubic_slerp** **(** :ref:`Quat` b, :ref:`Quat` pre_a, :ref:`Quat` post_b, :ref:`float` t **)** Performs a cubic spherical-linear interpolation with another quaternion. ---- .. _class_Quat_method_dot: - :ref:`float` **dot** **(** :ref:`Quat` b **)** Returns the dot product of two quaternions. ---- .. _class_Quat_method_get_euler: - :ref:`Vector3` **get_euler** **(** **)** 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). ---- .. _class_Quat_method_inverse: - :ref:`Quat` **inverse** **(** **)** Returns the inverse of the quaternion. ---- .. _class_Quat_method_is_normalized: - :ref:`bool` **is_normalized** **(** **)** Returns whether the quaternion is normalized or not. ---- .. _class_Quat_method_length: - :ref:`float` **length** **(** **)** Returns the length of the quaternion. ---- .. _class_Quat_method_length_squared: - :ref:`float` **length_squared** **(** **)** Returns the length of the quaternion, squared. ---- .. _class_Quat_method_normalized: - :ref:`Quat` **normalized** **(** **)** Returns a copy of the quaternion, normalized to unit length. ---- .. _class_Quat_method_set_axis_angle: - void **set_axis_angle** **(** :ref:`Vector3` axis, :ref:`float` angle **)** Set the quaternion to a rotation which rotates around axis by the specified angle, in radians. The axis must be a normalized vector. ---- .. _class_Quat_method_set_euler: - void **set_euler** **(** :ref:`Vector3` euler **)** 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). ---- .. _class_Quat_method_slerp: - :ref:`Quat` **slerp** **(** :ref:`Quat` b, :ref:`float` t **)** Performs a spherical-linear interpolation with another quaternion. ---- .. _class_Quat_method_slerpni: - :ref:`Quat` **slerpni** **(** :ref:`Quat` b, :ref:`float` t **)** Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°. ---- .. _class_Quat_method_xform: - :ref:`Vector3` **xform** **(** :ref:`Vector3` v **)** Transforms the vector ``v`` by this quaternion.