From d9a9eebe8bb7c437ac7eca9b7b3ebdc6c365f421 Mon Sep 17 00:00:00 2001 From: jan Date: Sat, 7 Mar 2026 07:08:36 -0800 Subject: [PATCH] [util] add get_aabb --- adze/util.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adze/util.py b/adze/util.py index d7af74f..247840d 100644 --- a/adze/util.py +++ b/adze/util.py @@ -310,6 +310,14 @@ def check_poly(poly: poly_t, check_connectivity: bool = True) -> None: raise AdzeError('Vertex graph is not 3-vertex-connected') +def get_aabb(poly: poly_t) -> tuple[NDArray, NDArray]: + """ + Get the axis-aligned bounding box of a polyhedron. + """ + if poly['vertices'].shape[0] == 0: + return numpy.zeros(3), numpy.zeros(3) + return poly['vertices'].min(axis=0), poly['vertices'].max(axis=0) + def plot_brep(brep: Sequence[dict[str, NDArray]]) -> None: """ Plot a boundary representation