Commit 3919e4d5 authored by Davis King's avatar Davis King

Added some functions to the rectangle to make it easy

to get the corner points.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402872
parent c6d4e03f
......@@ -125,6 +125,18 @@ namespace dlib
void set_bottom (
long bottom_
) { b = bottom_; }
const point tl_corner (
) const { return point(left(), top()); }
const point bl_corner (
) const { return point(left(), bottom()); }
const point tr_corner (
) const { return point(right(), top()); }
const point br_corner (
) const { return point(right(), bottom()); }
unsigned long width (
) const
......
......@@ -18,8 +18,8 @@ namespace dlib
WHAT THIS OBJECT REPRESENTS
This object represents a rectangular region inside a Cartesian
coordinate system. The region is the rectangle with its upper
left corner at position (left(),top()) and its lower right corner
coordinate system. The region is the rectangle with its top
left corner at position (left(),top()) and its bottom right corner
at (right(),bottom()).
Note that the origin of the coordinate system, i.e. (0,0), is located
......@@ -191,6 +191,38 @@ namespace dlib
- #bottom() == bottom_
!*/
const point tl_corner (
) const;
/*!
ensures
- returns point(left(), top())
(i.e. returns the top left corner point for this rectangle)
!*/
const point bl_corner (
) const;
/*!
ensures
- returns point(left(), bottom())
(i.e. returns the bottom left corner point for this rectangle)
!*/
const point tr_corner (
) const;
/*!
ensures
- returns point(right(), top())
(i.e. returns the top right corner point for this rectangle)
!*/
const point br_corner (
) const;
/*!
ensures
- returns point(right(), bottom())
(i.e. returns the bottom right corner point for this rectangle)
!*/
bool is_empty (
) const;
/*!
......
......@@ -249,6 +249,26 @@ namespace
DLIB_CASSERT((-v).z() == -5.0,"");
}
{
rectangle rect;
point tl(2,3);
point tr(8,3);
point bl(2,9);
point br(8,9);
rect += tl;
rect += tr;
rect += bl;
rect += br;
DLIB_CASSERT(rect.tl_corner() == tl, "");
DLIB_CASSERT(rect.tr_corner() == tr, "");
DLIB_CASSERT(rect.bl_corner() == bl, "");
DLIB_CASSERT(rect.br_corner() == br, "");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment