class_aabb.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AABB.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AABB:
  6. AABB
  7. ====
  8. Axis-Aligned Bounding Box.
  9. Description
  10. -----------
  11. AABB consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
  12. Tutorials
  13. ---------
  14. - :doc:`../tutorials/math/index`
  15. Properties
  16. ----------
  17. +-------------------------------+-----------------------------------------------+------------------------+
  18. | :ref:`Vector3<class_Vector3>` | :ref:`end<class_AABB_property_end>` | ``Vector3( 0, 0, 0 )`` |
  19. +-------------------------------+-----------------------------------------------+------------------------+
  20. | :ref:`Vector3<class_Vector3>` | :ref:`position<class_AABB_property_position>` | ``Vector3( 0, 0, 0 )`` |
  21. +-------------------------------+-----------------------------------------------+------------------------+
  22. | :ref:`Vector3<class_Vector3>` | :ref:`size<class_AABB_property_size>` | ``Vector3( 0, 0, 0 )`` |
  23. +-------------------------------+-----------------------------------------------+------------------------+
  24. Methods
  25. -------
  26. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`AABB<class_AABB>` | :ref:`AABB<class_AABB_method_AABB>` **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` size **)** |
  28. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`AABB<class_AABB>` | :ref:`abs<class_AABB_method_abs>` **(** **)** |
  30. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`encloses<class_AABB_method_encloses>` **(** :ref:`AABB<class_AABB>` with **)** |
  32. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`AABB<class_AABB>` | :ref:`expand<class_AABB_method_expand>` **(** :ref:`Vector3<class_Vector3>` to_point **)** |
  34. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`get_area<class_AABB_method_get_area>` **(** **)** |
  36. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Vector3<class_Vector3>` | :ref:`get_endpoint<class_AABB_method_get_endpoint>` **(** :ref:`int<class_int>` idx **)** |
  38. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Vector3<class_Vector3>` | :ref:`get_longest_axis<class_AABB_method_get_longest_axis>` **(** **)** |
  40. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_longest_axis_index<class_AABB_method_get_longest_axis_index>` **(** **)** |
  42. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`get_longest_axis_size<class_AABB_method_get_longest_axis_size>` **(** **)** |
  44. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector3<class_Vector3>` | :ref:`get_shortest_axis<class_AABB_method_get_shortest_axis>` **(** **)** |
  46. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_shortest_axis_index<class_AABB_method_get_shortest_axis_index>` **(** **)** |
  48. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_shortest_axis_size<class_AABB_method_get_shortest_axis_size>` **(** **)** |
  50. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector3<class_Vector3>` | :ref:`get_support<class_AABB_method_get_support>` **(** :ref:`Vector3<class_Vector3>` dir **)** |
  52. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`AABB<class_AABB>` | :ref:`grow<class_AABB_method_grow>` **(** :ref:`float<class_float>` by **)** |
  54. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`has_no_area<class_AABB_method_has_no_area>` **(** **)** |
  56. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`has_no_surface<class_AABB_method_has_no_surface>` **(** **)** |
  58. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`has_point<class_AABB_method_has_point>` **(** :ref:`Vector3<class_Vector3>` point **)** |
  60. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`AABB<class_AABB>` | :ref:`intersection<class_AABB_method_intersection>` **(** :ref:`AABB<class_AABB>` with **)** |
  62. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`intersects<class_AABB_method_intersects>` **(** :ref:`AABB<class_AABB>` with **)** |
  64. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`intersects_plane<class_AABB_method_intersects_plane>` **(** :ref:`Plane<class_Plane>` plane **)** |
  66. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`bool<class_bool>` | :ref:`intersects_segment<class_AABB_method_intersects_segment>` **(** :ref:`Vector3<class_Vector3>` from, :ref:`Vector3<class_Vector3>` to **)** |
  68. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_AABB_method_is_equal_approx>` **(** :ref:`AABB<class_AABB>` aabb **)** |
  70. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`AABB<class_AABB>` | :ref:`merge<class_AABB_method_merge>` **(** :ref:`AABB<class_AABB>` with **)** |
  72. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  73. Property Descriptions
  74. ---------------------
  75. .. _class_AABB_property_end:
  76. - :ref:`Vector3<class_Vector3>` **end**
  77. +-----------+------------------------+
  78. | *Default* | ``Vector3( 0, 0, 0 )`` |
  79. +-----------+------------------------+
  80. Ending corner. This is calculated as ``position + size``. Setting this value will change the size.
  81. ----
  82. .. _class_AABB_property_position:
  83. - :ref:`Vector3<class_Vector3>` **position**
  84. +-----------+------------------------+
  85. | *Default* | ``Vector3( 0, 0, 0 )`` |
  86. +-----------+------------------------+
  87. Beginning corner. Typically has values lower than :ref:`end<class_AABB_property_end>`.
  88. ----
  89. .. _class_AABB_property_size:
  90. - :ref:`Vector3<class_Vector3>` **size**
  91. +-----------+------------------------+
  92. | *Default* | ``Vector3( 0, 0, 0 )`` |
  93. +-----------+------------------------+
  94. Size from :ref:`position<class_AABB_property_position>` to :ref:`end<class_AABB_property_end>`. Typically all components are positive.
  95. If the size is negative, you can use :ref:`abs<class_AABB_method_abs>` to fix it.
  96. Method Descriptions
  97. -------------------
  98. .. _class_AABB_method_AABB:
  99. - :ref:`AABB<class_AABB>` **AABB** **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` size **)**
  100. Constructs an ``AABB`` from a position and size.
  101. ----
  102. .. _class_AABB_method_abs:
  103. - :ref:`AABB<class_AABB>` **abs** **(** **)**
  104. Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive.
  105. ----
  106. .. _class_AABB_method_encloses:
  107. - :ref:`bool<class_bool>` **encloses** **(** :ref:`AABB<class_AABB>` with **)**
  108. Returns ``true`` if this ``AABB`` completely encloses another one.
  109. ----
  110. .. _class_AABB_method_expand:
  111. - :ref:`AABB<class_AABB>` **expand** **(** :ref:`Vector3<class_Vector3>` to_point **)**
  112. Returns this ``AABB`` expanded to include a given point.
  113. ----
  114. .. _class_AABB_method_get_area:
  115. - :ref:`float<class_float>` **get_area** **(** **)**
  116. Returns the volume of the ``AABB``.
  117. ----
  118. .. _class_AABB_method_get_endpoint:
  119. - :ref:`Vector3<class_Vector3>` **get_endpoint** **(** :ref:`int<class_int>` idx **)**
  120. Gets the position of the 8 endpoints of the ``AABB`` in space.
  121. ----
  122. .. _class_AABB_method_get_longest_axis:
  123. - :ref:`Vector3<class_Vector3>` **get_longest_axis** **(** **)**
  124. Returns the normalized longest axis of the ``AABB``.
  125. ----
  126. .. _class_AABB_method_get_longest_axis_index:
  127. - :ref:`int<class_int>` **get_longest_axis_index** **(** **)**
  128. Returns the index of the longest axis of the ``AABB`` (according to :ref:`Vector3<class_Vector3>`'s ``AXIS_*`` constants).
  129. ----
  130. .. _class_AABB_method_get_longest_axis_size:
  131. - :ref:`float<class_float>` **get_longest_axis_size** **(** **)**
  132. Returns the scalar length of the longest axis of the ``AABB``.
  133. ----
  134. .. _class_AABB_method_get_shortest_axis:
  135. - :ref:`Vector3<class_Vector3>` **get_shortest_axis** **(** **)**
  136. Returns the normalized shortest axis of the ``AABB``.
  137. ----
  138. .. _class_AABB_method_get_shortest_axis_index:
  139. - :ref:`int<class_int>` **get_shortest_axis_index** **(** **)**
  140. Returns the index of the shortest axis of the ``AABB`` (according to :ref:`Vector3<class_Vector3>`::AXIS\* enum).
  141. ----
  142. .. _class_AABB_method_get_shortest_axis_size:
  143. - :ref:`float<class_float>` **get_shortest_axis_size** **(** **)**
  144. Returns the scalar length of the shortest axis of the ``AABB``.
  145. ----
  146. .. _class_AABB_method_get_support:
  147. - :ref:`Vector3<class_Vector3>` **get_support** **(** :ref:`Vector3<class_Vector3>` dir **)**
  148. Returns the support point in a given direction. This is useful for collision detection algorithms.
  149. ----
  150. .. _class_AABB_method_grow:
  151. - :ref:`AABB<class_AABB>` **grow** **(** :ref:`float<class_float>` by **)**
  152. Returns a copy of the ``AABB`` grown a given amount of units towards all the sides.
  153. ----
  154. .. _class_AABB_method_has_no_area:
  155. - :ref:`bool<class_bool>` **has_no_area** **(** **)**
  156. Returns ``true`` if the ``AABB`` is flat or empty.
  157. ----
  158. .. _class_AABB_method_has_no_surface:
  159. - :ref:`bool<class_bool>` **has_no_surface** **(** **)**
  160. Returns ``true`` if the ``AABB`` is empty.
  161. ----
  162. .. _class_AABB_method_has_point:
  163. - :ref:`bool<class_bool>` **has_point** **(** :ref:`Vector3<class_Vector3>` point **)**
  164. Returns ``true`` if the ``AABB`` contains a point.
  165. ----
  166. .. _class_AABB_method_intersection:
  167. - :ref:`AABB<class_AABB>` **intersection** **(** :ref:`AABB<class_AABB>` with **)**
  168. Returns the intersection between two ``AABB``. An empty AABB (size 0,0,0) is returned on failure.
  169. ----
  170. .. _class_AABB_method_intersects:
  171. - :ref:`bool<class_bool>` **intersects** **(** :ref:`AABB<class_AABB>` with **)**
  172. Returns ``true`` if the ``AABB`` overlaps with another.
  173. ----
  174. .. _class_AABB_method_intersects_plane:
  175. - :ref:`bool<class_bool>` **intersects_plane** **(** :ref:`Plane<class_Plane>` plane **)**
  176. Returns ``true`` if the ``AABB`` is on both sides of a plane.
  177. ----
  178. .. _class_AABB_method_intersects_segment:
  179. - :ref:`bool<class_bool>` **intersects_segment** **(** :ref:`Vector3<class_Vector3>` from, :ref:`Vector3<class_Vector3>` to **)**
  180. Returns ``true`` if the ``AABB`` intersects the line segment between ``from`` and ``to``.
  181. ----
  182. .. _class_AABB_method_is_equal_approx:
  183. - :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`AABB<class_AABB>` aabb **)**
  184. Returns ``true`` if this ``AABB`` and ``aabb`` are approximately equal, by calling :ref:`@GDScript.is_equal_approx<class_@GDScript_method_is_equal_approx>` on each component.
  185. ----
  186. .. _class_AABB_method_merge:
  187. - :ref:`AABB<class_AABB>` **merge** **(** :ref:`AABB<class_AABB>` with **)**
  188. Returns a larger ``AABB`` that contains both this ``AABB`` and ``with``.
  189. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  190. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  191. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`