Bounding Box Utilities

py123d.geometry.utils.bounding_box_utils.get_corners_2d_factors()[source]

Returns the factors to compute the corners of a SE2 bounding box in the body frame.

The factors are defined such that multiplying them with the length and width of the bounding box yields the corner coordinates in the body frame.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Returns:

A (4, 2), indexed by Corners2DIndex and Point2DIndex, respectively.

py123d.geometry.utils.bounding_box_utils.get_corners_3d_factors()[source]

Returns the factors to compute the corners of a SE3 bounding box in the body frame.

The factors are defined such that multiplying them with the length, width, and height of the bounding box yields the corner coordinates in the body frame.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Returns:

A (8, 3), indexed by Corners3DIndex and Vector3DIndex, respectively.

py123d.geometry.utils.bounding_box_utils.bbse2_array_to_corners_array(bbse2)[source]

Converts an array of BoundingBoxSE2 objects to the 2D coordinates array of their corners.

Parameters:

bbse2 (ndarray[tuple[Any, ...], dtype[float64]]) – Array of SE2 bounding boxes, indexed by BoundingBoxSE2Index.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Returns:

Coordinates array of shape (…, 4, 2), indexed by Corners2DIndex and Point2DIndex, respectively.

py123d.geometry.utils.bounding_box_utils.bbse2_array_to_polygon_array(bbse2)[source]

Converts an array of BoundingBoxSE2 objects to an array of shapely Polygons.

Parameters:

bbse2 (ndarray[tuple[Any, ...], dtype[float64]]) – Array of SE2 bounding boxes, indexed by BoundingBoxSE2Index.

Return type:

ndarray[tuple[Any, ...], dtype[object_]]

Returns:

Array of shapely Polygons.

py123d.geometry.utils.bounding_box_utils.corners_2d_array_to_polygon_array(corners_array)[source]

Converts an array of 2D corners to an array of shapely Polygons. TODO: Consider removing this function?

Parameters:

corners_array (ndarray[tuple[Any, ...], dtype[float64]]) – Array of shape (…, 4, 2) where 4 is the number of corners.

Return type:

ndarray[tuple[Any, ...], dtype[object_]]

Returns:

Array of shapely Polygons.

py123d.geometry.utils.bounding_box_utils.bbse3_array_to_corners_array(bbse3_array)[source]

Converts an array of BoundingBoxSE3 objects to the 3D coordinates array of their corners.

Parameters:

bbse3_array (ndarray[tuple[Any, ...], dtype[float64]]) – Array of SE3 bounding boxes, indexed by BoundingBoxSE3Index.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Returns:

Coordinates array of shape (…, 8, 3), indexed by Corners3DIndex and Point3DIndex, respectively.

py123d.geometry.utils.bounding_box_utils.corners_array_to_3d_mesh(corners_array)[source]

Creates a triangular mesh representation of boxes defined by their corner points.

Parameters:

corners_array (ndarray[tuple[Any, ...], dtype[float64]]) – An array of shape (…, 8, 3) representing the corners of the boxes.

Return type:

Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[int32]]]

Returns:

A tuple containing the vertices and faces of the mesh.

py123d.geometry.utils.bounding_box_utils.corners_array_to_edge_lines(corners_array)[source]

Creates line segments representing the edges of boxes defined by their corner points.

Parameters:

corners_array (ndarray[tuple[Any, ...], dtype[float64]]) – An array of shape (…, 8, 3) representing the corners of the boxes.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Returns:

An array of shape (…, 12, 2, 3) representing the edge lines of the boxes.

py123d.geometry.utils.bounding_box_utils.points_3d_in_bbse3_array(points_3d, bbse3_array, z_axis_threshold=None)[source]

Check which points are inside each bounding box in a batch. See [1], [2] for reference.

Parameters:
Return type:

ndarray[tuple[Any, ...], dtype[bool]]

Returns:

Boolean array of shape (N, M) or (M,) indicating if each point the respective box.

References