#include <wit/geometry.h>
Public Member Functions | |
Rect () | |
Rect (const Rect &other) | |
Rect (float x1, float y1, float x2, float y2) | |
Rect & | operator= (const Rect &other) |
bool | contains (float x, float y) |
bool | intersects (const Rect &other) |
float | width () const |
float | height () const |
Public Attributes | |
float | x1 |
float | y1 |
float | x2 |
float | y2 |
The Rect class describes a rectangle aligned with the horizontal and vertical axes.
Definition at line 16 of file geometry.h.
wit::Rect::Rect | ( | ) |
Creates a new Rect object at (0, 0) with no size.
Definition at line 92 of file geometry.cpp.
wit::Rect::Rect | ( | const Rect & | other ) |
Creates a new Rect object that is a copy of other.
Definition at line 100 of file geometry.cpp.
wit::Rect::Rect | ( | float | x1, |
float | y1, | ||
float | x2, | ||
float | y2 | ||
) |
Creates a new Rect object that spans from (x1, y1) to (x2, y2).
Definition at line 108 of file geometry.cpp.
bool wit::Rect::contains | ( | float | x, |
float | y | ||
) |
Returns true if the point (x, y) is contained within the rectangle.
Note that a rectangle with non-positive height or width contains no points.
Definition at line 130 of file geometry.cpp.
float wit::Rect::height | ( | ) | const |
Returns the height of the rectangle.
Note that the height may be negative if y2 < y1.
Definition at line 160 of file geometry.cpp.
bool wit::Rect::intersects | ( | const Rect & | other ) |
Returns true if the rect other intersects with this rectangle.
Note that a rectangle with non-positive height or width intersects with nothing.
Definition at line 140 of file geometry.cpp.
Replaces the coordinates of this rectangle with the coordinates from other.
Definition at line 116 of file geometry.cpp.
float wit::Rect::width | ( | ) | const |
Returns the width of the rectangle.
Note that the width may be negative if x2 < x1.
Definition at line 150 of file geometry.cpp.
float wit::Rect::x1 |
The x coordinate of the left side of the rectangle.
Definition at line 23 of file geometry.h.
float wit::Rect::x2 |
The x coordinate of the right side of the rectangle.
Definition at line 23 of file geometry.h.
float wit::Rect::y1 |
The y coordinate of the top side of the rectangle.
Definition at line 23 of file geometry.h.
float wit::Rect::y2 |
The y coordinate of the bottom side of the rectangle.
Definition at line 23 of file geometry.h.