class_vector4.rst 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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/Vector4.xml.
  6. .. _class_Vector4:
  7. Vector4
  8. =======
  9. A 4D vector using floating point coordinates.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. A 4-element structure that can be used to represent 4D coordinates or any other quadruplet 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:`Vector4i<class_Vector4i>` for its integer counterpart.
  16. \ **Note:** In a boolean context, a Vector4 will evaluate to ``false`` if it's equal to ``Vector4(0, 0, 0, 0)``. Otherwise, a Vector4 will always evaluate to ``true``.
  17. .. rst-class:: classref-reftable-group
  18. Properties
  19. ----------
  20. .. table::
  21. :widths: auto
  22. +---------------------------+------------------------------------+---------+
  23. | :ref:`float<class_float>` | :ref:`w<class_Vector4_property_w>` | ``0.0`` |
  24. +---------------------------+------------------------------------+---------+
  25. | :ref:`float<class_float>` | :ref:`x<class_Vector4_property_x>` | ``0.0`` |
  26. +---------------------------+------------------------------------+---------+
  27. | :ref:`float<class_float>` | :ref:`y<class_Vector4_property_y>` | ``0.0`` |
  28. +---------------------------+------------------------------------+---------+
  29. | :ref:`float<class_float>` | :ref:`z<class_Vector4_property_z>` | ``0.0`` |
  30. +---------------------------+------------------------------------+---------+
  31. .. rst-class:: classref-reftable-group
  32. Constructors
  33. ------------
  34. .. table::
  35. :widths: auto
  36. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Vector4<class_Vector4>` | :ref:`Vector4<class_Vector4_constructor_Vector4>` **(** **)** |
  38. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Vector4<class_Vector4>` | :ref:`Vector4<class_Vector4_constructor_Vector4>` **(** :ref:`Vector4<class_Vector4>` from **)** |
  40. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Vector4<class_Vector4>` | :ref:`Vector4<class_Vector4_constructor_Vector4>` **(** :ref:`Vector4i<class_Vector4i>` from **)** |
  42. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Vector4<class_Vector4>` | :ref:`Vector4<class_Vector4_constructor_Vector4>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)** |
  44. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. .. rst-class:: classref-reftable-group
  46. Methods
  47. -------
  48. .. table::
  49. :widths: auto
  50. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector4<class_Vector4>` | :ref:`abs<class_Vector4_method_abs>` **(** **)** |const| |
  52. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Vector4<class_Vector4>` | :ref:`ceil<class_Vector4_method_ceil>` **(** **)** |const| |
  54. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Vector4<class_Vector4>` | :ref:`clamp<class_Vector4_method_clamp>` **(** :ref:`Vector4<class_Vector4>` min, :ref:`Vector4<class_Vector4>` max **)** |const| |
  56. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Vector4<class_Vector4>` | :ref:`cubic_interpolate<class_Vector4_method_cubic_interpolate>` **(** :ref:`Vector4<class_Vector4>` b, :ref:`Vector4<class_Vector4>` pre_a, :ref:`Vector4<class_Vector4>` post_b, :ref:`float<class_float>` weight **)** |const| |
  58. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Vector4<class_Vector4>` | :ref:`cubic_interpolate_in_time<class_Vector4_method_cubic_interpolate_in_time>` **(** :ref:`Vector4<class_Vector4>` b, :ref:`Vector4<class_Vector4>` pre_a, :ref:`Vector4<class_Vector4>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const| |
  60. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`Vector4<class_Vector4>` | :ref:`direction_to<class_Vector4_method_direction_to>` **(** :ref:`Vector4<class_Vector4>` to **)** |const| |
  62. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector4_method_distance_squared_to>` **(** :ref:`Vector4<class_Vector4>` to **)** |const| |
  64. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector4_method_distance_to>` **(** :ref:`Vector4<class_Vector4>` to **)** |const| |
  66. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`float<class_float>` | :ref:`dot<class_Vector4_method_dot>` **(** :ref:`Vector4<class_Vector4>` with **)** |const| |
  68. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Vector4<class_Vector4>` | :ref:`floor<class_Vector4_method_floor>` **(** **)** |const| |
  70. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector4<class_Vector4>` | :ref:`inverse<class_Vector4_method_inverse>` **(** **)** |const| |
  72. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector4_method_is_equal_approx>` **(** :ref:`Vector4<class_Vector4>` to **)** |const| |
  74. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Vector4_method_is_finite>` **(** **)** |const| |
  76. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector4_method_is_normalized>` **(** **)** |const| |
  78. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_zero_approx<class_Vector4_method_is_zero_approx>` **(** **)** |const| |
  80. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`float<class_float>` | :ref:`length<class_Vector4_method_length>` **(** **)** |const| |
  82. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector4_method_length_squared>` **(** **)** |const| |
  84. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Vector4<class_Vector4>` | :ref:`lerp<class_Vector4_method_lerp>` **(** :ref:`Vector4<class_Vector4>` to, :ref:`float<class_float>` weight **)** |const| |
  86. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`int<class_int>` | :ref:`max_axis_index<class_Vector4_method_max_axis_index>` **(** **)** |const| |
  88. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`int<class_int>` | :ref:`min_axis_index<class_Vector4_method_min_axis_index>` **(** **)** |const| |
  90. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Vector4<class_Vector4>` | :ref:`normalized<class_Vector4_method_normalized>` **(** **)** |const| |
  92. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`Vector4<class_Vector4>` | :ref:`posmod<class_Vector4_method_posmod>` **(** :ref:`float<class_float>` mod **)** |const| |
  94. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`Vector4<class_Vector4>` | :ref:`posmodv<class_Vector4_method_posmodv>` **(** :ref:`Vector4<class_Vector4>` modv **)** |const| |
  96. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`Vector4<class_Vector4>` | :ref:`round<class_Vector4_method_round>` **(** **)** |const| |
  98. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`Vector4<class_Vector4>` | :ref:`sign<class_Vector4_method_sign>` **(** **)** |const| |
  100. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`Vector4<class_Vector4>` | :ref:`snapped<class_Vector4_method_snapped>` **(** :ref:`Vector4<class_Vector4>` step **)** |const| |
  102. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. .. rst-class:: classref-reftable-group
  104. Operators
  105. ---------
  106. .. table::
  107. :widths: auto
  108. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  109. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector4_operator_neq_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  110. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  111. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_Vector4_operator_mul_Projection>` **(** :ref:`Projection<class_Projection>` right **)** |
  112. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  113. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_Vector4_operator_mul_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  114. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  115. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_Vector4_operator_mul_float>` **(** :ref:`float<class_float>` right **)** |
  116. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  117. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_Vector4_operator_mul_int>` **(** :ref:`int<class_int>` right **)** |
  118. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  119. | :ref:`Vector4<class_Vector4>` | :ref:`operator +<class_Vector4_operator_sum_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  120. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  121. | :ref:`Vector4<class_Vector4>` | :ref:`operator -<class_Vector4_operator_dif_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  122. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  123. | :ref:`Vector4<class_Vector4>` | :ref:`operator /<class_Vector4_operator_div_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  124. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  125. | :ref:`Vector4<class_Vector4>` | :ref:`operator /<class_Vector4_operator_div_float>` **(** :ref:`float<class_float>` right **)** |
  126. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  127. | :ref:`Vector4<class_Vector4>` | :ref:`operator /<class_Vector4_operator_div_int>` **(** :ref:`int<class_int>` right **)** |
  128. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  129. | :ref:`bool<class_bool>` | :ref:`operator \<<class_Vector4_operator_lt_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  130. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  131. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_Vector4_operator_lte_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  132. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  133. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector4_operator_eq_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  134. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  135. | :ref:`bool<class_bool>` | :ref:`operator ><class_Vector4_operator_gt_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  136. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  137. | :ref:`bool<class_bool>` | :ref:`operator >=<class_Vector4_operator_gte_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  138. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  139. | :ref:`float<class_float>` | :ref:`operator []<class_Vector4_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
  140. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  141. | :ref:`Vector4<class_Vector4>` | :ref:`operator unary+<class_Vector4_operator_unplus>` **(** **)** |
  142. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  143. | :ref:`Vector4<class_Vector4>` | :ref:`operator unary-<class_Vector4_operator_unminus>` **(** **)** |
  144. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  145. .. rst-class:: classref-section-separator
  146. ----
  147. .. rst-class:: classref-descriptions-group
  148. Constants
  149. ---------
  150. .. _class_Vector4_constant_AXIS_X:
  151. .. rst-class:: classref-constant
  152. **AXIS_X** = ``0``
  153. Enumerated value for the X axis. Returned by :ref:`max_axis_index<class_Vector4_method_max_axis_index>` and :ref:`min_axis_index<class_Vector4_method_min_axis_index>`.
  154. .. _class_Vector4_constant_AXIS_Y:
  155. .. rst-class:: classref-constant
  156. **AXIS_Y** = ``1``
  157. Enumerated value for the Y axis. Returned by :ref:`max_axis_index<class_Vector4_method_max_axis_index>` and :ref:`min_axis_index<class_Vector4_method_min_axis_index>`.
  158. .. _class_Vector4_constant_AXIS_Z:
  159. .. rst-class:: classref-constant
  160. **AXIS_Z** = ``2``
  161. Enumerated value for the Z axis. Returned by :ref:`max_axis_index<class_Vector4_method_max_axis_index>` and :ref:`min_axis_index<class_Vector4_method_min_axis_index>`.
  162. .. _class_Vector4_constant_AXIS_W:
  163. .. rst-class:: classref-constant
  164. **AXIS_W** = ``3``
  165. Enumerated value for the W axis. Returned by :ref:`max_axis_index<class_Vector4_method_max_axis_index>` and :ref:`min_axis_index<class_Vector4_method_min_axis_index>`.
  166. .. _class_Vector4_constant_ZERO:
  167. .. rst-class:: classref-constant
  168. **ZERO** = ``Vector4(0, 0, 0, 0)``
  169. Zero vector, a vector with all components set to ``0``.
  170. .. _class_Vector4_constant_ONE:
  171. .. rst-class:: classref-constant
  172. **ONE** = ``Vector4(1, 1, 1, 1)``
  173. One vector, a vector with all components set to ``1``.
  174. .. _class_Vector4_constant_INF:
  175. .. rst-class:: classref-constant
  176. **INF** = ``Vector4(inf, inf, inf, inf)``
  177. Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
  178. .. rst-class:: classref-section-separator
  179. ----
  180. .. rst-class:: classref-descriptions-group
  181. Property Descriptions
  182. ---------------------
  183. .. _class_Vector4_property_w:
  184. .. rst-class:: classref-property
  185. :ref:`float<class_float>` **w** = ``0.0``
  186. The vector's W component. Also accessible by using the index position ``[3]``.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_Vector4_property_x:
  190. .. rst-class:: classref-property
  191. :ref:`float<class_float>` **x** = ``0.0``
  192. The vector's X component. Also accessible by using the index position ``[0]``.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_Vector4_property_y:
  196. .. rst-class:: classref-property
  197. :ref:`float<class_float>` **y** = ``0.0``
  198. The vector's Y component. Also accessible by using the index position ``[1]``.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_Vector4_property_z:
  202. .. rst-class:: classref-property
  203. :ref:`float<class_float>` **z** = ``0.0``
  204. The vector's Z component. Also accessible by using the index position ``[2]``.
  205. .. rst-class:: classref-section-separator
  206. ----
  207. .. rst-class:: classref-descriptions-group
  208. Constructor Descriptions
  209. ------------------------
  210. .. _class_Vector4_constructor_Vector4:
  211. .. rst-class:: classref-constructor
  212. :ref:`Vector4<class_Vector4>` **Vector4** **(** **)**
  213. Constructs a default-initialized **Vector4** with all components set to ``0``.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. rst-class:: classref-constructor
  217. :ref:`Vector4<class_Vector4>` **Vector4** **(** :ref:`Vector4<class_Vector4>` from **)**
  218. Constructs a **Vector4** as a copy of the given **Vector4**.
  219. .. rst-class:: classref-item-separator
  220. ----
  221. .. rst-class:: classref-constructor
  222. :ref:`Vector4<class_Vector4>` **Vector4** **(** :ref:`Vector4i<class_Vector4i>` from **)**
  223. Constructs a new **Vector4** from the given :ref:`Vector4i<class_Vector4i>`.
  224. .. rst-class:: classref-item-separator
  225. ----
  226. .. rst-class:: classref-constructor
  227. :ref:`Vector4<class_Vector4>` **Vector4** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)**
  228. Returns a **Vector4** with the given components.
  229. .. rst-class:: classref-section-separator
  230. ----
  231. .. rst-class:: classref-descriptions-group
  232. Method Descriptions
  233. -------------------
  234. .. _class_Vector4_method_abs:
  235. .. rst-class:: classref-method
  236. :ref:`Vector4<class_Vector4>` **abs** **(** **)** |const|
  237. Returns a new vector with all components in absolute values (i.e. positive).
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_Vector4_method_ceil:
  241. .. rst-class:: classref-method
  242. :ref:`Vector4<class_Vector4>` **ceil** **(** **)** |const|
  243. Returns a new vector with all components rounded up (towards positive infinity).
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_Vector4_method_clamp:
  247. .. rst-class:: classref-method
  248. :ref:`Vector4<class_Vector4>` **clamp** **(** :ref:`Vector4<class_Vector4>` min, :ref:`Vector4<class_Vector4>` max **)** |const|
  249. 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.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_Vector4_method_cubic_interpolate:
  253. .. rst-class:: classref-method
  254. :ref:`Vector4<class_Vector4>` **cubic_interpolate** **(** :ref:`Vector4<class_Vector4>` b, :ref:`Vector4<class_Vector4>` pre_a, :ref:`Vector4<class_Vector4>` post_b, :ref:`float<class_float>` weight **)** |const|
  255. 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.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_Vector4_method_cubic_interpolate_in_time:
  259. .. rst-class:: classref-method
  260. :ref:`Vector4<class_Vector4>` **cubic_interpolate_in_time** **(** :ref:`Vector4<class_Vector4>` b, :ref:`Vector4<class_Vector4>` pre_a, :ref:`Vector4<class_Vector4>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const|
  261. 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.
  262. It can perform smoother interpolation than :ref:`cubic_interpolate<class_Vector4_method_cubic_interpolate>` by the time values.
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_Vector4_method_direction_to:
  266. .. rst-class:: classref-method
  267. :ref:`Vector4<class_Vector4>` **direction_to** **(** :ref:`Vector4<class_Vector4>` to **)** |const|
  268. Returns the normalized vector pointing from this vector to ``to``. This is equivalent to using ``(b - a).normalized()``.
  269. .. rst-class:: classref-item-separator
  270. ----
  271. .. _class_Vector4_method_distance_squared_to:
  272. .. rst-class:: classref-method
  273. :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector4<class_Vector4>` to **)** |const|
  274. Returns the squared distance between this vector and ``to``.
  275. This method runs faster than :ref:`distance_to<class_Vector4_method_distance_to>`, so prefer it if you need to compare vectors or need the squared distance for some formula.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_Vector4_method_distance_to:
  279. .. rst-class:: classref-method
  280. :ref:`float<class_float>` **distance_to** **(** :ref:`Vector4<class_Vector4>` to **)** |const|
  281. Returns the distance between this vector and ``to``.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_Vector4_method_dot:
  285. .. rst-class:: classref-method
  286. :ref:`float<class_float>` **dot** **(** :ref:`Vector4<class_Vector4>` with **)** |const|
  287. Returns the dot product of this vector and ``with``.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_Vector4_method_floor:
  291. .. rst-class:: classref-method
  292. :ref:`Vector4<class_Vector4>` **floor** **(** **)** |const|
  293. Returns a new vector with all components rounded down (towards negative infinity).
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_Vector4_method_inverse:
  297. .. rst-class:: classref-method
  298. :ref:`Vector4<class_Vector4>` **inverse** **(** **)** |const|
  299. Returns the inverse of the vector. This is the same as ``Vector4(1.0 / v.x, 1.0 / v.y, 1.0 / v.z, 1.0 / v.w)``.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_Vector4_method_is_equal_approx:
  303. .. rst-class:: classref-method
  304. :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Vector4<class_Vector4>` to **)** |const|
  305. 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.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_Vector4_method_is_finite:
  309. .. rst-class:: classref-method
  310. :ref:`bool<class_bool>` **is_finite** **(** **)** |const|
  311. Returns ``true`` if this vector is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_Vector4_method_is_normalized:
  315. .. rst-class:: classref-method
  316. :ref:`bool<class_bool>` **is_normalized** **(** **)** |const|
  317. Returns ``true`` if the vector is normalized, i.e. its length is approximately equal to 1.
  318. .. rst-class:: classref-item-separator
  319. ----
  320. .. _class_Vector4_method_is_zero_approx:
  321. .. rst-class:: classref-method
  322. :ref:`bool<class_bool>` **is_zero_approx** **(** **)** |const|
  323. 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.
  324. This method is faster than using :ref:`is_equal_approx<class_Vector4_method_is_equal_approx>` with one value as a zero vector.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. _class_Vector4_method_length:
  328. .. rst-class:: classref-method
  329. :ref:`float<class_float>` **length** **(** **)** |const|
  330. Returns the length (magnitude) of this vector.
  331. .. rst-class:: classref-item-separator
  332. ----
  333. .. _class_Vector4_method_length_squared:
  334. .. rst-class:: classref-method
  335. :ref:`float<class_float>` **length_squared** **(** **)** |const|
  336. Returns the squared length (squared magnitude) of this vector.
  337. This method runs faster than :ref:`length<class_Vector4_method_length>`, so prefer it if you need to compare vectors or need the squared distance for some formula.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_Vector4_method_lerp:
  341. .. rst-class:: classref-method
  342. :ref:`Vector4<class_Vector4>` **lerp** **(** :ref:`Vector4<class_Vector4>` to, :ref:`float<class_float>` weight **)** |const|
  343. 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.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_Vector4_method_max_axis_index:
  347. .. rst-class:: classref-method
  348. :ref:`int<class_int>` **max_axis_index** **(** **)** |const|
  349. Returns the axis of the vector's highest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_X<class_Vector4_constant_AXIS_X>`.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_Vector4_method_min_axis_index:
  353. .. rst-class:: classref-method
  354. :ref:`int<class_int>` **min_axis_index** **(** **)** |const|
  355. Returns the axis of the vector's lowest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_W<class_Vector4_constant_AXIS_W>`.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_Vector4_method_normalized:
  359. .. rst-class:: classref-method
  360. :ref:`Vector4<class_Vector4>` **normalized** **(** **)** |const|
  361. Returns the result of scaling the vector to unit length. Equivalent to ``v / v.length()``. See also :ref:`is_normalized<class_Vector4_method_is_normalized>`.
  362. \ **Note:** This function may return incorrect values if the input vector length is near zero.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_Vector4_method_posmod:
  366. .. rst-class:: classref-method
  367. :ref:`Vector4<class_Vector4>` **posmod** **(** :ref:`float<class_float>` mod **)** |const|
  368. Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``mod``.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_Vector4_method_posmodv:
  372. .. rst-class:: classref-method
  373. :ref:`Vector4<class_Vector4>` **posmodv** **(** :ref:`Vector4<class_Vector4>` modv **)** |const|
  374. Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``modv``'s components.
  375. .. rst-class:: classref-item-separator
  376. ----
  377. .. _class_Vector4_method_round:
  378. .. rst-class:: classref-method
  379. :ref:`Vector4<class_Vector4>` **round** **(** **)** |const|
  380. Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  381. .. rst-class:: classref-item-separator
  382. ----
  383. .. _class_Vector4_method_sign:
  384. .. rst-class:: classref-method
  385. :ref:`Vector4<class_Vector4>` **sign** **(** **)** |const|
  386. 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.
  387. .. rst-class:: classref-item-separator
  388. ----
  389. .. _class_Vector4_method_snapped:
  390. .. rst-class:: classref-method
  391. :ref:`Vector4<class_Vector4>` **snapped** **(** :ref:`Vector4<class_Vector4>` step **)** |const|
  392. 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.
  393. .. rst-class:: classref-section-separator
  394. ----
  395. .. rst-class:: classref-descriptions-group
  396. Operator Descriptions
  397. ---------------------
  398. .. _class_Vector4_operator_neq_Vector4:
  399. .. rst-class:: classref-operator
  400. :ref:`bool<class_bool>` **operator !=** **(** :ref:`Vector4<class_Vector4>` right **)**
  401. Returns ``true`` if the vectors are not equal.
  402. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector4_method_is_equal_approx>` instead, which is more reliable.
  403. \ **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.
  404. .. rst-class:: classref-item-separator
  405. ----
  406. .. _class_Vector4_operator_mul_Projection:
  407. .. rst-class:: classref-operator
  408. :ref:`Vector4<class_Vector4>` **operator *** **(** :ref:`Projection<class_Projection>` right **)**
  409. Transforms (multiplies) the **Vector4** by the transpose of the given :ref:`Projection<class_Projection>` matrix.
  410. For transforming by inverse of a projection ``projection.inverse() * vector`` can be used instead. See :ref:`Projection.inverse<class_Projection_method_inverse>`.
  411. .. rst-class:: classref-item-separator
  412. ----
  413. .. _class_Vector4_operator_mul_Vector4:
  414. .. rst-class:: classref-operator
  415. :ref:`Vector4<class_Vector4>` **operator *** **(** :ref:`Vector4<class_Vector4>` right **)**
  416. Multiplies each component of the **Vector4** by the components of the given **Vector4**.
  417. ::
  418. print(Vector4(10, 20, 30, 40) * Vector4(3, 4, 5, 6)) # Prints "(30, 80, 150, 240)"
  419. .. rst-class:: classref-item-separator
  420. ----
  421. .. _class_Vector4_operator_mul_float:
  422. .. rst-class:: classref-operator
  423. :ref:`Vector4<class_Vector4>` **operator *** **(** :ref:`float<class_float>` right **)**
  424. Multiplies each component of the **Vector4** by the given :ref:`float<class_float>`.
  425. ::
  426. print(Vector4(10, 20, 30, 40) * 2) # Prints "(20, 40, 60, 80)"
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _class_Vector4_operator_mul_int:
  430. .. rst-class:: classref-operator
  431. :ref:`Vector4<class_Vector4>` **operator *** **(** :ref:`int<class_int>` right **)**
  432. Multiplies each component of the **Vector4** by the given :ref:`int<class_int>`.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_Vector4_operator_sum_Vector4:
  436. .. rst-class:: classref-operator
  437. :ref:`Vector4<class_Vector4>` **operator +** **(** :ref:`Vector4<class_Vector4>` right **)**
  438. Adds each component of the **Vector4** by the components of the given **Vector4**.
  439. ::
  440. print(Vector4(10, 20, 30, 40) + Vector4(3, 4, 5, 6)) # Prints "(13, 24, 35, 46)"
  441. .. rst-class:: classref-item-separator
  442. ----
  443. .. _class_Vector4_operator_dif_Vector4:
  444. .. rst-class:: classref-operator
  445. :ref:`Vector4<class_Vector4>` **operator -** **(** :ref:`Vector4<class_Vector4>` right **)**
  446. Subtracts each component of the **Vector4** by the components of the given **Vector4**.
  447. ::
  448. print(Vector4(10, 20, 30, 40) - Vector4(3, 4, 5, 6)) # Prints "(7, 16, 25, 34)"
  449. .. rst-class:: classref-item-separator
  450. ----
  451. .. _class_Vector4_operator_div_Vector4:
  452. .. rst-class:: classref-operator
  453. :ref:`Vector4<class_Vector4>` **operator /** **(** :ref:`Vector4<class_Vector4>` right **)**
  454. Divides each component of the **Vector4** by the components of the given **Vector4**.
  455. ::
  456. print(Vector4(10, 20, 30, 40) / Vector4(2, 5, 3, 4)) # Prints "(5, 4, 10, 10)"
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_Vector4_operator_div_float:
  460. .. rst-class:: classref-operator
  461. :ref:`Vector4<class_Vector4>` **operator /** **(** :ref:`float<class_float>` right **)**
  462. Divides each component of the **Vector4** by the given :ref:`float<class_float>`.
  463. ::
  464. print(Vector4(10, 20, 30, 40) / 2 # Prints "(5, 10, 15, 20)"
  465. .. rst-class:: classref-item-separator
  466. ----
  467. .. _class_Vector4_operator_div_int:
  468. .. rst-class:: classref-operator
  469. :ref:`Vector4<class_Vector4>` **operator /** **(** :ref:`int<class_int>` right **)**
  470. Divides each component of the **Vector4** by the given :ref:`int<class_int>`.
  471. .. rst-class:: classref-item-separator
  472. ----
  473. .. _class_Vector4_operator_lt_Vector4:
  474. .. rst-class:: classref-operator
  475. :ref:`bool<class_bool>` **operator <** **(** :ref:`Vector4<class_Vector4>` right **)**
  476. Compares two **Vector4** 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, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
  477. \ **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.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_Vector4_operator_lte_Vector4:
  481. .. rst-class:: classref-operator
  482. :ref:`bool<class_bool>` **operator <=** **(** :ref:`Vector4<class_Vector4>` right **)**
  483. Compares two **Vector4** 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, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
  484. \ **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.
  485. .. rst-class:: classref-item-separator
  486. ----
  487. .. _class_Vector4_operator_eq_Vector4:
  488. .. rst-class:: classref-operator
  489. :ref:`bool<class_bool>` **operator ==** **(** :ref:`Vector4<class_Vector4>` right **)**
  490. Returns ``true`` if the vectors are exactly equal.
  491. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector4_method_is_equal_approx>` instead, which is more reliable.
  492. \ **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.
  493. .. rst-class:: classref-item-separator
  494. ----
  495. .. _class_Vector4_operator_gt_Vector4:
  496. .. rst-class:: classref-operator
  497. :ref:`bool<class_bool>` **operator >** **(** :ref:`Vector4<class_Vector4>` right **)**
  498. Compares two **Vector4** 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, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
  499. \ **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.
  500. .. rst-class:: classref-item-separator
  501. ----
  502. .. _class_Vector4_operator_gte_Vector4:
  503. .. rst-class:: classref-operator
  504. :ref:`bool<class_bool>` **operator >=** **(** :ref:`Vector4<class_Vector4>` right **)**
  505. Compares two **Vector4** 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, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
  506. \ **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.
  507. .. rst-class:: classref-item-separator
  508. ----
  509. .. _class_Vector4_operator_idx_int:
  510. .. rst-class:: classref-operator
  511. :ref:`float<class_float>` **operator []** **(** :ref:`int<class_int>` index **)**
  512. Access vector components using their ``index``. ``v[0]`` is equivalent to ``v.x``, ``v[1]`` is equivalent to ``v.y``, ``v[2]`` is equivalent to ``v.z``, and ``v[3]`` is equivalent to ``v.w``.
  513. .. rst-class:: classref-item-separator
  514. ----
  515. .. _class_Vector4_operator_unplus:
  516. .. rst-class:: classref-operator
  517. :ref:`Vector4<class_Vector4>` **operator unary+** **(** **)**
  518. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  519. .. rst-class:: classref-item-separator
  520. ----
  521. .. _class_Vector4_operator_unminus:
  522. .. rst-class:: classref-operator
  523. :ref:`Vector4<class_Vector4>` **operator unary-** **(** **)**
  524. Returns the negative value of the **Vector4**. This is the same as writing ``Vector4(-v.x, -v.y, -v.z, -v.w)``. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
  525. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  526. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  527. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  528. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  529. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  530. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  531. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`