Browse Source

Math: functions for bottom right and top left Rectangle corners.

pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
e506951829
  1. 6
      src/Math/Geometry/Rectangle.h
  2. 3
      src/Math/Geometry/Test/RectangleTest.cpp

6
src/Math/Geometry/Rectangle.h

@ -85,6 +85,12 @@ template<class T> class Rectangle {
inline Vector2<T>& bottomLeft() { return _bottomLeft; } inline Vector2<T>& bottomLeft() { return _bottomLeft; }
inline constexpr Vector2<T> bottomLeft() const { return _bottomLeft; } /**< @overload */ inline constexpr Vector2<T> bottomLeft() const { return _bottomLeft; } /**< @overload */
/** @brief Bottom right corner */
inline constexpr Vector2<T> bottomRight() const { return {_topRight.x(), _bottomLeft.y()}; } /**< @overload */
/** @brief Top left corner */
inline constexpr Vector2<T> topLeft() const { return {_bottomLeft.x(), _topRight.y()}; } /**< @overload */
/** @brief Top right corner */ /** @brief Top right corner */
inline Vector2<T>& topRight() { return _topRight; } inline Vector2<T>& topRight() { return _topRight; }
inline constexpr Vector2<T> topRight() const { return _topRight; } /**< @overload */ inline constexpr Vector2<T> topRight() const { return _topRight; } /**< @overload */

3
src/Math/Geometry/Test/RectangleTest.cpp

@ -51,6 +51,9 @@ void RectangleTest::access() {
CORRADE_COMPARE(crect.top(), 30); CORRADE_COMPARE(crect.top(), 30);
CORRADE_COMPARE(crect.left(), 34); CORRADE_COMPARE(crect.left(), 34);
CORRADE_COMPARE(crect.right(), 47); CORRADE_COMPARE(crect.right(), 47);
CORRADE_COMPARE(rect.topLeft(), Vector2i(34, 30));
CORRADE_COMPARE(rect.bottomRight(), Vector2i(47, 23));
} }
void RectangleTest::compare() { void RectangleTest::compare() {

Loading…
Cancel
Save