class_basis.rst 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  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/Basis.xml.
  6. .. _class_Basis:
  7. Basis
  8. =====
  9. A 3×3 matrix for representing 3D rotation and scale.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. The **Basis** built-in :ref:`Variant<class_Variant>` type is a 3×3 `matrix <https://en.wikipedia.org/wiki/Matrix_(mathematics)>`__ used to represent 3D rotation, scale, and shear. It is frequently used within a :ref:`Transform3D<class_Transform3D>`.
  14. A **Basis** is composed by 3 axis vectors, each representing a column of the matrix: :ref:`x<class_Basis_property_x>`, :ref:`y<class_Basis_property_y>`, and :ref:`z<class_Basis_property_z>`. The length of each axis (:ref:`Vector3.length()<class_Vector3_method_length>`) influences the basis's scale, while the direction of all axes influence the rotation. Usually, these axes are perpendicular to one another. However, when you rotate any axis individually, the basis becomes sheared. Applying a sheared basis to a 3D model will make the model appear distorted.
  15. A **Basis** is:
  16. - **Orthogonal** if its axes are perpendicular to each other.
  17. - **Normalized** if the length of every axis is ``1.0``.
  18. - **Uniform** if all axes share the same length (see :ref:`get_scale()<class_Basis_method_get_scale>`).
  19. - **Orthonormal** if it is both orthogonal and normalized, which allows it to only represent rotations (see :ref:`orthonormalized()<class_Basis_method_orthonormalized>`).
  20. - **Conformal** if it is both orthogonal and uniform, which ensures it is not distorted.
  21. For a general introduction, see the :doc:`Matrices and transforms <../tutorials/math/matrices_and_transforms>` tutorial.
  22. \ **Note:** Godot uses a `right-handed coordinate system <https://en.wikipedia.org/wiki/Right-hand_rule>`__, which is a common standard. For directions, the convention for built-in types like :ref:`Camera3D<class_Camera3D>` is for -Z to point forward (+X is right, +Y is up, and +Z is back). Other objects may use different direction conventions. For more information, see the `3D asset direction conventions <../tutorials/assets_pipeline/importing_3d_scenes/model_export_considerations.html#d-asset-direction-conventions>`__ tutorial.
  23. \ **Note:** The basis matrices are exposed as `column-major <https://www.mindcontrol.org/~hplus/graphics/matrix-layout.html>`__ order, which is the same as OpenGL. However, they are stored internally in row-major order, which is the same as DirectX.
  24. .. note::
  25. There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
  26. .. rst-class:: classref-introduction-group
  27. Tutorials
  28. ---------
  29. - :doc:`Math documentation index <../tutorials/math/index>`
  30. - :doc:`Matrices and transforms <../tutorials/math/matrices_and_transforms>`
  31. - :doc:`Using 3D transforms <../tutorials/3d/using_transforms>`
  32. - `Matrix Transform Demo <https://godotengine.org/asset-library/asset/2787>`__
  33. - `3D Platformer Demo <https://godotengine.org/asset-library/asset/2748>`__
  34. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/2755>`__
  35. - `2.5D Game Demo <https://godotengine.org/asset-library/asset/2783>`__
  36. .. rst-class:: classref-reftable-group
  37. Properties
  38. ----------
  39. .. table::
  40. :widths: auto
  41. +-------------------------------+----------------------------------+----------------------+
  42. | :ref:`Vector3<class_Vector3>` | :ref:`x<class_Basis_property_x>` | ``Vector3(1, 0, 0)`` |
  43. +-------------------------------+----------------------------------+----------------------+
  44. | :ref:`Vector3<class_Vector3>` | :ref:`y<class_Basis_property_y>` | ``Vector3(0, 1, 0)`` |
  45. +-------------------------------+----------------------------------+----------------------+
  46. | :ref:`Vector3<class_Vector3>` | :ref:`z<class_Basis_property_z>` | ``Vector3(0, 0, 1)`` |
  47. +-------------------------------+----------------------------------+----------------------+
  48. .. rst-class:: classref-reftable-group
  49. Constructors
  50. ------------
  51. .. table::
  52. :widths: auto
  53. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Basis<class_Basis>` | :ref:`Basis<class_Basis_constructor_Basis>`\ (\ ) |
  55. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Basis<class_Basis>` | :ref:`Basis<class_Basis_constructor_Basis>`\ (\ from\: :ref:`Basis<class_Basis>`\ ) |
  57. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Basis<class_Basis>` | :ref:`Basis<class_Basis_constructor_Basis>`\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |
  59. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Basis<class_Basis>` | :ref:`Basis<class_Basis_constructor_Basis>`\ (\ from\: :ref:`Quaternion<class_Quaternion>`\ ) |
  61. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Basis<class_Basis>` | :ref:`Basis<class_Basis_constructor_Basis>`\ (\ x_axis\: :ref:`Vector3<class_Vector3>`, y_axis\: :ref:`Vector3<class_Vector3>`, z_axis\: :ref:`Vector3<class_Vector3>`\ ) |
  63. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. .. rst-class:: classref-reftable-group
  65. Methods
  66. -------
  67. .. table::
  68. :widths: auto
  69. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`float<class_float>` | :ref:`determinant<class_Basis_method_determinant>`\ (\ ) |const| |
  71. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Basis<class_Basis>` | :ref:`from_euler<class_Basis_method_from_euler>`\ (\ euler\: :ref:`Vector3<class_Vector3>`, order\: :ref:`int<class_int>` = 2\ ) |static| |
  73. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Basis<class_Basis>` | :ref:`from_scale<class_Basis_method_from_scale>`\ (\ scale\: :ref:`Vector3<class_Vector3>`\ ) |static| |
  75. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector3<class_Vector3>` | :ref:`get_euler<class_Basis_method_get_euler>`\ (\ order\: :ref:`int<class_int>` = 2\ ) |const| |
  77. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Quaternion<class_Quaternion>` | :ref:`get_rotation_quaternion<class_Basis_method_get_rotation_quaternion>`\ (\ ) |const| |
  79. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector3<class_Vector3>` | :ref:`get_scale<class_Basis_method_get_scale>`\ (\ ) |const| |
  81. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`Basis<class_Basis>` | :ref:`inverse<class_Basis_method_inverse>`\ (\ ) |const| |
  83. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`bool<class_bool>` | :ref:`is_conformal<class_Basis_method_is_conformal>`\ (\ ) |const| |
  85. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Basis_method_is_equal_approx>`\ (\ b\: :ref:`Basis<class_Basis>`\ ) |const| |
  87. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Basis_method_is_finite>`\ (\ ) |const| |
  89. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Basis<class_Basis>` | :ref:`looking_at<class_Basis_method_looking_at>`\ (\ target\: :ref:`Vector3<class_Vector3>`, up\: :ref:`Vector3<class_Vector3>` = Vector3(0, 1, 0), use_model_front\: :ref:`bool<class_bool>` = false\ ) |static| |
  91. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Basis<class_Basis>` | :ref:`orthonormalized<class_Basis_method_orthonormalized>`\ (\ ) |const| |
  93. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`Basis<class_Basis>` | :ref:`rotated<class_Basis_method_rotated>`\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |const| |
  95. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`Basis<class_Basis>` | :ref:`scaled<class_Basis_method_scaled>`\ (\ scale\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  97. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Basis<class_Basis>` | :ref:`slerp<class_Basis_method_slerp>`\ (\ to\: :ref:`Basis<class_Basis>`, weight\: :ref:`float<class_float>`\ ) |const| |
  99. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`float<class_float>` | :ref:`tdotx<class_Basis_method_tdotx>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  101. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`float<class_float>` | :ref:`tdoty<class_Basis_method_tdoty>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  103. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`float<class_float>` | :ref:`tdotz<class_Basis_method_tdotz>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  105. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`Basis<class_Basis>` | :ref:`transposed<class_Basis_method_transposed>`\ (\ ) |const| |
  107. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. .. rst-class:: classref-reftable-group
  109. Operators
  110. ---------
  111. .. table::
  112. :widths: auto
  113. +-------------------------------+--------------------------------------------------------------------------------------------------+
  114. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Basis_operator_neq_Basis>`\ (\ right\: :ref:`Basis<class_Basis>`\ ) |
  115. +-------------------------------+--------------------------------------------------------------------------------------------------+
  116. | :ref:`Basis<class_Basis>` | :ref:`operator *<class_Basis_operator_mul_Basis>`\ (\ right\: :ref:`Basis<class_Basis>`\ ) |
  117. +-------------------------------+--------------------------------------------------------------------------------------------------+
  118. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Basis_operator_mul_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  119. +-------------------------------+--------------------------------------------------------------------------------------------------+
  120. | :ref:`Basis<class_Basis>` | :ref:`operator *<class_Basis_operator_mul_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  121. +-------------------------------+--------------------------------------------------------------------------------------------------+
  122. | :ref:`Basis<class_Basis>` | :ref:`operator *<class_Basis_operator_mul_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  123. +-------------------------------+--------------------------------------------------------------------------------------------------+
  124. | :ref:`Basis<class_Basis>` | :ref:`operator /<class_Basis_operator_div_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  125. +-------------------------------+--------------------------------------------------------------------------------------------------+
  126. | :ref:`Basis<class_Basis>` | :ref:`operator /<class_Basis_operator_div_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  127. +-------------------------------+--------------------------------------------------------------------------------------------------+
  128. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Basis_operator_eq_Basis>`\ (\ right\: :ref:`Basis<class_Basis>`\ ) |
  129. +-------------------------------+--------------------------------------------------------------------------------------------------+
  130. | :ref:`Vector3<class_Vector3>` | :ref:`operator []<class_Basis_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
  131. +-------------------------------+--------------------------------------------------------------------------------------------------+
  132. .. rst-class:: classref-section-separator
  133. ----
  134. .. rst-class:: classref-descriptions-group
  135. Constants
  136. ---------
  137. .. _class_Basis_constant_IDENTITY:
  138. .. rst-class:: classref-constant
  139. **IDENTITY** = ``Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)`` :ref:`🔗<class_Basis_constant_IDENTITY>`
  140. The identity **Basis**. This is an orthonormal basis with no rotation, no shear, and a scale of :ref:`Vector3.ONE<class_Vector3_constant_ONE>`. This also means that:
  141. - The :ref:`x<class_Basis_property_x>` points right (:ref:`Vector3.RIGHT<class_Vector3_constant_RIGHT>`);
  142. - The :ref:`y<class_Basis_property_y>` points up (:ref:`Vector3.UP<class_Vector3_constant_UP>`);
  143. - The :ref:`z<class_Basis_property_z>` points back (:ref:`Vector3.BACK<class_Vector3_constant_BACK>`).
  144. ::
  145. var basis = Basis.IDENTITY
  146. print("| X | Y | Z")
  147. print("| %.f | %.f | %.f" % [basis.x.x, basis.y.x, basis.z.x])
  148. print("| %.f | %.f | %.f" % [basis.x.y, basis.y.y, basis.z.y])
  149. print("| %.f | %.f | %.f" % [basis.x.z, basis.y.z, basis.z.z])
  150. # Prints:
  151. # | X | Y | Z
  152. # | 1 | 0 | 0
  153. # | 0 | 1 | 0
  154. # | 0 | 0 | 1
  155. If a :ref:`Vector3<class_Vector3>` or another **Basis** is transformed (multiplied) by this constant, no transformation occurs.
  156. \ **Note:** In GDScript, this constant is equivalent to creating a :ref:`Basis<class_Basis_constructor_Basis>` without any arguments. It can be used to make your code clearer, and for consistency with C#.
  157. .. _class_Basis_constant_FLIP_X:
  158. .. rst-class:: classref-constant
  159. **FLIP_X** = ``Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1)`` :ref:`🔗<class_Basis_constant_FLIP_X>`
  160. When any basis is multiplied by :ref:`FLIP_X<class_Basis_constant_FLIP_X>`, it negates all components of the :ref:`x<class_Basis_property_x>` axis (the X column).
  161. When :ref:`FLIP_X<class_Basis_constant_FLIP_X>` is multiplied by any basis, it negates the :ref:`Vector3.x<class_Vector3_property_x>` component of all axes (the X row).
  162. .. _class_Basis_constant_FLIP_Y:
  163. .. rst-class:: classref-constant
  164. **FLIP_Y** = ``Basis(1, 0, 0, 0, -1, 0, 0, 0, 1)`` :ref:`🔗<class_Basis_constant_FLIP_Y>`
  165. When any basis is multiplied by :ref:`FLIP_Y<class_Basis_constant_FLIP_Y>`, it negates all components of the :ref:`y<class_Basis_property_y>` axis (the Y column).
  166. When :ref:`FLIP_Y<class_Basis_constant_FLIP_Y>` is multiplied by any basis, it negates the :ref:`Vector3.y<class_Vector3_property_y>` component of all axes (the Y row).
  167. .. _class_Basis_constant_FLIP_Z:
  168. .. rst-class:: classref-constant
  169. **FLIP_Z** = ``Basis(1, 0, 0, 0, 1, 0, 0, 0, -1)`` :ref:`🔗<class_Basis_constant_FLIP_Z>`
  170. When any basis is multiplied by :ref:`FLIP_Z<class_Basis_constant_FLIP_Z>`, it negates all components of the :ref:`z<class_Basis_property_z>` axis (the Z column).
  171. When :ref:`FLIP_Z<class_Basis_constant_FLIP_Z>` is multiplied by any basis, it negates the :ref:`Vector3.z<class_Vector3_property_z>` component of all axes (the Z row).
  172. .. rst-class:: classref-section-separator
  173. ----
  174. .. rst-class:: classref-descriptions-group
  175. Property Descriptions
  176. ---------------------
  177. .. _class_Basis_property_x:
  178. .. rst-class:: classref-property
  179. :ref:`Vector3<class_Vector3>` **x** = ``Vector3(1, 0, 0)`` :ref:`🔗<class_Basis_property_x>`
  180. The basis's X axis, and the column ``0`` of the matrix.
  181. On the identity basis, this vector points right (:ref:`Vector3.RIGHT<class_Vector3_constant_RIGHT>`).
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _class_Basis_property_y:
  185. .. rst-class:: classref-property
  186. :ref:`Vector3<class_Vector3>` **y** = ``Vector3(0, 1, 0)`` :ref:`🔗<class_Basis_property_y>`
  187. The basis's Y axis, and the column ``1`` of the matrix.
  188. On the identity basis, this vector points up (:ref:`Vector3.UP<class_Vector3_constant_UP>`).
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_Basis_property_z:
  192. .. rst-class:: classref-property
  193. :ref:`Vector3<class_Vector3>` **z** = ``Vector3(0, 0, 1)`` :ref:`🔗<class_Basis_property_z>`
  194. The basis's Z axis, and the column ``2`` of the matrix.
  195. On the identity basis, this vector points back (:ref:`Vector3.BACK<class_Vector3_constant_BACK>`).
  196. .. rst-class:: classref-section-separator
  197. ----
  198. .. rst-class:: classref-descriptions-group
  199. Constructor Descriptions
  200. ------------------------
  201. .. _class_Basis_constructor_Basis:
  202. .. rst-class:: classref-constructor
  203. :ref:`Basis<class_Basis>` **Basis**\ (\ ) :ref:`🔗<class_Basis_constructor_Basis>`
  204. Constructs a **Basis** identical to :ref:`IDENTITY<class_Basis_constant_IDENTITY>`.
  205. \ **Note:** In C#, this constructs a **Basis** with all of its components set to :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. rst-class:: classref-constructor
  209. :ref:`Basis<class_Basis>` **Basis**\ (\ from\: :ref:`Basis<class_Basis>`\ )
  210. Constructs a **Basis** as a copy of the given **Basis**.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. rst-class:: classref-constructor
  214. :ref:`Basis<class_Basis>` **Basis**\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ )
  215. Constructs a **Basis** that only represents rotation, rotated around the ``axis`` by the given ``angle``, in radians. The axis must be a normalized vector.
  216. \ **Note:** This is the same as using :ref:`rotated()<class_Basis_method_rotated>` on the :ref:`IDENTITY<class_Basis_constant_IDENTITY>` basis. With more than one angle consider using :ref:`from_euler()<class_Basis_method_from_euler>`, instead.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. rst-class:: classref-constructor
  220. :ref:`Basis<class_Basis>` **Basis**\ (\ from\: :ref:`Quaternion<class_Quaternion>`\ )
  221. Constructs a **Basis** that only represents rotation from the given :ref:`Quaternion<class_Quaternion>`.
  222. \ **Note:** Quaternions *only* store rotation, not scale. Because of this, conversions from **Basis** to :ref:`Quaternion<class_Quaternion>` cannot always be reversed.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. rst-class:: classref-constructor
  226. :ref:`Basis<class_Basis>` **Basis**\ (\ x_axis\: :ref:`Vector3<class_Vector3>`, y_axis\: :ref:`Vector3<class_Vector3>`, z_axis\: :ref:`Vector3<class_Vector3>`\ )
  227. Constructs a **Basis** from 3 axis vectors. These are the columns of the basis matrix.
  228. .. rst-class:: classref-section-separator
  229. ----
  230. .. rst-class:: classref-descriptions-group
  231. Method Descriptions
  232. -------------------
  233. .. _class_Basis_method_determinant:
  234. .. rst-class:: classref-method
  235. :ref:`float<class_float>` **determinant**\ (\ ) |const| :ref:`🔗<class_Basis_method_determinant>`
  236. Returns the `determinant <https://en.wikipedia.org/wiki/Determinant>`__ of this basis's matrix. For advanced math, this number can be used to determine a few attributes:
  237. - If the determinant is exactly ``0.0``, the basis is not invertible (see :ref:`inverse()<class_Basis_method_inverse>`).
  238. - If the determinant is a negative number, the basis represents a negative scale.
  239. \ **Note:** If the basis's scale is the same for every axis, its determinant is always that scale by the power of 2.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_Basis_method_from_euler:
  243. .. rst-class:: classref-method
  244. :ref:`Basis<class_Basis>` **from_euler**\ (\ euler\: :ref:`Vector3<class_Vector3>`, order\: :ref:`int<class_int>` = 2\ ) |static| :ref:`🔗<class_Basis_method_from_euler>`
  245. Constructs a new **Basis** that only represents rotation from the given :ref:`Vector3<class_Vector3>` of `Euler angles <https://en.wikipedia.org/wiki/Euler_angles>`__, in radians.
  246. - The :ref:`Vector3.x<class_Vector3_property_x>` should contain the angle around the :ref:`x<class_Basis_property_x>` axis (pitch);
  247. - The :ref:`Vector3.y<class_Vector3_property_y>` should contain the angle around the :ref:`y<class_Basis_property_y>` axis (yaw);
  248. - The :ref:`Vector3.z<class_Vector3_property_z>` should contain the angle around the :ref:`z<class_Basis_property_z>` axis (roll).
  249. .. tabs::
  250. .. code-tab:: gdscript
  251. # Creates a Basis whose z axis points down.
  252. var my_basis = Basis.from_euler(Vector3(TAU / 4, 0, 0))
  253. print(my_basis.z) # Prints (0.0, -1.0, 0.0)
  254. .. code-tab:: csharp
  255. // Creates a Basis whose z axis points down.
  256. var myBasis = Basis.FromEuler(new Vector3(Mathf.Tau / 4.0f, 0.0f, 0.0f));
  257. GD.Print(myBasis.Z); // Prints (0, -1, 0)
  258. The order of each consecutive rotation can be changed with ``order`` (see :ref:`EulerOrder<enum_@GlobalScope_EulerOrder>` constants). By default, the YXZ convention is used (:ref:`@GlobalScope.EULER_ORDER_YXZ<class_@GlobalScope_constant_EULER_ORDER_YXZ>`): the basis rotates first around the Y axis (yaw), then X (pitch), and lastly Z (roll). When using the opposite method :ref:`get_euler()<class_Basis_method_get_euler>`, this order is reversed.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_Basis_method_from_scale:
  262. .. rst-class:: classref-method
  263. :ref:`Basis<class_Basis>` **from_scale**\ (\ scale\: :ref:`Vector3<class_Vector3>`\ ) |static| :ref:`🔗<class_Basis_method_from_scale>`
  264. Constructs a new **Basis** that only represents scale, with no rotation or shear, from the given ``scale`` vector.
  265. .. tabs::
  266. .. code-tab:: gdscript
  267. var my_basis = Basis.from_scale(Vector3(2, 4, 8))
  268. print(my_basis.x) # Prints (2.0, 0.0, 0.0)
  269. print(my_basis.y) # Prints (0.0, 4.0, 0.0)
  270. print(my_basis.z) # Prints (0.0, 0.0, 8.0)
  271. .. code-tab:: csharp
  272. var myBasis = Basis.FromScale(new Vector3(2.0f, 4.0f, 8.0f));
  273. GD.Print(myBasis.X); // Prints (2, 0, 0)
  274. GD.Print(myBasis.Y); // Prints (0, 4, 0)
  275. GD.Print(myBasis.Z); // Prints (0, 0, 8)
  276. \ **Note:** In linear algebra, the matrix of this basis is also known as a `diagonal matrix <https://en.wikipedia.org/wiki/Diagonal_matrix>`__.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_Basis_method_get_euler:
  280. .. rst-class:: classref-method
  281. :ref:`Vector3<class_Vector3>` **get_euler**\ (\ order\: :ref:`int<class_int>` = 2\ ) |const| :ref:`🔗<class_Basis_method_get_euler>`
  282. Returns this basis's rotation as a :ref:`Vector3<class_Vector3>` of `Euler angles <https://en.wikipedia.org/wiki/Euler_angles>`__, in radians. For the returned value:
  283. - The :ref:`Vector3.x<class_Vector3_property_x>` contains the angle around the :ref:`x<class_Basis_property_x>` axis (pitch);
  284. - The :ref:`Vector3.y<class_Vector3_property_y>` contains the angle around the :ref:`y<class_Basis_property_y>` axis (yaw);
  285. - The :ref:`Vector3.z<class_Vector3_property_z>` contains the angle around the :ref:`z<class_Basis_property_z>` axis (roll).
  286. The order of each consecutive rotation can be changed with ``order`` (see :ref:`EulerOrder<enum_@GlobalScope_EulerOrder>` constants). By default, the YXZ convention is used (:ref:`@GlobalScope.EULER_ORDER_YXZ<class_@GlobalScope_constant_EULER_ORDER_YXZ>`): Z (roll) is calculated first, then X (pitch), and lastly Y (yaw). When using the opposite method :ref:`from_euler()<class_Basis_method_from_euler>`, this order is reversed.
  287. \ **Note:** For this method to return correctly, the basis needs to be *orthonormal* (see :ref:`orthonormalized()<class_Basis_method_orthonormalized>`).
  288. \ **Note:** Euler angles are much more intuitive but are not suitable for 3D math. Because of this, consider using the :ref:`get_rotation_quaternion()<class_Basis_method_get_rotation_quaternion>` method instead, which returns a :ref:`Quaternion<class_Quaternion>`.
  289. \ **Note:** In the Inspector dock, a basis's rotation is often displayed in Euler angles (in degrees), as is the case with the :ref:`Node3D.rotation<class_Node3D_property_rotation>` property.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_Basis_method_get_rotation_quaternion:
  293. .. rst-class:: classref-method
  294. :ref:`Quaternion<class_Quaternion>` **get_rotation_quaternion**\ (\ ) |const| :ref:`🔗<class_Basis_method_get_rotation_quaternion>`
  295. Returns this basis's rotation as a :ref:`Quaternion<class_Quaternion>`.
  296. \ **Note:** Quaternions are much more suitable for 3D math but are less intuitive. For user interfaces, consider using the :ref:`get_euler()<class_Basis_method_get_euler>` method, which returns Euler angles.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_Basis_method_get_scale:
  300. .. rst-class:: classref-method
  301. :ref:`Vector3<class_Vector3>` **get_scale**\ (\ ) |const| :ref:`🔗<class_Basis_method_get_scale>`
  302. Returns the length of each axis of this basis, as a :ref:`Vector3<class_Vector3>`. If the basis is not sheared, this value is the scaling factor. It is not affected by rotation.
  303. .. tabs::
  304. .. code-tab:: gdscript
  305. var my_basis = Basis(
  306. Vector3(2, 0, 0),
  307. Vector3(0, 4, 0),
  308. Vector3(0, 0, 8)
  309. )
  310. # Rotating the Basis in any way preserves its scale.
  311. my_basis = my_basis.rotated(Vector3.UP, TAU / 2)
  312. my_basis = my_basis.rotated(Vector3.RIGHT, TAU / 4)
  313. print(my_basis.get_scale()) # Prints (2.0, 4.0, 8.0)
  314. .. code-tab:: csharp
  315. var myBasis = new Basis(
  316. Vector3(2.0f, 0.0f, 0.0f),
  317. Vector3(0.0f, 4.0f, 0.0f),
  318. Vector3(0.0f, 0.0f, 8.0f)
  319. );
  320. // Rotating the Basis in any way preserves its scale.
  321. myBasis = myBasis.Rotated(Vector3.Up, Mathf.Tau / 2.0f);
  322. myBasis = myBasis.Rotated(Vector3.Right, Mathf.Tau / 4.0f);
  323. GD.Print(myBasis.Scale); // Prints (2, 4, 8)
  324. \ **Note:** If the value returned by :ref:`determinant()<class_Basis_method_determinant>` is negative, the scale is also negative.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. _class_Basis_method_inverse:
  328. .. rst-class:: classref-method
  329. :ref:`Basis<class_Basis>` **inverse**\ (\ ) |const| :ref:`🔗<class_Basis_method_inverse>`
  330. Returns the `inverse of this basis's matrix <https://en.wikipedia.org/wiki/Invertible_matrix>`__.
  331. .. rst-class:: classref-item-separator
  332. ----
  333. .. _class_Basis_method_is_conformal:
  334. .. rst-class:: classref-method
  335. :ref:`bool<class_bool>` **is_conformal**\ (\ ) |const| :ref:`🔗<class_Basis_method_is_conformal>`
  336. Returns ``true`` if this basis is conformal. A conformal basis is both *orthogonal* (the axes are perpendicular to each other) and *uniform* (the axes share the same length). This method can be especially useful during physics calculations.
  337. .. rst-class:: classref-item-separator
  338. ----
  339. .. _class_Basis_method_is_equal_approx:
  340. .. rst-class:: classref-method
  341. :ref:`bool<class_bool>` **is_equal_approx**\ (\ b\: :ref:`Basis<class_Basis>`\ ) |const| :ref:`🔗<class_Basis_method_is_equal_approx>`
  342. Returns ``true`` if this basis and ``b`` are approximately equal, by calling :ref:`@GlobalScope.is_equal_approx()<class_@GlobalScope_method_is_equal_approx>` on all vector components.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_Basis_method_is_finite:
  346. .. rst-class:: classref-method
  347. :ref:`bool<class_bool>` **is_finite**\ (\ ) |const| :ref:`🔗<class_Basis_method_is_finite>`
  348. Returns ``true`` if this basis is finite, by calling :ref:`@GlobalScope.is_finite()<class_@GlobalScope_method_is_finite>` on all vector components.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_Basis_method_looking_at:
  352. .. rst-class:: classref-method
  353. :ref:`Basis<class_Basis>` **looking_at**\ (\ target\: :ref:`Vector3<class_Vector3>`, up\: :ref:`Vector3<class_Vector3>` = Vector3(0, 1, 0), use_model_front\: :ref:`bool<class_bool>` = false\ ) |static| :ref:`🔗<class_Basis_method_looking_at>`
  354. Creates a new **Basis** with a rotation such that the forward axis (-Z) points towards the ``target`` position.
  355. By default, the -Z axis (camera forward) is treated as forward (implies +X is right). If ``use_model_front`` is ``true``, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the ``target`` position.
  356. The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized()<class_Basis_method_orthonormalized>`).
  357. The ``target`` and the ``up`` cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and shouldn't be colinear to avoid unintended rotation around local Z axis.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_Basis_method_orthonormalized:
  361. .. rst-class:: classref-method
  362. :ref:`Basis<class_Basis>` **orthonormalized**\ (\ ) |const| :ref:`🔗<class_Basis_method_orthonormalized>`
  363. Returns the orthonormalized version of this basis. An orthonormal basis is both *orthogonal* (the axes are perpendicular to each other) and *normalized* (the axes have a length of ``1.0``), which also means it can only represent a rotation.
  364. It is often useful to call this method to avoid rounding errors on a rotating basis:
  365. .. tabs::
  366. .. code-tab:: gdscript
  367. # Rotate this Node3D every frame.
  368. func _process(delta):
  369. basis = basis.rotated(Vector3.UP, TAU * delta)
  370. basis = basis.rotated(Vector3.RIGHT, TAU * delta)
  371. basis = basis.orthonormalized()
  372. .. code-tab:: csharp
  373. // Rotate this Node3D every frame.
  374. public override void _Process(double delta)
  375. {
  376. Basis = Basis.Rotated(Vector3.Up, Mathf.Tau * (float)delta)
  377. .Rotated(Vector3.Right, Mathf.Tau * (float)delta)
  378. .Orthonormalized();
  379. }
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_Basis_method_rotated:
  383. .. rst-class:: classref-method
  384. :ref:`Basis<class_Basis>` **rotated**\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Basis_method_rotated>`
  385. Returns a copy of this basis rotated around the given ``axis`` by the given ``angle`` (in radians).
  386. The ``axis`` must be a normalized vector (see :ref:`Vector3.normalized()<class_Vector3_method_normalized>`). If ``angle`` is positive, the basis is rotated counter-clockwise around the axis.
  387. .. tabs::
  388. .. code-tab:: gdscript
  389. var my_basis = Basis.IDENTITY
  390. var angle = TAU / 2
  391. my_basis = my_basis.rotated(Vector3.UP, angle) # Rotate around the up axis (yaw).
  392. my_basis = my_basis.rotated(Vector3.RIGHT, angle) # Rotate around the right axis (pitch).
  393. my_basis = my_basis.rotated(Vector3.BACK, angle) # Rotate around the back axis (roll).
  394. .. code-tab:: csharp
  395. var myBasis = Basis.Identity;
  396. var angle = Mathf.Tau / 2.0f;
  397. myBasis = myBasis.Rotated(Vector3.Up, angle); // Rotate around the up axis (yaw).
  398. myBasis = myBasis.Rotated(Vector3.Right, angle); // Rotate around the right axis (pitch).
  399. myBasis = myBasis.Rotated(Vector3.Back, angle); // Rotate around the back axis (roll).
  400. .. rst-class:: classref-item-separator
  401. ----
  402. .. _class_Basis_method_scaled:
  403. .. rst-class:: classref-method
  404. :ref:`Basis<class_Basis>` **scaled**\ (\ scale\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Basis_method_scaled>`
  405. Returns this basis with each axis's components scaled by the given ``scale``'s components.
  406. The basis matrix's rows are multiplied by ``scale``'s components. This operation is a global scale (relative to the parent).
  407. .. tabs::
  408. .. code-tab:: gdscript
  409. var my_basis = Basis(
  410. Vector3(1, 1, 1),
  411. Vector3(2, 2, 2),
  412. Vector3(3, 3, 3)
  413. )
  414. my_basis = my_basis.scaled(Vector3(0, 2, -2))
  415. print(my_basis.x) # Prints (0.0, 2.0, -2.0)
  416. print(my_basis.y) # Prints (0.0, 4.0, -4.0)
  417. print(my_basis.z) # Prints (0.0, 6.0, -6.0)
  418. .. code-tab:: csharp
  419. var myBasis = new Basis(
  420. new Vector3(1.0f, 1.0f, 1.0f),
  421. new Vector3(2.0f, 2.0f, 2.0f),
  422. new Vector3(3.0f, 3.0f, 3.0f)
  423. );
  424. myBasis = myBasis.Scaled(new Vector3(0.0f, 2.0f, -2.0f));
  425. GD.Print(myBasis.X); // Prints (0, 2, -2)
  426. GD.Print(myBasis.Y); // Prints (0, 4, -4)
  427. GD.Print(myBasis.Z); // Prints (0, 6, -6)
  428. .. rst-class:: classref-item-separator
  429. ----
  430. .. _class_Basis_method_slerp:
  431. .. rst-class:: classref-method
  432. :ref:`Basis<class_Basis>` **slerp**\ (\ to\: :ref:`Basis<class_Basis>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Basis_method_slerp>`
  433. Performs a spherical-linear interpolation with the ``to`` basis, given a ``weight``. Both this basis and ``to`` should represent a rotation.
  434. \ **Example:** Smoothly rotate a :ref:`Node3D<class_Node3D>` to the target basis over time, with a :ref:`Tween<class_Tween>`:
  435. ::
  436. var start_basis = Basis.IDENTITY
  437. var target_basis = Basis.IDENTITY.rotated(Vector3.UP, TAU / 2)
  438. func _ready():
  439. create_tween().tween_method(interpolate, 0.0, 1.0, 5.0).set_trans(Tween.TRANS_EXPO)
  440. func interpolate(weight):
  441. basis = start_basis.slerp(target_basis, weight)
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_Basis_method_tdotx:
  445. .. rst-class:: classref-method
  446. :ref:`float<class_float>` **tdotx**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Basis_method_tdotx>`
  447. Returns the transposed dot product between ``with`` and the :ref:`x<class_Basis_property_x>` axis (see :ref:`transposed()<class_Basis_method_transposed>`).
  448. This is equivalent to ``basis.x.dot(vector)``.
  449. .. rst-class:: classref-item-separator
  450. ----
  451. .. _class_Basis_method_tdoty:
  452. .. rst-class:: classref-method
  453. :ref:`float<class_float>` **tdoty**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Basis_method_tdoty>`
  454. Returns the transposed dot product between ``with`` and the :ref:`y<class_Basis_property_y>` axis (see :ref:`transposed()<class_Basis_method_transposed>`).
  455. This is equivalent to ``basis.y.dot(vector)``.
  456. .. rst-class:: classref-item-separator
  457. ----
  458. .. _class_Basis_method_tdotz:
  459. .. rst-class:: classref-method
  460. :ref:`float<class_float>` **tdotz**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Basis_method_tdotz>`
  461. Returns the transposed dot product between ``with`` and the :ref:`z<class_Basis_property_z>` axis (see :ref:`transposed()<class_Basis_method_transposed>`).
  462. This is equivalent to ``basis.z.dot(vector)``.
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_Basis_method_transposed:
  466. .. rst-class:: classref-method
  467. :ref:`Basis<class_Basis>` **transposed**\ (\ ) |const| :ref:`🔗<class_Basis_method_transposed>`
  468. Returns the transposed version of this basis. This turns the basis matrix's columns into rows, and its rows into columns.
  469. .. tabs::
  470. .. code-tab:: gdscript
  471. var my_basis = Basis(
  472. Vector3(1, 2, 3),
  473. Vector3(4, 5, 6),
  474. Vector3(7, 8, 9)
  475. )
  476. my_basis = my_basis.transposed()
  477. print(my_basis.x) # Prints (1.0, 4.0, 7.0)
  478. print(my_basis.y) # Prints (2.0, 5.0, 8.0)
  479. print(my_basis.z) # Prints (3.0, 6.0, 9.0)
  480. .. code-tab:: csharp
  481. var myBasis = new Basis(
  482. new Vector3(1.0f, 2.0f, 3.0f),
  483. new Vector3(4.0f, 5.0f, 6.0f),
  484. new Vector3(7.0f, 8.0f, 9.0f)
  485. );
  486. myBasis = myBasis.Transposed();
  487. GD.Print(myBasis.X); // Prints (1, 4, 7)
  488. GD.Print(myBasis.Y); // Prints (2, 5, 8)
  489. GD.Print(myBasis.Z); // Prints (3, 6, 9)
  490. .. rst-class:: classref-section-separator
  491. ----
  492. .. rst-class:: classref-descriptions-group
  493. Operator Descriptions
  494. ---------------------
  495. .. _class_Basis_operator_neq_Basis:
  496. .. rst-class:: classref-operator
  497. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`Basis<class_Basis>`\ ) :ref:`🔗<class_Basis_operator_neq_Basis>`
  498. Returns ``true`` if the components of both **Basis** matrices are not equal.
  499. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx()<class_Basis_method_is_equal_approx>` instead, which is more reliable.
  500. .. rst-class:: classref-item-separator
  501. ----
  502. .. _class_Basis_operator_mul_Basis:
  503. .. rst-class:: classref-operator
  504. :ref:`Basis<class_Basis>` **operator ***\ (\ right\: :ref:`Basis<class_Basis>`\ ) :ref:`🔗<class_Basis_operator_mul_Basis>`
  505. Transforms (multiplies) the ``right`` basis by this basis.
  506. This is the operation performed between parent and child :ref:`Node3D<class_Node3D>`\ s.
  507. .. rst-class:: classref-item-separator
  508. ----
  509. .. _class_Basis_operator_mul_Vector3:
  510. .. rst-class:: classref-operator
  511. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`🔗<class_Basis_operator_mul_Vector3>`
  512. Transforms (multiplies) the ``right`` vector by this basis, returning a :ref:`Vector3<class_Vector3>`.
  513. .. tabs::
  514. .. code-tab:: gdscript
  515. # Basis that swaps the X/Z axes and doubles the scale.
  516. var my_basis = Basis(Vector3(0, 2, 0), Vector3(2, 0, 0), Vector3(0, 0, 2))
  517. print(my_basis * Vector3(1, 2, 3)) # Prints (4.0, 2.0, 6.0)
  518. .. code-tab:: csharp
  519. // Basis that swaps the X/Z axes and doubles the scale.
  520. var myBasis = new Basis(new Vector3(0, 2, 0), new Vector3(2, 0, 0), new Vector3(0, 0, 2));
  521. GD.Print(myBasis * new Vector3(1, 2, 3)); // Prints (4, 2, 6)
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_Basis_operator_mul_float:
  525. .. rst-class:: classref-operator
  526. :ref:`Basis<class_Basis>` **operator ***\ (\ right\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Basis_operator_mul_float>`
  527. Multiplies all components of the **Basis** by the given :ref:`float<class_float>`. This affects the basis's scale uniformly, resizing all 3 axes by the ``right`` value.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_Basis_operator_mul_int:
  531. .. rst-class:: classref-operator
  532. :ref:`Basis<class_Basis>` **operator ***\ (\ right\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Basis_operator_mul_int>`
  533. Multiplies all components of the **Basis** by the given :ref:`int<class_int>`. This affects the basis's scale uniformly, resizing all 3 axes by the ``right`` value.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Basis_operator_div_float:
  537. .. rst-class:: classref-operator
  538. :ref:`Basis<class_Basis>` **operator /**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Basis_operator_div_float>`
  539. Divides all components of the **Basis** by the given :ref:`float<class_float>`. This affects the basis's scale uniformly, resizing all 3 axes by the ``right`` value.
  540. .. rst-class:: classref-item-separator
  541. ----
  542. .. _class_Basis_operator_div_int:
  543. .. rst-class:: classref-operator
  544. :ref:`Basis<class_Basis>` **operator /**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Basis_operator_div_int>`
  545. Divides all components of the **Basis** by the given :ref:`int<class_int>`. This affects the basis's scale uniformly, resizing all 3 axes by the ``right`` value.
  546. .. rst-class:: classref-item-separator
  547. ----
  548. .. _class_Basis_operator_eq_Basis:
  549. .. rst-class:: classref-operator
  550. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`Basis<class_Basis>`\ ) :ref:`🔗<class_Basis_operator_eq_Basis>`
  551. Returns ``true`` if the components of both **Basis** matrices are exactly equal.
  552. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx()<class_Basis_method_is_equal_approx>` instead, which is more reliable.
  553. .. rst-class:: classref-item-separator
  554. ----
  555. .. _class_Basis_operator_idx_int:
  556. .. rst-class:: classref-operator
  557. :ref:`Vector3<class_Vector3>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Basis_operator_idx_int>`
  558. Accesses each axis (column) of this basis by their index. Index ``0`` is the same as :ref:`x<class_Basis_property_x>`, index ``1`` is the same as :ref:`y<class_Basis_property_y>`, and index ``2`` is the same as :ref:`z<class_Basis_property_z>`.
  559. \ **Note:** In C++, this operator accesses the rows of the basis matrix, *not* the columns. For the same behavior as scripting languages, use the ``set_column`` and ``get_column`` methods.
  560. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  561. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  562. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  563. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  564. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  565. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  566. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  567. .. |void| replace:: :abbr:`void (No return value.)`