class_vector3.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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:`slide<class_Vector3_slide>` **(** :ref:`Vector3<class_vector3>` n **)** |
  59. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector3<class_vector3>` | :ref:`snapped<class_Vector3_snapped>` **(** :ref:`float<class_float>` by **)** |
  61. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Basis<class_basis>` | :ref:`to_diagonal_matrix<class_Vector3_to_diagonal_matrix>` **(** **)** |
  63. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. Member Variables
  65. ----------------
  66. .. _class_Vector3_x:
  67. - :ref:`float<class_float>` **x** - X component of the vector.
  68. .. _class_Vector3_y:
  69. - :ref:`float<class_float>` **y** - Y component of the vector.
  70. .. _class_Vector3_z:
  71. - :ref:`float<class_float>` **z** - Z component of the vector.
  72. Numeric Constants
  73. -----------------
  74. - **AXIS_X** = **0** --- Enumerated value for the X axis. Returned by functions like max_axis or min_axis.
  75. - **AXIS_Y** = **1** --- Enumerated value for the Y axis.
  76. - **AXIS_Z** = **2** --- Enumerated value for the Z axis.
  77. Description
  78. -----------
  79. Vector3 is one of the core classes of the engine, and includes several built-in helper functions to perform basic vector math operations.
  80. Member Function Description
  81. ---------------------------
  82. .. _class_Vector3_Vector3:
  83. - :ref:`Vector3<class_vector3>` **Vector3** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)**
  84. Returns a Vector3 with the given components.
  85. .. _class_Vector3_abs:
  86. - :ref:`Vector3<class_vector3>` **abs** **(** **)**
  87. Returns a new vector with all components in absolute values (i.e. positive).
  88. .. _class_Vector3_angle_to:
  89. - :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_vector3>` to **)**
  90. Returns the vector's minimum angle to the vector ``to``.
  91. .. _class_Vector3_bounce:
  92. - :ref:`Vector3<class_vector3>` **bounce** **(** :ref:`Vector3<class_vector3>` n **)**
  93. Bounce returns the vector "bounced off" from the given plane, specified by its normal vector.
  94. .. _class_Vector3_ceil:
  95. - :ref:`Vector3<class_vector3>` **ceil** **(** **)**
  96. Returns a new vector with all components rounded up.
  97. .. _class_Vector3_cross:
  98. - :ref:`Vector3<class_vector3>` **cross** **(** :ref:`Vector3<class_vector3>` b **)**
  99. Returns the cross product with ``b``.
  100. .. _class_Vector3_cubic_interpolate:
  101. - :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 **)**
  102. 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.
  103. .. _class_Vector3_distance_squared_to:
  104. - :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_vector3>` b **)**
  105. Returns the squared distance to ``b``. Prefer this function over distance_to if you need to sort vectors or need the squared distance for some formula.
  106. .. _class_Vector3_distance_to:
  107. - :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_vector3>` b **)**
  108. Returns the distance to b.
  109. .. _class_Vector3_dot:
  110. - :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_vector3>` b **)**
  111. Returns the dot product with b.
  112. .. _class_Vector3_floor:
  113. - :ref:`Vector3<class_vector3>` **floor** **(** **)**
  114. Returns a new vector with all components rounded down.
  115. .. _class_Vector3_inverse:
  116. - :ref:`Vector3<class_vector3>` **inverse** **(** **)**
  117. Returns the inverse of the vector. This is the same as Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )
  118. .. _class_Vector3_is_normalized:
  119. - :ref:`bool<class_bool>` **is_normalized** **(** **)**
  120. Returns whether the vector is normalized or not.
  121. .. _class_Vector3_length:
  122. - :ref:`float<class_float>` **length** **(** **)**
  123. Returns the length of the vector.
  124. .. _class_Vector3_length_squared:
  125. - :ref:`float<class_float>` **length_squared** **(** **)**
  126. Returns the length of the vector, squared. Prefer this function over "length" if you need to sort vectors or need the squared length for some formula.
  127. .. _class_Vector3_linear_interpolate:
  128. - :ref:`Vector3<class_vector3>` **linear_interpolate** **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)**
  129. Linearly interpolates the vector to a given one (b), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is.
  130. .. _class_Vector3_max_axis:
  131. - :ref:`int<class_int>` **max_axis** **(** **)**
  132. Returns AXIS_X, AXIS_Y or AXIS_Z depending on which axis is the largest.
  133. .. _class_Vector3_min_axis:
  134. - :ref:`int<class_int>` **min_axis** **(** **)**
  135. Returns AXIS_X, AXIS_Y or AXIS_Z depending on which axis is the smallest.
  136. .. _class_Vector3_normalized:
  137. - :ref:`Vector3<class_vector3>` **normalized** **(** **)**
  138. Returns a copy of the normalized vector to unit length. This is the same as v / v.length().
  139. .. _class_Vector3_outer:
  140. - :ref:`Basis<class_basis>` **outer** **(** :ref:`Vector3<class_vector3>` b **)**
  141. Returns the outer product with b.
  142. .. _class_Vector3_reflect:
  143. - :ref:`Vector3<class_vector3>` **reflect** **(** :ref:`Vector3<class_vector3>` n **)**
  144. Reflects the vector along the given plane, specified by its normal vector.
  145. .. _class_Vector3_rotated:
  146. - :ref:`Vector3<class_vector3>` **rotated** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)**
  147. Rotates the vector around some axis by phi radians. The axis must be a normalized vector.
  148. .. _class_Vector3_slide:
  149. - :ref:`Vector3<class_vector3>` **slide** **(** :ref:`Vector3<class_vector3>` n **)**
  150. Slide returns the component of the vector along the given plane, specified by its normal vector.
  151. .. _class_Vector3_snapped:
  152. - :ref:`Vector3<class_vector3>` **snapped** **(** :ref:`float<class_float>` by **)**
  153. Returns a copy of the vector, snapped to the lowest neared multiple.
  154. .. _class_Vector3_to_diagonal_matrix:
  155. - :ref:`Basis<class_basis>` **to_diagonal_matrix** **(** **)**
  156. Returns a diagonal matrix with the vector as main diagonal.