From e506951829eb3befa46b888dffefd980e448e87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 31 Dec 2012 18:52:53 +0100 Subject: [PATCH] Math: functions for bottom right and top left Rectangle corners. --- src/Math/Geometry/Rectangle.h | 6 ++++++ src/Math/Geometry/Test/RectangleTest.cpp | 3 +++ 2 files changed, 9 insertions(+) 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() {