Represents an axis-aligned rectangle in 2D space, defined by its top-left corner (X, Y) and its dimensions (Width, Height).
More...
#include <Rectangle.hpp>
|
| constexpr | Rectangle (int x=0, int y=0, int w=0, int h=0) |
| | Constructs an rectangle with the specified top-left corner and dimensions. If no values are provided, it creates a rectangle at the origin with zero width and height.
|
| | Rectangle (Point min, Point max) |
| | Creates a rectangle from two points, where 'min' is the top-left corner and 'max' is the bottom-right corner. The width and height are calculated based on these points.
|
| Point | TopLeft () const |
| | Returns the coordinates of the top-left corner of the rectangle.
|
| Point | TopRight () const |
| | Returns the top-right corner of the rectangle as a Point. The X coordinate is calculated as X + Width, and the Y coordinate remains the same as Y.
|
| Point | BottomLeft () const |
| | Returns the bottom-left corner of the rectangle as a Point. The X coordinate remains the same as X, and the Y coordinate is calculated as Y + Height.
|
| Point | BottomRight () const |
| | Returns the bottom-right corner of the rectangle as a Point. The X coordinate is calculated as X + Width, and the Y coordinate is calculated as Y + Height.
|
| Point | Center () const |
| | Returns the center point of the rectangle.
|
| bool | Contains (Point p) const noexcept |
| | Determines whether the specified point is contained within the rectangle.
|
| int | Area () const noexcept |
| | Calculates the area of the rectangle.
|
| bool | operator== (const Rectangle &r) const =default |
| | Checks if this rectangle is equal to another rectangle. Two rectangles are considered equal if they have the same top-left corner and dimensions.
|
| bool | operator!= (const Rectangle &r) const =default |
| | Checks if this rectangle is not equal to another rectangle. Two rectangles are considered not equal if they differ in either their top-left corner or dimensions.
|
|
| int | X |
| | The X coordinate of the top-left corner of the rectangle.
|
| int | Y |
| | The Y coordinate of the top-left corner of the rectangle.
|
| int | Width |
| | The width of this rectangle.
|
| int | Height |
| | The height of this rectangle.
|
Represents an axis-aligned rectangle in 2D space, defined by its top-left corner (X, Y) and its dimensions (Width, Height).
◆ Rectangle() [1/2]
| Engine3DRadSpace.Math::Rectangle::Rectangle |
( |
int | x = 0, |
|
|
int | y = 0, |
|
|
int | w = 0, |
|
|
int | h = 0 ) |
|
inlineexplicitconstexpr |
Constructs an rectangle with the specified top-left corner and dimensions. If no values are provided, it creates a rectangle at the origin with zero width and height.
- Parameters
-
| x | The X coordinate of the top-left corner. |
| y | The Y coordinate of the top-left corner. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |
◆ Rectangle() [2/2]
| Engine3DRadSpace.Math::Rectangle::Rectangle |
( |
Point | min, |
|
|
Point | max ) |
|
inlineexplicit |
Creates a rectangle from two points, where 'min' is the top-left corner and 'max' is the bottom-right corner. The width and height are calculated based on these points.
- Parameters
-
| min | Minimal point (top-left corner) |
| max | Maximum point (bottom-right corner) |
◆ Area()
| int Rectangle::Area |
( |
| ) |
const |
|
noexcept |
Calculates the area of the rectangle.
- Returns
- The area of the rectangle.
◆ BottomLeft()
| Point Rectangle::BottomLeft |
( |
| ) |
const |
Returns the bottom-left corner of the rectangle as a Point. The X coordinate remains the same as X, and the Y coordinate is calculated as Y + Height.
- Returns
- The bottom-left corner as a Point.
◆ BottomRight()
| Point Rectangle::BottomRight |
( |
| ) |
const |
Returns the bottom-right corner of the rectangle as a Point. The X coordinate is calculated as X + Width, and the Y coordinate is calculated as Y + Height.
- Returns
- The bottom-right corner as a Point.
◆ Center()
| Point Rectangle::Center |
( |
| ) |
const |
Returns the center point of the rectangle.
- Returns
- The center point as a Point.
◆ Contains()
Determines whether the specified point is contained within the rectangle.
- Parameters
-
- Returns
- True if the point is within the rectangle; otherwise, false.
◆ operator!=()
| bool Engine3DRadSpace.Math::Rectangle::operator!= |
( |
const Rectangle & | r | ) |
const |
|
default |
Checks if this rectangle is not equal to another rectangle. Two rectangles are considered not equal if they differ in either their top-left corner or dimensions.
- Parameters
-
| r | The rectangle to compare with. |
- Returns
- True if the rectangles are not equal; otherwise, false.
◆ operator==()
| bool Engine3DRadSpace.Math::Rectangle::operator== |
( |
const Rectangle & | r | ) |
const |
|
default |
Checks if this rectangle is equal to another rectangle. Two rectangles are considered equal if they have the same top-left corner and dimensions.
- Parameters
-
| r | The rectangle to compare with. |
- Returns
- True if the rectangles are equal; otherwise, false.
◆ TopLeft()
| Point Rectangle::TopLeft |
( |
| ) |
const |
Returns the coordinates of the top-left corner of the rectangle.
- Returns
- The top-left corner as a Point.
◆ TopRight()
| Point Rectangle::TopRight |
( |
| ) |
const |
Returns the top-right corner of the rectangle as a Point. The X coordinate is calculated as X + Width, and the Y coordinate remains the same as Y.
- Returns
- The top-right corner as a Point.
◆ Height
| int Engine3DRadSpace.Math::Rectangle::Height |
The height of this rectangle.
◆ Width
| int Engine3DRadSpace.Math::Rectangle::Width |
The width of this rectangle.
| int Engine3DRadSpace.Math::Rectangle::X |
The X coordinate of the top-left corner of the rectangle.
| int Engine3DRadSpace.Math::Rectangle::Y |
The Y coordinate of the top-left corner of the rectangle.
The documentation for this struct was generated from the following files: