class_vector3.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Vector3:
  4. Vector3
  5. =======
  6. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. Vector class, which performs basic 3D vector math operations.
  10. Member Functions
  11. ----------------
  12. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  13. | :ref:`Vector3<class_vector3>` | :ref:`Vector3<class_Vector3_Vector3>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |
  14. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Vector3<class_vector3>` | :ref:`abs<class_Vector3_abs>` **(** **)** |
  16. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector3_angle_to>` **(** :ref:`Vector3<class_vector3>` to **)** |
  18. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Vector3<class_vector3>` | :ref:`ceil<class_Vector3_ceil>` **(** **)** |
  20. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector3<class_vector3>` | :ref:`cross<class_Vector3_cross>` **(** :ref:`Vector3<class_vector3>` b **)** |
  22. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :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 **)** |
  24. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_distance_squared_to>` **(** :ref:`Vector3<class_vector3>` b **)** |
  26. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_distance_to>` **(** :ref:`Vector3<class_vector3>` b **)** |
  28. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`dot<class_Vector3_dot>` **(** :ref:`Vector3<class_vector3>` b **)** |
  30. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Vector3<class_vector3>` | :ref:`floor<class_Vector3_floor>` **(** **)** |
  32. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Vector3<class_vector3>` | :ref:`inverse<class_Vector3_inverse>` **(** **)** |
  34. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`length<class_Vector3_length>` **(** **)** |
  36. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_length_squared>` **(** **)** |
  38. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Vector3<class_vector3>` | :ref:`linear_interpolate<class_Vector3_linear_interpolate>` **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)** |
  40. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`max_axis<class_Vector3_max_axis>` **(** **)** |
  42. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`min_axis<class_Vector3_min_axis>` **(** **)** |
  44. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector3<class_vector3>` | :ref:`normalized<class_Vector3_normalized>` **(** **)** |
  46. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Vector3<class_vector3>` | :ref:`reflect<class_Vector3_reflect>` **(** :ref:`Vector3<class_vector3>` by **)** |
  48. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Vector3<class_vector3>` | :ref:`rotated<class_Vector3_rotated>` **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)** |
  50. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector3<class_vector3>` | :ref:`slide<class_Vector3_slide>` **(** :ref:`Vector3<class_vector3>` by **)** |
  52. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Vector3<class_vector3>` | :ref:`snapped<class_Vector3_snapped>` **(** :ref:`float<class_float>` by **)** |
  54. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. Member Variables
  56. ----------------
  57. - :ref:`float<class_float>` **x** - X component of the vector.
  58. - :ref:`float<class_float>` **y** - Y component of the vector.
  59. - :ref:`float<class_float>` **z** - Z component of the vector.
  60. Numeric Constants
  61. -----------------
  62. - **AXIS_X** = **0** --- Enumerated value for the X axis. Returned by functions like max_axis or min_axis.
  63. - **AXIS_Y** = **1** --- Enumerated value for the Y axis.
  64. - **AXIS_Z** = **2** --- Enumerated value for the Z axis.
  65. Description
  66. -----------
  67. Vector3 is one of the core classes of the engine, and includes several built-in helper functions to perform basic vector math operations.
  68. Member Function Description
  69. ---------------------------
  70. .. _class_Vector3_Vector3:
  71. - :ref:`Vector3<class_vector3>` **Vector3** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)**
  72. Returns a Vector3 with the given components.
  73. .. _class_Vector3_abs:
  74. - :ref:`Vector3<class_vector3>` **abs** **(** **)**
  75. Returns a new vector with all components in absolute values (i.e. positive).
  76. .. _class_Vector3_angle_to:
  77. - :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_vector3>` to **)**
  78. .. _class_Vector3_ceil:
  79. - :ref:`Vector3<class_vector3>` **ceil** **(** **)**
  80. Returns a new vector with all components rounded up.
  81. .. _class_Vector3_cross:
  82. - :ref:`Vector3<class_vector3>` **cross** **(** :ref:`Vector3<class_vector3>` b **)**
  83. Return the cross product with b.
  84. .. _class_Vector3_cubic_interpolate:
  85. - :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 **)**
  86. Perform a cubic interpolation between vectors pre_a, a, b, post_b (a is current), by the given amount (t).
  87. .. _class_Vector3_distance_squared_to:
  88. - :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_vector3>` b **)**
  89. 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.
  90. .. _class_Vector3_distance_to:
  91. - :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_vector3>` b **)**
  92. Return the distance to b.
  93. .. _class_Vector3_dot:
  94. - :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_vector3>` b **)**
  95. Return the dot product with b.
  96. .. _class_Vector3_floor:
  97. - :ref:`Vector3<class_vector3>` **floor** **(** **)**
  98. Returns a new vector with all components rounded down.
  99. .. _class_Vector3_inverse:
  100. - :ref:`Vector3<class_vector3>` **inverse** **(** **)**
  101. Returns the inverse of the vector. This is the same as Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )
  102. .. _class_Vector3_length:
  103. - :ref:`float<class_float>` **length** **(** **)**
  104. Return the length of the vector.
  105. .. _class_Vector3_length_squared:
  106. - :ref:`float<class_float>` **length_squared** **(** **)**
  107. 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.
  108. .. _class_Vector3_linear_interpolate:
  109. - :ref:`Vector3<class_vector3>` **linear_interpolate** **(** :ref:`Vector3<class_vector3>` b, :ref:`float<class_float>` t **)**
  110. Linearly interpolates the vector to a given one (b), by the given amount (t).
  111. .. _class_Vector3_max_axis:
  112. - :ref:`int<class_int>` **max_axis** **(** **)**
  113. Returns AXIS_X, AXIS_Y or AXIS_Z depending on which axis is the largest.
  114. .. _class_Vector3_min_axis:
  115. - :ref:`int<class_int>` **min_axis** **(** **)**
  116. Returns AXIS_X, AXIS_Y or AXIS_Z depending on which axis is the smallest.
  117. .. _class_Vector3_normalized:
  118. - :ref:`Vector3<class_vector3>` **normalized** **(** **)**
  119. Return a copy of the normalized vector to unit length. This is the same as v / v.length().
  120. .. _class_Vector3_reflect:
  121. - :ref:`Vector3<class_vector3>` **reflect** **(** :ref:`Vector3<class_vector3>` by **)**
  122. Like "slide", but reflects the Vector instead of continuing along the wall.
  123. .. _class_Vector3_rotated:
  124. - :ref:`Vector3<class_vector3>` **rotated** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)**
  125. Rotates the vector around some axis by phi radians.
  126. .. _class_Vector3_slide:
  127. - :ref:`Vector3<class_vector3>` **slide** **(** :ref:`Vector3<class_vector3>` by **)**
  128. Slides the vector along a wall.
  129. .. _class_Vector3_snapped:
  130. - :ref:`Vector3<class_vector3>` **snapped** **(** :ref:`float<class_float>` by **)**
  131. Return a copy of the vector, snapped to the lowest neared multiple.