Transform2D.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Transform2D" version="3.3">
  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">https://docs.godotengine.org/en/3.3/tutorials/math/index.html</link>
  12. <link title="Matrices and transforms">https://docs.godotengine.org/en/3.3/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="get_origin">
  64. <return type="Vector2" />
  65. <description>
  66. Returns the transform's origin (translation).
  67. </description>
  68. </method>
  69. <method name="get_rotation">
  70. <return type="float" />
  71. <description>
  72. Returns the transform's rotation (in radians).
  73. </description>
  74. </method>
  75. <method name="get_scale">
  76. <return type="Vector2" />
  77. <description>
  78. Returns the scale.
  79. </description>
  80. </method>
  81. <method name="interpolate_with">
  82. <return type="Transform2D" />
  83. <argument index="0" name="transform" type="Transform2D" />
  84. <argument index="1" name="weight" type="float" />
  85. <description>
  86. Returns a transform interpolated between this transform and another by a given [code]weight[/code] (on the range of 0.0 to 1.0).
  87. </description>
  88. </method>
  89. <method name="inverse">
  90. <return type="Transform2D" />
  91. <description>
  92. 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).
  93. </description>
  94. </method>
  95. <method name="is_equal_approx">
  96. <return type="bool" />
  97. <argument index="0" name="transform" type="Transform2D" />
  98. <description>
  99. Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component.
  100. </description>
  101. </method>
  102. <method name="orthonormalized">
  103. <return type="Transform2D" />
  104. <description>
  105. Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
  106. </description>
  107. </method>
  108. <method name="rotated">
  109. <return type="Transform2D" />
  110. <argument index="0" name="phi" type="float" />
  111. <description>
  112. Rotates the transform by the given angle (in radians), using matrix multiplication.
  113. </description>
  114. </method>
  115. <method name="scaled">
  116. <return type="Transform2D" />
  117. <argument index="0" name="scale" type="Vector2" />
  118. <description>
  119. Scales the transform by the given scale factor, using matrix multiplication.
  120. </description>
  121. </method>
  122. <method name="translated">
  123. <return type="Transform2D" />
  124. <argument index="0" name="offset" type="Vector2" />
  125. <description>
  126. Translates the transform by the given offset, relative to the transform's basis vectors.
  127. Unlike [method rotated] and [method scaled], this does not use matrix multiplication.
  128. </description>
  129. </method>
  130. <method name="xform">
  131. <return type="Variant" />
  132. <argument index="0" name="v" type="Variant" />
  133. <description>
  134. Transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform.
  135. </description>
  136. </method>
  137. <method name="xform_inv">
  138. <return type="Variant" />
  139. <argument index="0" name="v" type="Variant" />
  140. <description>
  141. Inverse-transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform.
  142. </description>
  143. </method>
  144. </methods>
  145. <members>
  146. <member name="origin" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
  147. The origin vector (column 2, the third column). Equivalent to array index [code]2[/code]. The origin vector represents translation.
  148. </member>
  149. <member name="x" type="Vector2" setter="" getter="" default="Vector2( 1, 0 )">
  150. The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code].
  151. </member>
  152. <member name="y" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )">
  153. The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code].
  154. </member>
  155. </members>
  156. <constants>
  157. <constant name="IDENTITY" value="Transform2D( 1, 0, 0, 1, 0, 0 )">
  158. The identity [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation.
  159. </constant>
  160. <constant name="FLIP_X" value="Transform2D( -1, 0, 0, 1, 0, 0 )">
  161. The [Transform2D] that will flip something along the X axis.
  162. </constant>
  163. <constant name="FLIP_Y" value="Transform2D( 1, 0, 0, -1, 0, 0 )">
  164. The [Transform2D] that will flip something along the Y axis.
  165. </constant>
  166. </constants>
  167. </class>