diff --git a/openmc/bounding_box.py b/openmc/bounding_box.py index e9f225fe1f..e297cc2251 100644 --- a/openmc/bounding_box.py +++ b/openmc/bounding_box.py @@ -13,10 +13,14 @@ class BoundingBox(tuple): Attributes ---------- - volume: float - The volume of the bounding box in cm3 center: numpy.array x, y, z coordinates of the center of the bounding box in cm. + lower_left: numpy.array + The x, y, z coordinates of the lower left corner of the bounding box + upper_right + The x, y, z coordinates of the upper right corner of the bounding box + volume: float + The volume of the bounding box in cm3 """ def __init__(self, corners): @@ -34,6 +38,16 @@ class BoundingBox(tuple): """The center x, y, z coordinates of the bounding box""" return (self.corners[0] + self.corners[1]) / 2 + @property + def lower_left(self): + """The x, y, z coordinates of the lower left corner of the bounding box""" + return self.corners[0] + + @property + def upper_right(self): + """The x, y, z coordinates of the upper right corner of the bounding box""" + return self.corners[1] + @property def volume(self): """The volume of the bounding box""" diff --git a/tests/unit_tests/test_bounding_box.py b/tests/unit_tests/test_bounding_box.py index 72c1baf486..419ada653b 100644 --- a/tests/unit_tests/test_bounding_box.py +++ b/tests/unit_tests/test_bounding_box.py @@ -26,6 +26,30 @@ def test_bounding_box_volume(bb, expected): assert bb.volume == expected +@pytest.mark.parametrize( + "bb, expected", + [ + (test_bb_1, np.array([-10.0, -20.0, -30.0])), + (test_bb_2, np.array([1.0, 2.0, 3.0])), + (test_bb_3, np.array([-10.0, -20.0, -30.0])), + ], +) +def test_bounding_lower_left(bb, expected): + assert np.array_equiv(expected, bb.lower_left) + + +@pytest.mark.parametrize( + "bb, expected", + [ + (test_bb_1, np.array([1.0, 2.0, 3.0])), + (test_bb_2, np.array([11.0, 22.0, 33.0])), + (test_bb_3, np.array([-1.0, -2.0, -3.0])), + ], +) +def test_bounding_upper_right(bb, expected): + assert np.array_equiv(expected, bb.upper_right) + + @pytest.mark.parametrize( "bb, expected", [