feat(tdcgal/plane/objects.py): add class Bbox2D
BREAKING CHANGE:
This commit is contained in:
parent
10334fa70e
commit
5905691cce
|
|
@ -481,3 +481,28 @@ class IsoRectangle2D(Shape2D, Iso_rectangle_2):
|
|||
# 返回第index个顶点
|
||||
def __getitem__(self, index: int) -> Point2D:
|
||||
return self.vertex(index)
|
||||
|
||||
|
||||
# 二维欧几里德平面中的边界框
|
||||
class Bbox2D(Shape2D, Bbox_2):
|
||||
def __init__(
|
||||
self,
|
||||
coord: Tuple[float, float, float, float] = None
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
二维欧几里德平面中的边界框Bbox2D的初始化方法
|
||||
|
||||
Args:
|
||||
coord: 边界框的坐标, 形式为(xmin, ymin, xmax, ymax)
|
||||
"""
|
||||
Shape2D.__init__(self, **kwargs)
|
||||
if coord is not None:
|
||||
Bbox_2.__init__(self, *coord)
|
||||
else:
|
||||
Bbox_2.__init__(self)
|
||||
|
||||
# 重载`repr`方法,返回Bbox2D的字符串表示
|
||||
def __repr__(self) -> str:
|
||||
return f"Bbox2D(xmin: {self.xmin}, ymin: {self.ymin}, xmax: {self.xmax}, ymax: {self.ymax})"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue