aabb2d.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. Macros:
  14. 1. :c:func:`glm_aabb2d_size`
  15. Functions:
  16. 1. :c:func:`glm_aabb2d_copy`
  17. #. :c:func:`glm_aabb2d_zero`
  18. #. :c:func:`glm_aabb2d_transform`
  19. #. :c:func:`glm_aabb2d_merge`
  20. #. :c:func:`glm_aabb2d_crop`
  21. #. :c:func:`glm_aabb2d_crop_until`
  22. #. :c:func:`glm_aabb2d_invalidate`
  23. #. :c:func:`glm_aabb2d_isvalid`
  24. #. :c:func:`glm_aabb2d_diag`
  25. #. :c:func:`glm_aabb2d_sizev`
  26. #. :c:func:`glm_aabb2d_radius`
  27. #. :c:func:`glm_aabb2d_center`
  28. #. :c:func:`glm_aabb2d_aabb`
  29. #. :c:func:`glm_aabb2d_circle`
  30. #. :c:func:`glm_aabb2d_point`
  31. #. :c:func:`glm_aabb2d_contains`
  32. Functions documentation
  33. ~~~~~~~~~~~~~~~~~~~~~~~
  34. .. c:function:: void glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2])
  35. | copy all members of [aabb] to [dest]
  36. Parameters:
  37. | *[in]* **aabb** bounding box
  38. | *[out]* **dest** destination
  39. .. c:function:: void glm_aabb2d_zero(vec2 aabb[2])
  40. | makes all members of [aabb] 0.0f (zero)
  41. Parameters:
  42. | *[in, out]* **aabb** bounding box
  43. .. c:function:: void glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2])
  44. | apply transform to Axis-Aligned Bounding Box
  45. Parameters:
  46. | *[in]* **aabb** bounding box
  47. | *[in]* **m** transform matrix
  48. | *[out]* **dest** transformed bounding box
  49. .. c:function:: void glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2])
  50. | merges two AABB bounding box and creates new one
  51. two aabb must be in the same space
  52. Parameters:
  53. | *[in]* **aabb1** bounding box 1
  54. | *[in]* **aabb2** bounding box 2
  55. | *[out]* **dest** merged bounding box
  56. .. c:function:: void glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2])
  57. | crops a bounding box with another one.
  58. this could be useful for gettng a bbox which fits with view frustum and
  59. object bounding boxes. In this case you crop view frustum box with objects
  60. box
  61. Parameters:
  62. | *[in]* **aabb** bounding box 1
  63. | *[in]* **cropAabb** crop box
  64. | *[out]* **dest** cropped bounding box
  65. .. c:function:: void glm_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2])
  66. | crops a bounding box with another one.
  67. this could be useful for gettng a bbox which fits with view frustum and
  68. object bounding boxes. In this case you crop view frustum box with objects
  69. box
  70. Parameters:
  71. | *[in]* **aabb** bounding box
  72. | *[in]* **cropAabb** crop box
  73. | *[in]* **clampAabb** minimum box
  74. | *[out]* **dest** cropped bounding box
  75. .. c:function:: void glm_aabb2d_invalidate(vec2 aabb[2])
  76. | invalidate AABB min and max values
  77. | It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX
  78. Parameters:
  79. | *[in, out]* **aabb** bounding box
  80. .. c:function:: bool glm_aabb2d_isvalid(vec2 aabb[2])
  81. | check if AABB is valid or not
  82. Parameters:
  83. | *[in]* **aabb** bounding box
  84. Returns:
  85. returns true if aabb is valid otherwise false
  86. .. c:function:: float glm_aabb2d_diag(vec2 aabb[2])
  87. | distance between min and max
  88. Parameters:
  89. | *[in]* **aabb** bounding box
  90. Returns:
  91. distance between min - max
  92. .. c:function:: void glm_aabb2d_sizev(vec2 aabb[2], vec2 dest)
  93. | size vector of aabb
  94. Parameters:
  95. | *[in]* **aabb** bounding box
  96. | *[out]* **dest** size vector
  97. Returns:
  98. size vector of aabb max - min
  99. .. c:function:: float glm_aabb2d_radius(vec2 aabb[2])
  100. | radius of sphere which surrounds AABB
  101. Parameters:
  102. | *[in]* **aabb** bounding box
  103. .. c:function:: void glm_aabb2d_center(vec2 aabb[2], vec2 dest)
  104. | computes center point of AABB
  105. Parameters:
  106. | *[in]* **aabb** bounding box
  107. | *[out]* **dest** center of bounding box
  108. .. c:function:: bool glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2])
  109. | check if two AABB intersects
  110. Parameters:
  111. | *[in]* **aabb** bounding box
  112. | *[out]* **other** other bounding box
  113. .. c:function:: bool glm_aabb2d_circle(vec2 aabb[2], vec3 c)
  114. | check if AABB intersects with sphere
  115. | https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
  116. | Solid Box - Solid Sphere test.
  117. Parameters:
  118. | *[in]* **aabb** solid bounding box
  119. | *[out]* **c** solid circle
  120. .. c:function:: bool glm_aabb2d_point(vec2 aabb[2], vec2 point)
  121. | check if point is inside of AABB
  122. Parameters:
  123. | *[in]* **aabb** bounding box
  124. | *[out]* **point** point
  125. .. c:function:: bool glm_aabb2d_contains(vec2 aabb[2], vec2 other[2])
  126. | check if AABB contains other AABB
  127. Parameters:
  128. | *[in]* **aabb** bounding box
  129. | *[out]* **other** other bounding box