Transform2D.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Transform2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. 2D transformation (2×3 matrix).
  5. </brief_description>
  6. <description>
  7. 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, or scaling. It consists of three [Vector2] values: [member x], [member y], and the [member origin].
  8. For more information, read the "Matrices and transforms" documentation article.
  9. </description>
  10. <tutorials>
  11. <link title="Math tutorial index">$DOCS_URL/tutorials/math/index.html</link>
  12. <link title="Matrices and transforms">$DOCS_URL/tutorials/math/matrices_and_transforms.html</link>
  13. <link title="Matrix Transform Demo">https://godotengine.org/asset-library/asset/584</link>
  14. <link title="2.5D Demo">https://godotengine.org/asset-library/asset/583</link>
  15. </tutorials>
  16. <methods>
  17. <method name="Transform2D">
  18. <return type="Transform2D" />
  19. <argument index="0" name="from" type="Transform" />
  20. <description>
  21. Constructs the transform from a 3D [Transform].
  22. </description>
  23. </method>
  24. <method name="Transform2D">
  25. <return type="Transform2D" />
  26. <argument index="0" name="x_axis" type="Vector2" />
  27. <argument index="1" name="y_axis" type="Vector2" />
  28. <argument index="2" name="origin" type="Vector2" />
  29. <description>
  30. Constructs the transform from 3 [Vector2] values representing [member x], [member y], and the [member origin] (the three column vectors).
  31. </description>
  32. </method>
  33. <method name="Transform2D">
  34. <return type="Transform2D" />
  35. <argument index="0" name="rotation" type="float" />
  36. <argument index="1" name="position" type="Vector2" />
  37. <description>
  38. Constructs the transform from a given angle (in radians) and position.
  39. </description>
  40. </method>
  41. <method name="affine_inverse">
  42. <return type="Transform2D" />
  43. <description>
  44. Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.
  45. </description>
  46. </method>
  47. <method name="basis_xform">
  48. <return type="Vector2" />
  49. <argument index="0" name="v" type="Vector2" />
  50. <description>
  51. Returns a vector transformed (multiplied) by the basis matrix.
  52. This method does not account for translation (the origin vector).
  53. </description>
  54. </method>
  55. <method name="basis_xform_inv">
  56. <return type="Vector2" />
  57. <argument index="0" name="v" type="Vector2" />
  58. <description>
  59. Returns a vector transformed (multiplied) by the inverse basis matrix.
  60. This method does not account for translation (the origin vector).
  61. </description>
  62. </method>
  63. <method name="determinant">
  64. <return type="float" />
  65. <description>
  66. Returns the determinant of the basis matrix. If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
  67. 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.
  68. </description>
  69. </method>
  70. <method name="get_origin">
  71. <return type="Vector2" />
  72. <description>
  73. Returns the transform's origin (translation).
  74. </description>
  75. </method>
  76. <method name="get_rotation">
  77. <return type="float" />
  78. <description>
  79. Returns the transform's rotation (in radians).
  80. </description>
  81. </method>
  82. <method name="get_scale">
  83. <return type="Vector2" />
  84. <description>
  85. Returns the scale.
  86. </description>
  87. </method>
  88. <method name="interpolate_with">
  89. <return type="Transform2D" />
  90. <argument index="0" name="transform" type="Transform2D" />
  91. <argument index="1" name="weight" type="float" />
  92. <description>
  93. Returns a transform interpolated between this transform and another by a given [code]weight[/code] (on the range of 0.0 to 1.0).
  94. </description>
  95. </method>
  96. <method name="inverse">
  97. <return type="Transform2D" />
  98. <description>
  99. Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use [method affine_inverse] for transforms with scaling).
  100. </description>
  101. </method>
  102. <method name="is_equal_approx">
  103. <return type="bool" />
  104. <argument index="0" name="transform" type="Transform2D" />
  105. <description>
  106. Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component.
  107. </description>
  108. </method>
  109. <method name="orthonormalized">
  110. <return type="Transform2D" />
  111. <description>
  112. Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
  113. </description>
  114. </method>
  115. <method name="rotated">
  116. <return type="Transform2D" />
  117. <argument index="0" name="angle" type="float" />
  118. <description>
  119. Returns a copy of the transform rotated by the given [code]angle[/code] (in radians), using matrix multiplication.
  120. </description>
  121. </method>
  122. <method name="scaled">
  123. <return type="Transform2D" />
  124. <argument index="0" name="scale" type="Vector2" />
  125. <description>
  126. Returns a copy of the transform scaled by the given [code]scale[/code] factor, using matrix multiplication.
  127. [b]Note:[/b] Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.
  128. </description>
  129. </method>
  130. <method name="translated">
  131. <return type="Transform2D" />
  132. <argument index="0" name="offset" type="Vector2" />
  133. <description>
  134. Returns a copy of the transform translated by the given [code]offset[/code], relative to the transform's basis vectors.
  135. Unlike [method rotated] and [method scaled], this does not use matrix multiplication.
  136. </description>
  137. </method>
  138. <method name="xform">
  139. <return type="Variant" />
  140. <argument index="0" name="v" type="Variant" />
  141. <description>
  142. Transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform.
  143. </description>
  144. </method>
  145. <method name="xform_inv">
  146. <return type="Variant" />
  147. <argument index="0" name="v" type="Variant" />
  148. <description>
  149. Inverse-transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform, under the assumption that the transformation is composed of rotation and translation (no scaling). Equivalent to calling [code]inverse().xform(v)[/code] on this transform. For affine transformations (e.g. with scaling) see [method affine_inverse] method.
  150. </description>
  151. </method>
  152. </methods>
  153. <members>
  154. <member name="origin" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
  155. The origin vector (column 2, the third column). Equivalent to array index [code]2[/code]. The origin vector represents translation.
  156. </member>
  157. <member name="x" type="Vector2" setter="" getter="" default="Vector2( 1, 0 )">
  158. The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code].
  159. </member>
  160. <member name="y" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )">
  161. The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code].
  162. </member>
  163. </members>
  164. <constants>
  165. <constant name="IDENTITY" value="Transform2D( 1, 0, 0, 1, 0, 0 )">
  166. The identity [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation.
  167. </constant>
  168. <constant name="FLIP_X" value="Transform2D( -1, 0, 0, 1, 0, 0 )">
  169. The [Transform2D] that will flip something along the X axis.
  170. </constant>
  171. <constant name="FLIP_Y" value="Transform2D( 1, 0, 0, -1, 0, 0 )">
  172. The [Transform2D] that will flip something along the Y axis.
  173. </constant>
  174. </constants>
  175. </class>