|
latest version v1.9 - last update 24 Nov 2005 |
|
#include <ltiRectangle.h>
Inheritance diagram for lti::trectangle< T, S >:

Public Member Functions | |
| trectangle () | |
| trectangle (const tpoint< T > &p1, const tpoint< T > &p2) | |
| trectangle (const T &x1, const T &y1, const T &x2, const T &y2) | |
| trectangle (const T &size) | |
| trectangle (const trectangle< T > &other) | |
Location and Dimensions | |
| void | resize (const tpoint< T > &dim) |
| void | resize (const T &x, const T &y) |
| tpoint< T > | getDimensions () const |
| T | getArea () const |
| tpoint< T > | getCenter () const |
| void | setCenter (tpoint< T > center) |
| void | ensureConsistency () |
| bool | isConsistent () const |
| void | shift (const tpoint< T > &delta) |
Simple operations | |
| bool | isInside (const tpoint< T > &p) const |
| bool | isInside (const T &x, const T &y) const |
Duplication | |
| trectangle< T > & | copy (const trectangle< T > &other) |
| template<class U, class SU> | |
| trectangle< T > & | castFrom (const trectangle< U, SU > &other) |
| trectangle< T > & | operator= (const trectangle< T > &other) |
Comparison | |
| bool | operator== (const trectangle< T > &other) const |
| bool | operator!= (const trectangle< T > &other) const |
Geometrical combination | |
| trectangle< T > & | intersectRect (const trectangle< T > &tRect) |
| trectangle< T > & | intersect (const trectangle< T > &tRect) |
| bool | overlaps (const trectangle< T > &tRect) const |
| bool | isClose (const trectangle< T > &tRect, const tpoint< T > &dist) const |
| trectangle< T > & | operator &= (const trectangle< T > &tRect) |
| trectangle< T > | operator & (const trectangle< T > &tRect) |
| trectangle< T > & | unionRect (const trectangle< T > &tRect) |
| trectangle< T > & | join (const trectangle< T > &tRect) |
| trectangle< T > & | operator|= (const trectangle< T > &tRect) |
| trectangle< T > | operator| (const trectangle< T > &tRect) |
Public Attributes | |
| tpoint< T > | ul |
| tpoint< T > | br |
A rectangle is described by a pair of points: the upper-left and bottom-right corners.
A consistent rectangle will have the x and y coordinates of its upper- left corner smaller than the ones of its bottom-right corner (note the use of a left coordinate system, as usual with imaging systems).
You can always check if a rectangle is consistent with the method isConsistent() or even force its consistency with ensureConsistency().
This is a template class, where the first template parameter T denotes the type used for the two points, which will be of type tpoint<T>. For example, the type trectangle<int> (which has the alias rectangle) contains to points (tpoint<int>) as corner representation. The second template parameter is optional and allows the trectangle to behave correctly in a discrete integer grid or in a continuous real grid (please see the lti::rectSide policy for more information).
|
|||||||||
|
default constructor The two points ul and br will be initialized with (0,0)
|
|
||||||||||||||||
|
constructor
|
|
||||||||||||||||||||||||
|
constructor
|
|
||||||||||
|
construct a square with the given side size. If the size is even and T is an integer type, the rectangle will be created from -|_size/2_| to size + |_size/2_| in both coordinates x and y. |
|
||||||||||
|
copy constructor
|
|
||||||||||||||
|
cast from a rectangle of another type
|
|
||||||||||
|
copy member
|
|
|||||||||
|
Ensure consistency of upper-left and bottom-right corners. A trectangle<T> is called "consistent" if the upper-left tpoint<T> has lower coordinate-values than the bottom-right tpoint<T>. |
|
|||||||||
|
Get the area of this rectangle. This value is always positive, regardless of the position of the upper left and bottom right corner. A rectangle whose corners coincide has an area of 1 for fixed point types or 0 for floating point ones.
For floating point values the size is just x2-x1, because of the assumtion that the rectangle lies on a real valued 2D space. |
|
|||||||||
|
Get center of trectangle<T>.
|
|
|||||||||
|
Get dimensions of trectangle<T>. If one coordinate of the two points coincide and the rectangle contains fixed point typed points, the returned dimension is one. For floating point types this case will return 0.
For floating point values the size is just x2-x1, because of the assumtion that the rectangle lies on a real valued 2D space. |
|
||||||||||
|
Intersection of this trectangle with tRect. (the largest rectangle which is contained both inside this rectangle and inside tRect). The result will be left in this instance. If the rectangles do not intersect, the resul will be inconsistent, so you should call isConsistent() to check for this case unless you know for sure that it cannot occur.
|
|
||||||||||
|
Intersection of this trectangle with tRect.
|
|
||||||||||||||||
|
Check whether this rectangle is close to the given rectangle, i.e. if the two rectangles overlap if one is extended by the given distance. |
|
|||||||||
|
Check for consistent trectangle<T>.
|
|
||||||||||||||||
|
Check if the given coordinates are inside the trectangle<T>. (border included!) |
|
||||||||||
|
Check if tpoint<T> p is inside the trectangle<T>. (border included!) |
|
||||||||||
|
Union of this trectangle with tRect (the smallest rectangle containing both this trectangle and tRect) The result will be left in this instance.
|
|
||||||||||
|
new trectangle = intersection of trectangle with tRect
|
|
||||||||||
|
trectangle = intersection of trectangle with tRect. (alias for intersect) |
|
||||||||||
|
test for inequality
|
|
||||||||||
|
alias for copy
|
|
||||||||||
|
test for equality
|
|
||||||||||
|
new trectangle = union of this trectangle with tRect
|
|
||||||||||
|
trectangle = union of this trectangle with tRect (alias for join)
|
|
||||||||||
|
Check whether this rectangle overlaps with the given rectangle.
|
|
||||||||||||||||
|
resize trectangle<T> with new dimensions, but keep its center
|
|
||||||||||
|
resize trectangle<T> with new dimensions, but keep its center
|
|
||||||||||
|
Set the center of this rectangle.
|
|
||||||||||
|
Shift trectangle<T> by delta.
|
|
||||||||||
|
Union of this trectangle with tRect.
|
|
|||||
|
bottom-right tpoint<T>
|
|
|||||
|
upper-left tpoint<T>
|