Represents a rectangle that is aligned with the axis. More...
#include <abox2d.h>
Public Member Functions | |
void | reset (void) |
bring the internal variables to their ground state | |
bool | operator== (const ABOX2D &other) const |
compares two rectangles | |
bool | operator!= (const ABOX2D &other) const |
compares two points (their coorsinates) | |
void | operator+= (const ABOX2D &other) |
computes the bounding rectangle for the two input boxes | |
void | operator-= (const ABOX2D &other) |
computes the rectangle that is common to the two input boxes | |
COORDV | width (void) const |
width (side on the x axis) | |
COORDV | height (void) const |
height (side on the y axis) | |
bool | isDegenerate (void) const |
tell if this box is degenerate or not | |
COORDV | diagonal (void) const |
lenght of diagonal | |
void | unite (const ABOX2D &first, const ABOX2D &second) |
set this rectangle to the union of two rectangles | |
void | unite (const ABOX2D &other) |
set this rectangle to the union of this and other rectangle | |
bool | contains (const P2D &other) const |
tell if the box contains a point | |
bool | contains (const ABOX2D &other) const |
tell if the box contains another box | |
bool | intersect (const ABOX2D &first, const ABOX2D &second) |
set this rectangle to the intersection of two rectangles | |
bool | intersect (const ABOX2D &other) |
set this rectangle to the intersection of this and other rectangle | |
bool | isNormalised (void) const |
tell if the rectangle is normalised (x1<x2, y1<y2) | |
void | normalise (void) |
normalise the rectangle (x1<x2, y1<y2) | |
void | offset (COORDV dist) |
extend or contract this box by given ammount | |
void | offset (COORDV dist, ABOX2D &out) const |
extend or contract the box by given ammount | |
void | translate (COORDV dx, COORDV dy) |
move the item by this ammount relative to current position | |
bool | visibleIn (const ABOX2D &other) const |
tell if the segment is "visible" inside given shape | |
COORDV | area (void) |
the area of this thing | |
void | center (P2D &c) |
the center point of this one |
Public Attributes | |
union { | |
COORDV pts_ [4] | |
coordinates in an array of 4 values: left, bottom, right, top | |
struct { | |
COORDV left_ | |
X1 component. | |
COORDV bottom_ | |
Y1 component. | |
COORDV right_ | |
X2 component. | |
COORDV top_ | |
Y2 component. | |
} | |
struct { | |
P2D bottom_left_ | |
first point | |
P2D top_right_ | |
second point | |
} | |
}; |
Represents a rectangle that is aligned with the axis.
The line isDegenerate() if the two points that define it are identical ( P2D::isEqual() == true )
bool ABOX2D::contains | ( | const P2D & | other | ) | const |
tell if the box contains a point
If the point is directly over left or bottom margin the method returns true; if the point is directly over right or top margin the method returns false.
bool ABOX2D::contains | ( | const ABOX2D & | other | ) | const |
tell if the box contains another box
Only returns true if the other box is fully contained by this box. Identical rectangles return true with this method.
set this rectangle to the intersection of two rectangles
bool ABOX2D::intersect | ( | const ABOX2D & | other | ) |
set this rectangle to the intersection of this and other rectangle
|
inline |
void ABOX2D::offset | ( | COORDV | dist | ) |
extend or contract this box by given ammount
A positive value will expand the box; a negative value will shrink it
extend or contract the box by given ammount
A positive value will expand the box; a negative value will shrink it
|
inline |
compares two rectangles
Two rectangles are the same if their coordinates are the same
bool ABOX2D::visibleIn | ( | const ABOX2D & | other | ) | const |
tell if the segment is "visible" inside given shape
"visible" is satisfied if the shape intersects or contains the segment.