diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-03-25 21:37:51 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-13 22:40:52 +0100 |
commit | 443d35771754821fbcf205005c7f5a632bdfbbd2 (patch) | |
tree | 8561f6037eeb7d5e6e36d8dff9c9a5d061234c66 /src/utils | |
parent | dffdab14fb56f2702abdc88c6df769a58e926c9d (diff) | |
download | usdx-443d35771754821fbcf205005c7f5a632bdfbbd2.tar.gz usdx-443d35771754821fbcf205005c7f5a632bdfbbd2.tar.xz usdx-443d35771754821fbcf205005c7f5a632bdfbbd2.zip |
utils/rectangle: could get top/bottom/left/right coordinates from Rectangle
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/rectangle.hpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/utils/rectangle.hpp b/src/utils/rectangle.hpp index 39743e5d..f3f4477d 100644 --- a/src/utils/rectangle.hpp +++ b/src/utils/rectangle.hpp @@ -31,6 +31,7 @@ #include "point.hpp" #include "dimension.hpp" +#include "math.hpp" namespace usdx { @@ -93,24 +94,34 @@ namespace usdx return point2; } - const T get_x(void) const + const T get_width(void) const { - return point1.get_x(); + return Math::abs(point2.get_x() - point1.get_x()); } - const T get_y(void) const + const T get_height(void) const { - return point1.get_y(); + return Math::abs(point2.get_y() - point1.get_y()); } - const T get_width(void) const + const T get_top(void) const { - return point2.get_x() - point1.get_x(); + return Math::min(point1.get_y(), point2.get_y()); } - const T get_height(void) const + const T get_bottom(void) const + { + return Math::max(point1.get_y(), point2.get_y()); + } + + const T get_left(void) const + { + return Math::min(point1.get_x(), point2.get_x()); + } + + const T get_right(void) const { - return point2.get_y() - point1.get_y(); + return Math::max(point1.get_x(), point2.get_x()); } const Rectangle<T> intersect(const Rectangle<T>& inner) const |