class_transform2d.rst 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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/Transform2D.xml.
  6. .. _class_Transform2D:
  7. Transform2D
  8. ===========
  9. A 2×3 matrix representing a 2D transformation.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. A 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, and scaling. It consists of three :ref:`Vector2<class_Vector2>` values: :ref:`x<class_Transform2D_property_x>`, :ref:`y<class_Transform2D_property_y>`, and the :ref:`origin<class_Transform2D_property_origin>`.
  14. For a general introduction, see the :doc:`Matrices and transforms <../tutorials/math/matrices_and_transforms>` tutorial.
  15. .. note::
  16. There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Math documentation index <../tutorials/math/index>`
  21. - :doc:`Matrices and transforms <../tutorials/math/matrices_and_transforms>`
  22. - `Matrix Transform Demo <https://godotengine.org/asset-library/asset/584>`__
  23. - `2.5D Demo <https://godotengine.org/asset-library/asset/583>`__
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +-------------------------------+--------------------------------------------------+-------------------+
  30. | :ref:`Vector2<class_Vector2>` | :ref:`origin<class_Transform2D_property_origin>` | ``Vector2(0, 0)`` |
  31. +-------------------------------+--------------------------------------------------+-------------------+
  32. | :ref:`Vector2<class_Vector2>` | :ref:`x<class_Transform2D_property_x>` | ``Vector2(1, 0)`` |
  33. +-------------------------------+--------------------------------------------------+-------------------+
  34. | :ref:`Vector2<class_Vector2>` | :ref:`y<class_Transform2D_property_y>` | ``Vector2(0, 1)`` |
  35. +-------------------------------+--------------------------------------------------+-------------------+
  36. .. rst-class:: classref-reftable-group
  37. Constructors
  38. ------------
  39. .. table::
  40. :widths: auto
  41. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Transform2D<class_Transform2D>` | :ref:`Transform2D<class_Transform2D_constructor_Transform2D>` **(** **)** |
  43. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Transform2D<class_Transform2D>` | :ref:`Transform2D<class_Transform2D_constructor_Transform2D>` **(** :ref:`Transform2D<class_Transform2D>` from **)** |
  45. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Transform2D<class_Transform2D>` | :ref:`Transform2D<class_Transform2D_constructor_Transform2D>` **(** :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` position **)** |
  47. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Transform2D<class_Transform2D>` | :ref:`Transform2D<class_Transform2D_constructor_Transform2D>` **(** :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` scale, :ref:`float<class_float>` skew, :ref:`Vector2<class_Vector2>` position **)** |
  49. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Transform2D<class_Transform2D>` | :ref:`Transform2D<class_Transform2D_constructor_Transform2D>` **(** :ref:`Vector2<class_Vector2>` x_axis, :ref:`Vector2<class_Vector2>` y_axis, :ref:`Vector2<class_Vector2>` origin **)** |
  51. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. .. rst-class:: classref-reftable-group
  53. Methods
  54. -------
  55. .. table::
  56. :widths: auto
  57. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Transform2D<class_Transform2D>` | :ref:`affine_inverse<class_Transform2D_method_affine_inverse>` **(** **)** |const| |
  59. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector2<class_Vector2>` | :ref:`basis_xform<class_Transform2D_method_basis_xform>` **(** :ref:`Vector2<class_Vector2>` v **)** |const| |
  61. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Vector2<class_Vector2>` | :ref:`basis_xform_inv<class_Transform2D_method_basis_xform_inv>` **(** :ref:`Vector2<class_Vector2>` v **)** |const| |
  63. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`float<class_float>` | :ref:`determinant<class_Transform2D_method_determinant>` **(** **)** |const| |
  65. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector2<class_Vector2>` | :ref:`get_origin<class_Transform2D_method_get_origin>` **(** **)** |const| |
  67. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`float<class_float>` | :ref:`get_rotation<class_Transform2D_method_get_rotation>` **(** **)** |const| |
  69. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Vector2<class_Vector2>` | :ref:`get_scale<class_Transform2D_method_get_scale>` **(** **)** |const| |
  71. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`float<class_float>` | :ref:`get_skew<class_Transform2D_method_get_skew>` **(** **)** |const| |
  73. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Transform2D<class_Transform2D>` | :ref:`interpolate_with<class_Transform2D_method_interpolate_with>` **(** :ref:`Transform2D<class_Transform2D>` xform, :ref:`float<class_float>` weight **)** |const| |
  75. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Transform2D<class_Transform2D>` | :ref:`inverse<class_Transform2D_method_inverse>` **(** **)** |const| |
  77. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`bool<class_bool>` | :ref:`is_conformal<class_Transform2D_method_is_conformal>` **(** **)** |const| |
  79. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Transform2D_method_is_equal_approx>` **(** :ref:`Transform2D<class_Transform2D>` xform **)** |const| |
  81. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Transform2D_method_is_finite>` **(** **)** |const| |
  83. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Transform2D<class_Transform2D>` | :ref:`looking_at<class_Transform2D_method_looking_at>` **(** :ref:`Vector2<class_Vector2>` target=Vector2(0, 0) **)** |const| |
  85. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`Transform2D<class_Transform2D>` | :ref:`orthonormalized<class_Transform2D_method_orthonormalized>` **(** **)** |const| |
  87. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Transform2D<class_Transform2D>` | :ref:`rotated<class_Transform2D_method_rotated>` **(** :ref:`float<class_float>` angle **)** |const| |
  89. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Transform2D<class_Transform2D>` | :ref:`rotated_local<class_Transform2D_method_rotated_local>` **(** :ref:`float<class_float>` angle **)** |const| |
  91. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Transform2D<class_Transform2D>` | :ref:`scaled<class_Transform2D_method_scaled>` **(** :ref:`Vector2<class_Vector2>` scale **)** |const| |
  93. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`Transform2D<class_Transform2D>` | :ref:`scaled_local<class_Transform2D_method_scaled_local>` **(** :ref:`Vector2<class_Vector2>` scale **)** |const| |
  95. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`Transform2D<class_Transform2D>` | :ref:`translated<class_Transform2D_method_translated>` **(** :ref:`Vector2<class_Vector2>` offset **)** |const| |
  97. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Transform2D<class_Transform2D>` | :ref:`translated_local<class_Transform2D_method_translated_local>` **(** :ref:`Vector2<class_Vector2>` offset **)** |const| |
  99. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. .. rst-class:: classref-reftable-group
  101. Operators
  102. ---------
  103. .. table::
  104. :widths: auto
  105. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Transform2D_operator_neq_Transform2D>` **(** :ref:`Transform2D<class_Transform2D>` right **)** |
  107. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`operator *<class_Transform2D_operator_mul_PackedVector2Array>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` right **)** |
  109. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`Rect2<class_Rect2>` | :ref:`operator *<class_Transform2D_operator_mul_Rect2>` **(** :ref:`Rect2<class_Rect2>` right **)** |
  111. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Transform2D<class_Transform2D>` | :ref:`operator *<class_Transform2D_operator_mul_Transform2D>` **(** :ref:`Transform2D<class_Transform2D>` right **)** |
  113. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_Transform2D_operator_mul_Vector2>` **(** :ref:`Vector2<class_Vector2>` right **)** |
  115. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`Transform2D<class_Transform2D>` | :ref:`operator *<class_Transform2D_operator_mul_float>` **(** :ref:`float<class_float>` right **)** |
  117. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`Transform2D<class_Transform2D>` | :ref:`operator *<class_Transform2D_operator_mul_int>` **(** :ref:`int<class_int>` right **)** |
  119. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`Transform2D<class_Transform2D>` | :ref:`operator /<class_Transform2D_operator_div_float>` **(** :ref:`float<class_float>` right **)** |
  121. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`Transform2D<class_Transform2D>` | :ref:`operator /<class_Transform2D_operator_div_int>` **(** :ref:`int<class_int>` right **)** |
  123. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Transform2D_operator_eq_Transform2D>` **(** :ref:`Transform2D<class_Transform2D>` right **)** |
  125. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`Vector2<class_Vector2>` | :ref:`operator []<class_Transform2D_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
  127. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  128. .. rst-class:: classref-section-separator
  129. ----
  130. .. rst-class:: classref-descriptions-group
  131. Constants
  132. ---------
  133. .. _class_Transform2D_constant_IDENTITY:
  134. .. rst-class:: classref-constant
  135. **IDENTITY** = ``Transform2D(1, 0, 0, 1, 0, 0)``
  136. The identity **Transform2D** with no translation, rotation or scaling applied. When applied to other data structures, :ref:`IDENTITY<class_Transform2D_constant_IDENTITY>` performs no transformation.
  137. .. _class_Transform2D_constant_FLIP_X:
  138. .. rst-class:: classref-constant
  139. **FLIP_X** = ``Transform2D(-1, 0, 0, 1, 0, 0)``
  140. The **Transform2D** that will flip something along the X axis.
  141. .. _class_Transform2D_constant_FLIP_Y:
  142. .. rst-class:: classref-constant
  143. **FLIP_Y** = ``Transform2D(1, 0, 0, -1, 0, 0)``
  144. The **Transform2D** that will flip something along the Y axis.
  145. .. rst-class:: classref-section-separator
  146. ----
  147. .. rst-class:: classref-descriptions-group
  148. Property Descriptions
  149. ---------------------
  150. .. _class_Transform2D_property_origin:
  151. .. rst-class:: classref-property
  152. :ref:`Vector2<class_Vector2>` **origin** = ``Vector2(0, 0)``
  153. The origin vector (column 2, the third column). Equivalent to array index ``2``. The origin vector represents translation.
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _class_Transform2D_property_x:
  157. .. rst-class:: classref-property
  158. :ref:`Vector2<class_Vector2>` **x** = ``Vector2(1, 0)``
  159. The basis matrix's X vector (column 0). Equivalent to array index ``0``.
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_Transform2D_property_y:
  163. .. rst-class:: classref-property
  164. :ref:`Vector2<class_Vector2>` **y** = ``Vector2(0, 1)``
  165. The basis matrix's Y vector (column 1). Equivalent to array index ``1``.
  166. .. rst-class:: classref-section-separator
  167. ----
  168. .. rst-class:: classref-descriptions-group
  169. Constructor Descriptions
  170. ------------------------
  171. .. _class_Transform2D_constructor_Transform2D:
  172. .. rst-class:: classref-constructor
  173. :ref:`Transform2D<class_Transform2D>` **Transform2D** **(** **)**
  174. Constructs a default-initialized **Transform2D** set to :ref:`IDENTITY<class_Transform2D_constant_IDENTITY>`.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. rst-class:: classref-constructor
  178. :ref:`Transform2D<class_Transform2D>` **Transform2D** **(** :ref:`Transform2D<class_Transform2D>` from **)**
  179. Constructs a **Transform2D** as a copy of the given **Transform2D**.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. rst-class:: classref-constructor
  183. :ref:`Transform2D<class_Transform2D>` **Transform2D** **(** :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` position **)**
  184. Constructs the transform from a given angle (in radians) and position.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. rst-class:: classref-constructor
  188. :ref:`Transform2D<class_Transform2D>` **Transform2D** **(** :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` scale, :ref:`float<class_float>` skew, :ref:`Vector2<class_Vector2>` position **)**
  189. Constructs the transform from a given angle (in radians), scale, skew (in radians) and position.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. rst-class:: classref-constructor
  193. :ref:`Transform2D<class_Transform2D>` **Transform2D** **(** :ref:`Vector2<class_Vector2>` x_axis, :ref:`Vector2<class_Vector2>` y_axis, :ref:`Vector2<class_Vector2>` origin **)**
  194. Constructs the transform from 3 :ref:`Vector2<class_Vector2>` values representing :ref:`x<class_Transform2D_property_x>`, :ref:`y<class_Transform2D_property_y>`, and the :ref:`origin<class_Transform2D_property_origin>` (the three column vectors).
  195. .. rst-class:: classref-section-separator
  196. ----
  197. .. rst-class:: classref-descriptions-group
  198. Method Descriptions
  199. -------------------
  200. .. _class_Transform2D_method_affine_inverse:
  201. .. rst-class:: classref-method
  202. :ref:`Transform2D<class_Transform2D>` **affine_inverse** **(** **)** |const|
  203. Returns the inverse of the transform, under the assumption that the basis is invertible (must have non-zero determinant).
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_Transform2D_method_basis_xform:
  207. .. rst-class:: classref-method
  208. :ref:`Vector2<class_Vector2>` **basis_xform** **(** :ref:`Vector2<class_Vector2>` v **)** |const|
  209. Returns a vector transformed (multiplied) by the basis matrix.
  210. This method does not account for translation (the :ref:`origin<class_Transform2D_property_origin>` vector).
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_Transform2D_method_basis_xform_inv:
  214. .. rst-class:: classref-method
  215. :ref:`Vector2<class_Vector2>` **basis_xform_inv** **(** :ref:`Vector2<class_Vector2>` v **)** |const|
  216. Returns a vector transformed (multiplied) by the inverse basis matrix, under the assumption that the basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
  217. This method does not account for translation (the :ref:`origin<class_Transform2D_property_origin>` vector).
  218. \ ``transform.basis_xform_inv(vector)`` is equivalent to ``transform.inverse().basis_xform(vector)``. See :ref:`inverse<class_Transform2D_method_inverse>`.
  219. For non-orthonormal transforms (e.g. with scaling) ``transform.affine_inverse().basis_xform(vector)`` can be used instead. See :ref:`affine_inverse<class_Transform2D_method_affine_inverse>`.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_Transform2D_method_determinant:
  223. .. rst-class:: classref-method
  224. :ref:`float<class_float>` **determinant** **(** **)** |const|
  225. Returns the determinant of the basis matrix. If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
  226. A negative determinant means the basis was flipped, so one part of the scale is negative. A zero determinant means the basis isn't invertible, and is usually considered invalid.
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_Transform2D_method_get_origin:
  230. .. rst-class:: classref-method
  231. :ref:`Vector2<class_Vector2>` **get_origin** **(** **)** |const|
  232. Returns the transform's origin (translation).
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_Transform2D_method_get_rotation:
  236. .. rst-class:: classref-method
  237. :ref:`float<class_float>` **get_rotation** **(** **)** |const|
  238. Returns the transform's rotation (in radians).
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_Transform2D_method_get_scale:
  242. .. rst-class:: classref-method
  243. :ref:`Vector2<class_Vector2>` **get_scale** **(** **)** |const|
  244. Returns the scale.
  245. .. rst-class:: classref-item-separator
  246. ----
  247. .. _class_Transform2D_method_get_skew:
  248. .. rst-class:: classref-method
  249. :ref:`float<class_float>` **get_skew** **(** **)** |const|
  250. Returns the transform's skew (in radians).
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_Transform2D_method_interpolate_with:
  254. .. rst-class:: classref-method
  255. :ref:`Transform2D<class_Transform2D>` **interpolate_with** **(** :ref:`Transform2D<class_Transform2D>` xform, :ref:`float<class_float>` weight **)** |const|
  256. Returns a transform interpolated between this transform and another by a given ``weight`` (on the range of 0.0 to 1.0).
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_Transform2D_method_inverse:
  260. .. rst-class:: classref-method
  261. :ref:`Transform2D<class_Transform2D>` **inverse** **(** **)** |const|
  262. Returns the inverse of the transform, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). Use :ref:`affine_inverse<class_Transform2D_method_affine_inverse>` for non-orthonormal transforms (e.g. with scaling).
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_Transform2D_method_is_conformal:
  266. .. rst-class:: classref-method
  267. :ref:`bool<class_bool>` **is_conformal** **(** **)** |const|
  268. Returns ``true`` if the transform's basis is conformal, meaning it preserves angles and distance ratios, and may only be composed of rotation and uniform scale. Returns ``false`` if the transform's basis has non-uniform scale or shear/skew. This can be used to validate if the transform is non-distorted, which is important for physics and other use cases.
  269. .. rst-class:: classref-item-separator
  270. ----
  271. .. _class_Transform2D_method_is_equal_approx:
  272. .. rst-class:: classref-method
  273. :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Transform2D<class_Transform2D>` xform **)** |const|
  274. Returns ``true`` if this transform and ``xform`` are approximately equal, by running :ref:`@GlobalScope.is_equal_approx<class_@GlobalScope_method_is_equal_approx>` on each component.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_Transform2D_method_is_finite:
  278. .. rst-class:: classref-method
  279. :ref:`bool<class_bool>` **is_finite** **(** **)** |const|
  280. Returns ``true`` if this transform is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
  281. .. rst-class:: classref-item-separator
  282. ----
  283. .. _class_Transform2D_method_looking_at:
  284. .. rst-class:: classref-method
  285. :ref:`Transform2D<class_Transform2D>` **looking_at** **(** :ref:`Vector2<class_Vector2>` target=Vector2(0, 0) **)** |const|
  286. Returns a copy of the transform rotated such that the rotated X-axis points towards the ``target`` position.
  287. Operations take place in global space.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_Transform2D_method_orthonormalized:
  291. .. rst-class:: classref-method
  292. :ref:`Transform2D<class_Transform2D>` **orthonormalized** **(** **)** |const|
  293. Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_Transform2D_method_rotated:
  297. .. rst-class:: classref-method
  298. :ref:`Transform2D<class_Transform2D>` **rotated** **(** :ref:`float<class_float>` angle **)** |const|
  299. Returns a copy of the transform rotated by the given ``angle`` (in radians).
  300. This method is an optimized version of multiplying the given transform ``X`` with a corresponding rotation transform ``R`` from the left, i.e., ``R * X``.
  301. This can be seen as transforming with respect to the global/parent frame.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_Transform2D_method_rotated_local:
  305. .. rst-class:: classref-method
  306. :ref:`Transform2D<class_Transform2D>` **rotated_local** **(** :ref:`float<class_float>` angle **)** |const|
  307. Returns a copy of the transform rotated by the given ``angle`` (in radians).
  308. This method is an optimized version of multiplying the given transform ``X`` with a corresponding rotation transform ``R`` from the right, i.e., ``X * R``.
  309. This can be seen as transforming with respect to the local frame.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_Transform2D_method_scaled:
  313. .. rst-class:: classref-method
  314. :ref:`Transform2D<class_Transform2D>` **scaled** **(** :ref:`Vector2<class_Vector2>` scale **)** |const|
  315. Returns a copy of the transform scaled by the given ``scale`` factor.
  316. This method is an optimized version of multiplying the given transform ``X`` with a corresponding scaling transform ``S`` from the left, i.e., ``S * X``.
  317. This can be seen as transforming with respect to the global/parent frame.
  318. .. rst-class:: classref-item-separator
  319. ----
  320. .. _class_Transform2D_method_scaled_local:
  321. .. rst-class:: classref-method
  322. :ref:`Transform2D<class_Transform2D>` **scaled_local** **(** :ref:`Vector2<class_Vector2>` scale **)** |const|
  323. Returns a copy of the transform scaled by the given ``scale`` factor.
  324. This method is an optimized version of multiplying the given transform ``X`` with a corresponding scaling transform ``S`` from the right, i.e., ``X * S``.
  325. This can be seen as transforming with respect to the local frame.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_Transform2D_method_translated:
  329. .. rst-class:: classref-method
  330. :ref:`Transform2D<class_Transform2D>` **translated** **(** :ref:`Vector2<class_Vector2>` offset **)** |const|
  331. Returns a copy of the transform translated by the given ``offset``.
  332. This method is an optimized version of multiplying the given transform ``X`` with a corresponding translation transform ``T`` from the left, i.e., ``T * X``.
  333. This can be seen as transforming with respect to the global/parent frame.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_Transform2D_method_translated_local:
  337. .. rst-class:: classref-method
  338. :ref:`Transform2D<class_Transform2D>` **translated_local** **(** :ref:`Vector2<class_Vector2>` offset **)** |const|
  339. Returns a copy of the transform translated by the given ``offset``.
  340. This method is an optimized version of multiplying the given transform ``X`` with a corresponding translation transform ``T`` from the right, i.e., ``X * T``.
  341. This can be seen as transforming with respect to the local frame.
  342. .. rst-class:: classref-section-separator
  343. ----
  344. .. rst-class:: classref-descriptions-group
  345. Operator Descriptions
  346. ---------------------
  347. .. _class_Transform2D_operator_neq_Transform2D:
  348. .. rst-class:: classref-operator
  349. :ref:`bool<class_bool>` **operator !=** **(** :ref:`Transform2D<class_Transform2D>` right **)**
  350. Returns ``true`` if the transforms are not equal.
  351. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Transform2D_method_is_equal_approx>` instead, which is more reliable.
  352. .. rst-class:: classref-item-separator
  353. ----
  354. .. _class_Transform2D_operator_mul_PackedVector2Array:
  355. .. rst-class:: classref-operator
  356. :ref:`PackedVector2Array<class_PackedVector2Array>` **operator *** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` right **)**
  357. Transforms (multiplies) each element of the :ref:`Vector2<class_Vector2>` array by the given **Transform2D** matrix.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_Transform2D_operator_mul_Rect2:
  361. .. rst-class:: classref-operator
  362. :ref:`Rect2<class_Rect2>` **operator *** **(** :ref:`Rect2<class_Rect2>` right **)**
  363. Transforms (multiplies) the :ref:`Rect2<class_Rect2>` by the given **Transform2D** matrix.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_Transform2D_operator_mul_Transform2D:
  367. .. rst-class:: classref-operator
  368. :ref:`Transform2D<class_Transform2D>` **operator *** **(** :ref:`Transform2D<class_Transform2D>` right **)**
  369. Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent).
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_Transform2D_operator_mul_Vector2:
  373. .. rst-class:: classref-operator
  374. :ref:`Vector2<class_Vector2>` **operator *** **(** :ref:`Vector2<class_Vector2>` right **)**
  375. Transforms (multiplies) the :ref:`Vector2<class_Vector2>` by the given **Transform2D** matrix.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_Transform2D_operator_mul_float:
  379. .. rst-class:: classref-operator
  380. :ref:`Transform2D<class_Transform2D>` **operator *** **(** :ref:`float<class_float>` right **)**
  381. This operator multiplies all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which scales it uniformly.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_Transform2D_operator_mul_int:
  385. .. rst-class:: classref-operator
  386. :ref:`Transform2D<class_Transform2D>` **operator *** **(** :ref:`int<class_int>` right **)**
  387. This operator multiplies all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which scales it uniformly.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_Transform2D_operator_div_float:
  391. .. rst-class:: classref-operator
  392. :ref:`Transform2D<class_Transform2D>` **operator /** **(** :ref:`float<class_float>` right **)**
  393. This operator divides all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which inversely scales it uniformly.
  394. .. rst-class:: classref-item-separator
  395. ----
  396. .. _class_Transform2D_operator_div_int:
  397. .. rst-class:: classref-operator
  398. :ref:`Transform2D<class_Transform2D>` **operator /** **(** :ref:`int<class_int>` right **)**
  399. This operator divides all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which inversely scales it uniformly.
  400. .. rst-class:: classref-item-separator
  401. ----
  402. .. _class_Transform2D_operator_eq_Transform2D:
  403. .. rst-class:: classref-operator
  404. :ref:`bool<class_bool>` **operator ==** **(** :ref:`Transform2D<class_Transform2D>` right **)**
  405. Returns ``true`` if the transforms are exactly equal.
  406. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Transform2D_method_is_equal_approx>` instead, which is more reliable.
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _class_Transform2D_operator_idx_int:
  410. .. rst-class:: classref-operator
  411. :ref:`Vector2<class_Vector2>` **operator []** **(** :ref:`int<class_int>` index **)**
  412. Access transform components using their index. ``t[0]`` is equivalent to ``t.x``, ``t[1]`` is equivalent to ``t.y``, and ``t[2]`` is equivalent to ``t.origin``.
  413. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  414. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  415. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  416. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  417. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  418. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  419. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`