Base#
- class gbox.base.BoundingBox(lower_bound: ndarray | Sequence[float], upper_bound: ndarray | Sequence[float])#
Bases:
objectA class for performing n-dimensional bounding box operations
It is expexcted that the number of elements in the lower and upper bound are same. Also, the lower bound must be less than the upper bound.
- Parameters:
- lower_boundlist or tuple
Lower bounds of the box
- upper_boundlist or tuple
Upper bounds of the box
- Raises:
- ValueError
If lower bound and upper bound have different length If lower bounds are greater than upper bounds
Examples
>>> import numpy as np >>> lower_bound = [0, 0] >>> upper_bound = [10, 10] >>> bounding_box = BoundingBox(lower_bound, upper_bound) >>> bounding_box.lb array([ 0., 0.]) >>> bounding_box.ub array([10., 10.])
- p_min#
- p_max#
- has_point(p: PointND | Sequence[float]) bool#
Checks if the point ‘p’ is within the bounding box
- Returns:
- bool
True if ‘p’ is within the bounding box
- overlaps(bb: BoundingBox, include_bounds=False) bool#
Returns True, if two bounding boxes overlap
- Returns:
- bool
True if two bounding boxes overlap
- property volume: float32#
Returns the volume of the bounding box
- property vertices: PointArrayND#
- plot(axs, **plt_opt) None#
Plots the bounding box for two dimensional bounding box
- Raises:
- ValueError
If the dimension of the bounding box is not 2