summaryrefslogtreecommitdiff
path: root/libs/cglm/docs/source/box.rst
blob: 7a388e2c6bac12ee87ea283efded11a2eca1bedf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
.. default-domain:: C

axis aligned bounding box (AABB)
================================================================================

Header: cglm/box.h

Some convenient functions provided for AABB.

**Definition of box:**

cglm defines box as two dimensional array of vec3.
The first element is **min** point and the second one is **max** point.
If you have another type e.g. struct or even another representation then you must
convert it before and after call cglm box function.

Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Functions:

1. :c:func:`glm_aabb_transform`
#. :c:func:`glm_aabb_merge`
#. :c:func:`glm_aabb_crop`
#. :c:func:`glm_aabb_crop_until`
#. :c:func:`glm_aabb_frustum`
#. :c:func:`glm_aabb_invalidate`
#. :c:func:`glm_aabb_isvalid`
#. :c:func:`glm_aabb_size`
#. :c:func:`glm_aabb_radius`
#. :c:func:`glm_aabb_center`
#. :c:func:`glm_aabb_aabb`
#. :c:func:`glm_aabb_sphere`
#. :c:func:`glm_aabb_point`
#. :c:func:`glm_aabb_contains`

Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~

.. c:function:: void  glm_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2])

    | apply transform to Axis-Aligned Bounding Box

    Parameters:
      | *[in]*  **box**   bounding box
      | *[in]*  **m**     transform matrix
      | *[out]* **dest**  transformed bounding box

.. c:function:: void  glm_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2])

    | merges two AABB bounding box and creates new one

    two box must be in same space, if one of box is in different space then
    you should consider to convert it's space by glm_box_space

    Parameters:
      | *[in]*  **box1** bounding box 1
      | *[in]*  **box2** bounding box 2
      | *[out]* **dest** merged bounding box

.. c:function:: void  glm_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2])

    | crops a bounding box with another one.

    this could be useful for gettng a bbox which fits with view frustum and
    object bounding boxes. In this case you crop view frustum box with objects
    box

    Parameters:
      | *[in]*  **box**      bounding box 1
      | *[in]*  **cropBox**  crop box
      | *[out]* **dest**     cropped bounding box

.. c:function:: void  glm_aabb_crop_until(vec3 box[2], vec3 cropBox[2], vec3 clampBox[2], vec3 dest[2])

    | crops a bounding box with another one.

    this could be useful for gettng a bbox which fits with view frustum and
    object bounding boxes. In this case you crop view frustum box with objects
    box

    Parameters:
      | *[in]*  **box**      bounding box
      | *[in]*  **cropBox**  crop box
      | *[in]*  **clampBox** miniumum box
      | *[out]* **dest**     cropped bounding box

.. c:function:: bool  glm_aabb_frustum(vec3 box[2], vec4 planes[6])

    | check if AABB intersects with frustum planes

    this could be useful for frustum culling using AABB.

    OPTIMIZATION HINT:
       if planes order is similar to LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
       then this method should run even faster because it would only use two
       planes if object is not inside the two planes
       fortunately cglm extracts planes as this order! just pass what you got!

    Parameters:
      | *[in]*   **box**     bounding box
      | *[out]*  **planes**  frustum planes

.. c:function:: void  glm_aabb_invalidate(vec3 box[2])

    | invalidate AABB min and max values

    | It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX

    Parameters:
      | *[in, out]*   **box**     bounding box

.. c:function:: bool  glm_aabb_isvalid(vec3 box[2])

    | check if AABB is valid or not

    Parameters:
      | *[in]*   **box**     bounding box

    Returns:
      returns true if aabb is valid otherwise false

.. c:function:: float  glm_aabb_size(vec3 box[2])

    | distance between of min and max

    Parameters:
      | *[in]*   **box**     bounding box

    Returns:
      distance between min - max

.. c:function:: float  glm_aabb_radius(vec3 box[2])

    | radius of sphere which surrounds AABB

    Parameters:
      | *[in]*   **box**     bounding box

.. c:function:: void  glm_aabb_center(vec3 box[2], vec3 dest)

    | computes center point of AABB

    Parameters:
      | *[in]*    **box**      bounding box
      | *[out]*   **dest**     center of bounding box

.. c:function:: bool  glm_aabb_aabb(vec3 box[2], vec3 other[2])

    | check if two AABB intersects

    Parameters:
      | *[in]*    **box**     bounding box
      | *[out]*   **other**   other bounding box

.. c:function:: bool  glm_aabb_sphere(vec3 box[2], vec4 s)

    | check if AABB intersects with sphere

    | https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
    | Solid Box - Solid Sphere test.

    Parameters:
      | *[in]*    **box**     solid bounding box
      | *[out]*   **s**       solid sphere

.. c:function:: bool  glm_aabb_point(vec3 box[2], vec3 point)

    | check if point is inside of AABB

    Parameters:
      | *[in]*    **box**     bounding box
      | *[out]*   **point**   point

.. c:function:: bool  glm_aabb_contains(vec3 box[2], vec3 other[2])

    | check if AABB contains other AABB

    Parameters:
      | *[in]*    **box**     bounding box
      | *[out]*   **other**   other bounding box