3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace.Math::Rectangle Struct Reference

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>

Public Member Functions

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.

Public Attributes

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.

Detailed Description

Represents an axis-aligned rectangle in 2D space, defined by its top-left corner (X, Y) and its dimensions (Width, Height).

Constructor & Destructor Documentation

◆ 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
xThe X coordinate of the top-left corner.
yThe Y coordinate of the top-left corner.
wThe width of the rectangle.
hThe 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
minMinimal point (top-left corner)
maxMaximum point (bottom-right corner)

Member Function Documentation

◆ 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()

bool Rectangle::Contains ( Point p) const
noexcept

Determines whether the specified point is contained within the rectangle.

Parameters
pThe point to test.
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
rThe 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
rThe 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.

Member Data Documentation

◆ Height

int Engine3DRadSpace.Math::Rectangle::Height

The height of this rectangle.

◆ Width

int Engine3DRadSpace.Math::Rectangle::Width

The width of this rectangle.

◆ X

int Engine3DRadSpace.Math::Rectangle::X

The X coordinate of the top-left corner of the rectangle.

◆ Y

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: