Vector2.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Vector2" category="Built-In Types" version="3.1.2">
  3. <brief_description>
  4. Vector used for 2D math.
  5. </brief_description>
  6. <description>
  7. 2-element structure that can be used to represent positions in 2D space or any other pair of numeric values.
  8. </description>
  9. <tutorials>
  10. <link>https://docs.godotengine.org/en/3.1/tutorials/math/index.html</link>
  11. </tutorials>
  12. <methods>
  13. <method name="Vector2">
  14. <return type="Vector2">
  15. </return>
  16. <argument index="0" name="x" type="float">
  17. </argument>
  18. <argument index="1" name="y" type="float">
  19. </argument>
  20. <description>
  21. Constructs a new Vector2 from the given x and y.
  22. </description>
  23. </method>
  24. <method name="abs">
  25. <return type="Vector2">
  26. </return>
  27. <description>
  28. Returns a new vector with all components in absolute values (i.e. positive).
  29. </description>
  30. </method>
  31. <method name="angle">
  32. <return type="float">
  33. </return>
  34. <description>
  35. Returns the vector's angle in radians with respect to the x-axis, or [code](1, 0)[/code] vector.
  36. Equivalent to the result of atan2 when called with the vector's x and y as parameters: [code]atan2(x, y)[/code].
  37. </description>
  38. </method>
  39. <method name="angle_to">
  40. <return type="float">
  41. </return>
  42. <argument index="0" name="to" type="Vector2">
  43. </argument>
  44. <description>
  45. Returns the angle in radians between the two vectors.
  46. </description>
  47. </method>
  48. <method name="angle_to_point">
  49. <return type="float">
  50. </return>
  51. <argument index="0" name="to" type="Vector2">
  52. </argument>
  53. <description>
  54. Returns the angle in radians between the line connecting the two points and the x coordinate.
  55. </description>
  56. </method>
  57. <method name="aspect">
  58. <return type="float">
  59. </return>
  60. <description>
  61. Returns the ratio of x to y.
  62. </description>
  63. </method>
  64. <method name="bounce">
  65. <return type="Vector2">
  66. </return>
  67. <argument index="0" name="n" type="Vector2">
  68. </argument>
  69. <description>
  70. Returns the vector "bounced off" from a plane defined by the given normal.
  71. </description>
  72. </method>
  73. <method name="ceil">
  74. <return type="Vector2">
  75. </return>
  76. <description>
  77. Returns the vector with all components rounded up.
  78. </description>
  79. </method>
  80. <method name="clamped">
  81. <return type="Vector2">
  82. </return>
  83. <argument index="0" name="length" type="float">
  84. </argument>
  85. <description>
  86. Returns the vector with a maximum length.
  87. </description>
  88. </method>
  89. <method name="cross">
  90. <return type="float">
  91. </return>
  92. <argument index="0" name="with" type="Vector2">
  93. </argument>
  94. <description>
  95. Returns the 2 dimensional analog of the cross product with the given vector.
  96. </description>
  97. </method>
  98. <method name="cubic_interpolate">
  99. <return type="Vector2">
  100. </return>
  101. <argument index="0" name="b" type="Vector2">
  102. </argument>
  103. <argument index="1" name="pre_a" type="Vector2">
  104. </argument>
  105. <argument index="2" name="post_b" type="Vector2">
  106. </argument>
  107. <argument index="3" name="t" type="float">
  108. </argument>
  109. <description>
  110. Cubicly interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation.
  111. </description>
  112. </method>
  113. <method name="direction_to">
  114. <return type="Vector2">
  115. </return>
  116. <argument index="0" name="b" type="Vector2">
  117. </argument>
  118. <description>
  119. Returns the normalized vector pointing from this vector to [code]b[/code].
  120. </description>
  121. </method>
  122. <method name="distance_squared_to">
  123. <return type="float">
  124. </return>
  125. <argument index="0" name="to" type="Vector2">
  126. </argument>
  127. <description>
  128. Returns the squared distance to vector [code]b[/code]. Prefer this function over [method distance_to] if you need to sort vectors or need the squared distance for some formula.
  129. </description>
  130. </method>
  131. <method name="distance_to">
  132. <return type="float">
  133. </return>
  134. <argument index="0" name="to" type="Vector2">
  135. </argument>
  136. <description>
  137. Returns the distance to vector [code]b[/code].
  138. </description>
  139. </method>
  140. <method name="dot">
  141. <return type="float">
  142. </return>
  143. <argument index="0" name="with" type="Vector2">
  144. </argument>
  145. <description>
  146. Returns the dot product with vector [code]b[/code].
  147. </description>
  148. </method>
  149. <method name="floor">
  150. <return type="Vector2">
  151. </return>
  152. <description>
  153. Returns the vector with all components rounded down.
  154. </description>
  155. </method>
  156. <method name="is_normalized">
  157. <return type="bool">
  158. </return>
  159. <description>
  160. Returns [code]true[/code] if the vector is normalized.
  161. </description>
  162. </method>
  163. <method name="length">
  164. <return type="float">
  165. </return>
  166. <description>
  167. Returns the vector's length.
  168. </description>
  169. </method>
  170. <method name="length_squared">
  171. <return type="float">
  172. </return>
  173. <description>
  174. Returns the vector's length squared. Prefer this method over [method length] if you need to sort vectors or need the squared length for some formula.
  175. </description>
  176. </method>
  177. <method name="linear_interpolate">
  178. <return type="Vector2">
  179. </return>
  180. <argument index="0" name="b" type="Vector2">
  181. </argument>
  182. <argument index="1" name="t" type="float">
  183. </argument>
  184. <description>
  185. Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation.
  186. </description>
  187. </method>
  188. <method name="normalized">
  189. <return type="Vector2">
  190. </return>
  191. <description>
  192. Returns the vector scaled to unit length. Equivalent to [code]v / v.length()[/code].
  193. </description>
  194. </method>
  195. <method name="project">
  196. <return type="Vector2">
  197. </return>
  198. <argument index="0" name="b" type="Vector2">
  199. </argument>
  200. <description>
  201. Returns the vector projected onto the vector [code]b[/code].
  202. </description>
  203. </method>
  204. <method name="reflect">
  205. <return type="Vector2">
  206. </return>
  207. <argument index="0" name="n" type="Vector2">
  208. </argument>
  209. <description>
  210. Returns the vector reflected from a plane defined by the given normal.
  211. </description>
  212. </method>
  213. <method name="rotated">
  214. <return type="Vector2">
  215. </return>
  216. <argument index="0" name="phi" type="float">
  217. </argument>
  218. <description>
  219. Returns the vector rotated by [code]phi[/code] radians. See also [method @GDScript.deg2rad].
  220. </description>
  221. </method>
  222. <method name="round">
  223. <return type="Vector2">
  224. </return>
  225. <description>
  226. Returns the vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  227. </description>
  228. </method>
  229. <method name="slerp">
  230. <return type="Vector2">
  231. </return>
  232. <argument index="0" name="b" type="Vector2">
  233. </argument>
  234. <argument index="1" name="t" type="float">
  235. </argument>
  236. <description>
  237. Returns the result of SLERP between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation.
  238. Both vectors need to be normalized.
  239. </description>
  240. </method>
  241. <method name="slide">
  242. <return type="Vector2">
  243. </return>
  244. <argument index="0" name="n" type="Vector2">
  245. </argument>
  246. <description>
  247. Returns the component of the vector along a plane defined by the given normal.
  248. </description>
  249. </method>
  250. <method name="snapped">
  251. <return type="Vector2">
  252. </return>
  253. <argument index="0" name="by" type="Vector2">
  254. </argument>
  255. <description>
  256. Returns the vector snapped to a grid with the given size.
  257. </description>
  258. </method>
  259. <method name="tangent">
  260. <return type="Vector2">
  261. </return>
  262. <description>
  263. Returns a perpendicular vector.
  264. </description>
  265. </method>
  266. </methods>
  267. <members>
  268. <member name="x" type="float" setter="" getter="">
  269. The vector's x component. Also accessible by using the index position [code][0][/code].
  270. </member>
  271. <member name="y" type="float" setter="" getter="">
  272. The vector's y component. Also accessible by using the index position [code][1][/code].
  273. </member>
  274. </members>
  275. <constants>
  276. <constant name="ZERO" value="Vector2( 0, 0 )">
  277. Zero vector.
  278. </constant>
  279. <constant name="ONE" value="Vector2( 1, 1 )">
  280. One vector.
  281. </constant>
  282. <constant name="INF" value="Vector2( inf, inf )">
  283. Infinite vector.
  284. </constant>
  285. <constant name="LEFT" value="Vector2( -1, 0 )">
  286. Left unit vector.
  287. </constant>
  288. <constant name="RIGHT" value="Vector2( 1, 0 )">
  289. Right unit vector.
  290. </constant>
  291. <constant name="UP" value="Vector2( 0, -1 )">
  292. Up unit vector.
  293. </constant>
  294. <constant name="DOWN" value="Vector2( 0, 1 )">
  295. Down unit vector.
  296. </constant>
  297. </constants>
  298. </class>