class_vector3.rst 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399
  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/Vector3.xml.
  6. .. _class_Vector3:
  7. Vector3
  8. =======
  9. A 3D vector using floating-point coordinates.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. A 3-element structure that can be used to represent 3D coordinates or any other triplet 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:`Vector3i<class_Vector3i>` for its integer counterpart.
  16. \ **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``.
  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 3D Demos <https://github.com/godotengine/godot-demo-projects/tree/master/3d>`__
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +---------------------------+------------------------------------+---------+
  32. | :ref:`float<class_float>` | :ref:`x<class_Vector3_property_x>` | ``0.0`` |
  33. +---------------------------+------------------------------------+---------+
  34. | :ref:`float<class_float>` | :ref:`y<class_Vector3_property_y>` | ``0.0`` |
  35. +---------------------------+------------------------------------+---------+
  36. | :ref:`float<class_float>` | :ref:`z<class_Vector3_property_z>` | ``0.0`` |
  37. +---------------------------+------------------------------------+---------+
  38. .. rst-class:: classref-reftable-group
  39. Constructors
  40. ------------
  41. .. table::
  42. :widths: auto
  43. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>`\ (\ ) |
  45. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>`\ (\ from\: :ref:`Vector3<class_Vector3>`\ ) |
  47. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>`\ (\ from\: :ref:`Vector3i<class_Vector3i>`\ ) |
  49. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>`\ (\ x\: :ref:`float<class_float>`, y\: :ref:`float<class_float>`, z\: :ref:`float<class_float>`\ ) |
  51. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. .. rst-class:: classref-reftable-group
  53. Methods
  54. -------
  55. .. table::
  56. :widths: auto
  57. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Vector3<class_Vector3>` | :ref:`abs<class_Vector3_method_abs>`\ (\ ) |const| |
  59. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector3_method_angle_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  61. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Vector3<class_Vector3>` | :ref:`bezier_derivative<class_Vector3_method_bezier_derivative>`\ (\ control_1\: :ref:`Vector3<class_Vector3>`, control_2\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`, t\: :ref:`float<class_float>`\ ) |const| |
  63. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Vector3<class_Vector3>` | :ref:`bezier_interpolate<class_Vector3_method_bezier_interpolate>`\ (\ control_1\: :ref:`Vector3<class_Vector3>`, control_2\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`, t\: :ref:`float<class_float>`\ ) |const| |
  65. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector3<class_Vector3>` | :ref:`bounce<class_Vector3_method_bounce>`\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  67. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Vector3<class_Vector3>` | :ref:`ceil<class_Vector3_method_ceil>`\ (\ ) |const| |
  69. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Vector3<class_Vector3>` | :ref:`clamp<class_Vector3_method_clamp>`\ (\ min\: :ref:`Vector3<class_Vector3>`, max\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  71. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Vector3<class_Vector3>` | :ref:`clampf<class_Vector3_method_clampf>`\ (\ min\: :ref:`float<class_float>`, max\: :ref:`float<class_float>`\ ) |const| |
  73. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Vector3<class_Vector3>` | :ref:`cross<class_Vector3_method_cross>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  75. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector3<class_Vector3>` | :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>`\ (\ b\: :ref:`Vector3<class_Vector3>`, pre_a\: :ref:`Vector3<class_Vector3>`, post_b\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| |
  77. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector3<class_Vector3>` | :ref:`cubic_interpolate_in_time<class_Vector3_method_cubic_interpolate_in_time>`\ (\ b\: :ref:`Vector3<class_Vector3>`, pre_a\: :ref:`Vector3<class_Vector3>`, post_b\: :ref:`Vector3<class_Vector3>`, 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| |
  79. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector3<class_Vector3>` | :ref:`direction_to<class_Vector3_method_direction_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  81. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_method_distance_squared_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  83. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_method_distance_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  85. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`float<class_float>` | :ref:`dot<class_Vector3_method_dot>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  87. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Vector3<class_Vector3>` | :ref:`floor<class_Vector3_method_floor>`\ (\ ) |const| |
  89. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Vector3<class_Vector3>` | :ref:`inverse<class_Vector3_method_inverse>`\ (\ ) |const| |
  91. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  93. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Vector3_method_is_finite>`\ (\ ) |const| |
  95. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector3_method_is_normalized>`\ (\ ) |const| |
  97. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`is_zero_approx<class_Vector3_method_is_zero_approx>`\ (\ ) |const| |
  99. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`float<class_float>` | :ref:`length<class_Vector3_method_length>`\ (\ ) |const| |
  101. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_method_length_squared>`\ (\ ) |const| |
  103. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Vector3<class_Vector3>` | :ref:`lerp<class_Vector3_method_lerp>`\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| |
  105. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`Vector3<class_Vector3>` | :ref:`limit_length<class_Vector3_method_limit_length>`\ (\ length\: :ref:`float<class_float>` = 1.0\ ) |const| |
  107. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Vector3<class_Vector3>` | :ref:`max<class_Vector3_method_max>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  109. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`int<class_int>` | :ref:`max_axis_index<class_Vector3_method_max_axis_index>`\ (\ ) |const| |
  111. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Vector3<class_Vector3>` | :ref:`maxf<class_Vector3_method_maxf>`\ (\ with\: :ref:`float<class_float>`\ ) |const| |
  113. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Vector3<class_Vector3>` | :ref:`min<class_Vector3_method_min>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  115. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`int<class_int>` | :ref:`min_axis_index<class_Vector3_method_min_axis_index>`\ (\ ) |const| |
  117. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`Vector3<class_Vector3>` | :ref:`minf<class_Vector3_method_minf>`\ (\ with\: :ref:`float<class_float>`\ ) |const| |
  119. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`Vector3<class_Vector3>` | :ref:`move_toward<class_Vector3_method_move_toward>`\ (\ to\: :ref:`Vector3<class_Vector3>`, delta\: :ref:`float<class_float>`\ ) |const| |
  121. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`Vector3<class_Vector3>` | :ref:`normalized<class_Vector3_method_normalized>`\ (\ ) |const| |
  123. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`Vector3<class_Vector3>` | :ref:`octahedron_decode<class_Vector3_method_octahedron_decode>`\ (\ uv\: :ref:`Vector2<class_Vector2>`\ ) |static| |
  125. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`Vector2<class_Vector2>` | :ref:`octahedron_encode<class_Vector3_method_octahedron_encode>`\ (\ ) |const| |
  127. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`Basis<class_Basis>` | :ref:`outer<class_Vector3_method_outer>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  129. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`Vector3<class_Vector3>` | :ref:`posmod<class_Vector3_method_posmod>`\ (\ mod\: :ref:`float<class_float>`\ ) |const| |
  131. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`Vector3<class_Vector3>` | :ref:`posmodv<class_Vector3_method_posmodv>`\ (\ modv\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  133. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`Vector3<class_Vector3>` | :ref:`project<class_Vector3_method_project>`\ (\ b\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  135. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`Vector3<class_Vector3>` | :ref:`reflect<class_Vector3_method_reflect>`\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  137. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`Vector3<class_Vector3>` | :ref:`rotated<class_Vector3_method_rotated>`\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |const| |
  139. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`Vector3<class_Vector3>` | :ref:`round<class_Vector3_method_round>`\ (\ ) |const| |
  141. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`Vector3<class_Vector3>` | :ref:`sign<class_Vector3_method_sign>`\ (\ ) |const| |
  143. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`float<class_float>` | :ref:`signed_angle_to<class_Vector3_method_signed_angle_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`, axis\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  145. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`Vector3<class_Vector3>` | :ref:`slerp<class_Vector3_method_slerp>`\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| |
  147. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`Vector3<class_Vector3>` | :ref:`slide<class_Vector3_method_slide>`\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  149. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | :ref:`Vector3<class_Vector3>` | :ref:`snapped<class_Vector3_method_snapped>`\ (\ step\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  151. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | :ref:`Vector3<class_Vector3>` | :ref:`snappedf<class_Vector3_method_snappedf>`\ (\ step\: :ref:`float<class_float>`\ ) |const| |
  153. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. .. rst-class:: classref-reftable-group
  155. Operators
  156. ---------
  157. .. table::
  158. :widths: auto
  159. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  160. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector3_operator_neq_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  161. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  162. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Basis>`\ (\ right\: :ref:`Basis<class_Basis>`\ ) |
  163. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  164. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Quaternion>`\ (\ right\: :ref:`Quaternion<class_Quaternion>`\ ) |
  165. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  166. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Transform3D>`\ (\ right\: :ref:`Transform3D<class_Transform3D>`\ ) |
  167. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  168. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  169. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  170. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  171. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  172. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  173. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  174. | :ref:`Vector3<class_Vector3>` | :ref:`operator +<class_Vector3_operator_sum_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  175. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  176. | :ref:`Vector3<class_Vector3>` | :ref:`operator -<class_Vector3_operator_dif_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  177. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  178. | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  179. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  180. | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  181. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  182. | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  183. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  184. | :ref:`bool<class_bool>` | :ref:`operator \<<class_Vector3_operator_lt_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  185. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  186. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_Vector3_operator_lte_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  187. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  188. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector3_operator_eq_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  189. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  190. | :ref:`bool<class_bool>` | :ref:`operator ><class_Vector3_operator_gt_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  191. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  192. | :ref:`bool<class_bool>` | :ref:`operator >=<class_Vector3_operator_gte_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  193. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  194. | :ref:`float<class_float>` | :ref:`operator []<class_Vector3_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
  195. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  196. | :ref:`Vector3<class_Vector3>` | :ref:`operator unary+<class_Vector3_operator_unplus>`\ (\ ) |
  197. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  198. | :ref:`Vector3<class_Vector3>` | :ref:`operator unary-<class_Vector3_operator_unminus>`\ (\ ) |
  199. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  200. .. rst-class:: classref-section-separator
  201. ----
  202. .. rst-class:: classref-descriptions-group
  203. Enumerations
  204. ------------
  205. .. _enum_Vector3_Axis:
  206. .. rst-class:: classref-enumeration
  207. enum **Axis**: :ref:`๐Ÿ”—<enum_Vector3_Axis>`
  208. .. _class_Vector3_constant_AXIS_X:
  209. .. rst-class:: classref-enumeration-constant
  210. :ref:`Axis<enum_Vector3_Axis>` **AXIS_X** = ``0``
  211. Enumerated value for the X axis. Returned by :ref:`max_axis_index<class_Vector3_method_max_axis_index>` and :ref:`min_axis_index<class_Vector3_method_min_axis_index>`.
  212. .. _class_Vector3_constant_AXIS_Y:
  213. .. rst-class:: classref-enumeration-constant
  214. :ref:`Axis<enum_Vector3_Axis>` **AXIS_Y** = ``1``
  215. Enumerated value for the Y axis. Returned by :ref:`max_axis_index<class_Vector3_method_max_axis_index>` and :ref:`min_axis_index<class_Vector3_method_min_axis_index>`.
  216. .. _class_Vector3_constant_AXIS_Z:
  217. .. rst-class:: classref-enumeration-constant
  218. :ref:`Axis<enum_Vector3_Axis>` **AXIS_Z** = ``2``
  219. Enumerated value for the Z axis. Returned by :ref:`max_axis_index<class_Vector3_method_max_axis_index>` and :ref:`min_axis_index<class_Vector3_method_min_axis_index>`.
  220. .. rst-class:: classref-section-separator
  221. ----
  222. .. rst-class:: classref-descriptions-group
  223. Constants
  224. ---------
  225. .. _class_Vector3_constant_ZERO:
  226. .. rst-class:: classref-constant
  227. **ZERO** = ``Vector3(0, 0, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_ZERO>`
  228. Zero vector, a vector with all components set to ``0``.
  229. .. _class_Vector3_constant_ONE:
  230. .. rst-class:: classref-constant
  231. **ONE** = ``Vector3(1, 1, 1)`` :ref:`๐Ÿ”—<class_Vector3_constant_ONE>`
  232. One vector, a vector with all components set to ``1``.
  233. .. _class_Vector3_constant_INF:
  234. .. rst-class:: classref-constant
  235. **INF** = ``Vector3(inf, inf, inf)`` :ref:`๐Ÿ”—<class_Vector3_constant_INF>`
  236. Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
  237. .. _class_Vector3_constant_LEFT:
  238. .. rst-class:: classref-constant
  239. **LEFT** = ``Vector3(-1, 0, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_LEFT>`
  240. Left unit vector. Represents the local direction of left, and the global direction of west.
  241. .. _class_Vector3_constant_RIGHT:
  242. .. rst-class:: classref-constant
  243. **RIGHT** = ``Vector3(1, 0, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_RIGHT>`
  244. Right unit vector. Represents the local direction of right, and the global direction of east.
  245. .. _class_Vector3_constant_UP:
  246. .. rst-class:: classref-constant
  247. **UP** = ``Vector3(0, 1, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_UP>`
  248. Up unit vector.
  249. .. _class_Vector3_constant_DOWN:
  250. .. rst-class:: classref-constant
  251. **DOWN** = ``Vector3(0, -1, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_DOWN>`
  252. Down unit vector.
  253. .. _class_Vector3_constant_FORWARD:
  254. .. rst-class:: classref-constant
  255. **FORWARD** = ``Vector3(0, 0, -1)`` :ref:`๐Ÿ”—<class_Vector3_constant_FORWARD>`
  256. Forward unit vector. Represents the local direction of forward, and the global direction of north. Keep in mind that the forward direction for lights, cameras, etc is different from 3D assets like characters, which face towards the camera by convention. Use :ref:`MODEL_FRONT<class_Vector3_constant_MODEL_FRONT>` and similar constants when working in 3D asset space.
  257. .. _class_Vector3_constant_BACK:
  258. .. rst-class:: classref-constant
  259. **BACK** = ``Vector3(0, 0, 1)`` :ref:`๐Ÿ”—<class_Vector3_constant_BACK>`
  260. Back unit vector. Represents the local direction of back, and the global direction of south.
  261. .. _class_Vector3_constant_MODEL_LEFT:
  262. .. rst-class:: classref-constant
  263. **MODEL_LEFT** = ``Vector3(1, 0, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_MODEL_LEFT>`
  264. Unit vector pointing towards the left side of imported 3D assets.
  265. .. _class_Vector3_constant_MODEL_RIGHT:
  266. .. rst-class:: classref-constant
  267. **MODEL_RIGHT** = ``Vector3(-1, 0, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_MODEL_RIGHT>`
  268. Unit vector pointing towards the right side of imported 3D assets.
  269. .. _class_Vector3_constant_MODEL_TOP:
  270. .. rst-class:: classref-constant
  271. **MODEL_TOP** = ``Vector3(0, 1, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_MODEL_TOP>`
  272. Unit vector pointing towards the top side (up) of imported 3D assets.
  273. .. _class_Vector3_constant_MODEL_BOTTOM:
  274. .. rst-class:: classref-constant
  275. **MODEL_BOTTOM** = ``Vector3(0, -1, 0)`` :ref:`๐Ÿ”—<class_Vector3_constant_MODEL_BOTTOM>`
  276. Unit vector pointing towards the bottom side (down) of imported 3D assets.
  277. .. _class_Vector3_constant_MODEL_FRONT:
  278. .. rst-class:: classref-constant
  279. **MODEL_FRONT** = ``Vector3(0, 0, 1)`` :ref:`๐Ÿ”—<class_Vector3_constant_MODEL_FRONT>`
  280. Unit vector pointing towards the front side (facing forward) of imported 3D assets.
  281. .. _class_Vector3_constant_MODEL_REAR:
  282. .. rst-class:: classref-constant
  283. **MODEL_REAR** = ``Vector3(0, 0, -1)`` :ref:`๐Ÿ”—<class_Vector3_constant_MODEL_REAR>`
  284. Unit vector pointing towards the rear side (back) of imported 3D assets.
  285. .. rst-class:: classref-section-separator
  286. ----
  287. .. rst-class:: classref-descriptions-group
  288. Property Descriptions
  289. ---------------------
  290. .. _class_Vector3_property_x:
  291. .. rst-class:: classref-property
  292. :ref:`float<class_float>` **x** = ``0.0`` :ref:`๐Ÿ”—<class_Vector3_property_x>`
  293. The vector's X component. Also accessible by using the index position ``[0]``.
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_Vector3_property_y:
  297. .. rst-class:: classref-property
  298. :ref:`float<class_float>` **y** = ``0.0`` :ref:`๐Ÿ”—<class_Vector3_property_y>`
  299. The vector's Y component. Also accessible by using the index position ``[1]``.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_Vector3_property_z:
  303. .. rst-class:: classref-property
  304. :ref:`float<class_float>` **z** = ``0.0`` :ref:`๐Ÿ”—<class_Vector3_property_z>`
  305. The vector's Z component. Also accessible by using the index position ``[2]``.
  306. .. rst-class:: classref-section-separator
  307. ----
  308. .. rst-class:: classref-descriptions-group
  309. Constructor Descriptions
  310. ------------------------
  311. .. _class_Vector3_constructor_Vector3:
  312. .. rst-class:: classref-constructor
  313. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ ) :ref:`๐Ÿ”—<class_Vector3_constructor_Vector3>`
  314. Constructs a default-initialized **Vector3** with all components set to ``0``.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. rst-class:: classref-constructor
  318. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ from\: :ref:`Vector3<class_Vector3>`\ )
  319. Constructs a **Vector3** as a copy of the given **Vector3**.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. rst-class:: classref-constructor
  323. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ from\: :ref:`Vector3i<class_Vector3i>`\ )
  324. Constructs a new **Vector3** from :ref:`Vector3i<class_Vector3i>`.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. rst-class:: classref-constructor
  328. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ x\: :ref:`float<class_float>`, y\: :ref:`float<class_float>`, z\: :ref:`float<class_float>`\ )
  329. Returns a **Vector3** with the given components.
  330. .. rst-class:: classref-section-separator
  331. ----
  332. .. rst-class:: classref-descriptions-group
  333. Method Descriptions
  334. -------------------
  335. .. _class_Vector3_method_abs:
  336. .. rst-class:: classref-method
  337. :ref:`Vector3<class_Vector3>` **abs**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_abs>`
  338. Returns a new vector with all components in absolute values (i.e. positive).
  339. .. rst-class:: classref-item-separator
  340. ----
  341. .. _class_Vector3_method_angle_to:
  342. .. rst-class:: classref-method
  343. :ref:`float<class_float>` **angle_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_angle_to>`
  344. Returns the unsigned minimum angle to the given vector, in radians.
  345. .. rst-class:: classref-item-separator
  346. ----
  347. .. _class_Vector3_method_bezier_derivative:
  348. .. rst-class:: classref-method
  349. :ref:`Vector3<class_Vector3>` **bezier_derivative**\ (\ control_1\: :ref:`Vector3<class_Vector3>`, control_2\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`, t\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_bezier_derivative>`
  350. 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.
  351. .. rst-class:: classref-item-separator
  352. ----
  353. .. _class_Vector3_method_bezier_interpolate:
  354. .. rst-class:: classref-method
  355. :ref:`Vector3<class_Vector3>` **bezier_interpolate**\ (\ control_1\: :ref:`Vector3<class_Vector3>`, control_2\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`, t\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_bezier_interpolate>`
  356. 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.
  357. .. rst-class:: classref-item-separator
  358. ----
  359. .. _class_Vector3_method_bounce:
  360. .. rst-class:: classref-method
  361. :ref:`Vector3<class_Vector3>` **bounce**\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_bounce>`
  362. Returns the vector "bounced off" from a plane defined by the given normal ``n``.
  363. \ **Note:** :ref:`bounce<class_Vector3_method_bounce>` performs the operation that most engines and frameworks call ``reflect()``.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_Vector3_method_ceil:
  367. .. rst-class:: classref-method
  368. :ref:`Vector3<class_Vector3>` **ceil**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_ceil>`
  369. Returns a new vector with all components rounded up (towards positive infinity).
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_Vector3_method_clamp:
  373. .. rst-class:: classref-method
  374. :ref:`Vector3<class_Vector3>` **clamp**\ (\ min\: :ref:`Vector3<class_Vector3>`, max\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_clamp>`
  375. 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.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_Vector3_method_clampf:
  379. .. rst-class:: classref-method
  380. :ref:`Vector3<class_Vector3>` **clampf**\ (\ min\: :ref:`float<class_float>`, max\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_clampf>`
  381. Returns a new vector with all components clamped between ``min`` and ``max``, by running :ref:`@GlobalScope.clamp<class_@GlobalScope_method_clamp>` on each component.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_Vector3_method_cross:
  385. .. rst-class:: classref-method
  386. :ref:`Vector3<class_Vector3>` **cross**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_cross>`
  387. Returns the cross product of this vector and ``with``.
  388. This returns a vector perpendicular to both this and ``with``, 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.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_Vector3_method_cubic_interpolate:
  392. .. rst-class:: classref-method
  393. :ref:`Vector3<class_Vector3>` **cubic_interpolate**\ (\ b\: :ref:`Vector3<class_Vector3>`, pre_a\: :ref:`Vector3<class_Vector3>`, post_b\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_cubic_interpolate>`
  394. 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.
  395. .. rst-class:: classref-item-separator
  396. ----
  397. .. _class_Vector3_method_cubic_interpolate_in_time:
  398. .. rst-class:: classref-method
  399. :ref:`Vector3<class_Vector3>` **cubic_interpolate_in_time**\ (\ b\: :ref:`Vector3<class_Vector3>`, pre_a\: :ref:`Vector3<class_Vector3>`, post_b\: :ref:`Vector3<class_Vector3>`, 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_Vector3_method_cubic_interpolate_in_time>`
  400. 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.
  401. It can perform smoother interpolation than :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>` by the time values.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_Vector3_method_direction_to:
  405. .. rst-class:: classref-method
  406. :ref:`Vector3<class_Vector3>` **direction_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_direction_to>`
  407. Returns the normalized vector pointing from this vector to ``to``. This is equivalent to using ``(b - a).normalized()``.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_Vector3_method_distance_squared_to:
  411. .. rst-class:: classref-method
  412. :ref:`float<class_float>` **distance_squared_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_distance_squared_to>`
  413. Returns the squared distance between this vector and ``to``.
  414. 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.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_Vector3_method_distance_to:
  418. .. rst-class:: classref-method
  419. :ref:`float<class_float>` **distance_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_distance_to>`
  420. Returns the distance between this vector and ``to``.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_Vector3_method_dot:
  424. .. rst-class:: classref-method
  425. :ref:`float<class_float>` **dot**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_dot>`
  426. 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.
  427. 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.
  428. 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.
  429. \ **Note:** ``a.dot(b)`` is equivalent to ``b.dot(a)``.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_Vector3_method_floor:
  433. .. rst-class:: classref-method
  434. :ref:`Vector3<class_Vector3>` **floor**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_floor>`
  435. Returns a new vector with all components rounded down (towards negative infinity).
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_Vector3_method_inverse:
  439. .. rst-class:: classref-method
  440. :ref:`Vector3<class_Vector3>` **inverse**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_inverse>`
  441. Returns the inverse of the vector. This is the same as ``Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z)``.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_Vector3_method_is_equal_approx:
  445. .. rst-class:: classref-method
  446. :ref:`bool<class_bool>` **is_equal_approx**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_is_equal_approx>`
  447. 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.
  448. .. rst-class:: classref-item-separator
  449. ----
  450. .. _class_Vector3_method_is_finite:
  451. .. rst-class:: classref-method
  452. :ref:`bool<class_bool>` **is_finite**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_is_finite>`
  453. Returns ``true`` if this vector is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
  454. .. rst-class:: classref-item-separator
  455. ----
  456. .. _class_Vector3_method_is_normalized:
  457. .. rst-class:: classref-method
  458. :ref:`bool<class_bool>` **is_normalized**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_is_normalized>`
  459. Returns ``true`` if the vector is normalized, i.e. its length is approximately equal to 1.
  460. .. rst-class:: classref-item-separator
  461. ----
  462. .. _class_Vector3_method_is_zero_approx:
  463. .. rst-class:: classref-method
  464. :ref:`bool<class_bool>` **is_zero_approx**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_is_zero_approx>`
  465. 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.
  466. This method is faster than using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` with one value as a zero vector.
  467. .. rst-class:: classref-item-separator
  468. ----
  469. .. _class_Vector3_method_length:
  470. .. rst-class:: classref-method
  471. :ref:`float<class_float>` **length**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_length>`
  472. Returns the length (magnitude) of this vector.
  473. .. rst-class:: classref-item-separator
  474. ----
  475. .. _class_Vector3_method_length_squared:
  476. .. rst-class:: classref-method
  477. :ref:`float<class_float>` **length_squared**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_length_squared>`
  478. Returns the squared length (squared magnitude) of this vector.
  479. 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.
  480. .. rst-class:: classref-item-separator
  481. ----
  482. .. _class_Vector3_method_lerp:
  483. .. rst-class:: classref-method
  484. :ref:`Vector3<class_Vector3>` **lerp**\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_lerp>`
  485. 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.
  486. .. rst-class:: classref-item-separator
  487. ----
  488. .. _class_Vector3_method_limit_length:
  489. .. rst-class:: classref-method
  490. :ref:`Vector3<class_Vector3>` **limit_length**\ (\ length\: :ref:`float<class_float>` = 1.0\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_limit_length>`
  491. Returns the vector with a maximum length by limiting its length to ``length``.
  492. .. rst-class:: classref-item-separator
  493. ----
  494. .. _class_Vector3_method_max:
  495. .. rst-class:: classref-method
  496. :ref:`Vector3<class_Vector3>` **max**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_max>`
  497. Returns the component-wise maximum of this and ``with``, equivalent to ``Vector3(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z))``.
  498. .. rst-class:: classref-item-separator
  499. ----
  500. .. _class_Vector3_method_max_axis_index:
  501. .. rst-class:: classref-method
  502. :ref:`int<class_int>` **max_axis_index**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_max_axis_index>`
  503. Returns the axis of the vector's highest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_X<class_Vector3_constant_AXIS_X>`.
  504. .. rst-class:: classref-item-separator
  505. ----
  506. .. _class_Vector3_method_maxf:
  507. .. rst-class:: classref-method
  508. :ref:`Vector3<class_Vector3>` **maxf**\ (\ with\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_maxf>`
  509. Returns the component-wise maximum of this and ``with``, equivalent to ``Vector3(maxf(x, with), maxf(y, with), maxf(z, with))``.
  510. .. rst-class:: classref-item-separator
  511. ----
  512. .. _class_Vector3_method_min:
  513. .. rst-class:: classref-method
  514. :ref:`Vector3<class_Vector3>` **min**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_min>`
  515. Returns the component-wise minimum of this and ``with``, equivalent to ``Vector3(minf(x, with.x), minf(y, with.y), minf(z, with.z))``.
  516. .. rst-class:: classref-item-separator
  517. ----
  518. .. _class_Vector3_method_min_axis_index:
  519. .. rst-class:: classref-method
  520. :ref:`int<class_int>` **min_axis_index**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_min_axis_index>`
  521. Returns the axis of the vector's lowest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_Z<class_Vector3_constant_AXIS_Z>`.
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_Vector3_method_minf:
  525. .. rst-class:: classref-method
  526. :ref:`Vector3<class_Vector3>` **minf**\ (\ with\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_minf>`
  527. Returns the component-wise minimum of this and ``with``, equivalent to ``Vector3(minf(x, with), minf(y, with), minf(z, with))``.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_Vector3_method_move_toward:
  531. .. rst-class:: classref-method
  532. :ref:`Vector3<class_Vector3>` **move_toward**\ (\ to\: :ref:`Vector3<class_Vector3>`, delta\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_move_toward>`
  533. Returns a new vector moved toward ``to`` by the fixed ``delta`` amount. Will not go past the final value.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Vector3_method_normalized:
  537. .. rst-class:: classref-method
  538. :ref:`Vector3<class_Vector3>` **normalized**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_normalized>`
  539. Returns the result of scaling the vector to unit length. Equivalent to ``v / v.length()``. Returns ``(0, 0, 0)`` if ``v.length() == 0``. See also :ref:`is_normalized<class_Vector3_method_is_normalized>`.
  540. \ **Note:** This function may return incorrect values if the input vector length is near zero.
  541. .. rst-class:: classref-item-separator
  542. ----
  543. .. _class_Vector3_method_octahedron_decode:
  544. .. rst-class:: classref-method
  545. :ref:`Vector3<class_Vector3>` **octahedron_decode**\ (\ uv\: :ref:`Vector2<class_Vector2>`\ ) |static| :ref:`๐Ÿ”—<class_Vector3_method_octahedron_decode>`
  546. Returns the **Vector3** from an octahedral-compressed form created using :ref:`octahedron_encode<class_Vector3_method_octahedron_encode>` (stored as a :ref:`Vector2<class_Vector2>`).
  547. .. rst-class:: classref-item-separator
  548. ----
  549. .. _class_Vector3_method_octahedron_encode:
  550. .. rst-class:: classref-method
  551. :ref:`Vector2<class_Vector2>` **octahedron_encode**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_octahedron_encode>`
  552. Returns the octahedral-encoded (oct32) form of this **Vector3** as a :ref:`Vector2<class_Vector2>`. Since a :ref:`Vector2<class_Vector2>` occupies 1/3 less memory compared to **Vector3**, this form of compression can be used to pass greater amounts of :ref:`normalized<class_Vector3_method_normalized>` **Vector3**\ s without increasing storage or memory requirements. See also :ref:`octahedron_decode<class_Vector3_method_octahedron_decode>`.
  553. \ **Note:** :ref:`octahedron_encode<class_Vector3_method_octahedron_encode>` can only be used for :ref:`normalized<class_Vector3_method_normalized>` vectors. :ref:`octahedron_encode<class_Vector3_method_octahedron_encode>` does *not* check whether this **Vector3** is normalized, and will return a value that does not decompress to the original value if the **Vector3** is not normalized.
  554. \ **Note:** Octahedral compression is *lossy*, although visual differences are rarely perceptible in real world scenarios.
  555. .. rst-class:: classref-item-separator
  556. ----
  557. .. _class_Vector3_method_outer:
  558. .. rst-class:: classref-method
  559. :ref:`Basis<class_Basis>` **outer**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_outer>`
  560. Returns the outer product with ``with``.
  561. .. rst-class:: classref-item-separator
  562. ----
  563. .. _class_Vector3_method_posmod:
  564. .. rst-class:: classref-method
  565. :ref:`Vector3<class_Vector3>` **posmod**\ (\ mod\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_posmod>`
  566. Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``mod``.
  567. .. rst-class:: classref-item-separator
  568. ----
  569. .. _class_Vector3_method_posmodv:
  570. .. rst-class:: classref-method
  571. :ref:`Vector3<class_Vector3>` **posmodv**\ (\ modv\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_posmodv>`
  572. Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``modv``'s components.
  573. .. rst-class:: classref-item-separator
  574. ----
  575. .. _class_Vector3_method_project:
  576. .. rst-class:: classref-method
  577. :ref:`Vector3<class_Vector3>` **project**\ (\ b\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_project>`
  578. 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_Vector3_method_slide>`.
  579. \ **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>`.
  580. .. rst-class:: classref-item-separator
  581. ----
  582. .. _class_Vector3_method_reflect:
  583. .. rst-class:: classref-method
  584. :ref:`Vector3<class_Vector3>` **reflect**\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_reflect>`
  585. Returns the result of reflecting the vector through a plane defined by the given normal vector ``n``.
  586. \ **Note:** :ref:`reflect<class_Vector3_method_reflect>` differs from what other engines and frameworks call ``reflect()``. In other engines, ``reflect()`` returns the result of the vector reflected by the given plane. The reflection thus passes through the given normal. While in Godot the reflection passes through the plane and can be thought of as bouncing off the normal. See also :ref:`bounce<class_Vector3_method_bounce>` which does what most engines call ``reflect()``.
  587. .. rst-class:: classref-item-separator
  588. ----
  589. .. _class_Vector3_method_rotated:
  590. .. rst-class:: classref-method
  591. :ref:`Vector3<class_Vector3>` **rotated**\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_rotated>`
  592. Returns the result of rotating this vector around a given axis by ``angle`` (in radians). The axis must be a normalized vector. See also :ref:`@GlobalScope.deg_to_rad<class_@GlobalScope_method_deg_to_rad>`.
  593. .. rst-class:: classref-item-separator
  594. ----
  595. .. _class_Vector3_method_round:
  596. .. rst-class:: classref-method
  597. :ref:`Vector3<class_Vector3>` **round**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_round>`
  598. Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  599. .. rst-class:: classref-item-separator
  600. ----
  601. .. _class_Vector3_method_sign:
  602. .. rst-class:: classref-method
  603. :ref:`Vector3<class_Vector3>` **sign**\ (\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_sign>`
  604. 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.
  605. .. rst-class:: classref-item-separator
  606. ----
  607. .. _class_Vector3_method_signed_angle_to:
  608. .. rst-class:: classref-method
  609. :ref:`float<class_float>` **signed_angle_to**\ (\ to\: :ref:`Vector3<class_Vector3>`, axis\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_signed_angle_to>`
  610. 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``.
  611. .. rst-class:: classref-item-separator
  612. ----
  613. .. _class_Vector3_method_slerp:
  614. .. rst-class:: classref-method
  615. :ref:`Vector3<class_Vector3>` **slerp**\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_slerp>`
  616. 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.
  617. 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_Vector3_method_lerp>`.
  618. .. rst-class:: classref-item-separator
  619. ----
  620. .. _class_Vector3_method_slide:
  621. .. rst-class:: classref-method
  622. :ref:`Vector3<class_Vector3>` **slide**\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_slide>`
  623. Returns a new vector resulting from sliding this vector along a plane 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_Vector3_method_project>`.
  624. \ **Note:** The vector ``n`` must be normalized. See also :ref:`normalized<class_Vector3_method_normalized>`.
  625. .. rst-class:: classref-item-separator
  626. ----
  627. .. _class_Vector3_method_snapped:
  628. .. rst-class:: classref-method
  629. :ref:`Vector3<class_Vector3>` **snapped**\ (\ step\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_snapped>`
  630. 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.
  631. .. rst-class:: classref-item-separator
  632. ----
  633. .. _class_Vector3_method_snappedf:
  634. .. rst-class:: classref-method
  635. :ref:`Vector3<class_Vector3>` **snappedf**\ (\ step\: :ref:`float<class_float>`\ ) |const| :ref:`๐Ÿ”—<class_Vector3_method_snappedf>`
  636. 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.
  637. .. rst-class:: classref-section-separator
  638. ----
  639. .. rst-class:: classref-descriptions-group
  640. Operator Descriptions
  641. ---------------------
  642. .. _class_Vector3_operator_neq_Vector3:
  643. .. rst-class:: classref-operator
  644. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_neq_Vector3>`
  645. Returns ``true`` if the vectors are not equal.
  646. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` instead, which is more reliable.
  647. \ **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.
  648. .. rst-class:: classref-item-separator
  649. ----
  650. .. _class_Vector3_operator_mul_Basis:
  651. .. rst-class:: classref-operator
  652. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Basis<class_Basis>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_mul_Basis>`
  653. Inversely transforms (multiplies) the **Vector3** by the given :ref:`Basis<class_Basis>` matrix, under the assumption that the basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
  654. \ ``vector * basis`` is equivalent to ``basis.transposed() * vector``. See :ref:`Basis.transposed<class_Basis_method_transposed>`.
  655. For transforming by inverse of a non-orthonormal basis (e.g. with scaling) ``basis.inverse() * vector`` can be used instead. See :ref:`Basis.inverse<class_Basis_method_inverse>`.
  656. .. rst-class:: classref-item-separator
  657. ----
  658. .. _class_Vector3_operator_mul_Quaternion:
  659. .. rst-class:: classref-operator
  660. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Quaternion<class_Quaternion>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_mul_Quaternion>`
  661. Inversely transforms (multiplies) the **Vector3** by the given :ref:`Quaternion<class_Quaternion>`.
  662. \ ``vector * quaternion`` is equivalent to ``quaternion.inverse() * vector``. See :ref:`Quaternion.inverse<class_Quaternion_method_inverse>`.
  663. .. rst-class:: classref-item-separator
  664. ----
  665. .. _class_Vector3_operator_mul_Transform3D:
  666. .. rst-class:: classref-operator
  667. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Transform3D<class_Transform3D>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_mul_Transform3D>`
  668. Inversely transforms (multiplies) the **Vector3** by the given :ref:`Transform3D<class_Transform3D>` transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
  669. \ ``vector * transform`` is equivalent to ``transform.inverse() * vector``. See :ref:`Transform3D.inverse<class_Transform3D_method_inverse>`.
  670. For transforming by inverse of an affine transformation (e.g. with scaling) ``transform.affine_inverse() * vector`` can be used instead. See :ref:`Transform3D.affine_inverse<class_Transform3D_method_affine_inverse>`.
  671. .. rst-class:: classref-item-separator
  672. ----
  673. .. _class_Vector3_operator_mul_Vector3:
  674. .. rst-class:: classref-operator
  675. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_mul_Vector3>`
  676. Multiplies each component of the **Vector3** by the components of the given **Vector3**.
  677. ::
  678. print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)"
  679. .. rst-class:: classref-item-separator
  680. ----
  681. .. _class_Vector3_operator_mul_float:
  682. .. rst-class:: classref-operator
  683. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_mul_float>`
  684. Multiplies each component of the **Vector3** by the given :ref:`float<class_float>`.
  685. .. rst-class:: classref-item-separator
  686. ----
  687. .. _class_Vector3_operator_mul_int:
  688. .. rst-class:: classref-operator
  689. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_mul_int>`
  690. Multiplies each component of the **Vector3** by the given :ref:`int<class_int>`.
  691. .. rst-class:: classref-item-separator
  692. ----
  693. .. _class_Vector3_operator_sum_Vector3:
  694. .. rst-class:: classref-operator
  695. :ref:`Vector3<class_Vector3>` **operator +**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_sum_Vector3>`
  696. Adds each component of the **Vector3** by the components of the given **Vector3**.
  697. ::
  698. print(Vector3(10, 20, 30) + Vector3(3, 4, 5)) # Prints "(13, 24, 35)"
  699. .. rst-class:: classref-item-separator
  700. ----
  701. .. _class_Vector3_operator_dif_Vector3:
  702. .. rst-class:: classref-operator
  703. :ref:`Vector3<class_Vector3>` **operator -**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_dif_Vector3>`
  704. Subtracts each component of the **Vector3** by the components of the given **Vector3**.
  705. ::
  706. print(Vector3(10, 20, 30) - Vector3(3, 4, 5)) # Prints "(7, 16, 25)"
  707. .. rst-class:: classref-item-separator
  708. ----
  709. .. _class_Vector3_operator_div_Vector3:
  710. .. rst-class:: classref-operator
  711. :ref:`Vector3<class_Vector3>` **operator /**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_div_Vector3>`
  712. Divides each component of the **Vector3** by the components of the given **Vector3**.
  713. ::
  714. print(Vector3(10, 20, 30) / Vector3(2, 5, 3)) # Prints "(5, 4, 10)"
  715. .. rst-class:: classref-item-separator
  716. ----
  717. .. _class_Vector3_operator_div_float:
  718. .. rst-class:: classref-operator
  719. :ref:`Vector3<class_Vector3>` **operator /**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_div_float>`
  720. Divides each component of the **Vector3** by the given :ref:`float<class_float>`.
  721. .. rst-class:: classref-item-separator
  722. ----
  723. .. _class_Vector3_operator_div_int:
  724. .. rst-class:: classref-operator
  725. :ref:`Vector3<class_Vector3>` **operator /**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_div_int>`
  726. Divides each component of the **Vector3** by the given :ref:`int<class_int>`.
  727. .. rst-class:: classref-item-separator
  728. ----
  729. .. _class_Vector3_operator_lt_Vector3:
  730. .. rst-class:: classref-operator
  731. :ref:`bool<class_bool>` **operator <**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_lt_Vector3>`
  732. Compares two **Vector3** 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, and then with the Z values. This operator is useful for sorting vectors.
  733. \ **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.
  734. .. rst-class:: classref-item-separator
  735. ----
  736. .. _class_Vector3_operator_lte_Vector3:
  737. .. rst-class:: classref-operator
  738. :ref:`bool<class_bool>` **operator <=**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_lte_Vector3>`
  739. Compares two **Vector3** 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, and then with the Z values. This operator is useful for sorting vectors.
  740. \ **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.
  741. .. rst-class:: classref-item-separator
  742. ----
  743. .. _class_Vector3_operator_eq_Vector3:
  744. .. rst-class:: classref-operator
  745. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_eq_Vector3>`
  746. Returns ``true`` if the vectors are exactly equal.
  747. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` instead, which is more reliable.
  748. \ **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.
  749. .. rst-class:: classref-item-separator
  750. ----
  751. .. _class_Vector3_operator_gt_Vector3:
  752. .. rst-class:: classref-operator
  753. :ref:`bool<class_bool>` **operator >**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_gt_Vector3>`
  754. Compares two **Vector3** 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, and then with the Z values. This operator is useful for sorting vectors.
  755. \ **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.
  756. .. rst-class:: classref-item-separator
  757. ----
  758. .. _class_Vector3_operator_gte_Vector3:
  759. .. rst-class:: classref-operator
  760. :ref:`bool<class_bool>` **operator >=**\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_gte_Vector3>`
  761. Compares two **Vector3** 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, and then with the Z values. This operator is useful for sorting vectors.
  762. \ **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.
  763. .. rst-class:: classref-item-separator
  764. ----
  765. .. _class_Vector3_operator_idx_int:
  766. .. rst-class:: classref-operator
  767. :ref:`float<class_float>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_Vector3_operator_idx_int>`
  768. Access vector components using their ``index``. ``v[0]`` is equivalent to ``v.x``, ``v[1]`` is equivalent to ``v.y``, and ``v[2]`` is equivalent to ``v.z``.
  769. .. rst-class:: classref-item-separator
  770. ----
  771. .. _class_Vector3_operator_unplus:
  772. .. rst-class:: classref-operator
  773. :ref:`Vector3<class_Vector3>` **operator unary+**\ (\ ) :ref:`๐Ÿ”—<class_Vector3_operator_unplus>`
  774. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  775. .. rst-class:: classref-item-separator
  776. ----
  777. .. _class_Vector3_operator_unminus:
  778. .. rst-class:: classref-operator
  779. :ref:`Vector3<class_Vector3>` **operator unary-**\ (\ ) :ref:`๐Ÿ”—<class_Vector3_operator_unminus>`
  780. Returns the negative value of the **Vector3**. This is the same as writing ``Vector3(-v.x, -v.y, -v.z)``. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
  781. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  782. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  783. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  784. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  785. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  786. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  787. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  788. .. |void| replace:: :abbr:`void (No return value.)`