is_intersection_box_box

compas_model.geometry.is_intersection_box_box(a, b)

Determine whether a box intersects another box.

Parameters:
acompas.geometry.Box

The first box.

bcompas.geometry.Box

The second box.

Returns:
bool

True if the boxes intersect. False otherwise.

Notes

The algorithm uses the method of separating axes, which states, for two convex objects: If there exists a line for which the intervals of projection of the two objects onto that line do not intersect, then the objects do not intersect.

The underlying theorem is described here [1].

For two oriented (bounding) boxes, this can be formulated in the form of 15 axis checks, based on the coordinate frames of the boxes, and the box coordinate extents.

References

Examples

>>> from compas.geometry import Box, Frame
>>> from compas_model.geometry import is_intersection_box_box
>>> A = Box(2, 2, 2)
>>> B = Box(1, 1, 1, frame=Frame(point=[1, 1, 1], xaxis=[1, 1, 0], yaxis=[-1, 1, 0]))
>>> is_intersection_box_box(A, B)
True