Bounding Boxes¤
compas_model.geometry.bbox
¤
Functions:¤
aabb_from_points
¤
Compute an axis-aligned bounding box from points.
Parameters:
Returns:
-
Box–The axis-aligned bounding box. Degenerate boxes are permitted for planar, linear, and single-point inputs.
Raises:
-
ValueError–If no points are provided.
combine_aabbs
¤
combine_obbs
¤
pca_box
¤
Compute an oriented bounding box for the given points based on the principle components of the XYZ coordinates.
Parameters:
Returns:
-
Box–The oriented bounding box.
Notes
The resulting box is not (necessarily) a minimum bounding volume. The box is computed by reprojecting the points onto the principle component vectors to identify the box extents. The origin of the box is found as the centroid of the points, corrected with the box extents.
Examples:
>>> import random
>>> import math
>>> from compas.geometry import Pointcloud
>>> from compas.geometry import Translation, Rotation
>>> from compas_model.geometry import pca_box
Construct a cloud of points.
Construct a random translation.
>>> vector = [10 * random.random(), 10 * random.random(), 10 * random.random()]
>>> T = Translation.from_vector(vector)
Construct a random rotation.
>>> axis = [random.random(), random.random(), random.random()]
>>> angle = math.radians(random.random() * 180)
>>> R = Rotation.from_axis_and_angle(axis, angle)
Transform the cloud and compute its PCA box.
Check.