def __init__( self, size: Iterable[float], translation: Iterable[float] = (0, 0, 0), rotation: Transform3D.RotationType = (1, 0, 0, 0), *, transform_matrix: Optional[MatrixType] = None, category: Optional[str] = None, attributes: Optional[Dict[str, Any]] = None, instance: Optional[str] = None, ): Box3D.__init__(self, size, translation, rotation, transform_matrix=transform_matrix) _LabelBase.__init__(self, category, attributes, instance)
def test_rmul(self): transform = Transform3D([1, 2, 3], quaternion(0, 1, 0, 0)) quaternion_1 = quaternion(1, 2, 3, 4) box3d = Box3D(size=(1, 1, 1), translation=[1, 2, 3], rotation=quaternion(0, 1, 0, 0)) assert box3d.__rmul__(transform) == Box3D( size=(1, 1, 1), translation=[2, 0, 0], rotation=quaternion(-1, 0, 0, 0) ) assert box3d.__rmul__(quaternion_1) == Box3D( size=(1, 1, 1), translation=[1.7999999999999996, 2, 2.6], rotation=quaternion(-2, 1, 4, -3), ) assert box3d.__rmul__(1) == NotImplemented
def test_init(self): translation = Vector3D(1, 2, 3) rotation = quaternion(0, 1, 0, 0) size = Vector3D(1, 2, 3) box3d = Box3D(size, translation, rotation) assert box3d.translation == translation assert box3d.rotation == rotation assert box3d.size == size
def __rmul__(self: _T, other: Transform3D) -> _T: if isinstance(other, (Transform3D, quaternion)): labeled_box_3d = Box3D.__rmul__(self, other) if hasattr(self, "category"): labeled_box_3d.category = self.category if hasattr(self, "attributes"): labeled_box_3d.attributes = self.attributes if hasattr(self, "instance"): labeled_box_3d.instance = self.instance return labeled_box_3d return NotImplemented # type: ignore[unreachable]
def test_iou(self): box3d_1 = Box3D(size=[1, 1, 1]) box3d_2 = Box3D(size=[2, 2, 2]) assert Box3D.iou(box3d_1, box3d_2) == 0.125
def test_dumps(self): box3d = Box3D(Vector3D(1, 2, 3), Vector3D(1, 2, 3), quaternion(0, 1, 0, 0)) assert box3d.dumps() == _DATA_3D
def test_loads(self): box3d = Box3D.loads(_DATA_3D) assert box3d.translation == Vector3D(1, 2, 3) assert box3d.rotation == quaternion(0, 1, 0, 0) assert box3d.size == Vector3D(1, 2, 3)
def test_line_intersect(self): assert Box3D._line_intersect(4, 4, 1) == 3.0
def test_eq(self): box3d_1 = Box3D((1, 1, 1)) box3d_2 = Box3D((1, 1, 1)) box3d_3 = Box3D(size=(1, 1, 1), translation=[1, 2, 3]) assert (box3d_1 == box3d_2) == True assert (box3d_1 == box3d_3) == False