class_vector2.rst 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  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/Vector2.xml.
  6. .. _class_Vector2:
  7. Vector2
  8. =======
  9. A 2D vector using floating-point coordinates.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. A 2-element structure that can be used to represent 2D coordinates or any other pair of numeric values.
  14. It uses floating-point coordinates. By default, these floating-point values use 32-bit precision, unlike :ref:`float<class_float>` which is always 64-bit. If double precision is needed, compile the engine with the option ``precision=double``.
  15. See :ref:`Vector2i<class_Vector2i>` for its integer counterpart.
  16. \ **Note:** In a boolean context, a Vector2 will evaluate to ``false`` if it's equal to ``Vector2(0, 0)``. Otherwise, a Vector2 will always evaluate to ``true``.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Math documentation index <../tutorials/math/index>`
  21. - :doc:`Vector math <../tutorials/math/vector_math>`
  22. - :doc:`Advanced vector math <../tutorials/math/vectors_advanced>`
  23. - `3Blue1Brown Essence of Linear Algebra <https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab>`__
  24. - `Matrix Transform Demo <https://godotengine.org/asset-library/asset/2787>`__
  25. - `All 2D Demos <https://github.com/godotengine/godot-demo-projects/tree/master/2d>`__
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +---------------------------+------------------------------------+---------+
  32. | :ref:`float<class_float>` | :ref:`x<class_Vector2_property_x>` | ``0.0`` |
  33. +---------------------------+------------------------------------+---------+
  34. | :ref:`float<class_float>` | :ref:`y<class_Vector2_property_y>` | ``0.0`` |
  35. +---------------------------+------------------------------------+---------+
  36. .. rst-class:: classref-reftable-group
  37. Constructors
  38. ------------
  39. .. table::
  40. :widths: auto
  41. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Vector2<class_Vector2>` | :ref:`Vector2<class_Vector2_constructor_Vector2>`\ (\ ) |
  43. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Vector2<class_Vector2>` | :ref:`Vector2<class_Vector2_constructor_Vector2>`\ (\ from\: :ref:`Vector2<class_Vector2>`\ ) |
  45. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector2<class_Vector2>` | :ref:`Vector2<class_Vector2_constructor_Vector2>`\ (\ from\: :ref:`Vector2i<class_Vector2i>`\ ) |
  47. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Vector2<class_Vector2>` | :ref:`Vector2<class_Vector2_constructor_Vector2>`\ (\ x\: :ref:`float<class_float>`, y\: :ref:`float<class_float>`\ ) |
  49. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  50. .. rst-class:: classref-reftable-group
  51. Methods
  52. -------
  53. .. table::
  54. :widths: auto
  55. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Vector2<class_Vector2>` | :ref:`abs<class_Vector2_method_abs>`\ (\ ) |const| |
  57. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`float<class_float>` | :ref:`angle<class_Vector2_method_angle>`\ (\ ) |const| |
  59. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector2_method_angle_to>`\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  61. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`float<class_float>` | :ref:`angle_to_point<class_Vector2_method_angle_to_point>`\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  63. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`float<class_float>` | :ref:`aspect<class_Vector2_method_aspect>`\ (\ ) |const| |
  65. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector2<class_Vector2>` | :ref:`bezier_derivative<class_Vector2_method_bezier_derivative>`\ (\ control_1\: :ref:`Vector2<class_Vector2>`, control_2\: :ref:`Vector2<class_Vector2>`, end\: :ref:`Vector2<class_Vector2>`, t\: :ref:`float<class_float>`\ ) |const| |
  67. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Vector2<class_Vector2>` | :ref:`bezier_interpolate<class_Vector2_method_bezier_interpolate>`\ (\ control_1\: :ref:`Vector2<class_Vector2>`, control_2\: :ref:`Vector2<class_Vector2>`, end\: :ref:`Vector2<class_Vector2>`, t\: :ref:`float<class_float>`\ ) |const| |
  69. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Vector2<class_Vector2>` | :ref:`bounce<class_Vector2_method_bounce>`\ (\ n\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  71. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Vector2<class_Vector2>` | :ref:`ceil<class_Vector2_method_ceil>`\ (\ ) |const| |
  73. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Vector2<class_Vector2>` | :ref:`clamp<class_Vector2_method_clamp>`\ (\ min\: :ref:`Vector2<class_Vector2>`, max\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  75. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector2<class_Vector2>` | :ref:`clampf<class_Vector2_method_clampf>`\ (\ min\: :ref:`float<class_float>`, max\: :ref:`float<class_float>`\ ) |const| |
  77. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`float<class_float>` | :ref:`cross<class_Vector2_method_cross>`\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  79. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector2<class_Vector2>` | :ref:`cubic_interpolate<class_Vector2_method_cubic_interpolate>`\ (\ b\: :ref:`Vector2<class_Vector2>`, pre_a\: :ref:`Vector2<class_Vector2>`, post_b\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`\ ) |const| |
  81. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`Vector2<class_Vector2>` | :ref:`cubic_interpolate_in_time<class_Vector2_method_cubic_interpolate_in_time>`\ (\ b\: :ref:`Vector2<class_Vector2>`, pre_a\: :ref:`Vector2<class_Vector2>`, post_b\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`, b_t\: :ref:`float<class_float>`, pre_a_t\: :ref:`float<class_float>`, post_b_t\: :ref:`float<class_float>`\ ) |const| |
  83. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Vector2<class_Vector2>` | :ref:`direction_to<class_Vector2_method_direction_to>`\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  85. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector2_method_distance_squared_to>`\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  87. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector2_method_distance_to>`\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  89. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`float<class_float>` | :ref:`dot<class_Vector2_method_dot>`\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  91. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Vector2<class_Vector2>` | :ref:`floor<class_Vector2_method_floor>`\ (\ ) |const| |
  93. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`Vector2<class_Vector2>` | :ref:`from_angle<class_Vector2_method_from_angle>`\ (\ angle\: :ref:`float<class_float>`\ ) |static| |
  95. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector2_method_is_equal_approx>`\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  97. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Vector2_method_is_finite>`\ (\ ) |const| |
  99. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector2_method_is_normalized>`\ (\ ) |const| |
  101. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`bool<class_bool>` | :ref:`is_zero_approx<class_Vector2_method_is_zero_approx>`\ (\ ) |const| |
  103. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`float<class_float>` | :ref:`length<class_Vector2_method_length>`\ (\ ) |const| |
  105. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector2_method_length_squared>`\ (\ ) |const| |
  107. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Vector2<class_Vector2>` | :ref:`lerp<class_Vector2_method_lerp>`\ (\ to\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`\ ) |const| |
  109. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`Vector2<class_Vector2>` | :ref:`limit_length<class_Vector2_method_limit_length>`\ (\ length\: :ref:`float<class_float>` = 1.0\ ) |const| |
  111. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Vector2<class_Vector2>` | :ref:`max<class_Vector2_method_max>`\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  113. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`int<class_int>` | :ref:`max_axis_index<class_Vector2_method_max_axis_index>`\ (\ ) |const| |
  115. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`Vector2<class_Vector2>` | :ref:`maxf<class_Vector2_method_maxf>`\ (\ with\: :ref:`float<class_float>`\ ) |const| |
  117. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`Vector2<class_Vector2>` | :ref:`min<class_Vector2_method_min>`\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  119. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`int<class_int>` | :ref:`min_axis_index<class_Vector2_method_min_axis_index>`\ (\ ) |const| |
  121. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`Vector2<class_Vector2>` | :ref:`minf<class_Vector2_method_minf>`\ (\ with\: :ref:`float<class_float>`\ ) |const| |
  123. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`Vector2<class_Vector2>` | :ref:`move_toward<class_Vector2_method_move_toward>`\ (\ to\: :ref:`Vector2<class_Vector2>`, delta\: :ref:`float<class_float>`\ ) |const| |
  125. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`Vector2<class_Vector2>` | :ref:`normalized<class_Vector2_method_normalized>`\ (\ ) |const| |
  127. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`Vector2<class_Vector2>` | :ref:`orthogonal<class_Vector2_method_orthogonal>`\ (\ ) |const| |
  129. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`Vector2<class_Vector2>` | :ref:`posmod<class_Vector2_method_posmod>`\ (\ mod\: :ref:`float<class_float>`\ ) |const| |
  131. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`Vector2<class_Vector2>` | :ref:`posmodv<class_Vector2_method_posmodv>`\ (\ modv\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  133. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`Vector2<class_Vector2>` | :ref:`project<class_Vector2_method_project>`\ (\ b\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  135. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`Vector2<class_Vector2>` | :ref:`reflect<class_Vector2_method_reflect>`\ (\ line\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  137. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`Vector2<class_Vector2>` | :ref:`rotated<class_Vector2_method_rotated>`\ (\ angle\: :ref:`float<class_float>`\ ) |const| |
  139. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`Vector2<class_Vector2>` | :ref:`round<class_Vector2_method_round>`\ (\ ) |const| |
  141. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`Vector2<class_Vector2>` | :ref:`sign<class_Vector2_method_sign>`\ (\ ) |const| |
  143. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`Vector2<class_Vector2>` | :ref:`slerp<class_Vector2_method_slerp>`\ (\ to\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`\ ) |const| |
  145. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`Vector2<class_Vector2>` | :ref:`slide<class_Vector2_method_slide>`\ (\ n\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  147. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`Vector2<class_Vector2>` | :ref:`snapped<class_Vector2_method_snapped>`\ (\ step\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  149. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | :ref:`Vector2<class_Vector2>` | :ref:`snappedf<class_Vector2_method_snappedf>`\ (\ step\: :ref:`float<class_float>`\ ) |const| |
  151. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. .. rst-class:: classref-reftable-group
  153. Operators
  154. ---------
  155. .. table::
  156. :widths: auto
  157. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  158. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector2_operator_neq_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  159. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  160. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_Vector2_operator_mul_Transform2D>`\ (\ right\: :ref:`Transform2D<class_Transform2D>`\ ) |
  161. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  162. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_Vector2_operator_mul_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  163. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  164. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_Vector2_operator_mul_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  165. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  166. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_Vector2_operator_mul_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  167. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  168. | :ref:`Vector2<class_Vector2>` | :ref:`operator +<class_Vector2_operator_sum_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  169. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  170. | :ref:`Vector2<class_Vector2>` | :ref:`operator -<class_Vector2_operator_dif_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  171. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  172. | :ref:`Vector2<class_Vector2>` | :ref:`operator /<class_Vector2_operator_div_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  173. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  174. | :ref:`Vector2<class_Vector2>` | :ref:`operator /<class_Vector2_operator_div_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  175. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  176. | :ref:`Vector2<class_Vector2>` | :ref:`operator /<class_Vector2_operator_div_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  177. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  178. | :ref:`bool<class_bool>` | :ref:`operator \<<class_Vector2_operator_lt_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  179. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  180. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_Vector2_operator_lte_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  181. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  182. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector2_operator_eq_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  183. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  184. | :ref:`bool<class_bool>` | :ref:`operator ><class_Vector2_operator_gt_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  185. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  186. | :ref:`bool<class_bool>` | :ref:`operator >=<class_Vector2_operator_gte_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  187. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  188. | :ref:`float<class_float>` | :ref:`operator []<class_Vector2_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
  189. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  190. | :ref:`Vector2<class_Vector2>` | :ref:`operator unary+<class_Vector2_operator_unplus>`\ (\ ) |
  191. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  192. | :ref:`Vector2<class_Vector2>` | :ref:`operator unary-<class_Vector2_operator_unminus>`\ (\ ) |
  193. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  194. .. rst-class:: classref-section-separator
  195. ----
  196. .. rst-class:: classref-descriptions-group
  197. Enumerations
  198. ------------
  199. .. _enum_Vector2_Axis:
  200. .. rst-class:: classref-enumeration
  201. enum **Axis**: :ref:`🔗<enum_Vector2_Axis>`
  202. .. _class_Vector2_constant_AXIS_X:
  203. .. rst-class:: classref-enumeration-constant
  204. :ref:`Axis<enum_Vector2_Axis>` **AXIS_X** = ``0``
  205. Enumerated value for the X axis. Returned by :ref:`max_axis_index()<class_Vector2_method_max_axis_index>` and :ref:`min_axis_index()<class_Vector2_method_min_axis_index>`.
  206. .. _class_Vector2_constant_AXIS_Y:
  207. .. rst-class:: classref-enumeration-constant
  208. :ref:`Axis<enum_Vector2_Axis>` **AXIS_Y** = ``1``
  209. Enumerated value for the Y axis. Returned by :ref:`max_axis_index()<class_Vector2_method_max_axis_index>` and :ref:`min_axis_index()<class_Vector2_method_min_axis_index>`.
  210. .. rst-class:: classref-section-separator
  211. ----
  212. .. rst-class:: classref-descriptions-group
  213. Constants
  214. ---------
  215. .. _class_Vector2_constant_ZERO:
  216. .. rst-class:: classref-constant
  217. **ZERO** = ``Vector2(0, 0)`` :ref:`🔗<class_Vector2_constant_ZERO>`
  218. Zero vector, a vector with all components set to ``0``.
  219. .. _class_Vector2_constant_ONE:
  220. .. rst-class:: classref-constant
  221. **ONE** = ``Vector2(1, 1)`` :ref:`🔗<class_Vector2_constant_ONE>`
  222. One vector, a vector with all components set to ``1``.
  223. .. _class_Vector2_constant_INF:
  224. .. rst-class:: classref-constant
  225. **INF** = ``Vector2(inf, inf)`` :ref:`🔗<class_Vector2_constant_INF>`
  226. Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
  227. .. _class_Vector2_constant_LEFT:
  228. .. rst-class:: classref-constant
  229. **LEFT** = ``Vector2(-1, 0)`` :ref:`🔗<class_Vector2_constant_LEFT>`
  230. Left unit vector. Represents the direction of left.
  231. .. _class_Vector2_constant_RIGHT:
  232. .. rst-class:: classref-constant
  233. **RIGHT** = ``Vector2(1, 0)`` :ref:`🔗<class_Vector2_constant_RIGHT>`
  234. Right unit vector. Represents the direction of right.
  235. .. _class_Vector2_constant_UP:
  236. .. rst-class:: classref-constant
  237. **UP** = ``Vector2(0, -1)`` :ref:`🔗<class_Vector2_constant_UP>`
  238. Up unit vector. Y is down in 2D, so this vector points -Y.
  239. .. _class_Vector2_constant_DOWN:
  240. .. rst-class:: classref-constant
  241. **DOWN** = ``Vector2(0, 1)`` :ref:`🔗<class_Vector2_constant_DOWN>`
  242. Down unit vector. Y is down in 2D, so this vector points +Y.
  243. .. rst-class:: classref-section-separator
  244. ----
  245. .. rst-class:: classref-descriptions-group
  246. Property Descriptions
  247. ---------------------
  248. .. _class_Vector2_property_x:
  249. .. rst-class:: classref-property
  250. :ref:`float<class_float>` **x** = ``0.0`` :ref:`🔗<class_Vector2_property_x>`
  251. The vector's X component. Also accessible by using the index position ``[0]``.
  252. .. rst-class:: classref-item-separator
  253. ----
  254. .. _class_Vector2_property_y:
  255. .. rst-class:: classref-property
  256. :ref:`float<class_float>` **y** = ``0.0`` :ref:`🔗<class_Vector2_property_y>`
  257. The vector's Y component. Also accessible by using the index position ``[1]``.
  258. .. rst-class:: classref-section-separator
  259. ----
  260. .. rst-class:: classref-descriptions-group
  261. Constructor Descriptions
  262. ------------------------
  263. .. _class_Vector2_constructor_Vector2:
  264. .. rst-class:: classref-constructor
  265. :ref:`Vector2<class_Vector2>` **Vector2**\ (\ ) :ref:`🔗<class_Vector2_constructor_Vector2>`
  266. Constructs a default-initialized **Vector2** with all components set to ``0``.
  267. .. rst-class:: classref-item-separator
  268. ----
  269. .. rst-class:: classref-constructor
  270. :ref:`Vector2<class_Vector2>` **Vector2**\ (\ from\: :ref:`Vector2<class_Vector2>`\ )
  271. Constructs a **Vector2** as a copy of the given **Vector2**.
  272. .. rst-class:: classref-item-separator
  273. ----
  274. .. rst-class:: classref-constructor
  275. :ref:`Vector2<class_Vector2>` **Vector2**\ (\ from\: :ref:`Vector2i<class_Vector2i>`\ )
  276. Constructs a new **Vector2** from :ref:`Vector2i<class_Vector2i>`.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. rst-class:: classref-constructor
  280. :ref:`Vector2<class_Vector2>` **Vector2**\ (\ x\: :ref:`float<class_float>`, y\: :ref:`float<class_float>`\ )
  281. Constructs a new **Vector2** from the given ``x`` and ``y``.
  282. .. rst-class:: classref-section-separator
  283. ----
  284. .. rst-class:: classref-descriptions-group
  285. Method Descriptions
  286. -------------------
  287. .. _class_Vector2_method_abs:
  288. .. rst-class:: classref-method
  289. :ref:`Vector2<class_Vector2>` **abs**\ (\ ) |const| :ref:`🔗<class_Vector2_method_abs>`
  290. Returns a new vector with all components in absolute values (i.e. positive).
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_Vector2_method_angle:
  294. .. rst-class:: classref-method
  295. :ref:`float<class_float>` **angle**\ (\ ) |const| :ref:`🔗<class_Vector2_method_angle>`
  296. Returns this vector's angle with respect to the positive X axis, or ``(1, 0)`` vector, in radians.
  297. For example, ``Vector2.RIGHT.angle()`` will return zero, ``Vector2.DOWN.angle()`` will return ``PI / 2`` (a quarter turn, or 90 degrees), and ``Vector2(1, -1).angle()`` will return ``-PI / 4`` (a negative eighth turn, or -45 degrees).
  298. This is equivalent to calling :ref:`@GlobalScope.atan2()<class_@GlobalScope_method_atan2>` with :ref:`y<class_Vector2_property_y>` and :ref:`x<class_Vector2_property_x>`.
  299. \ `Illustration of the returned angle. <https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle.png>`__
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_Vector2_method_angle_to:
  303. .. rst-class:: classref-method
  304. :ref:`float<class_float>` **angle_to**\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_angle_to>`
  305. Returns the signed angle to the given vector, in radians. The result ranges from ``-PI`` to ``PI`` (inclusive).
  306. \ `Illustration of the returned angle. <https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to.png>`__
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_Vector2_method_angle_to_point:
  310. .. rst-class:: classref-method
  311. :ref:`float<class_float>` **angle_to_point**\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_angle_to_point>`
  312. Returns the signed angle between the X axis and the line from this vector to point ``to``, in radians. The result ranges from ``-PI`` to ``PI`` (inclusive).
  313. \ ``a.angle_to_point(b)`` is equivalent to ``(b - a).angle()``. See also :ref:`angle()<class_Vector2_method_angle>`.
  314. \ `Illustration of the returned angle. <https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to_point.png>`__
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_Vector2_method_aspect:
  318. .. rst-class:: classref-method
  319. :ref:`float<class_float>` **aspect**\ (\ ) |const| :ref:`🔗<class_Vector2_method_aspect>`
  320. Returns this vector's aspect ratio, which is :ref:`x<class_Vector2_property_x>` divided by :ref:`y<class_Vector2_property_y>`.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_Vector2_method_bezier_derivative:
  324. .. rst-class:: classref-method
  325. :ref:`Vector2<class_Vector2>` **bezier_derivative**\ (\ control_1\: :ref:`Vector2<class_Vector2>`, control_2\: :ref:`Vector2<class_Vector2>`, end\: :ref:`Vector2<class_Vector2>`, t\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_bezier_derivative>`
  326. Returns the derivative at the given ``t`` on the `Bézier curve <https://en.wikipedia.org/wiki/B%C3%A9zier_curve>`__ defined by this vector and the given ``control_1``, ``control_2``, and ``end`` points.
  327. .. rst-class:: classref-item-separator
  328. ----
  329. .. _class_Vector2_method_bezier_interpolate:
  330. .. rst-class:: classref-method
  331. :ref:`Vector2<class_Vector2>` **bezier_interpolate**\ (\ control_1\: :ref:`Vector2<class_Vector2>`, control_2\: :ref:`Vector2<class_Vector2>`, end\: :ref:`Vector2<class_Vector2>`, t\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_bezier_interpolate>`
  332. Returns the point at the given ``t`` on the `Bézier curve <https://en.wikipedia.org/wiki/B%C3%A9zier_curve>`__ defined by this vector and the given ``control_1``, ``control_2``, and ``end`` points.
  333. .. rst-class:: classref-item-separator
  334. ----
  335. .. _class_Vector2_method_bounce:
  336. .. rst-class:: classref-method
  337. :ref:`Vector2<class_Vector2>` **bounce**\ (\ n\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_bounce>`
  338. Returns the vector "bounced off" from a line defined by the given normal ``n`` perpendicular to the line.
  339. \ **Note:** :ref:`bounce()<class_Vector2_method_bounce>` performs the operation that most engines and frameworks call ``reflect()``.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_Vector2_method_ceil:
  343. .. rst-class:: classref-method
  344. :ref:`Vector2<class_Vector2>` **ceil**\ (\ ) |const| :ref:`🔗<class_Vector2_method_ceil>`
  345. Returns a new vector with all components rounded up (towards positive infinity).
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_Vector2_method_clamp:
  349. .. rst-class:: classref-method
  350. :ref:`Vector2<class_Vector2>` **clamp**\ (\ min\: :ref:`Vector2<class_Vector2>`, max\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_clamp>`
  351. Returns a new vector with all components clamped between the components of ``min`` and ``max``, by running :ref:`@GlobalScope.clamp()<class_@GlobalScope_method_clamp>` on each component.
  352. .. rst-class:: classref-item-separator
  353. ----
  354. .. _class_Vector2_method_clampf:
  355. .. rst-class:: classref-method
  356. :ref:`Vector2<class_Vector2>` **clampf**\ (\ min\: :ref:`float<class_float>`, max\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_clampf>`
  357. Returns a new vector with all components clamped between ``min`` and ``max``, by running :ref:`@GlobalScope.clamp()<class_@GlobalScope_method_clamp>` on each component.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_Vector2_method_cross:
  361. .. rst-class:: classref-method
  362. :ref:`float<class_float>` **cross**\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_cross>`
  363. Returns the 2D analog of the cross product for this vector and ``with``.
  364. This is the signed area of the parallelogram formed by the two vectors. If the second vector is clockwise from the first vector, then the cross product is the positive area. If counter-clockwise, the cross product is the negative area. If the two vectors are parallel this returns zero, making it useful for testing if two vectors are parallel.
  365. \ **Note:** Cross product is not defined in 2D mathematically. This method embeds the 2D vectors in the XY plane of 3D space and uses their cross product's Z component as the analog.
  366. .. rst-class:: classref-item-separator
  367. ----
  368. .. _class_Vector2_method_cubic_interpolate:
  369. .. rst-class:: classref-method
  370. :ref:`Vector2<class_Vector2>` **cubic_interpolate**\ (\ b\: :ref:`Vector2<class_Vector2>`, pre_a\: :ref:`Vector2<class_Vector2>`, post_b\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_cubic_interpolate>`
  371. Performs a cubic interpolation between this vector and ``b`` using ``pre_a`` and ``post_b`` as handles, and returns the result at position ``weight``. ``weight`` is on the range of 0.0 to 1.0, representing the amount of interpolation.
  372. .. rst-class:: classref-item-separator
  373. ----
  374. .. _class_Vector2_method_cubic_interpolate_in_time:
  375. .. rst-class:: classref-method
  376. :ref:`Vector2<class_Vector2>` **cubic_interpolate_in_time**\ (\ b\: :ref:`Vector2<class_Vector2>`, pre_a\: :ref:`Vector2<class_Vector2>`, post_b\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`, b_t\: :ref:`float<class_float>`, pre_a_t\: :ref:`float<class_float>`, post_b_t\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_cubic_interpolate_in_time>`
  377. Performs a cubic interpolation between this vector and ``b`` using ``pre_a`` and ``post_b`` as handles, and returns the result at position ``weight``. ``weight`` is on the range of 0.0 to 1.0, representing the amount of interpolation.
  378. It can perform smoother interpolation than :ref:`cubic_interpolate()<class_Vector2_method_cubic_interpolate>` by the time values.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_Vector2_method_direction_to:
  382. .. rst-class:: classref-method
  383. :ref:`Vector2<class_Vector2>` **direction_to**\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_direction_to>`
  384. Returns the normalized vector pointing from this vector to ``to``.
  385. \ ``a.direction_to(b)`` is equivalent to ``(b - a).normalized()``. See also :ref:`normalized()<class_Vector2_method_normalized>`.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_Vector2_method_distance_squared_to:
  389. .. rst-class:: classref-method
  390. :ref:`float<class_float>` **distance_squared_to**\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_distance_squared_to>`
  391. Returns the squared distance between this vector and ``to``.
  392. This method runs faster than :ref:`distance_to()<class_Vector2_method_distance_to>`, so prefer it if you need to compare vectors or need the squared distance for some formula.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_Vector2_method_distance_to:
  396. .. rst-class:: classref-method
  397. :ref:`float<class_float>` **distance_to**\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_distance_to>`
  398. Returns the distance between this vector and ``to``.
  399. .. rst-class:: classref-item-separator
  400. ----
  401. .. _class_Vector2_method_dot:
  402. .. rst-class:: classref-method
  403. :ref:`float<class_float>` **dot**\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_dot>`
  404. Returns the dot product of this vector and ``with``. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
  405. The dot product will be ``0`` for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
  406. When using unit (normalized) vectors, the result will always be between ``-1.0`` (180 degree angle) when the vectors are facing opposite directions, and ``1.0`` (0 degree angle) when the vectors are aligned.
  407. \ **Note:** ``a.dot(b)`` is equivalent to ``b.dot(a)``.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_Vector2_method_floor:
  411. .. rst-class:: classref-method
  412. :ref:`Vector2<class_Vector2>` **floor**\ (\ ) |const| :ref:`🔗<class_Vector2_method_floor>`
  413. Returns a new vector with all components rounded down (towards negative infinity).
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_Vector2_method_from_angle:
  417. .. rst-class:: classref-method
  418. :ref:`Vector2<class_Vector2>` **from_angle**\ (\ angle\: :ref:`float<class_float>`\ ) |static| :ref:`🔗<class_Vector2_method_from_angle>`
  419. Creates a **Vector2** rotated to the given ``angle`` in radians. This is equivalent to doing ``Vector2(cos(angle), sin(angle))`` or ``Vector2.RIGHT.rotated(angle)``.
  420. ::
  421. print(Vector2.from_angle(0)) # Prints (1.0, 0.0)
  422. print(Vector2(1, 0).angle()) # Prints 0.0, which is the angle used above.
  423. print(Vector2.from_angle(PI / 2)) # Prints (0.0, 1.0)
  424. \ **Note:** The length of the returned **Vector2** is *approximately* ``1.0``, but is is not guaranteed to be exactly ``1.0`` due to floating-point precision issues. Call :ref:`normalized()<class_Vector2_method_normalized>` on the returned **Vector2** if you require a unit vector.
  425. .. rst-class:: classref-item-separator
  426. ----
  427. .. _class_Vector2_method_is_equal_approx:
  428. .. rst-class:: classref-method
  429. :ref:`bool<class_bool>` **is_equal_approx**\ (\ to\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_is_equal_approx>`
  430. Returns ``true`` if this vector and ``to`` are approximately equal, by running :ref:`@GlobalScope.is_equal_approx()<class_@GlobalScope_method_is_equal_approx>` on each component.
  431. .. rst-class:: classref-item-separator
  432. ----
  433. .. _class_Vector2_method_is_finite:
  434. .. rst-class:: classref-method
  435. :ref:`bool<class_bool>` **is_finite**\ (\ ) |const| :ref:`🔗<class_Vector2_method_is_finite>`
  436. Returns ``true`` if this vector is finite, by calling :ref:`@GlobalScope.is_finite()<class_@GlobalScope_method_is_finite>` on each component.
  437. .. rst-class:: classref-item-separator
  438. ----
  439. .. _class_Vector2_method_is_normalized:
  440. .. rst-class:: classref-method
  441. :ref:`bool<class_bool>` **is_normalized**\ (\ ) |const| :ref:`🔗<class_Vector2_method_is_normalized>`
  442. Returns ``true`` if the vector is normalized, i.e. its length is approximately equal to 1.
  443. .. rst-class:: classref-item-separator
  444. ----
  445. .. _class_Vector2_method_is_zero_approx:
  446. .. rst-class:: classref-method
  447. :ref:`bool<class_bool>` **is_zero_approx**\ (\ ) |const| :ref:`🔗<class_Vector2_method_is_zero_approx>`
  448. Returns ``true`` if this vector's values are approximately zero, by running :ref:`@GlobalScope.is_zero_approx()<class_@GlobalScope_method_is_zero_approx>` on each component.
  449. This method is faster than using :ref:`is_equal_approx()<class_Vector2_method_is_equal_approx>` with one value as a zero vector.
  450. .. rst-class:: classref-item-separator
  451. ----
  452. .. _class_Vector2_method_length:
  453. .. rst-class:: classref-method
  454. :ref:`float<class_float>` **length**\ (\ ) |const| :ref:`🔗<class_Vector2_method_length>`
  455. Returns the length (magnitude) of this vector.
  456. .. rst-class:: classref-item-separator
  457. ----
  458. .. _class_Vector2_method_length_squared:
  459. .. rst-class:: classref-method
  460. :ref:`float<class_float>` **length_squared**\ (\ ) |const| :ref:`🔗<class_Vector2_method_length_squared>`
  461. Returns the squared length (squared magnitude) of this vector.
  462. This method runs faster than :ref:`length()<class_Vector2_method_length>`, so prefer it if you need to compare vectors or need the squared distance for some formula.
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_Vector2_method_lerp:
  466. .. rst-class:: classref-method
  467. :ref:`Vector2<class_Vector2>` **lerp**\ (\ to\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_lerp>`
  468. Returns the result of the linear interpolation between this vector and ``to`` by amount ``weight``. ``weight`` is on the range of ``0.0`` to ``1.0``, representing the amount of interpolation.
  469. .. rst-class:: classref-item-separator
  470. ----
  471. .. _class_Vector2_method_limit_length:
  472. .. rst-class:: classref-method
  473. :ref:`Vector2<class_Vector2>` **limit_length**\ (\ length\: :ref:`float<class_float>` = 1.0\ ) |const| :ref:`🔗<class_Vector2_method_limit_length>`
  474. Returns the vector with a maximum length by limiting its length to ``length``. If the vector is non-finite, the result is undefined.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_Vector2_method_max:
  478. .. rst-class:: classref-method
  479. :ref:`Vector2<class_Vector2>` **max**\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_max>`
  480. Returns the component-wise maximum of this and ``with``, equivalent to ``Vector2(maxf(x, with.x), maxf(y, with.y))``.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_Vector2_method_max_axis_index:
  484. .. rst-class:: classref-method
  485. :ref:`int<class_int>` **max_axis_index**\ (\ ) |const| :ref:`🔗<class_Vector2_method_max_axis_index>`
  486. Returns the axis of the vector's highest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_X<class_Vector2_constant_AXIS_X>`.
  487. .. rst-class:: classref-item-separator
  488. ----
  489. .. _class_Vector2_method_maxf:
  490. .. rst-class:: classref-method
  491. :ref:`Vector2<class_Vector2>` **maxf**\ (\ with\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_maxf>`
  492. Returns the component-wise maximum of this and ``with``, equivalent to ``Vector2(maxf(x, with), maxf(y, with))``.
  493. .. rst-class:: classref-item-separator
  494. ----
  495. .. _class_Vector2_method_min:
  496. .. rst-class:: classref-method
  497. :ref:`Vector2<class_Vector2>` **min**\ (\ with\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_min>`
  498. Returns the component-wise minimum of this and ``with``, equivalent to ``Vector2(minf(x, with.x), minf(y, with.y))``.
  499. .. rst-class:: classref-item-separator
  500. ----
  501. .. _class_Vector2_method_min_axis_index:
  502. .. rst-class:: classref-method
  503. :ref:`int<class_int>` **min_axis_index**\ (\ ) |const| :ref:`🔗<class_Vector2_method_min_axis_index>`
  504. Returns the axis of the vector's lowest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_Y<class_Vector2_constant_AXIS_Y>`.
  505. .. rst-class:: classref-item-separator
  506. ----
  507. .. _class_Vector2_method_minf:
  508. .. rst-class:: classref-method
  509. :ref:`Vector2<class_Vector2>` **minf**\ (\ with\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_minf>`
  510. Returns the component-wise minimum of this and ``with``, equivalent to ``Vector2(minf(x, with), minf(y, with))``.
  511. .. rst-class:: classref-item-separator
  512. ----
  513. .. _class_Vector2_method_move_toward:
  514. .. rst-class:: classref-method
  515. :ref:`Vector2<class_Vector2>` **move_toward**\ (\ to\: :ref:`Vector2<class_Vector2>`, delta\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_move_toward>`
  516. Returns a new vector moved toward ``to`` by the fixed ``delta`` amount. Will not go past the final value.
  517. .. rst-class:: classref-item-separator
  518. ----
  519. .. _class_Vector2_method_normalized:
  520. .. rst-class:: classref-method
  521. :ref:`Vector2<class_Vector2>` **normalized**\ (\ ) |const| :ref:`🔗<class_Vector2_method_normalized>`
  522. Returns the result of scaling the vector to unit length. Equivalent to ``v / v.length()``. Returns ``(0, 0)`` if ``v.length() == 0``. See also :ref:`is_normalized()<class_Vector2_method_is_normalized>`.
  523. \ **Note:** This function may return incorrect values if the input vector length is near zero.
  524. .. rst-class:: classref-item-separator
  525. ----
  526. .. _class_Vector2_method_orthogonal:
  527. .. rst-class:: classref-method
  528. :ref:`Vector2<class_Vector2>` **orthogonal**\ (\ ) |const| :ref:`🔗<class_Vector2_method_orthogonal>`
  529. Returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length.
  530. .. rst-class:: classref-item-separator
  531. ----
  532. .. _class_Vector2_method_posmod:
  533. .. rst-class:: classref-method
  534. :ref:`Vector2<class_Vector2>` **posmod**\ (\ mod\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_posmod>`
  535. Returns a vector composed of the :ref:`@GlobalScope.fposmod()<class_@GlobalScope_method_fposmod>` of this vector's components and ``mod``.
  536. .. rst-class:: classref-item-separator
  537. ----
  538. .. _class_Vector2_method_posmodv:
  539. .. rst-class:: classref-method
  540. :ref:`Vector2<class_Vector2>` **posmodv**\ (\ modv\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_posmodv>`
  541. Returns a vector composed of the :ref:`@GlobalScope.fposmod()<class_@GlobalScope_method_fposmod>` of this vector's components and ``modv``'s components.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _class_Vector2_method_project:
  545. .. rst-class:: classref-method
  546. :ref:`Vector2<class_Vector2>` **project**\ (\ b\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_project>`
  547. Returns a new vector resulting from projecting this vector onto the given vector ``b``. The resulting new vector is parallel to ``b``. See also :ref:`slide()<class_Vector2_method_slide>`.
  548. \ **Note:** If the vector ``b`` is a zero vector, the components of the resulting new vector will be :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>`.
  549. .. rst-class:: classref-item-separator
  550. ----
  551. .. _class_Vector2_method_reflect:
  552. .. rst-class:: classref-method
  553. :ref:`Vector2<class_Vector2>` **reflect**\ (\ line\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_reflect>`
  554. Returns the result of reflecting the vector from a line defined by the given direction vector ``line``.
  555. \ **Note:** :ref:`reflect()<class_Vector2_method_reflect>` differs from what other engines and frameworks call ``reflect()``. In other engines, ``reflect()`` takes a normal direction which is a direction perpendicular to the line. In Godot, you specify the direction of the line directly. See also :ref:`bounce()<class_Vector2_method_bounce>` which does what most engines call ``reflect()``.
  556. .. rst-class:: classref-item-separator
  557. ----
  558. .. _class_Vector2_method_rotated:
  559. .. rst-class:: classref-method
  560. :ref:`Vector2<class_Vector2>` **rotated**\ (\ angle\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_rotated>`
  561. Returns the result of rotating this vector by ``angle`` (in radians). See also :ref:`@GlobalScope.deg_to_rad()<class_@GlobalScope_method_deg_to_rad>`.
  562. .. rst-class:: classref-item-separator
  563. ----
  564. .. _class_Vector2_method_round:
  565. .. rst-class:: classref-method
  566. :ref:`Vector2<class_Vector2>` **round**\ (\ ) |const| :ref:`🔗<class_Vector2_method_round>`
  567. Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  568. .. rst-class:: classref-item-separator
  569. ----
  570. .. _class_Vector2_method_sign:
  571. .. rst-class:: classref-method
  572. :ref:`Vector2<class_Vector2>` **sign**\ (\ ) |const| :ref:`🔗<class_Vector2_method_sign>`
  573. Returns a new vector with each component set to ``1.0`` if it's positive, ``-1.0`` if it's negative, and ``0.0`` if it's zero. The result is identical to calling :ref:`@GlobalScope.sign()<class_@GlobalScope_method_sign>` on each component.
  574. .. rst-class:: classref-item-separator
  575. ----
  576. .. _class_Vector2_method_slerp:
  577. .. rst-class:: classref-method
  578. :ref:`Vector2<class_Vector2>` **slerp**\ (\ to\: :ref:`Vector2<class_Vector2>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_slerp>`
  579. Returns the result of spherical linear interpolation between this vector and ``to``, by amount ``weight``. ``weight`` is on the range of 0.0 to 1.0, representing the amount of interpolation.
  580. This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like :ref:`lerp()<class_Vector2_method_lerp>`.
  581. .. rst-class:: classref-item-separator
  582. ----
  583. .. _class_Vector2_method_slide:
  584. .. rst-class:: classref-method
  585. :ref:`Vector2<class_Vector2>` **slide**\ (\ n\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_slide>`
  586. Returns a new vector resulting from sliding this vector along a line with normal ``n``. The resulting new vector is perpendicular to ``n``, and is equivalent to this vector minus its projection on ``n``. See also :ref:`project()<class_Vector2_method_project>`.
  587. \ **Note:** The vector ``n`` must be normalized. See also :ref:`normalized()<class_Vector2_method_normalized>`.
  588. .. rst-class:: classref-item-separator
  589. ----
  590. .. _class_Vector2_method_snapped:
  591. .. rst-class:: classref-method
  592. :ref:`Vector2<class_Vector2>` **snapped**\ (\ step\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Vector2_method_snapped>`
  593. Returns a new vector with each component snapped to the nearest multiple of the corresponding component in ``step``. This can also be used to round the components to an arbitrary number of decimals.
  594. .. rst-class:: classref-item-separator
  595. ----
  596. .. _class_Vector2_method_snappedf:
  597. .. rst-class:: classref-method
  598. :ref:`Vector2<class_Vector2>` **snappedf**\ (\ step\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Vector2_method_snappedf>`
  599. Returns a new vector with each component snapped to the nearest multiple of ``step``. This can also be used to round the components to an arbitrary number of decimals.
  600. .. rst-class:: classref-section-separator
  601. ----
  602. .. rst-class:: classref-descriptions-group
  603. Operator Descriptions
  604. ---------------------
  605. .. _class_Vector2_operator_neq_Vector2:
  606. .. rst-class:: classref-operator
  607. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_neq_Vector2>`
  608. Returns ``true`` if the vectors are not equal.
  609. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx()<class_Vector2_method_is_equal_approx>` instead, which is more reliable.
  610. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  611. .. rst-class:: classref-item-separator
  612. ----
  613. .. _class_Vector2_operator_mul_Transform2D:
  614. .. rst-class:: classref-operator
  615. :ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`Transform2D<class_Transform2D>`\ ) :ref:`🔗<class_Vector2_operator_mul_Transform2D>`
  616. Inversely transforms (multiplies) the **Vector2** by the given :ref:`Transform2D<class_Transform2D>` transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
  617. \ ``vector * transform`` is equivalent to ``transform.inverse() * vector``. See :ref:`Transform2D.inverse()<class_Transform2D_method_inverse>`.
  618. For transforming by inverse of an affine transformation (e.g. with scaling) ``transform.affine_inverse() * vector`` can be used instead. See :ref:`Transform2D.affine_inverse()<class_Transform2D_method_affine_inverse>`.
  619. .. rst-class:: classref-item-separator
  620. ----
  621. .. _class_Vector2_operator_mul_Vector2:
  622. .. rst-class:: classref-operator
  623. :ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_mul_Vector2>`
  624. Multiplies each component of the **Vector2** by the components of the given **Vector2**.
  625. ::
  626. print(Vector2(10, 20) * Vector2(3, 4)) # Prints (30.0, 80.0)
  627. .. rst-class:: classref-item-separator
  628. ----
  629. .. _class_Vector2_operator_mul_float:
  630. .. rst-class:: classref-operator
  631. :ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Vector2_operator_mul_float>`
  632. Multiplies each component of the **Vector2** by the given :ref:`float<class_float>`.
  633. .. rst-class:: classref-item-separator
  634. ----
  635. .. _class_Vector2_operator_mul_int:
  636. .. rst-class:: classref-operator
  637. :ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Vector2_operator_mul_int>`
  638. Multiplies each component of the **Vector2** by the given :ref:`int<class_int>`.
  639. .. rst-class:: classref-item-separator
  640. ----
  641. .. _class_Vector2_operator_sum_Vector2:
  642. .. rst-class:: classref-operator
  643. :ref:`Vector2<class_Vector2>` **operator +**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_sum_Vector2>`
  644. Adds each component of the **Vector2** by the components of the given **Vector2**.
  645. ::
  646. print(Vector2(10, 20) + Vector2(3, 4)) # Prints (13.0, 24.0)
  647. .. rst-class:: classref-item-separator
  648. ----
  649. .. _class_Vector2_operator_dif_Vector2:
  650. .. rst-class:: classref-operator
  651. :ref:`Vector2<class_Vector2>` **operator -**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_dif_Vector2>`
  652. Subtracts each component of the **Vector2** by the components of the given **Vector2**.
  653. ::
  654. print(Vector2(10, 20) - Vector2(3, 4)) # Prints (7.0, 16.0)
  655. .. rst-class:: classref-item-separator
  656. ----
  657. .. _class_Vector2_operator_div_Vector2:
  658. .. rst-class:: classref-operator
  659. :ref:`Vector2<class_Vector2>` **operator /**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_div_Vector2>`
  660. Divides each component of the **Vector2** by the components of the given **Vector2**.
  661. ::
  662. print(Vector2(10, 20) / Vector2(2, 5)) # Prints (5.0, 4.0)
  663. .. rst-class:: classref-item-separator
  664. ----
  665. .. _class_Vector2_operator_div_float:
  666. .. rst-class:: classref-operator
  667. :ref:`Vector2<class_Vector2>` **operator /**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Vector2_operator_div_float>`
  668. Divides each component of the **Vector2** by the given :ref:`float<class_float>`.
  669. .. rst-class:: classref-item-separator
  670. ----
  671. .. _class_Vector2_operator_div_int:
  672. .. rst-class:: classref-operator
  673. :ref:`Vector2<class_Vector2>` **operator /**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Vector2_operator_div_int>`
  674. Divides each component of the **Vector2** by the given :ref:`int<class_int>`.
  675. .. rst-class:: classref-item-separator
  676. ----
  677. .. _class_Vector2_operator_lt_Vector2:
  678. .. rst-class:: classref-operator
  679. :ref:`bool<class_bool>` **operator <**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_lt_Vector2>`
  680. Compares two **Vector2** vectors by first checking if the X value of the left vector is less than the X value of the ``right`` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
  681. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  682. .. rst-class:: classref-item-separator
  683. ----
  684. .. _class_Vector2_operator_lte_Vector2:
  685. .. rst-class:: classref-operator
  686. :ref:`bool<class_bool>` **operator <=**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_lte_Vector2>`
  687. Compares two **Vector2** vectors by first checking if the X value of the left vector is less than or equal to the X value of the ``right`` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
  688. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  689. .. rst-class:: classref-item-separator
  690. ----
  691. .. _class_Vector2_operator_eq_Vector2:
  692. .. rst-class:: classref-operator
  693. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_eq_Vector2>`
  694. Returns ``true`` if the vectors are exactly equal.
  695. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx()<class_Vector2_method_is_equal_approx>` instead, which is more reliable.
  696. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  697. .. rst-class:: classref-item-separator
  698. ----
  699. .. _class_Vector2_operator_gt_Vector2:
  700. .. rst-class:: classref-operator
  701. :ref:`bool<class_bool>` **operator >**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_gt_Vector2>`
  702. Compares two **Vector2** vectors by first checking if the X value of the left vector is greater than the X value of the ``right`` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
  703. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  704. .. rst-class:: classref-item-separator
  705. ----
  706. .. _class_Vector2_operator_gte_Vector2:
  707. .. rst-class:: classref-operator
  708. :ref:`bool<class_bool>` **operator >=**\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Vector2_operator_gte_Vector2>`
  709. Compares two **Vector2** vectors by first checking if the X value of the left vector is greater than or equal to the X value of the ``right`` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
  710. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  711. .. rst-class:: classref-item-separator
  712. ----
  713. .. _class_Vector2_operator_idx_int:
  714. .. rst-class:: classref-operator
  715. :ref:`float<class_float>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Vector2_operator_idx_int>`
  716. Access vector components using their ``index``. ``v[0]`` is equivalent to ``v.x``, and ``v[1]`` is equivalent to ``v.y``.
  717. .. rst-class:: classref-item-separator
  718. ----
  719. .. _class_Vector2_operator_unplus:
  720. .. rst-class:: classref-operator
  721. :ref:`Vector2<class_Vector2>` **operator unary+**\ (\ ) :ref:`🔗<class_Vector2_operator_unplus>`
  722. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  723. .. rst-class:: classref-item-separator
  724. ----
  725. .. _class_Vector2_operator_unminus:
  726. .. rst-class:: classref-operator
  727. :ref:`Vector2<class_Vector2>` **operator unary-**\ (\ ) :ref:`🔗<class_Vector2_operator_unminus>`
  728. Returns the negative value of the **Vector2**. This is the same as writing ``Vector2(-v.x, -v.y)``. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
  729. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  730. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  731. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  732. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  733. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  734. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  735. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  736. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  737. .. |void| replace:: :abbr:`void (No return value.)`