class_quat.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Quat.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Quat:
  6. Quat
  7. ====
  8. **Category:** Built-In Types
  9. Brief Description
  10. -----------------
  11. Quaternion.
  12. Properties
  13. ----------
  14. +---------------------------+---------------------------------+
  15. | :ref:`float<class_float>` | :ref:`w<class_Quat_property_w>` |
  16. +---------------------------+---------------------------------+
  17. | :ref:`float<class_float>` | :ref:`x<class_Quat_property_x>` |
  18. +---------------------------+---------------------------------+
  19. | :ref:`float<class_float>` | :ref:`y<class_Quat_property_y>` |
  20. +---------------------------+---------------------------------+
  21. | :ref:`float<class_float>` | :ref:`z<class_Quat_property_z>` |
  22. +---------------------------+---------------------------------+
  23. Methods
  24. -------
  25. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_method_Quat>` **(** :ref:`Basis<class_Basis>` from **)** |
  27. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_method_Quat>` **(** :ref:`Vector3<class_Vector3>` euler **)** |
  29. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_method_Quat>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  31. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_method_Quat>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)** |
  33. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Quat<class_Quat>` | :ref:`cubic_slerp<class_Quat_method_cubic_slerp>` **(** :ref:`Quat<class_Quat>` b, :ref:`Quat<class_Quat>` pre_a, :ref:`Quat<class_Quat>` post_b, :ref:`float<class_float>` t **)** |
  35. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`dot<class_Quat_method_dot>` **(** :ref:`Quat<class_Quat>` b **)** |
  37. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Vector3<class_Vector3>` | :ref:`get_euler<class_Quat_method_get_euler>` **(** **)** |
  39. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Quat<class_Quat>` | :ref:`inverse<class_Quat_method_inverse>` **(** **)** |
  41. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Quat_method_is_normalized>` **(** **)** |
  43. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`length<class_Quat_method_length>` **(** **)** |
  45. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`length_squared<class_Quat_method_length_squared>` **(** **)** |
  47. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Quat<class_Quat>` | :ref:`normalized<class_Quat_method_normalized>` **(** **)** |
  49. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_axis_angle<class_Quat_method_set_axis_angle>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  51. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_euler<class_Quat_method_set_euler>` **(** :ref:`Vector3<class_Vector3>` euler **)** |
  53. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Quat<class_Quat>` | :ref:`slerp<class_Quat_method_slerp>` **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)** |
  55. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Quat<class_Quat>` | :ref:`slerpni<class_Quat_method_slerpni>` **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)** |
  57. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Vector3<class_Vector3>` | :ref:`xform<class_Quat_method_xform>` **(** :ref:`Vector3<class_Vector3>` v **)** |
  59. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. Constants
  61. ---------
  62. .. _class_Quat_constant_IDENTITY:
  63. - **IDENTITY** = **Quat( 0, 0, 0, 1 )**
  64. Description
  65. -----------
  66. A unit quaternion used for representing 3D rotations.
  67. It is similar to :ref:`Basis<class_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.
  68. Quaternions need to be (re)normalized.
  69. Tutorials
  70. ---------
  71. - `#interpolating-with-quaternions <../tutorials/3d/using_transforms.html#interpolating-with-quaternions>`_ in :doc:`../tutorials/3d/using_transforms`
  72. Property Descriptions
  73. ---------------------
  74. .. _class_Quat_property_w:
  75. - :ref:`float<class_float>` **w**
  76. W component of the quaternion. Default value: ``1``
  77. ----
  78. .. _class_Quat_property_x:
  79. - :ref:`float<class_float>` **x**
  80. X component of the quaternion. Default value: ``0``
  81. ----
  82. .. _class_Quat_property_y:
  83. - :ref:`float<class_float>` **y**
  84. Y component of the quaternion. Default value: ``0``
  85. ----
  86. .. _class_Quat_property_z:
  87. - :ref:`float<class_float>` **z**
  88. Z component of the quaternion. Default value: ``0``
  89. Method Descriptions
  90. -------------------
  91. .. _class_Quat_method_Quat:
  92. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`Basis<class_Basis>` from **)**
  93. Returns the rotation matrix corresponding to the given quaternion.
  94. ----
  95. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`Vector3<class_Vector3>` euler **)**
  96. 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).
  97. ----
  98. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  99. Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
  100. ----
  101. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)**
  102. Returns a quaternion defined by these values.
  103. ----
  104. .. _class_Quat_method_cubic_slerp:
  105. - :ref:`Quat<class_Quat>` **cubic_slerp** **(** :ref:`Quat<class_Quat>` b, :ref:`Quat<class_Quat>` pre_a, :ref:`Quat<class_Quat>` post_b, :ref:`float<class_float>` t **)**
  106. Performs a cubic spherical-linear interpolation with another quaternion.
  107. ----
  108. .. _class_Quat_method_dot:
  109. - :ref:`float<class_float>` **dot** **(** :ref:`Quat<class_Quat>` b **)**
  110. Returns the dot product of two quaternions.
  111. ----
  112. .. _class_Quat_method_get_euler:
  113. - :ref:`Vector3<class_Vector3>` **get_euler** **(** **)**
  114. 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).
  115. ----
  116. .. _class_Quat_method_inverse:
  117. - :ref:`Quat<class_Quat>` **inverse** **(** **)**
  118. Returns the inverse of the quaternion.
  119. ----
  120. .. _class_Quat_method_is_normalized:
  121. - :ref:`bool<class_bool>` **is_normalized** **(** **)**
  122. Returns whether the quaternion is normalized or not.
  123. ----
  124. .. _class_Quat_method_length:
  125. - :ref:`float<class_float>` **length** **(** **)**
  126. Returns the length of the quaternion.
  127. ----
  128. .. _class_Quat_method_length_squared:
  129. - :ref:`float<class_float>` **length_squared** **(** **)**
  130. Returns the length of the quaternion, squared.
  131. ----
  132. .. _class_Quat_method_normalized:
  133. - :ref:`Quat<class_Quat>` **normalized** **(** **)**
  134. Returns a copy of the quaternion, normalized to unit length.
  135. ----
  136. .. _class_Quat_method_set_axis_angle:
  137. - void **set_axis_angle** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  138. Set the quaternion to a rotation which rotates around axis by the specified angle, in radians. The axis must be a normalized vector.
  139. ----
  140. .. _class_Quat_method_set_euler:
  141. - void **set_euler** **(** :ref:`Vector3<class_Vector3>` euler **)**
  142. 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).
  143. ----
  144. .. _class_Quat_method_slerp:
  145. - :ref:`Quat<class_Quat>` **slerp** **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)**
  146. Performs a spherical-linear interpolation with another quaternion.
  147. ----
  148. .. _class_Quat_method_slerpni:
  149. - :ref:`Quat<class_Quat>` **slerpni** **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)**
  150. Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°.
  151. ----
  152. .. _class_Quat_method_xform:
  153. - :ref:`Vector3<class_Vector3>` **xform** **(** :ref:`Vector3<class_Vector3>` v **)**
  154. Transforms the vector ``v`` by this quaternion.