class_vector3.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Vector3.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Vector3:
  5. Vector3
  6. =======
  7. **Category:** Built-In Types
  8. Brief Description
  9. -----------------
  10. Vector class, which performs basic 3D vector math operations.
  11. Member Functions
  12. ----------------
  13. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`Vector3<class_vector3>` | :ref:`Vector3<class_Vector3_Vector3>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |
  15. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`Vector3<class_vector3>` | :ref:`abs<class_Vector3_abs>` **(** **)** |
  17. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector3_angle_to>` **(** :ref:`Vector3<class_vector3>` to **)** |
  19. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Vector3<class_vector3>` | :ref:`bounce<class_Vector3_bounce>` **(** :ref:`Vector3<class_vector3>` n **)** |
  21. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Vector3<class_vector3>` | :ref:`ceil<class_Vector3_ceil>` **(** **)** |
  23. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Vector3<class_vector3>` | :ref:`cross<class_Vector3_cross>` **(** :ref:`Vector3<class_vector3>` b **)** |
  25. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Vector3<class_vector3>` | :ref:`cubic_interpolate<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>` t **)** |
  27. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_distance_squared_to>` **(** :ref:`Vector3<class_vector3>` b **)** |
  29. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_distance_to>` **(** :ref:`Vector3<class_vector3>` b **)** |
  31. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`dot<class_Vector3_dot>` **(** :ref:`Vector3<class_vector3>` b **)** |
  33. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Vector3<class_vector3>` | :ref:`floor<class_Vector3_floor>` **(** **)** |
  35. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Vector3<class_vector3>` | :ref:`inverse<class_Vector3_inverse>` **(** **)** |
  37. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector3_is_normalized>` **(** **)** |
  39. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`length<class_Vector3_length>` **(** **)** |
  41. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_length_squared>` **(** **)** |
  43. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Vector3<class_vector3>` | :ref:`linear_interpolate<class_Vector3_linear_interpolate>` **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)** |
  45. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`max_axis<class_Vector3_max_axis>` **(** **)** |
  47. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`min_axis<class_Vector3_min_axis>` **(** **)** |
  49. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Vector3<class_vector3>` | :ref:`normalized<class_Vector3_normalized>` **(** **)** |
  51. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Basis<class_basis>` | :ref:`outer<class_Vector3_outer>` **(** :ref:`Vector3<class_vector3>` b **)** |
  53. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Vector3<class_vector3>` | :ref:`reflect<class_Vector3_reflect>` **(** :ref:`Vector3<class_vector3>` n **)** |
  55. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Vector3<class_vector3>` | :ref:`rotated<class_Vector3_rotated>` **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)** |
  57. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Vector3<class_vector3>` | :ref:`round<class_Vector3_round>` **(** **)** |
  59. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector3<class_vector3>` | :ref:`slerp<class_Vector3_slerp>` **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)** |
  61. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Vector3<class_vector3>` | :ref:`slide<class_Vector3_slide>` **(** :ref:`Vector3<class_vector3>` n **)** |
  63. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Vector3<class_vector3>` | :ref:`snapped<class_Vector3_snapped>` **(** :ref:`Vector3<class_vector3>` by **)** |
  65. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Basis<class_basis>` | :ref:`to_diagonal_matrix<class_Vector3_to_diagonal_matrix>` **(** **)** |
  67. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. Member Variables
  69. ----------------
  70. .. _class_Vector3_x:
  71. - :ref:`float<class_float>` **x** - The vector's x component.
  72. .. _class_Vector3_y:
  73. - :ref:`float<class_float>` **y** - The vector's y component.
  74. .. _class_Vector3_z:
  75. - :ref:`float<class_float>` **z** - The vector's z component.
  76. Numeric Constants
  77. -----------------
  78. - **AXIS_X** = **0** --- Enumerated value for the X axis. Returned by :ref:`max_axis<class_Vector3_max_axis>` and :ref:`min_axis<class_Vector3_min_axis>`.
  79. - **AXIS_Y** = **1** --- Enumerated value for the Y axis.
  80. - **AXIS_Z** = **2** --- Enumerated value for the Z axis.
  81. Description
  82. -----------
  83. Vector3 is one of the core classes of the engine, and includes several built-in helper functions to perform basic vector math operations.
  84. Member Function Description
  85. ---------------------------
  86. .. _class_Vector3_Vector3:
  87. - :ref:`Vector3<class_vector3>` **Vector3** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)**
  88. Returns a Vector3 with the given components.
  89. .. _class_Vector3_abs:
  90. - :ref:`Vector3<class_vector3>` **abs** **(** **)**
  91. Returns a new vector with all components in absolute values (i.e. positive).
  92. .. _class_Vector3_angle_to:
  93. - :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_vector3>` to **)**
  94. Returns the minimum angle to the given vector.
  95. .. _class_Vector3_bounce:
  96. - :ref:`Vector3<class_vector3>` **bounce** **(** :ref:`Vector3<class_vector3>` n **)**
  97. Returns the vector "bounced off" from a plane defined by the given normal.
  98. .. _class_Vector3_ceil:
  99. - :ref:`Vector3<class_vector3>` **ceil** **(** **)**
  100. Returns a new vector with all components rounded up.
  101. .. _class_Vector3_cross:
  102. - :ref:`Vector3<class_vector3>` **cross** **(** :ref:`Vector3<class_vector3>` b **)**
  103. Returns the cross product with ``b``.
  104. .. _class_Vector3_cubic_interpolate:
  105. - :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>` t **)**
  106. Performs a cubic interpolation between vectors ``pre_a``, ``a``, ``b``, ``post_b`` (``a`` is current), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is.
  107. .. _class_Vector3_distance_squared_to:
  108. - :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_vector3>` b **)**
  109. Returns the squared distance to ``b``. Prefer this function over :ref:`distance_to<class_Vector3_distance_to>` if you need to sort vectors or need the squared distance for some formula.
  110. .. _class_Vector3_distance_to:
  111. - :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_vector3>` b **)**
  112. Returns the distance to ``b``.
  113. .. _class_Vector3_dot:
  114. - :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_vector3>` b **)**
  115. Returns the dot product with ``b``.
  116. .. _class_Vector3_floor:
  117. - :ref:`Vector3<class_vector3>` **floor** **(** **)**
  118. Returns a new vector with all components rounded down.
  119. .. _class_Vector3_inverse:
  120. - :ref:`Vector3<class_vector3>` **inverse** **(** **)**
  121. Returns the inverse of the vector. This is the same as ``Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )``.
  122. .. _class_Vector3_is_normalized:
  123. - :ref:`bool<class_bool>` **is_normalized** **(** **)**
  124. Returns ``true`` if the vector is normalized.
  125. .. _class_Vector3_length:
  126. - :ref:`float<class_float>` **length** **(** **)**
  127. Returns the vector's length.
  128. .. _class_Vector3_length_squared:
  129. - :ref:`float<class_float>` **length_squared** **(** **)**
  130. Returns the vector's length squared. Prefer this function over :ref:`length<class_Vector3_length>` if you need to sort vectors or need the squared length for some formula.
  131. .. _class_Vector3_linear_interpolate:
  132. - :ref:`Vector3<class_vector3>` **linear_interpolate** **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)**
  133. Returns the result of the linear interpolation between this vector and ``b`` by amount ``t``. ``t`` is in the range of ``0.0 - 1.0``, a percentage of how far along the interpolation is.
  134. .. _class_Vector3_max_axis:
  135. - :ref:`int<class_int>` **max_axis** **(** **)**
  136. Returns the axis of the vector's largest value. See ``AXIS_*`` constants.
  137. .. _class_Vector3_min_axis:
  138. - :ref:`int<class_int>` **min_axis** **(** **)**
  139. Returns the axis of the vector's smallest value. See ``AXIS_*`` constants.
  140. .. _class_Vector3_normalized:
  141. - :ref:`Vector3<class_vector3>` **normalized** **(** **)**
  142. Returns the vector scaled to unit length. Equivalent to ``v / v.length()``.
  143. .. _class_Vector3_outer:
  144. - :ref:`Basis<class_basis>` **outer** **(** :ref:`Vector3<class_vector3>` b **)**
  145. Returns the outer product with ``b``.
  146. .. _class_Vector3_reflect:
  147. - :ref:`Vector3<class_vector3>` **reflect** **(** :ref:`Vector3<class_vector3>` n **)**
  148. Returns the vector reflected from a plane defined by the given normal.
  149. .. _class_Vector3_rotated:
  150. - :ref:`Vector3<class_vector3>` **rotated** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)**
  151. Rotates the vector around a given axis by ``phi`` radians. The axis must be a normalized vector.
  152. .. _class_Vector3_round:
  153. - :ref:`Vector3<class_vector3>` **round** **(** **)**
  154. .. _class_Vector3_slerp:
  155. - :ref:`Vector3<class_vector3>` **slerp** **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)**
  156. Returns the result of SLERP between this vector and "b", by amount "t". "t" should be a float of 0.0-1.0, a percentage of how far along the interpolation is.
  157. Both vectors need to be normalized.
  158. .. _class_Vector3_slide:
  159. - :ref:`Vector3<class_vector3>` **slide** **(** :ref:`Vector3<class_vector3>` n **)**
  160. Returns the component of the vector along a plane defined by the given normal.
  161. .. _class_Vector3_snapped:
  162. - :ref:`Vector3<class_vector3>` **snapped** **(** :ref:`Vector3<class_vector3>` by **)**
  163. Returns a copy of the vector, snapped to the lowest neared multiple.
  164. .. _class_Vector3_to_diagonal_matrix:
  165. - :ref:`Basis<class_basis>` **to_diagonal_matrix** **(** **)**
  166. Returns a diagonal matrix with the vector as main diagonal.