Bounding Boxes

class py123d.geometry.BoundingBoxSE2[source]

Rotated bounding box in 2D defined by a center PoseSE2, length and width.

Example

>>> from py123d.geometry import PoseSE2, BoundingBoxSE2
>>> bbox = BoundingBoxSE2(center_se2=PoseSE2(1.0, 2.0, 0.5), length=4.0, width=2.0)
>>> bbox.array
array([1. , 2. , 0.5, 4. , 2. ])
>>> bbox.corners_array.shape
(4, 2)
>>> bbox.shapely_polygon.area
8.0

Public Data Attributes:

center_se2

The center of the bounding box as a PoseSE2 instance.

length

Length of the bounding box along the x-axis in the local frame.

width

Width of the bounding box along the y-axis in the local frame.

array

The numpy array representation of shape (5,), indexed by BoundingBoxSE2Index.

corners_array

The corner points of the bounding box as a numpy array of shape (4, 2), indexed by Corners2DIndex and Point2DIndex, respectively.

corners_dict

Dictionary of corner points of the bounding box, mapping Corners2DIndex to Point2D instances.

shapely_polygon

The shapely polygon representation of the bounding box.

bounding_box_se2

The BoundingBoxSE2 instance itself.

Inherited from ArrayMixin

array

The array representation of the geometric entity.

shape

Return the shape of the array.

Public Methods:

from_array(array[, copy])

Create a BoundingBoxSE2 from a (5,) numpy array, indexed by BoundingBoxSE2Index.

Inherited from ArrayMixin

from_array(array[, copy])

Create an instance from a NumPy array.

from_list(values)

Create an instance from a list of values.

tolist()

Convert the array to a Python list.

to_list()

Convert the array to a Python list.

copy()

Return a copy of the object with a copied array.


__init__(center_se2, length, width)[source]

Initialize BoundingBoxSE2 with PoseSE2 center, length and width.

Parameters:
  • center_se2 (PoseSE2) – Center of the bounding box as a PoseSE2 instance.

  • length (float) – Length of the bounding box along the x-axis in the local frame.

  • width (float) – Width of the bounding box along the y-axis in the local frame.

classmethod from_array(array, copy=True)[source]

Create a BoundingBoxSE2 from a (5,) numpy array, indexed by BoundingBoxSE2Index.

Parameters:
  • array (ndarray[tuple[Any, ...], dtype[float64]]) – A 1D numpy array containing the bounding box parameters.

  • copy (bool) – Whether to copy the input array. Defaults to True.

Return type:

BoundingBoxSE2

Returns:

A BoundingBoxSE2 instance.

property center_se2: PoseSE2

The center of the bounding box as a PoseSE2 instance.

property length: float

Length of the bounding box along the x-axis in the local frame.

property width: float

Width of the bounding box along the y-axis in the local frame.

property array: ndarray[tuple[Any, ...], dtype[float64]]

The numpy array representation of shape (5,), indexed by BoundingBoxSE2Index.

property corners_array: ndarray[tuple[Any, ...], dtype[float64]]

The corner points of the bounding box as a numpy array of shape (4, 2), indexed by Corners2DIndex and Point2DIndex, respectively.

property corners_dict: Dict[Corners2DIndex, Point2D]

Dictionary of corner points of the bounding box, mapping Corners2DIndex to Point2D instances.

property shapely_polygon: Polygon

The shapely polygon representation of the bounding box.

property bounding_box_se2: BoundingBoxSE2

The BoundingBoxSE2 instance itself.

copy()

Return a copy of the object with a copied array.

Return type:

ArrayMixin

classmethod from_list(values)

Create an instance from a list of values.

Return type:

Self

Parameters:

values (list)

property shape: tuple

Return the shape of the array.

to_list()

Convert the array to a Python list.

Return type:

list

tolist()

Convert the array to a Python list.

Return type:

list

class py123d.geometry.BoundingBoxSE3[source]

Rotated bounding box in 3D defined by center with quaternion rotation (PoseSE3), length, width and height.

Example

