diff --git a/src/Math/Geometry/Rectangle.h b/src/Math/Geometry/Rectangle.h index 3a0d848a2..18fed134a 100644 --- a/src/Math/Geometry/Rectangle.h +++ b/src/Math/Geometry/Rectangle.h @@ -85,6 +85,12 @@ template class Rectangle { inline Vector2& bottomLeft() { return _bottomLeft; } inline constexpr Vector2 bottomLeft() const { return _bottomLeft; } /**< @overload */ + /** @brief Bottom right corner */ + inline constexpr Vector2 bottomRight() const { return {_topRight.x(), _bottomLeft.y()}; } /**< @overload */ + + /** @brief Top left corner */ + inline constexpr Vector2 topLeft() const { return {_bottomLeft.x(), _topRight.y()}; } /**< @overload */ + /** @brief Top right corner */ inline Vector2& topRight() { return _topRight; } inline constexpr Vector2 topRight() const { return _topRight; } /**< @overload */ diff --git a/src/Math/Geometry/Test/RectangleTest.cpp b/src/Math/Geometry/Test/RectangleTest.cpp index 362bed166..c5ab1f6e6 100644 --- a/src/Math/Geometry/Test/RectangleTest.cpp +++ b/src/Math/Geometry/Test/RectangleTest.cpp @@ -51,6 +51,9 @@ void RectangleTest::access() { CORRADE_COMPARE(crect.top(), 30); CORRADE_COMPARE(crect.left(), 34); CORRADE_COMPARE(crect.right(), 47); + + CORRADE_COMPARE(rect.topLeft(), Vector2i(34, 30)); + CORRADE_COMPARE(rect.bottomRight(), Vector2i(47, 23)); } void RectangleTest::compare() {