class_vector3.rst 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  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/584>`__
  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:`cross<class_Vector3_method_cross>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  73. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :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| |
  75. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :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| |
  77. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector3<class_Vector3>` | :ref:`direction_to<class_Vector3_method_direction_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  79. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_method_distance_squared_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  81. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_method_distance_to>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  83. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`float<class_float>` | :ref:`dot<class_Vector3_method_dot>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  85. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`Vector3<class_Vector3>` | :ref:`floor<class_Vector3_method_floor>`\ (\ ) |const| |
  87. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Vector3<class_Vector3>` | :ref:`inverse<class_Vector3_method_inverse>`\ (\ ) |const| |
  89. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>`\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  91. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Vector3_method_is_finite>`\ (\ ) |const| |
  93. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector3_method_is_normalized>`\ (\ ) |const| |
  95. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`is_zero_approx<class_Vector3_method_is_zero_approx>`\ (\ ) |const| |
  97. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`float<class_float>` | :ref:`length<class_Vector3_method_length>`\ (\ ) |const| |
  99. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_method_length_squared>`\ (\ ) |const| |
  101. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`Vector3<class_Vector3>` | :ref:`lerp<class_Vector3_method_lerp>`\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| |
  103. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Vector3<class_Vector3>` | :ref:`limit_length<class_Vector3_method_limit_length>`\ (\ length\: :ref:`float<class_float>` = 1.0\ ) |const| |
  105. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`max_axis_index<class_Vector3_method_max_axis_index>`\ (\ ) |const| |
  107. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`int<class_int>` | :ref:`min_axis_index<class_Vector3_method_min_axis_index>`\ (\ ) |const| |
  109. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`Vector3<class_Vector3>` | :ref:`move_toward<class_Vector3_method_move_toward>`\ (\ to\: :ref:`Vector3<class_Vector3>`, delta\: :ref:`float<class_float>`\ ) |const| |
  111. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Vector3<class_Vector3>` | :ref:`normalized<class_Vector3_method_normalized>`\ (\ ) |const| |
  113. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Vector3<class_Vector3>` | :ref:`octahedron_decode<class_Vector3_method_octahedron_decode>`\ (\ uv\: :ref:`Vector2<class_Vector2>`\ ) |static| |
  115. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`Vector2<class_Vector2>` | :ref:`octahedron_encode<class_Vector3_method_octahedron_encode>`\ (\ ) |const| |
  117. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`Basis<class_Basis>` | :ref:`outer<class_Vector3_method_outer>`\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  119. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`Vector3<class_Vector3>` | :ref:`posmod<class_Vector3_method_posmod>`\ (\ mod\: :ref:`float<class_float>`\ ) |const| |
  121. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`Vector3<class_Vector3>` | :ref:`posmodv<class_Vector3_method_posmodv>`\ (\ modv\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  123. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`Vector3<class_Vector3>` | :ref:`project<class_Vector3_method_project>`\ (\ b\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  125. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`Vector3<class_Vector3>` | :ref:`reflect<class_Vector3_method_reflect>`\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  127. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`Vector3<class_Vector3>` | :ref:`rotated<class_Vector3_method_rotated>`\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |const| |
  129. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`Vector3<class_Vector3>` | :ref:`round<class_Vector3_method_round>`\ (\ ) |const| |
  131. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`Vector3<class_Vector3>` | :ref:`sign<class_Vector3_method_sign>`\ (\ ) |const| |
  133. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :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| |
  135. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`Vector3<class_Vector3>` | :ref:`slerp<class_Vector3_method_slerp>`\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const| |
  137. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`Vector3<class_Vector3>` | :ref:`slide<class_Vector3_method_slide>`\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  139. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`Vector3<class_Vector3>` | :ref:`snapped<class_Vector3_method_snapped>`\ (\ step\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  141. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. .. rst-class:: classref-reftable-group
  143. Operators
  144. ---------
  145. .. table::
  146. :widths: auto
  147. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  148. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector3_operator_neq_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  149. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  150. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Basis>`\ (\ right\: :ref:`Basis<class_Basis>`\ ) |
  151. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  152. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Quaternion>`\ (\ right\: :ref:`Quaternion<class_Quaternion>`\ ) |
  153. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  154. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Transform3D>`\ (\ right\: :ref:`Transform3D<class_Transform3D>`\ ) |
  155. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  156. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  157. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  158. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  159. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  160. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  161. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  162. | :ref:`Vector3<class_Vector3>` | :ref:`operator +<class_Vector3_operator_sum_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  163. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  164. | :ref:`Vector3<class_Vector3>` | :ref:`operator -<class_Vector3_operator_dif_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  165. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  166. | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  167. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  168. | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  169. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  170. | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  171. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  172. | :ref:`bool<class_bool>` | :ref:`operator \<<class_Vector3_operator_lt_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  173. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  174. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_Vector3_operator_lte_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  175. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  176. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector3_operator_eq_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  177. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  178. | :ref:`bool<class_bool>` | :ref:`operator ><class_Vector3_operator_gt_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  179. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  180. | :ref:`bool<class_bool>` | :ref:`operator >=<class_Vector3_operator_gte_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  181. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  182. | :ref:`float<class_float>` | :ref:`operator []<class_Vector3_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
  183. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  184. | :ref:`Vector3<class_Vector3>` | :ref:`operator unary+<class_Vector3_operator_unplus>`\ (\ ) |
  185. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  186. | :ref:`Vector3<class_Vector3>` | :ref:`operator unary-<class_Vector3_operator_unminus>`\ (\ ) |
  187. +-------------------------------+----------------------------------------------------------------------------------------------------------------+
  188. .. rst-class:: classref-section-separator
  189. ----
  190. .. rst-class:: classref-descriptions-group
  191. Constants
  192. ---------
  193. .. _class_Vector3_constant_AXIS_X:
  194. .. rst-class:: classref-constant
  195. **AXIS_X** = ``0``
  196. 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>`.
  197. .. _class_Vector3_constant_AXIS_Y:
  198. .. rst-class:: classref-constant
  199. **AXIS_Y** = ``1``
  200. 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>`.
  201. .. _class_Vector3_constant_AXIS_Z:
  202. .. rst-class:: classref-constant
  203. **AXIS_Z** = ``2``
  204. 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>`.
  205. .. _class_Vector3_constant_ZERO:
  206. .. rst-class:: classref-constant
  207. **ZERO** = ``Vector3(0, 0, 0)``
  208. Zero vector, a vector with all components set to ``0``.
  209. .. _class_Vector3_constant_ONE:
  210. .. rst-class:: classref-constant
  211. **ONE** = ``Vector3(1, 1, 1)``
  212. One vector, a vector with all components set to ``1``.
  213. .. _class_Vector3_constant_INF:
  214. .. rst-class:: classref-constant
  215. **INF** = ``Vector3(inf, inf, inf)``
  216. Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
  217. .. _class_Vector3_constant_LEFT:
  218. .. rst-class:: classref-constant
  219. **LEFT** = ``Vector3(-1, 0, 0)``
  220. Left unit vector. Represents the local direction of left, and the global direction of west.
  221. .. _class_Vector3_constant_RIGHT:
  222. .. rst-class:: classref-constant
  223. **RIGHT** = ``Vector3(1, 0, 0)``
  224. Right unit vector. Represents the local direction of right, and the global direction of east.
  225. .. _class_Vector3_constant_UP:
  226. .. rst-class:: classref-constant
  227. **UP** = ``Vector3(0, 1, 0)``
  228. Up unit vector.
  229. .. _class_Vector3_constant_DOWN:
  230. .. rst-class:: classref-constant
  231. **DOWN** = ``Vector3(0, -1, 0)``
  232. Down unit vector.
  233. .. _class_Vector3_constant_FORWARD:
  234. .. rst-class:: classref-constant
  235. **FORWARD** = ``Vector3(0, 0, -1)``
  236. 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.
  237. .. _class_Vector3_constant_BACK:
  238. .. rst-class:: classref-constant
  239. **BACK** = ``Vector3(0, 0, 1)``
  240. Back unit vector. Represents the local direction of back, and the global direction of south.
  241. .. _class_Vector3_constant_MODEL_LEFT:
  242. .. rst-class:: classref-constant
  243. **MODEL_LEFT** = ``Vector3(1, 0, 0)``
  244. Unit vector pointing towards the left side of imported 3D assets.
  245. .. _class_Vector3_constant_MODEL_RIGHT:
  246. .. rst-class:: classref-constant
  247. **MODEL_RIGHT** = ``Vector3(-1, 0, 0)``
  248. Unit vector pointing towards the right side of imported 3D assets.
  249. .. _class_Vector3_constant_MODEL_TOP:
  250. .. rst-class:: classref-constant
  251. **MODEL_TOP** = ``Vector3(0, 1, 0)``
  252. Unit vector pointing towards the top side (up) of imported 3D assets.
  253. .. _class_Vector3_constant_MODEL_BOTTOM:
  254. .. rst-class:: classref-constant
  255. **MODEL_BOTTOM** = ``Vector3(0, -1, 0)``
  256. Unit vector pointing towards the bottom side (down) of imported 3D assets.
  257. .. _class_Vector3_constant_MODEL_FRONT:
  258. .. rst-class:: classref-constant
  259. **MODEL_FRONT** = ``Vector3(0, 0, 1)``
  260. Unit vector pointing towards the front side (facing forward) of imported 3D assets.
  261. .. _class_Vector3_constant_MODEL_REAR:
  262. .. rst-class:: classref-constant
  263. **MODEL_REAR** = ``Vector3(0, 0, -1)``
  264. Unit vector pointing towards the rear side (back) of imported 3D assets.
  265. .. rst-class:: classref-section-separator
  266. ----
  267. .. rst-class:: classref-descriptions-group
  268. Property Descriptions
  269. ---------------------
  270. .. _class_Vector3_property_x:
  271. .. rst-class:: classref-property
  272. :ref:`float<class_float>` **x** = ``0.0``
  273. The vector's X component. Also accessible by using the index position ``[0]``.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_Vector3_property_y:
  277. .. rst-class:: classref-property
  278. :ref:`float<class_float>` **y** = ``0.0``
  279. The vector's Y component. Also accessible by using the index position ``[1]``.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_Vector3_property_z:
  283. .. rst-class:: classref-property
  284. :ref:`float<class_float>` **z** = ``0.0``
  285. The vector's Z component. Also accessible by using the index position ``[2]``.
  286. .. rst-class:: classref-section-separator
  287. ----
  288. .. rst-class:: classref-descriptions-group
  289. Constructor Descriptions
  290. ------------------------
  291. .. _class_Vector3_constructor_Vector3:
  292. .. rst-class:: classref-constructor
  293. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ )
  294. Constructs a default-initialized **Vector3** with all components set to ``0``.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. rst-class:: classref-constructor
  298. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ from\: :ref:`Vector3<class_Vector3>`\ )
  299. Constructs a **Vector3** as a copy of the given **Vector3**.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. rst-class:: classref-constructor
  303. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ from\: :ref:`Vector3i<class_Vector3i>`\ )
  304. Constructs a new **Vector3** from :ref:`Vector3i<class_Vector3i>`.
  305. .. rst-class:: classref-item-separator
  306. ----
  307. .. rst-class:: classref-constructor
  308. :ref:`Vector3<class_Vector3>` **Vector3**\ (\ x\: :ref:`float<class_float>`, y\: :ref:`float<class_float>`, z\: :ref:`float<class_float>`\ )
  309. Returns a **Vector3** with the given components.
  310. .. rst-class:: classref-section-separator
  311. ----
  312. .. rst-class:: classref-descriptions-group
  313. Method Descriptions
  314. -------------------
  315. .. _class_Vector3_method_abs:
  316. .. rst-class:: classref-method
  317. :ref:`Vector3<class_Vector3>` **abs**\ (\ ) |const|
  318. Returns a new vector with all components in absolute values (i.e. positive).
  319. .. rst-class:: classref-item-separator
  320. ----
  321. .. _class_Vector3_method_angle_to:
  322. .. rst-class:: classref-method
  323. :ref:`float<class_float>` **angle_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const|
  324. Returns the unsigned minimum angle to the given vector, in radians.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. _class_Vector3_method_bezier_derivative:
  328. .. rst-class:: classref-method
  329. :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|
  330. 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.
  331. .. rst-class:: classref-item-separator
  332. ----
  333. .. _class_Vector3_method_bezier_interpolate:
  334. .. rst-class:: classref-method
  335. :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|
  336. 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.
  337. .. rst-class:: classref-item-separator
  338. ----
  339. .. _class_Vector3_method_bounce:
  340. .. rst-class:: classref-method
  341. :ref:`Vector3<class_Vector3>` **bounce**\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const|
  342. Returns the vector "bounced off" from a plane defined by the given normal.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_Vector3_method_ceil:
  346. .. rst-class:: classref-method
  347. :ref:`Vector3<class_Vector3>` **ceil**\ (\ ) |const|
  348. Returns a new vector with all components rounded up (towards positive infinity).
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_Vector3_method_clamp:
  352. .. rst-class:: classref-method
  353. :ref:`Vector3<class_Vector3>` **clamp**\ (\ min\: :ref:`Vector3<class_Vector3>`, max\: :ref:`Vector3<class_Vector3>`\ ) |const|
  354. 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.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_Vector3_method_cross:
  358. .. rst-class:: classref-method
  359. :ref:`Vector3<class_Vector3>` **cross**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const|
  360. Returns the cross product of this vector and ``with``.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_Vector3_method_cubic_interpolate:
  364. .. rst-class:: classref-method
  365. :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|
  366. 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.
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_Vector3_method_cubic_interpolate_in_time:
  370. .. rst-class:: classref-method
  371. :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|
  372. 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.
  373. It can perform smoother interpolation than :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>` by the time values.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_Vector3_method_direction_to:
  377. .. rst-class:: classref-method
  378. :ref:`Vector3<class_Vector3>` **direction_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const|
  379. Returns the normalized vector pointing from this vector to ``to``. This is equivalent to using ``(b - a).normalized()``.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_Vector3_method_distance_squared_to:
  383. .. rst-class:: classref-method
  384. :ref:`float<class_float>` **distance_squared_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const|
  385. Returns the squared distance between this vector and ``to``.
  386. 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.
  387. .. rst-class:: classref-item-separator
  388. ----
  389. .. _class_Vector3_method_distance_to:
  390. .. rst-class:: classref-method
  391. :ref:`float<class_float>` **distance_to**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const|
  392. Returns the distance between this vector and ``to``.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_Vector3_method_dot:
  396. .. rst-class:: classref-method
  397. :ref:`float<class_float>` **dot**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const|
  398. 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.
  399. 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.
  400. 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.
  401. \ **Note:** ``a.dot(b)`` is equivalent to ``b.dot(a)``.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_Vector3_method_floor:
  405. .. rst-class:: classref-method
  406. :ref:`Vector3<class_Vector3>` **floor**\ (\ ) |const|
  407. Returns a new vector with all components rounded down (towards negative infinity).
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_Vector3_method_inverse:
  411. .. rst-class:: classref-method
  412. :ref:`Vector3<class_Vector3>` **inverse**\ (\ ) |const|
  413. Returns the inverse of the vector. This is the same as ``Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z)``.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_Vector3_method_is_equal_approx:
  417. .. rst-class:: classref-method
  418. :ref:`bool<class_bool>` **is_equal_approx**\ (\ to\: :ref:`Vector3<class_Vector3>`\ ) |const|
  419. 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.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_Vector3_method_is_finite:
  423. .. rst-class:: classref-method
  424. :ref:`bool<class_bool>` **is_finite**\ (\ ) |const|
  425. Returns ``true`` if this vector is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_Vector3_method_is_normalized:
  429. .. rst-class:: classref-method
  430. :ref:`bool<class_bool>` **is_normalized**\ (\ ) |const|
  431. Returns ``true`` if the vector is normalized, i.e. its length is approximately equal to 1.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_Vector3_method_is_zero_approx:
  435. .. rst-class:: classref-method
  436. :ref:`bool<class_bool>` **is_zero_approx**\ (\ ) |const|
  437. 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.
  438. This method is faster than using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` with one value as a zero vector.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_Vector3_method_length:
  442. .. rst-class:: classref-method
  443. :ref:`float<class_float>` **length**\ (\ ) |const|
  444. Returns the length (magnitude) of this vector.
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_Vector3_method_length_squared:
  448. .. rst-class:: classref-method
  449. :ref:`float<class_float>` **length_squared**\ (\ ) |const|
  450. Returns the squared length (squared magnitude) of this vector.
  451. 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.
  452. .. rst-class:: classref-item-separator
  453. ----
  454. .. _class_Vector3_method_lerp:
  455. .. rst-class:: classref-method
  456. :ref:`Vector3<class_Vector3>` **lerp**\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const|
  457. 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.
  458. .. rst-class:: classref-item-separator
  459. ----
  460. .. _class_Vector3_method_limit_length:
  461. .. rst-class:: classref-method
  462. :ref:`Vector3<class_Vector3>` **limit_length**\ (\ length\: :ref:`float<class_float>` = 1.0\ ) |const|
  463. Returns the vector with a maximum length by limiting its length to ``length``.
  464. .. rst-class:: classref-item-separator
  465. ----
  466. .. _class_Vector3_method_max_axis_index:
  467. .. rst-class:: classref-method
  468. :ref:`int<class_int>` **max_axis_index**\ (\ ) |const|
  469. 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>`.
  470. .. rst-class:: classref-item-separator
  471. ----
  472. .. _class_Vector3_method_min_axis_index:
  473. .. rst-class:: classref-method
  474. :ref:`int<class_int>` **min_axis_index**\ (\ ) |const|
  475. 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>`.
  476. .. rst-class:: classref-item-separator
  477. ----
  478. .. _class_Vector3_method_move_toward:
  479. .. rst-class:: classref-method
  480. :ref:`Vector3<class_Vector3>` **move_toward**\ (\ to\: :ref:`Vector3<class_Vector3>`, delta\: :ref:`float<class_float>`\ ) |const|
  481. Returns a new vector moved toward ``to`` by the fixed ``delta`` amount. Will not go past the final value.
  482. .. rst-class:: classref-item-separator
  483. ----
  484. .. _class_Vector3_method_normalized:
  485. .. rst-class:: classref-method
  486. :ref:`Vector3<class_Vector3>` **normalized**\ (\ ) |const|
  487. Returns the result of scaling the vector to unit length. Equivalent to ``v / v.length()``. See also :ref:`is_normalized<class_Vector3_method_is_normalized>`.
  488. \ **Note:** This function may return incorrect values if the input vector length is near zero.
  489. .. rst-class:: classref-item-separator
  490. ----
  491. .. _class_Vector3_method_octahedron_decode:
  492. .. rst-class:: classref-method
  493. :ref:`Vector3<class_Vector3>` **octahedron_decode**\ (\ uv\: :ref:`Vector2<class_Vector2>`\ ) |static|
  494. 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>`).
  495. .. rst-class:: classref-item-separator
  496. ----
  497. .. _class_Vector3_method_octahedron_encode:
  498. .. rst-class:: classref-method
  499. :ref:`Vector2<class_Vector2>` **octahedron_encode**\ (\ ) |const|
  500. 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>`.
  501. \ **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.
  502. \ **Note:** Octahedral compression is *lossy*, although visual differences are rarely perceptible in real world scenarios.
  503. .. rst-class:: classref-item-separator
  504. ----
  505. .. _class_Vector3_method_outer:
  506. .. rst-class:: classref-method
  507. :ref:`Basis<class_Basis>` **outer**\ (\ with\: :ref:`Vector3<class_Vector3>`\ ) |const|
  508. Returns the outer product with ``with``.
  509. .. rst-class:: classref-item-separator
  510. ----
  511. .. _class_Vector3_method_posmod:
  512. .. rst-class:: classref-method
  513. :ref:`Vector3<class_Vector3>` **posmod**\ (\ mod\: :ref:`float<class_float>`\ ) |const|
  514. Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``mod``.
  515. .. rst-class:: classref-item-separator
  516. ----
  517. .. _class_Vector3_method_posmodv:
  518. .. rst-class:: classref-method
  519. :ref:`Vector3<class_Vector3>` **posmodv**\ (\ modv\: :ref:`Vector3<class_Vector3>`\ ) |const|
  520. Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``modv``'s components.
  521. .. rst-class:: classref-item-separator
  522. ----
  523. .. _class_Vector3_method_project:
  524. .. rst-class:: classref-method
  525. :ref:`Vector3<class_Vector3>` **project**\ (\ b\: :ref:`Vector3<class_Vector3>`\ ) |const|
  526. 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>`.
  527. \ **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>`.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_Vector3_method_reflect:
  531. .. rst-class:: classref-method
  532. :ref:`Vector3<class_Vector3>` **reflect**\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const|
  533. Returns the result of reflecting the vector from a plane defined by the given normal ``n``.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Vector3_method_rotated:
  537. .. rst-class:: classref-method
  538. :ref:`Vector3<class_Vector3>` **rotated**\ (\ axis\: :ref:`Vector3<class_Vector3>`, angle\: :ref:`float<class_float>`\ ) |const|
  539. 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>`.
  540. .. rst-class:: classref-item-separator
  541. ----
  542. .. _class_Vector3_method_round:
  543. .. rst-class:: classref-method
  544. :ref:`Vector3<class_Vector3>` **round**\ (\ ) |const|
  545. Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  546. .. rst-class:: classref-item-separator
  547. ----
  548. .. _class_Vector3_method_sign:
  549. .. rst-class:: classref-method
  550. :ref:`Vector3<class_Vector3>` **sign**\ (\ ) |const|
  551. 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.
  552. .. rst-class:: classref-item-separator
  553. ----
  554. .. _class_Vector3_method_signed_angle_to:
  555. .. rst-class:: classref-method
  556. :ref:`float<class_float>` **signed_angle_to**\ (\ to\: :ref:`Vector3<class_Vector3>`, axis\: :ref:`Vector3<class_Vector3>`\ ) |const|
  557. 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``.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_Vector3_method_slerp:
  561. .. rst-class:: classref-method
  562. :ref:`Vector3<class_Vector3>` **slerp**\ (\ to\: :ref:`Vector3<class_Vector3>`, weight\: :ref:`float<class_float>`\ ) |const|
  563. 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.
  564. 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>`.
  565. .. rst-class:: classref-item-separator
  566. ----
  567. .. _class_Vector3_method_slide:
  568. .. rst-class:: classref-method
  569. :ref:`Vector3<class_Vector3>` **slide**\ (\ n\: :ref:`Vector3<class_Vector3>`\ ) |const|
  570. 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>`.
  571. \ **Note:** The vector ``n`` must be normalized. See also :ref:`normalized<class_Vector3_method_normalized>`.
  572. .. rst-class:: classref-item-separator
  573. ----
  574. .. _class_Vector3_method_snapped:
  575. .. rst-class:: classref-method
  576. :ref:`Vector3<class_Vector3>` **snapped**\ (\ step\: :ref:`Vector3<class_Vector3>`\ ) |const|
  577. 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.
  578. .. rst-class:: classref-section-separator
  579. ----
  580. .. rst-class:: classref-descriptions-group
  581. Operator Descriptions
  582. ---------------------
  583. .. _class_Vector3_operator_neq_Vector3:
  584. .. rst-class:: classref-operator
  585. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  586. Returns ``true`` if the vectors are not equal.
  587. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` instead, which is more reliable.
  588. \ **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.
  589. .. rst-class:: classref-item-separator
  590. ----
  591. .. _class_Vector3_operator_mul_Basis:
  592. .. rst-class:: classref-operator
  593. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Basis<class_Basis>`\ )
  594. 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).
  595. \ ``vector * basis`` is equivalent to ``basis.transposed() * vector``. See :ref:`Basis.transposed<class_Basis_method_transposed>`.
  596. 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>`.
  597. .. rst-class:: classref-item-separator
  598. ----
  599. .. _class_Vector3_operator_mul_Quaternion:
  600. .. rst-class:: classref-operator
  601. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Quaternion<class_Quaternion>`\ )
  602. Inversely transforms (multiplies) the **Vector3** by the given :ref:`Quaternion<class_Quaternion>`.
  603. \ ``vector * quaternion`` is equivalent to ``quaternion.inverse() * vector``. See :ref:`Quaternion.inverse<class_Quaternion_method_inverse>`.
  604. .. rst-class:: classref-item-separator
  605. ----
  606. .. _class_Vector3_operator_mul_Transform3D:
  607. .. rst-class:: classref-operator
  608. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Transform3D<class_Transform3D>`\ )
  609. 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).
  610. \ ``vector * transform`` is equivalent to ``transform.inverse() * vector``. See :ref:`Transform3D.inverse<class_Transform3D_method_inverse>`.
  611. 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>`.
  612. .. rst-class:: classref-item-separator
  613. ----
  614. .. _class_Vector3_operator_mul_Vector3:
  615. .. rst-class:: classref-operator
  616. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  617. Multiplies each component of the **Vector3** by the components of the given **Vector3**.
  618. ::
  619. print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)"
  620. .. rst-class:: classref-item-separator
  621. ----
  622. .. _class_Vector3_operator_mul_float:
  623. .. rst-class:: classref-operator
  624. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`float<class_float>`\ )
  625. Multiplies each component of the **Vector3** by the given :ref:`float<class_float>`.
  626. .. rst-class:: classref-item-separator
  627. ----
  628. .. _class_Vector3_operator_mul_int:
  629. .. rst-class:: classref-operator
  630. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`int<class_int>`\ )
  631. Multiplies each component of the **Vector3** by the given :ref:`int<class_int>`.
  632. .. rst-class:: classref-item-separator
  633. ----
  634. .. _class_Vector3_operator_sum_Vector3:
  635. .. rst-class:: classref-operator
  636. :ref:`Vector3<class_Vector3>` **operator +**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  637. Adds each component of the **Vector3** by the components of the given **Vector3**.
  638. ::
  639. print(Vector3(10, 20, 30) + Vector3(3, 4, 5)) # Prints "(13, 24, 35)"
  640. .. rst-class:: classref-item-separator
  641. ----
  642. .. _class_Vector3_operator_dif_Vector3:
  643. .. rst-class:: classref-operator
  644. :ref:`Vector3<class_Vector3>` **operator -**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  645. Subtracts each component of the **Vector3** by the components of the given **Vector3**.
  646. ::
  647. print(Vector3(10, 20, 30) - Vector3(3, 4, 5)) # Prints "(7, 16, 25)"
  648. .. rst-class:: classref-item-separator
  649. ----
  650. .. _class_Vector3_operator_div_Vector3:
  651. .. rst-class:: classref-operator
  652. :ref:`Vector3<class_Vector3>` **operator /**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  653. Divides each component of the **Vector3** by the components of the given **Vector3**.
  654. ::
  655. print(Vector3(10, 20, 30) / Vector3(2, 5, 3)) # Prints "(5, 4, 10)"
  656. .. rst-class:: classref-item-separator
  657. ----
  658. .. _class_Vector3_operator_div_float:
  659. .. rst-class:: classref-operator
  660. :ref:`Vector3<class_Vector3>` **operator /**\ (\ right\: :ref:`float<class_float>`\ )
  661. Divides each component of the **Vector3** by the given :ref:`float<class_float>`.
  662. .. rst-class:: classref-item-separator
  663. ----
  664. .. _class_Vector3_operator_div_int:
  665. .. rst-class:: classref-operator
  666. :ref:`Vector3<class_Vector3>` **operator /**\ (\ right\: :ref:`int<class_int>`\ )
  667. Divides each component of the **Vector3** by the given :ref:`int<class_int>`.
  668. .. rst-class:: classref-item-separator
  669. ----
  670. .. _class_Vector3_operator_lt_Vector3:
  671. .. rst-class:: classref-operator
  672. :ref:`bool<class_bool>` **operator <**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  673. 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.
  674. \ **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.
  675. .. rst-class:: classref-item-separator
  676. ----
  677. .. _class_Vector3_operator_lte_Vector3:
  678. .. rst-class:: classref-operator
  679. :ref:`bool<class_bool>` **operator <=**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  680. 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.
  681. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  682. .. rst-class:: classref-item-separator
  683. ----
  684. .. _class_Vector3_operator_eq_Vector3:
  685. .. rst-class:: classref-operator
  686. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  687. Returns ``true`` if the vectors are exactly equal.
  688. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` instead, which is more reliable.
  689. \ **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.
  690. .. rst-class:: classref-item-separator
  691. ----
  692. .. _class_Vector3_operator_gt_Vector3:
  693. .. rst-class:: classref-operator
  694. :ref:`bool<class_bool>` **operator >**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  695. 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.
  696. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  697. .. rst-class:: classref-item-separator
  698. ----
  699. .. _class_Vector3_operator_gte_Vector3:
  700. .. rst-class:: classref-operator
  701. :ref:`bool<class_bool>` **operator >=**\ (\ right\: :ref:`Vector3<class_Vector3>`\ )
  702. 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.
  703. \ **Note:** Vectors with :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
  704. .. rst-class:: classref-item-separator
  705. ----
  706. .. _class_Vector3_operator_idx_int:
  707. .. rst-class:: classref-operator
  708. :ref:`float<class_float>` **operator []**\ (\ index\: :ref:`int<class_int>`\ )
  709. 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``.
  710. .. rst-class:: classref-item-separator
  711. ----
  712. .. _class_Vector3_operator_unplus:
  713. .. rst-class:: classref-operator
  714. :ref:`Vector3<class_Vector3>` **operator unary+**\ (\ )
  715. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  716. .. rst-class:: classref-item-separator
  717. ----
  718. .. _class_Vector3_operator_unminus:
  719. .. rst-class:: classref-operator
  720. :ref:`Vector3<class_Vector3>` **operator unary-**\ (\ )
  721. 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.
  722. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  723. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  724. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  725. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  726. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  727. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  728. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  729. .. |void| replace:: :abbr:`void (No return value.)`