class_vector3.rst 18 KB

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