![]() |
Murl Engine API
Version 2018.3
|
A rectangle class with 2D coordinates. More...
#include <murl_math_rectangle.h>
A rectangle class with 2D coordinates.
Public Types | |
typedef DataType | ValueType |
The template parameter value type. More... | |
Public Member Functions | |
Rectangle () | |
The default constructor. More... | |
Rectangle (DataType x1, DataType y1, DataType x2, DataType y2) | |
Constructor to initialize a rectangle with given coordinates. More... | |
template<class DataType2 > | |
Rectangle (const Rectangle< DataType2 > &r) | |
The copy constructor using a rectangle of different type. More... | |
void | Set (const Rectangle &other) |
Copy the content of a source rectangle to the rectangle instance. More... | |
void | Set (DataType x1, DataType y1, DataType x2, DataType y2) |
Set all coordinates of the rectangle instance to a set of given coordinates. More... | |
void | SetX1 (DataType x1) |
Set the horizontal start coordinate. More... | |
void | SetY1 (DataType y1) |
Set the vertical start coordinate. More... | |
void | SetX2 (DataType x2) |
Set the horizontal end coordinate. More... | |
void | SetY2 (DataType y2) |
Set the vertical end coordinate. More... | |
void | SetPositionAndSize (DataType x, DataType y, DataType sizeX, DataType sizeY) |
Set the x / y coordinate and the horizontal / vertical size of the rectangle. More... | |
void | SetSize (DataType sizeX, DataType sizeY) |
Set the horizontal and vertical size of the rectangle. More... | |
void | SetSizeX (DataType size) |
Set the horizontal size of the rectangle. More... | |
void | SetSizeY (DataType size) |
Set the vertical size of the rectangle. More... | |
DataType | GetX1 () const |
Get the lower X coordinate. More... | |
DataType | GetY1 () const |
Get the lower Y coordinate. More... | |
DataType | GetX2 () const |
Get the higher X coordinate. More... | |
DataType | GetY2 () const |
Get the higher Y coordinate. More... | |
DataType | GetSizeX () const |
Get the horizontal size of the rectangle. More... | |
DataType | GetSizeY () const |
Get the vertical size of the rectangle. More... | |
DataType | GetArea () const |
Get the area occupied by the rectangle. More... | |
void | Unite (const Rectangle &other) |
Unite this rectangle with another rectangle. More... | |
void | Intersect (const Rectangle &other) |
Intersect this rectangle with another rectangle. More... | |
void | Include (DataType x, DataType y) |
Include a point in this rectangle. More... | |
Bool | IsIntersecting (const Rectangle &other) const |
Check if a given rectangle is intersecting this rectangle. More... | |
Bool | IsEmpty () const |
Check if a given rectangle is empty, i.e. More... | |
Bool | IsEqual (const Rectangle &r) const |
Check if the rectangle instance is equal to a given second rectangle. More... | |
Bool | IsEqual (const Rectangle &r, DataType epsilon) const |
Check if the rectangle instance is equal to a given second rectangle. More... | |
String | ToString () const |
Get the string representation of the object. More... | |
Protected Attributes | |
DataType | mX1 |
The lower X coordinate. More... | |
DataType | mY1 |
The lower Y coordinate. More... | |
DataType | mX2 |
The higher X coordinate. More... | |
DataType | mY2 |
The higher Y coordinate. More... | |
Friends | |
bool | operator== (const Rectangle< DataType > &lhs, const Rectangle< DataType > &rhs) |
Equal to comparison operator. More... | |
bool | operator!= (const Rectangle< DataType > &lhs, const Rectangle< DataType > &rhs) |
Not equal to comparison operator. More... | |
typedef DataType Murl::Math::Rectangle< DataType >::ValueType |
The template parameter value type.
|
inline |
The default constructor.
Create an empty rectangle with the following properties:
This allowes to Include() a point in an empty rectangle which sets the lower and higher coordinates to the included point.
|
inline |
Constructor to initialize a rectangle with given coordinates.
Takes care of setting the lower and higher coordinates correctly.
x1 | The X coordinate of the first point. |
y1 | The Y coordinate of the first point. |
x2 | The X coordinate of the second point. |
y2 | The Y coordinate of the second point. |
|
inline |
The copy constructor using a rectangle of different type.
r | The rectangle to copy. |
|
inline |
Copy the content of a source rectangle to the rectangle instance.
other | The rectangle to copy from. |
|
inline |
Set all coordinates of the rectangle instance to a set of given coordinates.
Takes care of setting the lower and higher coordinates correctly.
x1 | The X coordinate of the first point. |
y1 | The Y coordinate of the first point. |
x2 | The X coordinate of the second point. |
y2 | The Y coordinate of the second point. |
|
inline |
Set the horizontal start coordinate.
This sets the coordinate without taking care about lower and higher coordinates.
x1 | The X coordinate of the first point. |
|
inline |
Set the vertical start coordinate.
This sets the coordinate without taking care about lower and higher coordinates.
y1 | The Y coordinate of the first point. |
|
inline |
Set the horizontal end coordinate.
This sets the coordinate without taking care about lower and higher coordinates.
x2 | The X coordinate of the second point. |
|
inline |
Set the vertical end coordinate.
This sets the coordinate without taking care about lower and higher coordinates.
y2 | The Y coordinate of the second point. |
|
inline |
Set the x / y coordinate and the horizontal / vertical size of the rectangle.
x | The X coordinate of the first point. |
y | The Y coordinate of the first point. |
sizeX | The horizontal size of the rectangle. |
sizeY | The vertical size of the rectangle. |
|
inline |
Set the horizontal and vertical size of the rectangle.
sizeX | The horizontal size of the rectangle. |
sizeY | The vertical size of the rectangle. |
|
inline |
Set the horizontal size of the rectangle.
size | The horizontal size of the rectangle. |
|
inline |
Set the vertical size of the rectangle.
size | The vertical size of the rectangle. |
|
inline |
Get the lower X coordinate.
|
inline |
Get the lower Y coordinate.
|
inline |
Get the higher X coordinate.
|
inline |
Get the higher Y coordinate.
|
inline |
Get the horizontal size of the rectangle.
|
inline |
Get the vertical size of the rectangle.
|
inline |
Get the area occupied by the rectangle.
|
inline |
Unite this rectangle with another rectangle.
other | The other rectangle to unite. |
|
inline |
Intersect this rectangle with another rectangle.
other | The other rectangle to intersect. |
|
inline |
Include a point in this rectangle.
Sets the lower and higher coordinates to the included point if the rectangle is empty, see default constructor Rectangle().
x | The x-position of the point to include. |
y | The y-position of the point to include. |
|
inline |
Check if a given rectangle is intersecting this rectangle.
other | The other rectangle to check. |
|
inline |
Check if a given rectangle is empty, i.e.
its area is zero.
|
inline |
Check if the rectangle instance is equal to a given second rectangle.
Compares all values within the default epsilon range Limits::Epsilon().
r | The rectangle to compare. |
|
inline |
Check if the rectangle instance is equal to a given second rectangle.
Compares all values within a given epsilon range.
r | The rectangle to compare. |
epsilon | The epsilon to compare. |
|
inline |
Get the string representation of the object.
|
friend |
Equal to comparison operator.
Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Rectangle> class. To compare within an epsilon range use Rectangle::IsEqual().
lhs | The left hand side rectangle to compare. |
rhs | The right hand side rectangle to compare. |
|
friend |
Not equal to comparison operator.
Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Rectangle> class. To compare within an epsilon range use Rectangle::IsEqual().
lhs | The left hand side rectangle to compare. |
rhs | The right hand side rectangle to compare. |
|
protected |
The lower X coordinate.
|
protected |
The lower Y coordinate.
|
protected |
The higher X coordinate.
|
protected |
The higher Y coordinate.