class_quat.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Quat.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Quat:
  5. Quat
  6. ====
  7. **Category:** Built-In Types
  8. Brief Description
  9. -----------------
  10. Quaternion.
  11. Properties
  12. ----------
  13. +---------------------------+------------------------+
  14. | :ref:`float<class_float>` | :ref:`w<class_Quat_w>` |
  15. +---------------------------+------------------------+
  16. | :ref:`float<class_float>` | :ref:`x<class_Quat_x>` |
  17. +---------------------------+------------------------+
  18. | :ref:`float<class_float>` | :ref:`y<class_Quat_y>` |
  19. +---------------------------+------------------------+
  20. | :ref:`float<class_float>` | :ref:`z<class_Quat_z>` |
  21. +---------------------------+------------------------+
  22. Methods
  23. -------
  24. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_Quat>` **(** :ref:`Basis<class_Basis>` from **)** |
  26. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_Quat>` **(** :ref:`Vector3<class_Vector3>` euler **)** |
  28. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Quat<class_Quat>` | :ref:`Quat<class_Quat_Quat>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  30. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Quat<class_Quat>` | :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 **)** |
  32. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Quat<class_Quat>` | :ref:`cubic_slerp<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 **)** |
  34. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`dot<class_Quat_dot>` **(** :ref:`Quat<class_Quat>` b **)** |
  36. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Vector3<class_Vector3>` | :ref:`get_euler<class_Quat_get_euler>` **(** **)** |
  38. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Quat<class_Quat>` | :ref:`inverse<class_Quat_inverse>` **(** **)** |
  40. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Quat_is_normalized>` **(** **)** |
  42. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`length<class_Quat_length>` **(** **)** |
  44. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`float<class_float>` | :ref:`length_squared<class_Quat_length_squared>` **(** **)** |
  46. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Quat<class_Quat>` | :ref:`normalized<class_Quat_normalized>` **(** **)** |
  48. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_axis_angle<class_Quat_set_axis_angle>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  50. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_euler<class_Quat_set_euler>` **(** :ref:`Vector3<class_Vector3>` euler **)** |
  52. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Quat<class_Quat>` | :ref:`slerp<class_Quat_slerp>` **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)** |
  54. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Quat<class_Quat>` | :ref:`slerpni<class_Quat_slerpni>` **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)** |
  56. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Vector3<class_Vector3>` | :ref:`xform<class_Quat_xform>` **(** :ref:`Vector3<class_Vector3>` v **)** |
  58. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. Constants
  60. ---------
  61. - **IDENTITY** = **Quat( 0, 0, 0, 1 )**
  62. Description
  63. -----------
  64. A unit quaternion used for representing 3D rotations.
  65. 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.
  66. Quaternions need to be (re)normalized.
  67. Tutorials
  68. ---------
  69. - `#interpolating-with-quaternions <../tutorials/3d/using_transforms.html#interpolating-with-quaternions>`_ in :doc:`../tutorials/3d/using_transforms`
  70. - :doc:`../tutorials/math/rotations`
  71. Property Descriptions
  72. ---------------------
  73. .. _class_Quat_w:
  74. - :ref:`float<class_float>` **w**
  75. W component of the quaternion. Default value: ``1``
  76. .. _class_Quat_x:
  77. - :ref:`float<class_float>` **x**
  78. X component of the quaternion. Default value: ``0``
  79. .. _class_Quat_y:
  80. - :ref:`float<class_float>` **y**
  81. Y component of the quaternion. Default value: ``0``
  82. .. _class_Quat_z:
  83. - :ref:`float<class_float>` **z**
  84. Z component of the quaternion. Default value: ``0``
  85. Method Descriptions
  86. -------------------
  87. .. _class_Quat_Quat:
  88. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`Basis<class_Basis>` from **)**
  89. Returns the rotation matrix corresponding to the given quaternion.
  90. .. _class_Quat_Quat:
  91. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`Vector3<class_Vector3>` euler **)**
  92. 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).
  93. .. _class_Quat_Quat:
  94. - :ref:`Quat<class_Quat>` **Quat** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  95. Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
  96. .. _class_Quat_Quat:
  97. - :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 **)**
  98. Returns a quaternion defined by these values.
  99. .. _class_Quat_cubic_slerp:
  100. - :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 **)**
  101. Performs a cubic spherical-linear interpolation with another quaternion.
  102. .. _class_Quat_dot:
  103. - :ref:`float<class_float>` **dot** **(** :ref:`Quat<class_Quat>` b **)**
  104. Returns the dot product of two quaternions.
  105. .. _class_Quat_get_euler:
  106. - :ref:`Vector3<class_Vector3>` **get_euler** **(** **)**
  107. Return 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).
  108. .. _class_Quat_inverse:
  109. - :ref:`Quat<class_Quat>` **inverse** **(** **)**
  110. Returns the inverse of the quaternion.
  111. .. _class_Quat_is_normalized:
  112. - :ref:`bool<class_bool>` **is_normalized** **(** **)**
  113. Returns whether the quaternion is normalized or not.
  114. .. _class_Quat_length:
  115. - :ref:`float<class_float>` **length** **(** **)**
  116. Returns the length of the quaternion.
  117. .. _class_Quat_length_squared:
  118. - :ref:`float<class_float>` **length_squared** **(** **)**
  119. Returns the length of the quaternion, squared.
  120. .. _class_Quat_normalized:
  121. - :ref:`Quat<class_Quat>` **normalized** **(** **)**
  122. Returns a copy of the quaternion, normalized to unit length.
  123. .. _class_Quat_set_axis_angle:
  124. - void **set_axis_angle** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  125. Set the quaternion to a rotation which rotates around axis by the specified angle, in radians. The axis must be a normalized vector.
  126. .. _class_Quat_set_euler:
  127. - void **set_euler** **(** :ref:`Vector3<class_Vector3>` euler **)**
  128. 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).
  129. .. _class_Quat_slerp:
  130. - :ref:`Quat<class_Quat>` **slerp** **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)**
  131. Performs a spherical-linear interpolation with another quaternion.
  132. .. _class_Quat_slerpni:
  133. - :ref:`Quat<class_Quat>` **slerpni** **(** :ref:`Quat<class_Quat>` b, :ref:`float<class_float>` t **)**
  134. Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°.
  135. .. _class_Quat_xform:
  136. - :ref:`Vector3<class_Vector3>` **xform** **(** :ref:`Vector3<class_Vector3>` v **)**
  137. Transforms the vector ``v`` by this quaternion.