>>> from py123d.geometry import PoseSE3, BoundingBoxSE3
>>> bbox = BoundingBoxSE3(center_se3=PoseSE3(1.0, 2.0, 3.0, 1.0, 0.0, 0.0, 0.0), length=4.0, width=2.0, height=1.5)
>>> bbox.array
array([1. , 2. , 3. , 1. , 0. , 0. , 0. , 4. , 2. , 1.5])
>>> bbox.bounding_box_se2.array
array([1., 2., 0., 4., 2.])
>>> bbox.shapely_polygon.area
8.0

Public Data Attributes:

center_se3

The center of the bounding box as a PoseSE3 instance.

center_se2

The center of the bounding box as a PoseSE2 instance.

length

The length of the bounding box along the x-axis in the local frame.

width

The width of the bounding box along the y-axis in the local frame.

height

The height of the bounding box along the z-axis in the local frame.

array

The numpy array representation of shape (10,), indexed by BoundingBoxSE3Index.

bounding_box_se2

The SE2 projection BoundingBoxSE2 of the bounding box.

corners_array

The corner points of the bounding box as a numpy array of shape (8, 3), indexed by Corners3DIndex and Point3DIndex, respectively.

corners_dict

Dictionary of corner points of the bounding box, mapping Corners3DIndex to Point3D instances.

shapely_polygon

The shapely polygon representation of the SE2 projection of the bounding box.

Inherited from ArrayMixin

array

The array representation of the geometric entity.

shape

Return the shape of the array.

Public Methods:

from_array(array[, copy])

Create a BoundingBoxSE3 from a (10,) numpy array, indexed by BoundingBoxSE3Index.

Inherited from ArrayMixin

from_array(array[, copy])

Create an instance from a NumPy array.

from_list(values)

Create an instance from a list of values.

tolist()

Convert the array to a Python list.

to_list()

Convert the array to a Python list.

copy()

Return a copy of the object with a copied array.


__init__(center_se3, length, width, height)[source]

Initialize BoundingBoxSE3 with PoseSE3 center, length, width and height.

Parameters:
  • center_se3 (PoseSE3) – Center of the bounding box as a PoseSE3 instance.

  • length (float) – Length of the bounding box along the x-axis in the local frame.

  • width (float) – Width of the bounding box along the y-axis in the local frame.

  • height (float) – Height of the bounding box along the z-axis in the local frame.

classmethod from_array(array, copy=True)[source]

Create a BoundingBoxSE3 from a (10,) numpy array, indexed by BoundingBoxSE3Index.

Parameters:
  • array (ndarray[tuple[Any, ...], dtype[float64]]) – A (10,) numpy array containing the bounding box parameters.

  • copy (bool) – Whether to copy the input array. Defaults to True.

Return type:

BoundingBoxSE3

Returns:

A BoundingBoxSE3 instance.

property center_se3: PoseSE3

The center of the bounding box as a PoseSE3 instance.

property center_se2: PoseSE2

The center of the bounding box as a PoseSE2 instance.

property length: float

The length of the bounding box along the x-axis in the local frame.

property width: float

The width of the bounding box along the y-axis in the local frame.

property height: float

The height of the bounding box along the z-axis in the local frame.

property array: ndarray[tuple[Any, ...], dtype[float64]]

The numpy array representation of shape (10,), indexed by BoundingBoxSE3Index.

property bounding_box_se2: BoundingBoxSE2

The SE2 projection BoundingBoxSE2 of the bounding box.

property corners_array: ndarray[tuple[Any, ...], dtype[float64]]

The corner points of the bounding box as a numpy array of shape (8, 3), indexed by Corners3DIndex and Point3DIndex, respectively.

property corners_dict: Dict[Corners3DIndex, Point3D]

Dictionary of corner points of the bounding box, mapping Corners3DIndex to Point3D instances.

property shapely_polygon: Polygon

The shapely polygon representation of the SE2 projection of the bounding box.

copy()

Return a copy of the object with a copied array.

Return type:

ArrayMixin

classmethod from_list(values)

Create an instance from a list of values.

Return type:

Self

Parameters:

values (list)

property shape: tuple

Return the shape of the array.

to_list()

Convert the array to a Python list.

Return type:

list

tolist()

Convert the array to a Python list.

Return type:

list