Vector2.xml 8.6 KB

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