aabb2d.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. .. default-domain:: C
  2. 2d axis aligned bounding box (AABB)
  3. ================================================================================
  4. Header: cglm/aabb2d.h
  5. Some convenient functions provided for AABB.
  6. **Definition of aabb:**
  7. cglm defines an aabb as a two dimensional array of vec2's.
  8. The first element is the **min** point and the second one is the **max** point.
  9. If you have another type e.g. struct or even another representation then you must
  10. convert it before and after calling a cglm aabb2d function.
  11. Table of contents (click to go):
  12. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. Functions:
  14. 1. :c:func:`glm_aabb2d_copy`
  15. #. :c:func:`glm_aabb2d_transform`
  16. #. :c:func:`glm_aabb2d_merge`
  17. #. :c:func:`glm_aabb2d_crop`
  18. #. :c:func:`glm_aabb2d_crop_until`
  19. #. :c:func:`glm_aabb2d_invalidate`
  20. #. :c:func:`glm_aabb2d_isvalid`
  21. #. :c:func:`glm_aabb2d_size`
  22. #. :c:func:`glm_aabb2d_radius`
  23. #. :c:func:`glm_aabb2d_center`
  24. #. :c:func:`glm_aabb2d_aabb`
  25. #. :c:func:`glm_aabb2d_circle`
  26. #. :c:func:`glm_aabb2d_point`
  27. #. :c:func:`glm_aabb2d_contains`
  28. Functions documentation
  29. ~~~~~~~~~~~~~~~~~~~~~~~
  30. .. c:function:: void glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2])
  31. | copy all members of [aabb] to [dest]
  32. Parameters:
  33. | *[in]* **aabb** bounding box
  34. | *[out]* **dest** destination
  35. .. c:function:: void glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2])
  36. | apply transform to Axis-Aligned Bounding Box
  37. Parameters:
  38. | *[in]* **aabb** bounding box
  39. | *[in]* **m** transform matrix
  40. | *[out]* **dest** transformed bounding box
  41. .. c:function:: void glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2])
  42. | merges two AABB bounding box and creates new one
  43. two aabb must be in the same space
  44. Parameters:
  45. | *[in]* **aabb1** bounding box 1
  46. | *[in]* **aabb2** bounding box 2
  47. | *[out]* **dest** merged bounding box
  48. .. c:function:: void glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2])
  49. | crops a bounding box with another one.
  50. this could be useful for gettng a bbox which fits with view frustum and
  51. object bounding boxes. In this case you crop view frustum box with objects
  52. box
  53. Parameters:
  54. | *[in]* **aabb** bounding box 1
  55. | *[in]* **cropAabb** crop box
  56. | *[out]* **dest** cropped bounding box
  57. .. c:function:: void glm_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2])
  58. | crops a bounding box with another one.
  59. this could be useful for gettng a bbox which fits with view frustum and
  60. object bounding boxes. In this case you crop view frustum box with objects
  61. box
  62. Parameters:
  63. | *[in]* **aabb** bounding box
  64. | *[in]* **cropAabb** crop box
  65. | *[in]* **clampAabb** miniumum box
  66. | *[out]* **dest** cropped bounding box
  67. .. c:function:: void glm_aabb2d_invalidate(vec2 aabb[2])
  68. | invalidate AABB min and max values
  69. | It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX
  70. Parameters:
  71. | *[in, out]* **aabb** bounding box
  72. .. c:function:: bool glm_aabb2d_isvalid(vec2 aabb[2])
  73. | check if AABB is valid or not
  74. Parameters:
  75. | *[in]* **aabb** bounding box
  76. Returns:
  77. returns true if aabb is valid otherwise false
  78. .. c:function:: float glm_aabb2d_size(vec2 aabb[2])
  79. | distance between of min and max
  80. Parameters:
  81. | *[in]* **aabb** bounding box
  82. Returns:
  83. distance between min - max
  84. .. c:function:: float glm_aabb2d_radius(vec2 aabb[2])
  85. | radius of sphere which surrounds AABB
  86. Parameters:
  87. | *[in]* **aabb** bounding box
  88. .. c:function:: void glm_aabb2d_center(vec2 aabb[2], vec2 dest)
  89. | computes center point of AABB
  90. Parameters:
  91. | *[in]* **aabb** bounding box
  92. | *[out]* **dest** center of bounding box
  93. .. c:function:: bool glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2])
  94. | check if two AABB intersects
  95. Parameters:
  96. | *[in]* **aabb** bounding box
  97. | *[out]* **other** other bounding box
  98. .. c:function:: bool glm_aabb2d_circle(vec2 aabb[2], vec3 c)
  99. | check if AABB intersects with sphere
  100. | https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
  101. | Solid Box - Solid Sphere test.
  102. Parameters:
  103. | *[in]* **aabb** solid bounding box
  104. | *[out]* **c** solid circle
  105. .. c:function:: bool glm_aabb2d_point(vec2 aabb[2], vec2 point)
  106. | check if point is inside of AABB
  107. Parameters:
  108. | *[in]* **aabb** bounding box
  109. | *[out]* **point** point
  110. .. c:function:: bool glm_aabb2d_contains(vec2 aabb[2], vec2 other[2])
  111. | check if AABB contains other AABB
  112. Parameters:
  113. | *[in]* **aabb** bounding box
  114. | *[out]* **other** other bounding box