class_quat.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. Member Functions
  12. ----------------
  13. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`Quat<class_quat>` | :ref:`Quat<class_Quat_Quat>` **(** :ref:`Basis<class_basis>` from **)** |
  15. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`Quat<class_quat>` | :ref:`Quat<class_Quat_Quat>` **(** :ref:`Vector3<class_vector3>` euler **)** |
  17. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`Quat<class_quat>` | :ref:`Quat<class_Quat_Quat>` **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` angle **)** |
  19. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :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 **)** |
  21. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :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 **)** |
  23. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`float<class_float>` | :ref:`dot<class_Quat_dot>` **(** :ref:`Quat<class_quat>` b **)** |
  25. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Vector3<class_vector3>` | :ref:`get_euler<class_Quat_get_euler>` **(** **)** |
  27. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Quat<class_quat>` | :ref:`inverse<class_Quat_inverse>` **(** **)** |
  29. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Quat_is_normalized>` **(** **)** |
  31. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`length<class_Quat_length>` **(** **)** |
  33. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`length_squared<class_Quat_length_squared>` **(** **)** |
  35. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Quat<class_quat>` | :ref:`normalized<class_Quat_normalized>` **(** **)** |
  37. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_axis_angle<class_Quat_set_axis_angle>` **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` angle **)** |
  39. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_euler<class_Quat_set_euler>` **(** :ref:`Vector3<class_vector3>` euler **)** |
  41. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Quat<class_quat>` | :ref:`slerp<class_Quat_slerp>` **(** :ref:`Quat<class_quat>` b, :ref:`float<class_float>` t **)** |
  43. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Quat<class_quat>` | :ref:`slerpni<class_Quat_slerpni>` **(** :ref:`Quat<class_quat>` b, :ref:`float<class_float>` t **)** |
  45. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector3<class_vector3>` | :ref:`xform<class_Quat_xform>` **(** :ref:`Vector3<class_vector3>` v **)** |
  47. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. Member Variables
  49. ----------------
  50. .. _class_Quat_w:
  51. - :ref:`float<class_float>` **w** - W component of the quaternion. Default value: ``1``
  52. .. _class_Quat_x:
  53. - :ref:`float<class_float>` **x** - X component of the quaternion. Default value: ``0``
  54. .. _class_Quat_y:
  55. - :ref:`float<class_float>` **y** - Y component of the quaternion. Default value: ``0``
  56. .. _class_Quat_z:
  57. - :ref:`float<class_float>` **z** - Z component of the quaternion. Default value: ``0``
  58. Description
  59. -----------
  60. A unit quaternion used for representing 3D rotations.
  61. 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.
  62. Quaternions need to be (re)normalized.
  63. Member Function Description
  64. ---------------------------
  65. .. _class_Quat_Quat:
  66. - :ref:`Quat<class_quat>` **Quat** **(** :ref:`Basis<class_basis>` from **)**
  67. Returns the rotation matrix corresponding to the given quaternion.
  68. .. _class_Quat_Quat:
  69. - :ref:`Quat<class_quat>` **Quat** **(** :ref:`Vector3<class_vector3>` euler **)**
  70. 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).
  71. .. _class_Quat_Quat:
  72. - :ref:`Quat<class_quat>` **Quat** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` angle **)**
  73. Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
  74. .. _class_Quat_Quat:
  75. - :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 **)**
  76. Returns a quaternion defined by these values.
  77. .. _class_Quat_cubic_slerp:
  78. - :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 **)**
  79. Performs a cubic spherical-linear interpolation with another quaternion.
  80. .. _class_Quat_dot:
  81. - :ref:`float<class_float>` **dot** **(** :ref:`Quat<class_quat>` b **)**
  82. Returns the dot product of two quaternions.
  83. .. _class_Quat_get_euler:
  84. - :ref:`Vector3<class_vector3>` **get_euler** **(** **)**
  85. 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).
  86. .. _class_Quat_inverse:
  87. - :ref:`Quat<class_quat>` **inverse** **(** **)**
  88. Returns the inverse of the quaternion.
  89. .. _class_Quat_is_normalized:
  90. - :ref:`bool<class_bool>` **is_normalized** **(** **)**
  91. Returns whether the quaternion is normalized or not.
  92. .. _class_Quat_length:
  93. - :ref:`float<class_float>` **length** **(** **)**
  94. Returns the length of the quaternion.
  95. .. _class_Quat_length_squared:
  96. - :ref:`float<class_float>` **length_squared** **(** **)**
  97. Returns the length of the quaternion, squared.
  98. .. _class_Quat_normalized:
  99. - :ref:`Quat<class_quat>` **normalized** **(** **)**
  100. Returns a copy of the quaternion, normalized to unit length.
  101. .. _class_Quat_set_axis_angle:
  102. - void **set_axis_angle** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` angle **)**
  103. Set the quaternion to a rotation which rotates around axis by the specified angle, in radians. The axis must be a normalized vector.
  104. .. _class_Quat_set_euler:
  105. - void **set_euler** **(** :ref:`Vector3<class_vector3>` euler **)**
  106. 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).
  107. .. _class_Quat_slerp:
  108. - :ref:`Quat<class_quat>` **slerp** **(** :ref:`Quat<class_quat>` b, :ref:`float<class_float>` t **)**
  109. Performs a spherical-linear interpolation with another quaternion.
  110. .. _class_Quat_slerpni:
  111. - :ref:`Quat<class_quat>` **slerpni** **(** :ref:`Quat<class_quat>` b, :ref:`float<class_float>` t **)**
  112. Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°.
  113. .. _class_Quat_xform:
  114. - :ref:`Vector3<class_vector3>` **xform** **(** :ref:`Vector3<class_vector3>` v **)**
  115. Transforms the vector ``v`` by this quaternion.