# Compute bounding box¶

Primal’s bounding boxes are rectangular right prisms. That is, they are boxes where neighboring walls are at right angles.

The BoundingBox class represents an axis-aligned bounding box, which has two walls perpendicular to the X-axis, two perpendicular to the Y-axis, and two perpendicular to the Z-axis. This is sufficient for many computations; range and intersection operations tend to be fast.

The OrientedBoundingBox class can be oriented in any way with respect to the coordinate axes. This can provide a tighter fit to the bounded data, but construction, intersection, and range calculation are more costly.

Here a group of points is used to create both an (axis-aligned) BoundingBox and an OrientedBoundingBox. The points are drawn in blue, the BoundingBox in black, and the OrientedBoundingBox in orange.

```
#include "axom/primal/operators/compute_bounding_box.hpp"
```

```
// An array of Points to include in the bounding boxes
const int nbr_points = 6;
PointType data[nbr_points] = {PointType {0.6, 1.2, 1.0},
PointType {1.3, 1.6, 1.8},
PointType {2.9, 2.4, 2.3},
PointType {3.2, 3.5, 3.0},
PointType {3.6, 3.2, 4.0},
PointType {4.3, 4.3, 4.5}};
// A BoundingBox constructor takes an array of Point objects
BoundingBoxType bbox(data, nbr_points);
// Make an OrientedBoundingBox
OrientedBoundingBoxType obbox = compute_oriented_bounding_box(data, nbr_points);
```

Primal also provides a `merge_boxes()`

function to produce a bounding box that
contains two input bounding boxes. This is available for client codes to use and
also supports the operation of the BVHTree class.