mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 23:28:59 +00:00
791 lines
49 KiB
ReStructuredText
791 lines
49 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the Vector3.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_Vector3:
|
|
|
|
Vector3
|
|
=======
|
|
|
|
Vector used for 3D math using floating point coordinates.
|
|
|
|
Description
|
|
-----------
|
|
|
|
3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
|
|
|
|
It uses floating-point coordinates. 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``.
|
|
|
|
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>`__
|
|
|
|
Properties
|
|
----------
|
|
|
|
+---------------------------+------------------------------------+---------+
|
|
| :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`` |
|
|
+---------------------------+------------------------------------+---------+
|
|
|
|
Constructors
|
|
------------
|
|
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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 **)** |
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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:`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:`direction_to<class_Vector3_method_direction_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |const| |
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_method_distance_squared_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |const| |
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_method_distance_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |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_normalized<class_Vector3_method_is_normalized>` **(** **)** |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<class_Vector3_method_max_axis>` **(** **)** |const| |
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`min_axis<class_Vector3_method_min_axis>` **(** **)** |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>` by_axis, :ref:`float<class_float>` phi **)** |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| |
|
|
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Operators
|
|
---------
|
|
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector3_operator_neq_bool>` **(** **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator !=<class_Vector3_operator_neq_bool>` **(** :ref:`Vector3<class_Vector3>` 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_Vector3>` **(** :ref:`Basis<class_Basis>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>` **(** :ref:`Transform3D<class_Transform3D>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>` **(** :ref:`float<class_float>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Vector3_operator_mul_Vector3>` **(** :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_Vector3>` **(** :ref:`float<class_float>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator /<class_Vector3_operator_div_Vector3>` **(** :ref:`int<class_int>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator <<class_Vector3_operator_lt_bool>` **(** :ref:`Vector3<class_Vector3>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator <=<class_Vector3_operator_lte_bool>` **(** :ref:`Vector3<class_Vector3>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector3_operator_eq_bool>` **(** **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator ==<class_Vector3_operator_eq_bool>` **(** :ref:`Vector3<class_Vector3>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator ><class_Vector3_operator_gt_bool>` **(** :ref:`Vector3<class_Vector3>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`operator >=<class_Vector3_operator_gte_bool>` **(** :ref:`Vector3<class_Vector3>` right **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`operator []<class_Vector3_operator_idx_float>` **(** :ref:`int<class_int>` index **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator unary+<class_Vector3_operator_unplus_Vector3>` **(** **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector3<class_Vector3>` | :ref:`operator unary-<class_Vector3_operator_unminus_Vector3>` **(** **)** |
|
|
+-------------------------------+---------------------------------------------------------------------------------------------------------------+
|
|
|
|
Constants
|
|
---------
|
|
|
|
.. _class_Vector3_constant_AXIS_X:
|
|
|
|
.. _class_Vector3_constant_AXIS_Y:
|
|
|
|
.. _class_Vector3_constant_AXIS_Z:
|
|
|
|
.. _class_Vector3_constant_ZERO:
|
|
|
|
.. _class_Vector3_constant_ONE:
|
|
|
|
.. _class_Vector3_constant_INF:
|
|
|
|
.. _class_Vector3_constant_LEFT:
|
|
|
|
.. _class_Vector3_constant_RIGHT:
|
|
|
|
.. _class_Vector3_constant_UP:
|
|
|
|
.. _class_Vector3_constant_DOWN:
|
|
|
|
.. _class_Vector3_constant_FORWARD:
|
|
|
|
.. _class_Vector3_constant_BACK:
|
|
|
|
- **AXIS_X** = **0** --- Enumerated value for the X axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
|
|
|
|
- **AXIS_Y** = **1** --- Enumerated value for the Y axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
|
|
|
|
- **AXIS_Z** = **2** --- Enumerated value for the Z axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
|
|
|
|
- **ZERO** = **Vector3(0, 0, 0)** --- Zero vector, a vector with all components set to ``0``.
|
|
|
|
- **ONE** = **Vector3(1, 1, 1)** --- One vector, a vector with all components set to ``1``.
|
|
|
|
- **INF** = **Vector3(inf, inf, inf)** --- Infinity vector, a vector with all components set to :ref:`@GDScript.INF<class_@GDScript_constant_INF>`.
|
|
|
|
- **LEFT** = **Vector3(-1, 0, 0)** --- Left unit vector. Represents the local direction of left, and the global direction of west.
|
|
|
|
- **RIGHT** = **Vector3(1, 0, 0)** --- Right unit vector. Represents the local direction of right, and the global direction of east.
|
|
|
|
- **UP** = **Vector3(0, 1, 0)** --- Up unit vector.
|
|
|
|
- **DOWN** = **Vector3(0, -1, 0)** --- Down unit vector.
|
|
|
|
- **FORWARD** = **Vector3(0, 0, -1)** --- Forward unit vector. Represents the local direction of forward, and the global direction of north.
|
|
|
|
- **BACK** = **Vector3(0, 0, 1)** --- Back unit vector. Represents the local direction of back, and the global direction of south.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_Vector3_property_x:
|
|
|
|
- :ref:`float<class_float>` **x**
|
|
|
|
+-----------+---------+
|
|
| *Default* | ``0.0`` |
|
|
+-----------+---------+
|
|
|
|
The vector's X component. Also accessible by using the index position ``[0]``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_property_y:
|
|
|
|
- :ref:`float<class_float>` **y**
|
|
|
|
+-----------+---------+
|
|
| *Default* | ``0.0`` |
|
|
+-----------+---------+
|
|
|
|
The vector's Y component. Also accessible by using the index position ``[1]``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_property_z:
|
|
|
|
- :ref:`float<class_float>` **z**
|
|
|
|
+-----------+---------+
|
|
| *Default* | ``0.0`` |
|
|
+-----------+---------+
|
|
|
|
The vector's Z component. Also accessible by using the index position ``[2]``.
|
|
|
|
Constructor Descriptions
|
|
------------------------
|
|
|
|
.. _class_Vector3_constructor_Vector3:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **Vector3** **(** **)**
|
|
|
|
Constructs a default-initialized ``Vector3`` with all components set to ``0``.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`Vector3<class_Vector3>` from **)**
|
|
|
|
Constructs a ``Vector3`` as a copy of the given ``Vector3``.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`Vector3i<class_Vector3i>` from **)**
|
|
|
|
Constructs a new ``Vector3`` from :ref:`Vector3i<class_Vector3i>`.
|
|
|
|
----
|
|
|
|
- :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.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_Vector3_method_abs:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **abs** **(** **)** |const|
|
|
|
|
Returns a new vector with all components in absolute values (i.e. positive).
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_angle_to:
|
|
|
|
- :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
|
|
|
|
Returns the unsigned minimum angle to the given vector, in radians.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_bounce:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **bounce** **(** :ref:`Vector3<class_Vector3>` n **)** |const|
|
|
|
|
Returns the vector "bounced off" from a plane defined by the given normal.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_ceil:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **ceil** **(** **)** |const|
|
|
|
|
Returns a new vector with all components rounded up (towards positive infinity).
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_clamp:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_cross:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **cross** **(** :ref:`Vector3<class_Vector3>` with **)** |const|
|
|
|
|
Returns the cross product of this vector and ``b``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_cubic_interpolate:
|
|
|
|
- :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 vectors ``pre_a``, ``a``, ``b``, ``post_b`` (``a`` is current), by the given amount ``weight``. ``weight`` is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_direction_to:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **direction_to** **(** :ref:`Vector3<class_Vector3>` b **)** |const|
|
|
|
|
Returns the normalized vector pointing from this vector to ``b``. This is equivalent to using ``(b - a).normalized()``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_distance_squared_to:
|
|
|
|
- :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_Vector3>` b **)** |const|
|
|
|
|
Returns the squared distance between this vector and ``b``.
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_distance_to:
|
|
|
|
- :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_Vector3>` b **)** |const|
|
|
|
|
Returns the distance between this vector and ``b``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_dot:
|
|
|
|
- :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_Vector3>` with **)** |const|
|
|
|
|
Returns the dot product of this vector and ``b``. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
|
|
|
|
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)``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_floor:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **floor** **(** **)** |const|
|
|
|
|
Returns a new vector with all components rounded down (towards negative infinity).
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_inverse:
|
|
|
|
- :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)``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_is_equal_approx:
|
|
|
|
- :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Vector3<class_Vector3>` to **)** |const|
|
|
|
|
Returns ``true`` if this vector and ``v`` are approximately equal, by running :ref:`@GlobalScope.is_equal_approx<class_@GlobalScope_method_is_equal_approx>` on each component.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_is_normalized:
|
|
|
|
- :ref:`bool<class_bool>` **is_normalized** **(** **)** |const|
|
|
|
|
Returns ``true`` if the vector is normalized, ``false`` otherwise.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_length:
|
|
|
|
- :ref:`float<class_float>` **length** **(** **)** |const|
|
|
|
|
Returns the length (magnitude) of this vector.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_length_squared:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_lerp:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_limit_length:
|
|
|
|
- :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``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_max_axis:
|
|
|
|
- :ref:`int<class_int>` **max_axis** **(** **)** |const|
|
|
|
|
Returns the axis of the vector's largest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_X<class_Vector3_constant_AXIS_X>`.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_min_axis:
|
|
|
|
- :ref:`int<class_int>` **min_axis** **(** **)** |const|
|
|
|
|
Returns the axis of the vector's smallest value. See ``AXIS_*`` constants. If all components are equal, this method returns :ref:`AXIS_Z<class_Vector3_constant_AXIS_Z>`.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_move_toward:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **move_toward** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)** |const|
|
|
|
|
Moves this vector toward ``to`` by the fixed ``delta`` amount.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_normalized:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **normalized** **(** **)** |const|
|
|
|
|
Returns the vector scaled to unit length. Equivalent to ``v / v.length()``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_octahedron_decode:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **octahedron_decode** **(** :ref:`Vector2<class_Vector2>` uv **)** |static|
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_octahedron_encode:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **octahedron_encode** **(** **)** |const|
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_outer:
|
|
|
|
- :ref:`Basis<class_Basis>` **outer** **(** :ref:`Vector3<class_Vector3>` with **)** |const|
|
|
|
|
Returns the outer product with ``b``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_posmod:
|
|
|
|
- :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``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_posmodv:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_project:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **project** **(** :ref:`Vector3<class_Vector3>` b **)** |const|
|
|
|
|
Returns this vector projected onto another vector ``b``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_reflect:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **reflect** **(** :ref:`Vector3<class_Vector3>` n **)** |const|
|
|
|
|
Returns this vector reflected from a plane defined by the given normal.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_rotated:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **rotated** **(** :ref:`Vector3<class_Vector3>` by_axis, :ref:`float<class_float>` phi **)** |const|
|
|
|
|
Rotates this vector around a given axis by ``phi`` radians. The axis must be a normalized vector.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_round:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **round** **(** **)** |const|
|
|
|
|
Returns this vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_sign:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **sign** **(** **)** |const|
|
|
|
|
Returns a vector with each component set to one or negative one, depending on the signs of this vector's components, or zero if the component is zero, by calling :ref:`@GlobalScope.sign<class_@GlobalScope_method_sign>` on each component.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_signed_angle_to:
|
|
|
|
- :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``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_slerp:
|
|
|
|
- :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.
|
|
|
|
**Note:** Both vectors must be normalized.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_slide:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **slide** **(** :ref:`Vector3<class_Vector3>` n **)** |const|
|
|
|
|
Returns this vector slid along a plane defined by the given normal.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_method_snapped:
|
|
|
|
- :ref:`Vector3<class_Vector3>` **snapped** **(** :ref:`Vector3<class_Vector3>` step **)** |const|
|
|
|
|
Returns this vector with each component snapped to the nearest multiple of ``step``. This can also be used to round to an arbitrary number of decimals.
|
|
|
|
Operator Descriptions
|
|
---------------------
|
|
|
|
.. _class_Vector3_operator_neq_bool:
|
|
|
|
- :ref:`bool<class_bool>` **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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_mul_Vector3:
|
|
|
|
- :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)"
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Basis<class_Basis>` right **)**
|
|
|
|
Inversely transforms (multiplies) the ``Vector3`` by the given :ref:`Basis<class_Basis>` matrix.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Quaternion<class_Quaternion>` right **)**
|
|
|
|
Inversely transforms (multiplies) the ``Vector3`` by the given :ref:`Quaternion<class_Quaternion>`.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Transform3D<class_Transform3D>` right **)**
|
|
|
|
Inversely transforms (multiplies) the ``Vector3`` by the given :ref:`Transform3D<class_Transform3D>` transformation matrix.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`float<class_float>` right **)**
|
|
|
|
Multiplies each component of the ``Vector3`` by the given :ref:`float<class_float>`.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`int<class_int>` right **)**
|
|
|
|
Multiplies each component of the ``Vector3`` by the given :ref:`int<class_int>`.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_sum_Vector3:
|
|
|
|
- :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)"
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_dif_Vector3:
|
|
|
|
- :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)"
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_div_Vector3:
|
|
|
|
- :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)"
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator /** **(** :ref:`float<class_float>` right **)**
|
|
|
|
Divides each component of the ``Vector3`` by the given :ref:`float<class_float>`.
|
|
|
|
----
|
|
|
|
- :ref:`Vector3<class_Vector3>` **operator /** **(** :ref:`int<class_int>` right **)**
|
|
|
|
Divides each component of the ``Vector3`` by the given :ref:`int<class_int>`.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_lt_bool:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_lte_bool:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_eq_bool:
|
|
|
|
- :ref:`bool<class_bool>` **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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_gt_bool:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_gte_bool:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_idx_float:
|
|
|
|
- :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``.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_unplus_Vector3:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_Vector3_operator_unminus_Vector3:
|
|
|
|
- :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.)`
|