class_vector3.rst 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Vector3.xml.
  6. .. _class_Vector3:
  7. Vector3
  8. =======
  9. Vector used for 3D math.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. 3-element structure that can be used to represent positions in 3D space or any other triplet of numeric values.
  14. \ **Note:** In a boolean context, a Vector3 will evaluate to ``false`` if it's equal to ``Vector3(0, 0, 0)``. Otherwise, a Vector3 will always evaluate to ``true``.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`Math tutorial index <../tutorials/math/index>`
  19. - :doc:`Vector math <../tutorials/math/vector_math>`
  20. - :doc:`Advanced vector math <../tutorials/math/vectors_advanced>`
  21. - `3Blue1Brown Essence of Linear Algebra <https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab>`__
  22. - `Matrix Transform Demo <https://godotengine.org/asset-library/asset/584>`__
  23. - `All 3D Demos <https://github.com/godotengine/godot-demo-projects/tree/master/3d>`__
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +---------------------------+------------------------------------+---------+
  30. | :ref:`float<class_float>` | :ref:`x<class_Vector3_property_x>` | ``0.0`` |
  31. +---------------------------+------------------------------------+---------+
  32. | :ref:`float<class_float>` | :ref:`y<class_Vector3_property_y>` | ``0.0`` |
  33. +---------------------------+------------------------------------+---------+
  34. | :ref:`float<class_float>` | :ref:`z<class_Vector3_property_z>` | ``0.0`` |
  35. +---------------------------+------------------------------------+---------+
  36. .. rst-class:: classref-reftable-group
  37. Methods
  38. -------
  39. .. table::
  40. :widths: auto
  41. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_method_Vector3>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |
  43. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Vector3<class_Vector3>` | :ref:`abs<class_Vector3_method_abs>` **(** **)** |
  45. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector3_method_angle_to>` **(** :ref:`Vector3<class_Vector3>` to **)** |
  47. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Vector3<class_Vector3>` | :ref:`bounce<class_Vector3_method_bounce>` **(** :ref:`Vector3<class_Vector3>` n **)** |
  49. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Vector3<class_Vector3>` | :ref:`ceil<class_Vector3_method_ceil>` **(** **)** |
  51. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Vector3<class_Vector3>` | :ref:`cross<class_Vector3_method_cross>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  53. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Vector3<class_Vector3>` | :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>` **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` weight **)** |
  55. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Vector3<class_Vector3>` | :ref:`direction_to<class_Vector3_method_direction_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  57. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_method_distance_squared_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  59. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_method_distance_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  61. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`float<class_float>` | :ref:`dot<class_Vector3_method_dot>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  63. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Vector3<class_Vector3>` | :ref:`floor<class_Vector3_method_floor>` **(** **)** |
  65. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector3<class_Vector3>` | :ref:`inverse<class_Vector3_method_inverse>` **(** **)** |
  67. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` **(** :ref:`Vector3<class_Vector3>` v **)** |
  69. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector3_method_is_normalized>` **(** **)** |
  71. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_zero_approx<class_Vector3_method_is_zero_approx>` **(** **)** |
  73. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`float<class_float>` | :ref:`length<class_Vector3_method_length>` **(** **)** |
  75. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_method_length_squared>` **(** **)** |
  77. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector3<class_Vector3>` | :ref:`limit_length<class_Vector3_method_limit_length>` **(** :ref:`float<class_float>` length=1.0 **)** |
  79. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector3<class_Vector3>` | :ref:`linear_interpolate<class_Vector3_method_linear_interpolate>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)** |
  81. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`int<class_int>` | :ref:`max_axis<class_Vector3_method_max_axis>` **(** **)** |
  83. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`int<class_int>` | :ref:`min_axis<class_Vector3_method_min_axis>` **(** **)** |
  85. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`Vector3<class_Vector3>` | :ref:`move_toward<class_Vector3_method_move_toward>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)** |
  87. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Vector3<class_Vector3>` | :ref:`normalized<class_Vector3_method_normalized>` **(** **)** |
  89. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Basis<class_Basis>` | :ref:`outer<class_Vector3_method_outer>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  91. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Vector3<class_Vector3>` | :ref:`posmod<class_Vector3_method_posmod>` **(** :ref:`float<class_float>` mod **)** |
  93. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`Vector3<class_Vector3>` | :ref:`posmodv<class_Vector3_method_posmodv>` **(** :ref:`Vector3<class_Vector3>` modv **)** |
  95. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`Vector3<class_Vector3>` | :ref:`project<class_Vector3_method_project>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  97. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Vector3<class_Vector3>` | :ref:`reflect<class_Vector3_method_reflect>` **(** :ref:`Vector3<class_Vector3>` n **)** |
  99. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Vector3<class_Vector3>` | :ref:`rotated<class_Vector3_method_rotated>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  101. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`Vector3<class_Vector3>` | :ref:`round<class_Vector3_method_round>` **(** **)** |
  103. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Vector3<class_Vector3>` | :ref:`sign<class_Vector3_method_sign>` **(** **)** |
  105. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`float<class_float>` | :ref:`signed_angle_to<class_Vector3_method_signed_angle_to>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`Vector3<class_Vector3>` axis **)** |
  107. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Vector3<class_Vector3>` | :ref:`slerp<class_Vector3_method_slerp>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)** |
  109. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`Vector3<class_Vector3>` | :ref:`slide<class_Vector3_method_slide>` **(** :ref:`Vector3<class_Vector3>` n **)** |
  111. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Vector3<class_Vector3>` | :ref:`snapped<class_Vector3_method_snapped>` **(** :ref:`Vector3<class_Vector3>` by **)** |
  113. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Basis<class_Basis>` | :ref:`to_diagonal_matrix<class_Vector3_method_to_diagonal_matrix>` **(** **)** |
  115. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. .. rst-class:: classref-section-separator
  117. ----
  118. .. rst-class:: classref-descriptions-group
  119. Constants
  120. ---------
  121. .. _class_Vector3_constant_AXIS_X:
  122. .. rst-class:: classref-constant
  123. **AXIS_X** = ``0``
  124. Enumerated value for the X axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
  125. .. _class_Vector3_constant_AXIS_Y:
  126. .. rst-class:: classref-constant
  127. **AXIS_Y** = ``1``
  128. Enumerated value for the Y axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
  129. .. _class_Vector3_constant_AXIS_Z:
  130. .. rst-class:: classref-constant
  131. **AXIS_Z** = ``2``
  132. Enumerated value for the Z axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
  133. .. _class_Vector3_constant_ZERO:
  134. .. rst-class:: classref-constant
  135. **ZERO** = ``Vector3( 0, 0, 0 )``
  136. Zero vector, a vector with all components set to ``0``.
  137. .. _class_Vector3_constant_ONE:
  138. .. rst-class:: classref-constant
  139. **ONE** = ``Vector3( 1, 1, 1 )``
  140. One vector, a vector with all components set to ``1``.
  141. .. _class_Vector3_constant_INF:
  142. .. rst-class:: classref-constant
  143. **INF** = ``Vector3( inf, inf, inf )``
  144. Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
  145. .. _class_Vector3_constant_LEFT:
  146. .. rst-class:: classref-constant
  147. **LEFT** = ``Vector3( -1, 0, 0 )``
  148. Left unit vector. Represents the local direction of left, and the global direction of west.
  149. .. _class_Vector3_constant_RIGHT:
  150. .. rst-class:: classref-constant
  151. **RIGHT** = ``Vector3( 1, 0, 0 )``
  152. Right unit vector. Represents the local direction of right, and the global direction of east.
  153. .. _class_Vector3_constant_UP:
  154. .. rst-class:: classref-constant
  155. **UP** = ``Vector3( 0, 1, 0 )``
  156. Up unit vector.
  157. .. _class_Vector3_constant_DOWN:
  158. .. rst-class:: classref-constant
  159. **DOWN** = ``Vector3( 0, -1, 0 )``
  160. Down unit vector.
  161. .. _class_Vector3_constant_FORWARD:
  162. .. rst-class:: classref-constant
  163. **FORWARD** = ``Vector3( 0, 0, -1 )``
  164. Forward unit vector. Represents the local direction of forward, and the global direction of north.
  165. .. _class_Vector3_constant_BACK:
  166. .. rst-class:: classref-constant
  167. **BACK** = ``Vector3( 0, 0, 1 )``
  168. Back unit vector. Represents the local direction of back, and the global direction of south.
  169. .. rst-class:: classref-section-separator
  170. ----
  171. .. rst-class:: classref-descriptions-group
  172. Property Descriptions
  173. ---------------------
  174. .. _class_Vector3_property_x:
  175. .. rst-class:: classref-property
  176. :ref:`float<class_float>` **x** = ``0.0``
  177. The vector's X component. Also accessible by using the index position ``[0]``.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_Vector3_property_y:
  181. .. rst-class:: classref-property
  182. :ref:`float<class_float>` **y** = ``0.0``
  183. The vector's Y component. Also accessible by using the index position ``[1]``.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_Vector3_property_z:
  187. .. rst-class:: classref-property
  188. :ref:`float<class_float>` **z** = ``0.0``
  189. The vector's Z component. Also accessible by using the index position ``[2]``.
  190. .. rst-class:: classref-section-separator
  191. ----
  192. .. rst-class:: classref-descriptions-group
  193. Method Descriptions
  194. -------------------
  195. .. _class_Vector3_method_Vector3:
  196. .. rst-class:: classref-method
  197. :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)**
  198. Returns a Vector3 with the given components.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_Vector3_method_abs:
  202. .. rst-class:: classref-method
  203. :ref:`Vector3<class_Vector3>` **abs** **(** **)**
  204. Returns a new vector with all components in absolute values (i.e. positive).
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _class_Vector3_method_angle_to:
  208. .. rst-class:: classref-method
  209. :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_Vector3>` to **)**
  210. Returns the unsigned minimum angle to the given vector, in radians.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_Vector3_method_bounce:
  214. .. rst-class:: classref-method
  215. :ref:`Vector3<class_Vector3>` **bounce** **(** :ref:`Vector3<class_Vector3>` n **)**
  216. Returns the vector "bounced off" from a plane defined by the given normal.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. _class_Vector3_method_ceil:
  220. .. rst-class:: classref-method
  221. :ref:`Vector3<class_Vector3>` **ceil** **(** **)**
  222. Returns a new vector with all components rounded up (towards positive infinity).
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_Vector3_method_cross:
  226. .. rst-class:: classref-method
  227. :ref:`Vector3<class_Vector3>` **cross** **(** :ref:`Vector3<class_Vector3>` b **)**
  228. Returns the cross product of this vector and ``b``.
  229. This returns a vector perpendicular to both this and ``b``, which would be the normal vector of the plane defined by the two vectors. As there are two such vectors, in opposite directions, this method returns the vector defined by a right-handed coordinate system. If the two vectors are parallel this returns an empty vector, making it useful for testing if two vectors are parallel.
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_Vector3_method_cubic_interpolate:
  233. .. rst-class:: classref-method
  234. :ref:`Vector3<class_Vector3>` **cubic_interpolate** **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` weight **)**
  235. 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.
  236. .. rst-class:: classref-item-separator
  237. ----
  238. .. _class_Vector3_method_direction_to:
  239. .. rst-class:: classref-method
  240. :ref:`Vector3<class_Vector3>` **direction_to** **(** :ref:`Vector3<class_Vector3>` b **)**
  241. Returns the normalized vector pointing from this vector to ``b``. This is equivalent to using ``(b - a).normalized()``.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_Vector3_method_distance_squared_to:
  245. .. rst-class:: classref-method
  246. :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_Vector3>` b **)**
  247. Returns the squared distance between this vector and ``b``.
  248. This method runs faster than :ref:`distance_to<class_Vector3_method_distance_to>`, so prefer it if you need to compare vectors or need the squared distance for some formula.
  249. .. rst-class:: classref-item-separator
  250. ----
  251. .. _class_Vector3_method_distance_to:
  252. .. rst-class:: classref-method
  253. :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_Vector3>` b **)**
  254. Returns the distance between this vector and ``b``.
  255. .. rst-class:: classref-item-separator
  256. ----
  257. .. _class_Vector3_method_dot:
  258. .. rst-class:: classref-method
  259. :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_Vector3>` b **)**
  260. Returns the dot product of this vector and ``b``. 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.
  261. The dot product will be ``0`` for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
  262. 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.
  263. \ **Note:** ``a.dot(b)`` is equivalent to ``b.dot(a)``.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_Vector3_method_floor:
  267. .. rst-class:: classref-method
  268. :ref:`Vector3<class_Vector3>` **floor** **(** **)**
  269. Returns a new vector with all components rounded down (towards negative infinity).
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_Vector3_method_inverse:
  273. .. rst-class:: classref-method
  274. :ref:`Vector3<class_Vector3>` **inverse** **(** **)**
  275. Returns the inverse of the vector. This is the same as ``Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )``.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_Vector3_method_is_equal_approx:
  279. .. rst-class:: classref-method
  280. :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Vector3<class_Vector3>` v **)**
  281. Returns ``true`` if this vector and ``v`` are approximately equal, by running :ref:`@GDScript.is_equal_approx<class_@GDScript_method_is_equal_approx>` on each component.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_Vector3_method_is_normalized:
  285. .. rst-class:: classref-method
  286. :ref:`bool<class_bool>` **is_normalized** **(** **)**
  287. Returns ``true`` if the vector is normalized, ``false`` otherwise.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_Vector3_method_is_zero_approx:
  291. .. rst-class:: classref-method
  292. :ref:`bool<class_bool>` **is_zero_approx** **(** **)**
  293. Returns ``true`` if this vector's values are approximately zero, by running :ref:`@GDScript.is_zero_approx<class_@GDScript_method_is_zero_approx>` on each component.
  294. This method is faster than using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` with one value as a zero vector.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_Vector3_method_length:
  298. .. rst-class:: classref-method
  299. :ref:`float<class_float>` **length** **(** **)**
  300. Returns the length (magnitude) of this vector.
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_Vector3_method_length_squared:
  304. .. rst-class:: classref-method
  305. :ref:`float<class_float>` **length_squared** **(** **)**
  306. Returns the squared length (squared magnitude) of this vector.
  307. This method runs faster than :ref:`length<class_Vector3_method_length>`, so prefer it if you need to compare vectors or need the squared distance for some formula.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_Vector3_method_limit_length:
  311. .. rst-class:: classref-method
  312. :ref:`Vector3<class_Vector3>` **limit_length** **(** :ref:`float<class_float>` length=1.0 **)**
  313. Returns the vector with a maximum length by limiting its length to ``length``.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_Vector3_method_linear_interpolate:
  317. .. rst-class:: classref-method
  318. :ref:`Vector3<class_Vector3>` **linear_interpolate** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)**
  319. Returns the result of the linear interpolation between this vector and ``to`` by amount ``t``. ``weight`` is on the range of 0.0 to 1.0, representing the amount of interpolation.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_Vector3_method_max_axis:
  323. .. rst-class:: classref-method
  324. :ref:`int<class_int>` **max_axis** **(** **)**
  325. Returns the axis of the vector's largest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_X<class_Vector3_constant_AXIS_X>`.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_Vector3_method_min_axis:
  329. .. rst-class:: classref-method
  330. :ref:`int<class_int>` **min_axis** **(** **)**
  331. Returns the axis of the vector's smallest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_Z<class_Vector3_constant_AXIS_Z>`.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_Vector3_method_move_toward:
  335. .. rst-class:: classref-method
  336. :ref:`Vector3<class_Vector3>` **move_toward** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)**
  337. Returns a new vector moved toward ``to`` by the fixed ``delta`` amount. Will not go past the final value.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_Vector3_method_normalized:
  341. .. rst-class:: classref-method
  342. :ref:`Vector3<class_Vector3>` **normalized** **(** **)**
  343. Returns the vector scaled to unit length. Equivalent to ``v / v.length()``.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_Vector3_method_outer:
  347. .. rst-class:: classref-method
  348. :ref:`Basis<class_Basis>` **outer** **(** :ref:`Vector3<class_Vector3>` b **)**
  349. Returns the outer product with ``b``.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_Vector3_method_posmod:
  353. .. rst-class:: classref-method
  354. :ref:`Vector3<class_Vector3>` **posmod** **(** :ref:`float<class_float>` mod **)**
  355. Returns a vector composed of the :ref:`@GDScript.fposmod<class_@GDScript_method_fposmod>` of this vector's components and ``mod``.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_Vector3_method_posmodv:
  359. .. rst-class:: classref-method
  360. :ref:`Vector3<class_Vector3>` **posmodv** **(** :ref:`Vector3<class_Vector3>` modv **)**
  361. Returns a vector composed of the :ref:`@GDScript.fposmod<class_@GDScript_method_fposmod>` of this vector's components and ``modv``'s components.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_Vector3_method_project:
  365. .. rst-class:: classref-method
  366. :ref:`Vector3<class_Vector3>` **project** **(** :ref:`Vector3<class_Vector3>` b **)**
  367. Returns this vector projected onto the vector ``b``.
  368. .. rst-class:: classref-item-separator
  369. ----
  370. .. _class_Vector3_method_reflect:
  371. .. rst-class:: classref-method
  372. :ref:`Vector3<class_Vector3>` **reflect** **(** :ref:`Vector3<class_Vector3>` n **)**
  373. Returns this vector reflected from a plane defined by the given normal.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_Vector3_method_rotated:
  377. .. rst-class:: classref-method
  378. :ref:`Vector3<class_Vector3>` **rotated** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  379. Rotates this vector around a given axis by ``angle`` (in radians). The axis must be a normalized vector.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_Vector3_method_round:
  383. .. rst-class:: classref-method
  384. :ref:`Vector3<class_Vector3>` **round** **(** **)**
  385. Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_Vector3_method_sign:
  389. .. rst-class:: classref-method
  390. :ref:`Vector3<class_Vector3>` **sign** **(** **)**
  391. Returns a new vector with each component set to one or negative one, depending on the signs of the components. If a component is zero, it returns positive one.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _class_Vector3_method_signed_angle_to:
  395. .. rst-class:: classref-method
  396. :ref:`float<class_float>` **signed_angle_to** **(** :ref:`Vector3<class_Vector3>` to, :ref:`Vector3<class_Vector3>` axis **)**
  397. Returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the ``axis``.
  398. .. rst-class:: classref-item-separator
  399. ----
  400. .. _class_Vector3_method_slerp:
  401. .. rst-class:: classref-method
  402. :ref:`Vector3<class_Vector3>` **slerp** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)**
  403. 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.
  404. \ **Note:** Both vectors must be normalized.
  405. .. rst-class:: classref-item-separator
  406. ----
  407. .. _class_Vector3_method_slide:
  408. .. rst-class:: classref-method
  409. :ref:`Vector3<class_Vector3>` **slide** **(** :ref:`Vector3<class_Vector3>` n **)**
  410. Returns this vector slid along a plane defined by the given normal.
  411. .. rst-class:: classref-item-separator
  412. ----
  413. .. _class_Vector3_method_snapped:
  414. .. rst-class:: classref-method
  415. :ref:`Vector3<class_Vector3>` **snapped** **(** :ref:`Vector3<class_Vector3>` by **)**
  416. Returns this vector with each component snapped to the nearest multiple of ``step``. This can also be used to round to an arbitrary number of decimals.
  417. .. rst-class:: classref-item-separator
  418. ----
  419. .. _class_Vector3_method_to_diagonal_matrix:
  420. .. rst-class:: classref-method
  421. :ref:`Basis<class_Basis>` **to_diagonal_matrix** **(** **)**
  422. Returns a diagonal matrix with the vector as main diagonal.
  423. This is equivalent to a Basis with no rotation or shearing and this vector's components set as the scale.
  424. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  425. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  426. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  427. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`