#include <PhxRectangle.h>
Public Member Functions | |
| Rectangle (T x0, T y0, T x1, T y1) | |
| T | x0 (void) const |
| T | y0 (void) const |
| T | x1 (void) const |
| T | y1 (void) const |
| T | left (void) const |
| T | right (void) const |
| T | top (void) const |
| T | bottom (void) const |
| T | width (void) const |
| T | height (void) const |
| void | x0 (T x0) |
| void | y0 (T y0) |
| void | x1 (T x1) |
| void | y1 (T y1) |
| T | area (void) const |
| Returns the area of this rectangle. | |
| T | perimeter (void) const |
| Returns the perimeter of this rectangle. | |
| bool | empty (void) const |
| Returns whether this rectangle is empty. | |
| Rectangle | intersection (const Rectangle &R) const |
| Returns the "intersection" of two rectangles. | |
| Rectangle | cover (const Rectangle &R) const |
| Returns the smallest rectangle containing two rectangles. | |
| bool | operator== (const Rectangle &r) |
| Compares another rectangle with this one for equality. | |
The rectangle is represented by two corner points (x0,y0) and (x1,y1). The corners may be at any location, and the width, height, and area of the rectangle is always considered to be positive. The "left" side of the rectangle is defined to be the minimum of x1 and x1; the "right" side is the maximum. The "top" of the rectangle is defined as the maximum of y0 and y1, and the "bottom" is the minimum. This choice of top and bottom is the opposite of some GUI/screen coordinate systems.
The template parameter is optional, allowing rectangles of different coordinate base types (e.g., one could have a rectangle with int-type coordinates). The default is double. Other types may be used, provided they support the appropriate arithmetic operations (addition, subtraction, multiplication, division) and comparison (less-than comparable). The type must also allow initialization to '0' for default construction.
|
||||||||||
|
Returns the area of this rectangle.
|
|
||||||||||
|
Returns the smallest rectangle containing two rectangles.
The returned rectangle is the smallest rectangle that includes the area in this rectangle and the rectangle
|
|
||||||||||
|
Returns whether this rectangle is empty. The rectangle is "empty" if its area is identically 0.
|
|
||||||||||
|
Returns the "intersection" of two rectangles. The intersection of two disjoint rectangles is a zero-area rectangle. If the rectangles are disjoint along one axis, then the coordinates of the "intersection" on that axis are the mid-point between the nearest edges. e.g., if the right side of rectangle A is 0 and the left side of B is 1.0, then for C = A.intersection(B), we have C.x0() = C.x1() = 0.5. This ensures that C.area() is zero but that the intersection is a well-defined symmetric function of A and B.
|
|
||||||||||
|
Compares another rectangle with this one for equality.
|
|
||||||||||
|
Returns the perimeter of this rectangle.
|
1.4.2