12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Vector3.xml.
- .. _class_Vector3:
- Vector3
- =======
- A 3D vector using floating point coordinates.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- A 3-element structure that can be used to represent 3D coordinates or any other triplet of numeric values.
- 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``.
- See :ref:`Vector3i<class_Vector3i>` for its integer counterpart.
- \ **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``.
- .. rst-class:: classref-introduction-group
- Tutorials
- ---------
- - :doc:`Math documentation index <../tutorials/math/index>`
- - :doc:`Vector math <../tutorials/math/vector_math>`
- - :doc:`Advanced vector math <../tutorials/math/vectors_advanced>`
- - `3Blue1Brown Essence of Linear Algebra <https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab>`__
- - `Matrix Transform Demo <https://godotengine.org/asset-library/asset/584>`__
- - `All 3D Demos <https://github.com/godotengine/godot-demo-projects/tree/master/3d>`__
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +---------------------------+------------------------------------+---------+
- | :ref:`float<class_float>` | :ref:`x<class_Vector3_property_x>` | ``0.0`` |
- +---------------------------+------------------------------------+---------+
- | :ref:`float<class_float>` | :ref:`y<class_Vector3_property_y>` | ``0.0`` |
- +---------------------------+------------------------------------+---------+
- | :ref:`float<class_float>` | :ref:`z<class_Vector3_property_z>` | ``0.0`` |
- +---------------------------+------------------------------------+---------+
- .. rst-class:: classref-reftable-group
- Constructors
- ------------
- .. table::
- :widths: auto
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>` **(** **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>` **(** :ref:`Vector3<class_Vector3>` from **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>` **(** :ref:`Vector3i<class_Vector3i>` from **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_constructor_Vector3>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`abs<class_Vector3_method_abs>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`angle_to<class_Vector3_method_angle_to>` **(** :ref:`Vector3<class_Vector3>` to **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`bezier_derivative<class_Vector3_method_bezier_derivative>` **(** :ref:`Vector3<class_Vector3>` control_1, :ref:`Vector3<class_Vector3>` control_2, :ref:`Vector3<class_Vector3>` end, :ref:`float<class_float>` t **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`bezier_interpolate<class_Vector3_method_bezier_interpolate>` **(** :ref:`Vector3<class_Vector3>` control_1, :ref:`Vector3<class_Vector3>` control_2, :ref:`Vector3<class_Vector3>` end, :ref:`float<class_float>` t **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`bounce<class_Vector3_method_bounce>` **(** :ref:`Vector3<class_Vector3>` n **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`ceil<class_Vector3_method_ceil>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`clamp<class_Vector3_method_clamp>` **(** :ref:`Vector3<class_Vector3>` min, :ref:`Vector3<class_Vector3>` max **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`cross<class_Vector3_method_cross>` **(** :ref:`Vector3<class_Vector3>` with **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>` **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` weight **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`cubic_interpolate_in_time<class_Vector3_method_cubic_interpolate_in_time>` **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`direction_to<class_Vector3_method_direction_to>` **(** :ref:`Vector3<class_Vector3>` to **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_method_distance_squared_to>` **(** :ref:`Vector3<class_Vector3>` to **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_method_distance_to>` **(** :ref:`Vector3<class_Vector3>` to **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`dot<class_Vector3_method_dot>` **(** :ref:`Vector3<class_Vector3>` with **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`floor<class_Vector3_method_floor>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`inverse<class_Vector3_method_inverse>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` **(** :ref:`Vector3<class_Vector3>` to **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_finite<class_Vector3_method_is_finite>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector3_method_is_normalized>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_zero_approx<class_Vector3_method_is_zero_approx>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`length<class_Vector3_method_length>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_method_length_squared>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`lerp<class_Vector3_method_lerp>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`limit_length<class_Vector3_method_limit_length>` **(** :ref:`float<class_float>` length=1.0 **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`max_axis_index<class_Vector3_method_max_axis_index>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`min_axis_index<class_Vector3_method_min_axis_index>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`move_toward<class_Vector3_method_move_toward>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`normalized<class_Vector3_method_normalized>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`octahedron_decode<class_Vector3_method_octahedron_decode>` **(** :ref:`Vector2<class_Vector2>` uv **)** |static| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_Vector2>` | :ref:`octahedron_encode<class_Vector3_method_octahedron_encode>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Basis<class_Basis>` | :ref:`outer<class_Vector3_method_outer>` **(** :ref:`Vector3<class_Vector3>` with **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`posmod<class_Vector3_method_posmod>` **(** :ref:`float<class_float>` mod **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`posmodv<class_Vector3_method_posmodv>` **(** :ref:`Vector3<class_Vector3>` modv **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`project<class_Vector3_method_project>` **(** :ref:`Vector3<class_Vector3>` b **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`reflect<class_Vector3_method_reflect>` **(** :ref:`Vector3<class_Vector3>` n **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`rotated<class_Vector3_method_rotated>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`round<class_Vector3_method_round>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`sign<class_Vector3_method_sign>` **(** **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`signed_angle_to<class_Vector3_method_signed_angle_to>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`Vector3<class_Vector3>` axis **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`slerp<class_Vector3_method_slerp>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`slide<class_Vector3_method_slide>` **(** :ref:`Vector3<class_Vector3>` n **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`snapped<class_Vector3_method_snapped>` **(** :ref:`Vector3<class_Vector3>` step **)** |const| |
- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Operators
- ---------
- .. table::
- :widths: auto
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector3_operator_neq_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Basis>` **(** :ref:`Basis<class_Basis>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Transform3D>` **(** :ref:`Transform3D<class_Transform3D>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_float>` **(** :ref:`float<class_float>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_int>` **(** :ref:`int<class_int>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator +<class_Vector3_operator_sum_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator -<class_Vector3_operator_dif_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_float>` **(** :ref:`float<class_float>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_int>` **(** :ref:`int<class_int>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator \<<class_Vector3_operator_lt_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator \<=<class_Vector3_operator_lte_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector3_operator_eq_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator ><class_Vector3_operator_gt_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator >=<class_Vector3_operator_gte_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`operator []<class_Vector3_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator unary+<class_Vector3_operator_unplus>` **(** **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`operator unary-<class_Vector3_operator_unminus>` **(** **)** |
- +-------------------------------+-------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Constants
- ---------
- .. _class_Vector3_constant_AXIS_X:
- .. rst-class:: classref-constant
- **AXIS_X** = ``0``
- 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>`.
- .. _class_Vector3_constant_AXIS_Y:
- .. rst-class:: classref-constant
- **AXIS_Y** = ``1``
- 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>`.
- .. _class_Vector3_constant_AXIS_Z:
- .. rst-class:: classref-constant
- **AXIS_Z** = ``2``
- 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>`.
- .. _class_Vector3_constant_ZERO:
- .. rst-class:: classref-constant
- **ZERO** = ``Vector3(0, 0, 0)``
- Zero vector, a vector with all components set to ``0``.
- .. _class_Vector3_constant_ONE:
- .. rst-class:: classref-constant
- **ONE** = ``Vector3(1, 1, 1)``
- One vector, a vector with all components set to ``1``.
- .. _class_Vector3_constant_INF:
- .. rst-class:: classref-constant
- **INF** = ``Vector3(inf, inf, inf)``
- Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
- .. _class_Vector3_constant_LEFT:
- .. rst-class:: classref-constant
- **LEFT** = ``Vector3(-1, 0, 0)``
- Left unit vector. Represents the local direction of left, and the global direction of west.
- .. _class_Vector3_constant_RIGHT:
- .. rst-class:: classref-constant
- **RIGHT** = ``Vector3(1, 0, 0)``
- Right unit vector. Represents the local direction of right, and the global direction of east.
- .. _class_Vector3_constant_UP:
- .. rst-class:: classref-constant
- **UP** = ``Vector3(0, 1, 0)``
- Up unit vector.
- .. _class_Vector3_constant_DOWN:
- .. rst-class:: classref-constant
- **DOWN** = ``Vector3(0, -1, 0)``
- Down unit vector.
- .. _class_Vector3_constant_FORWARD:
- .. rst-class:: classref-constant
- **FORWARD** = ``Vector3(0, 0, -1)``
- 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.
- .. _class_Vector3_constant_BACK:
- .. rst-class:: classref-constant
- **BACK** = ``Vector3(0, 0, 1)``
- Back unit vector. Represents the local direction of back, and the global direction of south.
- .. _class_Vector3_constant_MODEL_LEFT:
- .. rst-class:: classref-constant
- **MODEL_LEFT** = ``Vector3(1, 0, 0)``
- Unit vector pointing towards the left side of imported 3D assets.
- .. _class_Vector3_constant_MODEL_RIGHT:
- .. rst-class:: classref-constant
- **MODEL_RIGHT** = ``Vector3(-1, 0, 0)``
- Unit vector pointing towards the right side of imported 3D assets.
- .. _class_Vector3_constant_MODEL_TOP:
- .. rst-class:: classref-constant
- **MODEL_TOP** = ``Vector3(0, 1, 0)``
- Unit vector pointing towards the top side (up) of imported 3D assets.
- .. _class_Vector3_constant_MODEL_BOTTOM:
- .. rst-class:: classref-constant
- **MODEL_BOTTOM** = ``Vector3(0, -1, 0)``
- Unit vector pointing towards the bottom side (down) of imported 3D assets.
- .. _class_Vector3_constant_MODEL_FRONT:
- .. rst-class:: classref-constant
- **MODEL_FRONT** = ``Vector3(0, 0, 1)``
- Unit vector pointing towards the front side (facing forward) of imported 3D assets.
- .. _class_Vector3_constant_MODEL_REAR:
- .. rst-class:: classref-constant
- **MODEL_REAR** = ``Vector3(0, 0, -1)``
- Unit vector pointing towards the rear side (back) of imported 3D assets.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Property Descriptions
- ---------------------
- .. _class_Vector3_property_x:
- .. rst-class:: classref-property
- :ref:`float<class_float>` **x** = ``0.0``
- The vector's X component. Also accessible by using the index position ``[0]``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_property_y:
- .. rst-class:: classref-property
- :ref:`float<class_float>` **y** = ``0.0``
- The vector's Y component. Also accessible by using the index position ``[1]``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_property_z:
- .. rst-class:: classref-property
- :ref:`float<class_float>` **z** = ``0.0``
- The vector's Z component. Also accessible by using the index position ``[2]``.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Constructor Descriptions
- ------------------------
- .. _class_Vector3_constructor_Vector3:
- .. rst-class:: classref-constructor
- :ref:`Vector3<class_Vector3>` **Vector3** **(** **)**
- Constructs a default-initialized **Vector3** with all components set to ``0``.
- .. rst-class:: classref-item-separator
- ----
- .. rst-class:: classref-constructor
- :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`Vector3<class_Vector3>` from **)**
- Constructs a **Vector3** as a copy of the given **Vector3**.
- .. rst-class:: classref-item-separator
- ----
- .. rst-class:: classref-constructor
- :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`Vector3i<class_Vector3i>` from **)**
- Constructs a new **Vector3** from :ref:`Vector3i<class_Vector3i>`.
- .. rst-class:: classref-item-separator
- ----
- .. rst-class:: classref-constructor
- :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)**
- Returns a **Vector3** with the given components.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Method Descriptions
- -------------------
- .. _class_Vector3_method_abs:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **abs** **(** **)** |const|
- Returns a new vector with all components in absolute values (i.e. positive).
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_angle_to:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
- Returns the unsigned minimum angle to the given vector, in radians.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_bezier_derivative:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **bezier_derivative** **(** :ref:`Vector3<class_Vector3>` control_1, :ref:`Vector3<class_Vector3>` control_2, :ref:`Vector3<class_Vector3>` end, :ref:`float<class_float>` t **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_bezier_interpolate:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **bezier_interpolate** **(** :ref:`Vector3<class_Vector3>` control_1, :ref:`Vector3<class_Vector3>` control_2, :ref:`Vector3<class_Vector3>` end, :ref:`float<class_float>` t **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_bounce:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **bounce** **(** :ref:`Vector3<class_Vector3>` n **)** |const|
- Returns the vector "bounced off" from a plane defined by the given normal.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_ceil:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **ceil** **(** **)** |const|
- Returns a new vector with all components rounded up (towards positive infinity).
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_clamp:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **clamp** **(** :ref:`Vector3<class_Vector3>` min, :ref:`Vector3<class_Vector3>` max **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_cross:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **cross** **(** :ref:`Vector3<class_Vector3>` with **)** |const|
- Returns the cross product of this vector and ``with``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_cubic_interpolate:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **cubic_interpolate** **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` weight **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_cubic_interpolate_in_time:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **cubic_interpolate_in_time** **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const|
- 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.
- It can perform smoother interpolation than :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>` by the time values.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_direction_to:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **direction_to** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
- Returns the normalized vector pointing from this vector to ``to``. This is equivalent to using ``(b - a).normalized()``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_distance_squared_to:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
- Returns the squared distance between this vector and ``to``.
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_distance_to:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
- Returns the distance between this vector and ``to``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_dot:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_Vector3>` with **)** |const|
- 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.
- 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.
- 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.
- \ **Note:** ``a.dot(b)`` is equivalent to ``b.dot(a)``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_floor:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **floor** **(** **)** |const|
- Returns a new vector with all components rounded down (towards negative infinity).
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_inverse:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **inverse** **(** **)** |const|
- Returns the inverse of the vector. This is the same as ``Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z)``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_is_equal_approx:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_is_finite:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_finite** **(** **)** |const|
- Returns ``true`` if this vector is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_is_normalized:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_normalized** **(** **)** |const|
- Returns ``true`` if the vector is normalized, i.e. its length is approximately equal to 1.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_is_zero_approx:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_zero_approx** **(** **)** |const|
- 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.
- This method is faster than using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` with one value as a zero vector.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_length:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **length** **(** **)** |const|
- Returns the length (magnitude) of this vector.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_length_squared:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **length_squared** **(** **)** |const|
- Returns the squared length (squared magnitude) of this vector.
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_lerp:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **lerp** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_limit_length:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **limit_length** **(** :ref:`float<class_float>` length=1.0 **)** |const|
- Returns the vector with a maximum length by limiting its length to ``length``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_max_axis_index:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **max_axis_index** **(** **)** |const|
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_min_axis_index:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **min_axis_index** **(** **)** |const|
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_move_toward:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **move_toward** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)** |const|
- Returns a new vector moved toward ``to`` by the fixed ``delta`` amount. Will not go past the final value.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_normalized:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **normalized** **(** **)** |const|
- 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>`.
- \ **Note:** This function may return incorrect values if the input vector length is near zero.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_octahedron_decode:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **octahedron_decode** **(** :ref:`Vector2<class_Vector2>` uv **)** |static|
- 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>`).
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_octahedron_encode:
- .. rst-class:: classref-method
- :ref:`Vector2<class_Vector2>` **octahedron_encode** **(** **)** |const|
- 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>`.
- \ **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.
- \ **Note:** Octahedral compression is *lossy*, although visual differences are rarely perceptible in real world scenarios.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_outer:
- .. rst-class:: classref-method
- :ref:`Basis<class_Basis>` **outer** **(** :ref:`Vector3<class_Vector3>` with **)** |const|
- Returns the outer product with ``with``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_posmod:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **posmod** **(** :ref:`float<class_float>` mod **)** |const|
- Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``mod``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_posmodv:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **posmodv** **(** :ref:`Vector3<class_Vector3>` modv **)** |const|
- Returns a vector composed of the :ref:`@GlobalScope.fposmod<class_@GlobalScope_method_fposmod>` of this vector's components and ``modv``'s components.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_project:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **project** **(** :ref:`Vector3<class_Vector3>` b **)** |const|
- Returns the result of projecting the vector onto the given vector ``b``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_reflect:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **reflect** **(** :ref:`Vector3<class_Vector3>` n **)** |const|
- Returns the result of reflecting the vector from a plane defined by the given normal ``n``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_rotated:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **rotated** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |const|
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_round:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **round** **(** **)** |const|
- Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_sign:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **sign** **(** **)** |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_signed_angle_to:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **signed_angle_to** **(** :ref:`Vector3<class_Vector3>` to, :ref:`Vector3<class_Vector3>` axis **)** |const|
- 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``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_slerp:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **slerp** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` weight **)** |const|
- 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.
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_slide:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **slide** **(** :ref:`Vector3<class_Vector3>` n **)** |const|
- Returns a new vector slid along a plane defined by the given normal.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_method_snapped:
- .. rst-class:: classref-method
- :ref:`Vector3<class_Vector3>` **snapped** **(** :ref:`Vector3<class_Vector3>` step **)** |const|
- 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.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Operator Descriptions
- ---------------------
- .. _class_Vector3_operator_neq_Vector3:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator !=** **(** :ref:`Vector3<class_Vector3>` right **)**
- Returns ``true`` if the vectors are not equal.
- \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` instead, which is more reliable.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_mul_Basis:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Basis<class_Basis>` right **)**
- 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).
- \ ``vector * basis`` is equivalent to ``basis.transposed() * vector``. See :ref:`Basis.transposed<class_Basis_method_transposed>`.
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_mul_Quaternion:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Quaternion<class_Quaternion>` right **)**
- Inversely transforms (multiplies) the **Vector3** by the given :ref:`Quaternion<class_Quaternion>`.
- \ ``vector * quaternion`` is equivalent to ``quaternion.inverse() * vector``. See :ref:`Quaternion.inverse<class_Quaternion_method_inverse>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_mul_Transform3D:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Transform3D<class_Transform3D>` right **)**
- 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).
- \ ``vector * transform`` is equivalent to ``transform.inverse() * vector``. See :ref:`Transform3D.inverse<class_Transform3D_method_inverse>`.
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_mul_Vector3:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Vector3<class_Vector3>` right **)**
- Multiplies each component of the **Vector3** by the components of the given **Vector3**.
- ::
- print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)"
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_mul_float:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`float<class_float>` right **)**
- Multiplies each component of the **Vector3** by the given :ref:`float<class_float>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_mul_int:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`int<class_int>` right **)**
- Multiplies each component of the **Vector3** by the given :ref:`int<class_int>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_sum_Vector3:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator +** **(** :ref:`Vector3<class_Vector3>` right **)**
- Adds each component of the **Vector3** by the components of the given **Vector3**.
- ::
- print(Vector3(10, 20, 30) + Vector3(3, 4, 5)) # Prints "(13, 24, 35)"
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_dif_Vector3:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator -** **(** :ref:`Vector3<class_Vector3>` right **)**
- Subtracts each component of the **Vector3** by the components of the given **Vector3**.
- ::
- print(Vector3(10, 20, 30) - Vector3(3, 4, 5)) # Prints "(7, 16, 25)"
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_div_Vector3:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator /** **(** :ref:`Vector3<class_Vector3>` right **)**
- Divides each component of the **Vector3** by the components of the given **Vector3**.
- ::
- print(Vector3(10, 20, 30) / Vector3(2, 5, 3)) # Prints "(5, 4, 10)"
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_div_float:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator /** **(** :ref:`float<class_float>` right **)**
- Divides each component of the **Vector3** by the given :ref:`float<class_float>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_div_int:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator /** **(** :ref:`int<class_int>` right **)**
- Divides each component of the **Vector3** by the given :ref:`int<class_int>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_lt_Vector3:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator <** **(** :ref:`Vector3<class_Vector3>` right **)**
- 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.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_lte_Vector3:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator <=** **(** :ref:`Vector3<class_Vector3>` right **)**
- 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.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_eq_Vector3:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator ==** **(** :ref:`Vector3<class_Vector3>` right **)**
- Returns ``true`` if the vectors are exactly equal.
- \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` instead, which is more reliable.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_gt_Vector3:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator >** **(** :ref:`Vector3<class_Vector3>` right **)**
- 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.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_gte_Vector3:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator >=** **(** :ref:`Vector3<class_Vector3>` right **)**
- 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.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_idx_int:
- .. rst-class:: classref-operator
- :ref:`float<class_float>` **operator []** **(** :ref:`int<class_int>` index **)**
- 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``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_unplus:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator unary+** **(** **)**
- Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Vector3_operator_unminus:
- .. rst-class:: classref-operator
- :ref:`Vector3<class_Vector3>` **operator unary-** **(** **)**
- 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.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
- .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
|