Base#
- class gbox.base.BoundingBox(lower_bound: ndarray | Sequence[float], upper_bound: ndarray | Sequence[float])#
Bases:
PlotMixinA 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 perimeter: float32#
- property vertices: PointArrayND#
- get_patch(**rect_patch_kwargs) Patch#
Subclasses must implement this method to return the appropriate matplotlib patch. Any kwargs can be used to control styling.