class_quaternion.rst 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Quaternion.xml.
  6. .. _class_Quaternion:
  7. Quaternion
  8. ==========
  9. Quaternion.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. A unit quaternion used for representing 3D rotations. Quaternions need to be normalized to be used for rotation.
  14. It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. Basis stores rotation, scale, and shearing, while Quaternion only stores rotation.
  15. 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.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `Using 3D transforms <../tutorials/3d/using_transforms.html#interpolating-with-quaternions>`__
  20. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +---------------------------+---------------------------------------+---------+
  27. | :ref:`float<class_float>` | :ref:`w<class_Quaternion_property_w>` | ``1.0`` |
  28. +---------------------------+---------------------------------------+---------+
  29. | :ref:`float<class_float>` | :ref:`x<class_Quaternion_property_x>` | ``0.0`` |
  30. +---------------------------+---------------------------------------+---------+
  31. | :ref:`float<class_float>` | :ref:`y<class_Quaternion_property_y>` | ``0.0`` |
  32. +---------------------------+---------------------------------------+---------+
  33. | :ref:`float<class_float>` | :ref:`z<class_Quaternion_property_z>` | ``0.0`` |
  34. +---------------------------+---------------------------------------+---------+
  35. .. rst-class:: classref-reftable-group
  36. Constructors
  37. ------------
  38. .. table::
  39. :widths: auto
  40. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** **)** |
  42. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` from **)** |
  44. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Vector3<class_Vector3>` arc_from, :ref:`Vector3<class_Vector3>` arc_to **)** |
  46. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  48. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Basis<class_Basis>` from **)** |
  50. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)** |
  52. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. .. rst-class:: classref-reftable-group
  54. Methods
  55. -------
  56. .. table::
  57. :widths: auto
  58. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`float<class_float>` | :ref:`angle_to<class_Quaternion_method_angle_to>` **(** :ref:`Quaternion<class_Quaternion>` to **)** |const| |
  60. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`float<class_float>` | :ref:`dot<class_Quaternion_method_dot>` **(** :ref:`Quaternion<class_Quaternion>` with **)** |const| |
  62. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Quaternion<class_Quaternion>` | :ref:`exp<class_Quaternion_method_exp>` **(** **)** |const| |
  64. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Quaternion<class_Quaternion>` | :ref:`from_euler<class_Quaternion_method_from_euler>` **(** :ref:`Vector3<class_Vector3>` euler **)** |static| |
  66. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`float<class_float>` | :ref:`get_angle<class_Quaternion_method_get_angle>` **(** **)** |const| |
  68. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Vector3<class_Vector3>` | :ref:`get_axis<class_Quaternion_method_get_axis>` **(** **)** |const| |
  70. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector3<class_Vector3>` | :ref:`get_euler<class_Quaternion_method_get_euler>` **(** :ref:`int<class_int>` order=2 **)** |const| |
  72. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Quaternion<class_Quaternion>` | :ref:`inverse<class_Quaternion_method_inverse>` **(** **)** |const| |
  74. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Quaternion_method_is_equal_approx>` **(** :ref:`Quaternion<class_Quaternion>` to **)** |const| |
  76. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Quaternion_method_is_finite>` **(** **)** |const| |
  78. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Quaternion_method_is_normalized>` **(** **)** |const| |
  80. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`float<class_float>` | :ref:`length<class_Quaternion_method_length>` **(** **)** |const| |
  82. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`float<class_float>` | :ref:`length_squared<class_Quaternion_method_length_squared>` **(** **)** |const| |
  84. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Quaternion<class_Quaternion>` | :ref:`log<class_Quaternion_method_log>` **(** **)** |const| |
  86. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`Quaternion<class_Quaternion>` | :ref:`normalized<class_Quaternion_method_normalized>` **(** **)** |const| |
  88. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`Quaternion<class_Quaternion>` | :ref:`slerp<class_Quaternion_method_slerp>` **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const| |
  90. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Quaternion<class_Quaternion>` | :ref:`slerpni<class_Quaternion_method_slerpni>` **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const| |
  92. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`Quaternion<class_Quaternion>` | :ref:`spherical_cubic_interpolate<class_Quaternion_method_spherical_cubic_interpolate>` **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight **)** |const| |
  94. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`Quaternion<class_Quaternion>` | :ref:`spherical_cubic_interpolate_in_time<class_Quaternion_method_spherical_cubic_interpolate_in_time>` **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const| |
  96. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. .. rst-class:: classref-reftable-group
  98. Operators
  99. ---------
  100. .. table::
  101. :widths: auto
  102. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Quaternion_operator_neq_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
  104. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_Quaternion_operator_mul_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
  106. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Quaternion_operator_mul_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
  108. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_Quaternion_operator_mul_float>` **(** :ref:`float<class_float>` right **)** |
  110. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_Quaternion_operator_mul_int>` **(** :ref:`int<class_int>` right **)** |
  112. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator +<class_Quaternion_operator_sum_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
  114. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator -<class_Quaternion_operator_dif_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
  116. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator /<class_Quaternion_operator_div_float>` **(** :ref:`float<class_float>` right **)** |
  118. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator /<class_Quaternion_operator_div_int>` **(** :ref:`int<class_int>` right **)** |
  120. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Quaternion_operator_eq_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
  122. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`float<class_float>` | :ref:`operator []<class_Quaternion_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
  124. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator unary+<class_Quaternion_operator_unplus>` **(** **)** |
  126. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator unary-<class_Quaternion_operator_unminus>` **(** **)** |
  128. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  129. .. rst-class:: classref-section-separator
  130. ----
  131. .. rst-class:: classref-descriptions-group
  132. Constants
  133. ---------
  134. .. _class_Quaternion_constant_IDENTITY:
  135. .. rst-class:: classref-constant
  136. **IDENTITY** = ``Quaternion(0, 0, 0, 1)``
  137. The identity quaternion, representing no rotation. Equivalent to an identity :ref:`Basis<class_Basis>` matrix. If a vector is transformed by an identity quaternion, it will not change.
  138. .. rst-class:: classref-section-separator
  139. ----
  140. .. rst-class:: classref-descriptions-group
  141. Property Descriptions
  142. ---------------------
  143. .. _class_Quaternion_property_w:
  144. .. rst-class:: classref-property
  145. :ref:`float<class_float>` **w** = ``1.0``
  146. W component of the quaternion (real part).
  147. Quaternion components should usually not be manipulated directly.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_Quaternion_property_x:
  151. .. rst-class:: classref-property
  152. :ref:`float<class_float>` **x** = ``0.0``
  153. X component of the quaternion (imaginary ``i`` axis part).
  154. Quaternion components should usually not be manipulated directly.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_Quaternion_property_y:
  158. .. rst-class:: classref-property
  159. :ref:`float<class_float>` **y** = ``0.0``
  160. Y component of the quaternion (imaginary ``j`` axis part).
  161. Quaternion components should usually not be manipulated directly.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_Quaternion_property_z:
  165. .. rst-class:: classref-property
  166. :ref:`float<class_float>` **z** = ``0.0``
  167. Z component of the quaternion (imaginary ``k`` axis part).
  168. Quaternion components should usually not be manipulated directly.
  169. .. rst-class:: classref-section-separator
  170. ----
  171. .. rst-class:: classref-descriptions-group
  172. Constructor Descriptions
  173. ------------------------
  174. .. _class_Quaternion_constructor_Quaternion:
  175. .. rst-class:: classref-constructor
  176. :ref:`Quaternion<class_Quaternion>` **Quaternion** **(** **)**
  177. Constructs a default-initialized quaternion with all components set to ``0``.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. rst-class:: classref-constructor
  181. :ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Quaternion<class_Quaternion>` from **)**
  182. Constructs a **Quaternion** as a copy of the given **Quaternion**.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. rst-class:: classref-constructor
  186. :ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Vector3<class_Vector3>` arc_from, :ref:`Vector3<class_Vector3>` arc_to **)**
  187. .. container:: contribute
  188. There is currently no description for this constructor. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. rst-class:: classref-constructor
  192. :ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  193. Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
  194. .. rst-class:: classref-item-separator
  195. ----
  196. .. rst-class:: classref-constructor
  197. :ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Basis<class_Basis>` from **)**
  198. Constructs a quaternion from the given :ref:`Basis<class_Basis>`.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. rst-class:: classref-constructor
  202. :ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)**
  203. Constructs a quaternion defined by the given values.
  204. .. rst-class:: classref-section-separator
  205. ----
  206. .. rst-class:: classref-descriptions-group
  207. Method Descriptions
  208. -------------------
  209. .. _class_Quaternion_method_angle_to:
  210. .. rst-class:: classref-method
  211. :ref:`float<class_float>` **angle_to** **(** :ref:`Quaternion<class_Quaternion>` to **)** |const|
  212. Returns the angle between this quaternion and ``to``. This is the magnitude of the angle you would need to rotate by to get from one to the other.
  213. \ **Note:** The magnitude of the floating-point error for this method is abnormally high, so methods such as ``is_zero_approx`` will not work reliably.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_Quaternion_method_dot:
  217. .. rst-class:: classref-method
  218. :ref:`float<class_float>` **dot** **(** :ref:`Quaternion<class_Quaternion>` with **)** |const|
  219. Returns the dot product of two quaternions.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_Quaternion_method_exp:
  223. .. rst-class:: classref-method
  224. :ref:`Quaternion<class_Quaternion>` **exp** **(** **)** |const|
  225. .. container:: contribute
  226. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_Quaternion_method_from_euler:
  230. .. rst-class:: classref-method
  231. :ref:`Quaternion<class_Quaternion>` **from_euler** **(** :ref:`Vector3<class_Vector3>` euler **)** |static|
  232. Constructs a Quaternion from Euler angles in YXZ rotation order.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_Quaternion_method_get_angle:
  236. .. rst-class:: classref-method
  237. :ref:`float<class_float>` **get_angle** **(** **)** |const|
  238. .. container:: contribute
  239. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_Quaternion_method_get_axis:
  243. .. rst-class:: classref-method
  244. :ref:`Vector3<class_Vector3>` **get_axis** **(** **)** |const|
  245. .. container:: contribute
  246. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  247. .. rst-class:: classref-item-separator
  248. ----
  249. .. _class_Quaternion_method_get_euler:
  250. .. rst-class:: classref-method
  251. :ref:`Vector3<class_Vector3>` **get_euler** **(** :ref:`int<class_int>` order=2 **)** |const|
  252. Returns the quaternion's rotation in the form of Euler angles. The Euler order depends on the ``order`` parameter, for example using the YXZ convention: since this method decomposes, first Z, then X, and Y last. See the :ref:`EulerOrder<enum_@GlobalScope_EulerOrder>` enum for possible values. The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_Quaternion_method_inverse:
  256. .. rst-class:: classref-method
  257. :ref:`Quaternion<class_Quaternion>` **inverse** **(** **)** |const|
  258. Returns the inverse of the quaternion.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_Quaternion_method_is_equal_approx:
  262. .. rst-class:: classref-method
  263. :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Quaternion<class_Quaternion>` to **)** |const|
  264. Returns ``true`` if this quaternion and ``to`` are approximately equal, by running :ref:`@GlobalScope.is_equal_approx<class_@GlobalScope_method_is_equal_approx>` on each component.
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_Quaternion_method_is_finite:
  268. .. rst-class:: classref-method
  269. :ref:`bool<class_bool>` **is_finite** **(** **)** |const|
  270. Returns ``true`` if this quaternion is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_Quaternion_method_is_normalized:
  274. .. rst-class:: classref-method
  275. :ref:`bool<class_bool>` **is_normalized** **(** **)** |const|
  276. Returns whether the quaternion is normalized or not.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_Quaternion_method_length:
  280. .. rst-class:: classref-method
  281. :ref:`float<class_float>` **length** **(** **)** |const|
  282. Returns the length of the quaternion.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_Quaternion_method_length_squared:
  286. .. rst-class:: classref-method
  287. :ref:`float<class_float>` **length_squared** **(** **)** |const|
  288. Returns the length of the quaternion, squared.
  289. .. rst-class:: classref-item-separator
  290. ----
  291. .. _class_Quaternion_method_log:
  292. .. rst-class:: classref-method
  293. :ref:`Quaternion<class_Quaternion>` **log** **(** **)** |const|
  294. .. container:: contribute
  295. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_Quaternion_method_normalized:
  299. .. rst-class:: classref-method
  300. :ref:`Quaternion<class_Quaternion>` **normalized** **(** **)** |const|
  301. Returns a copy of the quaternion, normalized to unit length.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_Quaternion_method_slerp:
  305. .. rst-class:: classref-method
  306. :ref:`Quaternion<class_Quaternion>` **slerp** **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const|
  307. Returns the result of the spherical linear interpolation between this quaternion and ``to`` by amount ``weight``.
  308. \ **Note:** Both quaternions must be normalized.
  309. .. rst-class:: classref-item-separator
  310. ----
  311. .. _class_Quaternion_method_slerpni:
  312. .. rst-class:: classref-method
  313. :ref:`Quaternion<class_Quaternion>` **slerpni** **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const|
  314. 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.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_Quaternion_method_spherical_cubic_interpolate:
  318. .. rst-class:: classref-method
  319. :ref:`Quaternion<class_Quaternion>` **spherical_cubic_interpolate** **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight **)** |const|
  320. Performs a spherical cubic interpolation between quaternions ``pre_a``, this vector, ``b``, and ``post_b``, by the given amount ``weight``.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_Quaternion_method_spherical_cubic_interpolate_in_time:
  324. .. rst-class:: classref-method
  325. :ref:`Quaternion<class_Quaternion>` **spherical_cubic_interpolate_in_time** **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const|
  326. Performs a spherical cubic interpolation between quaternions ``pre_a``, this vector, ``b``, and ``post_b``, by the given amount ``weight``.
  327. It can perform smoother interpolation than ``spherical_cubic_interpolate()`` by the time values.
  328. .. rst-class:: classref-section-separator
  329. ----
  330. .. rst-class:: classref-descriptions-group
  331. Operator Descriptions
  332. ---------------------
  333. .. _class_Quaternion_operator_neq_Quaternion:
  334. .. rst-class:: classref-operator
  335. :ref:`bool<class_bool>` **operator !=** **(** :ref:`Quaternion<class_Quaternion>` right **)**
  336. Returns ``true`` if the quaternions are not equal.
  337. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Quaternion_method_is_equal_approx>` instead, which is more reliable.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_Quaternion_operator_mul_Quaternion:
  341. .. rst-class:: classref-operator
  342. :ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`Quaternion<class_Quaternion>` right **)**
  343. Composes these two quaternions by multiplying them together. This has the effect of rotating the second quaternion (the child) by the first quaternion (the parent).
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_Quaternion_operator_mul_Vector3:
  347. .. rst-class:: classref-operator
  348. :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Vector3<class_Vector3>` right **)**
  349. Rotates (multiplies) the :ref:`Vector3<class_Vector3>` by the given **Quaternion**.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_Quaternion_operator_mul_float:
  353. .. rst-class:: classref-operator
  354. :ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`float<class_float>` right **)**
  355. Multiplies each component of the **Quaternion** by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_Quaternion_operator_mul_int:
  359. .. rst-class:: classref-operator
  360. :ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`int<class_int>` right **)**
  361. Multiplies each component of the **Quaternion** by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_Quaternion_operator_sum_Quaternion:
  365. .. rst-class:: classref-operator
  366. :ref:`Quaternion<class_Quaternion>` **operator +** **(** :ref:`Quaternion<class_Quaternion>` right **)**
  367. Adds each component of the left **Quaternion** to the right **Quaternion**. This operation is not meaningful on its own, but it can be used as a part of a larger expression, such as approximating an intermediate rotation between two nearby rotations.
  368. .. rst-class:: classref-item-separator
  369. ----
  370. .. _class_Quaternion_operator_dif_Quaternion:
  371. .. rst-class:: classref-operator
  372. :ref:`Quaternion<class_Quaternion>` **operator -** **(** :ref:`Quaternion<class_Quaternion>` right **)**
  373. Subtracts each component of the left **Quaternion** by the right **Quaternion**. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_Quaternion_operator_div_float:
  377. .. rst-class:: classref-operator
  378. :ref:`Quaternion<class_Quaternion>` **operator /** **(** :ref:`float<class_float>` right **)**
  379. Divides each component of the **Quaternion** by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_Quaternion_operator_div_int:
  383. .. rst-class:: classref-operator
  384. :ref:`Quaternion<class_Quaternion>` **operator /** **(** :ref:`int<class_int>` right **)**
  385. Divides each component of the **Quaternion** by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_Quaternion_operator_eq_Quaternion:
  389. .. rst-class:: classref-operator
  390. :ref:`bool<class_bool>` **operator ==** **(** :ref:`Quaternion<class_Quaternion>` right **)**
  391. Returns ``true`` if the quaternions are exactly equal.
  392. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Quaternion_method_is_equal_approx>` instead, which is more reliable.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_Quaternion_operator_idx_int:
  396. .. rst-class:: classref-operator
  397. :ref:`float<class_float>` **operator []** **(** :ref:`int<class_int>` index **)**
  398. Access quaternion components using their index. ``q[0]`` is equivalent to ``q.x``, ``q[1]`` is equivalent to ``q.y``, ``q[2]`` is equivalent to ``q.z``, and ``q[3]`` is equivalent to ``q.w``.
  399. .. rst-class:: classref-item-separator
  400. ----
  401. .. _class_Quaternion_operator_unplus:
  402. .. rst-class:: classref-operator
  403. :ref:`Quaternion<class_Quaternion>` **operator unary+** **(** **)**
  404. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  405. .. rst-class:: classref-item-separator
  406. ----
  407. .. _class_Quaternion_operator_unminus:
  408. .. rst-class:: classref-operator
  409. :ref:`Quaternion<class_Quaternion>` **operator unary-** **(** **)**
  410. Returns the negative value of the **Quaternion**. This is the same as writing ``Quaternion(-q.x, -q.y, -q.z, -q.w)``. This operation results in a quaternion that represents the same rotation.
  411. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  412. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  413. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  414. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  415. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  416. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`