API Documentation
Public Member Functions | Public Attributes | List of all members
nkMaths::Rectangle Class Reference

Represents a 2D rectangle. More...

Public Member Functions

 Rectangle () noexcept
 
 Rectangle (float x, float y, float width, float height) noexcept
 
bool pointInside (Point point) const
 
Rectangle operator+ (const Rectangle &other) const
 

Public Attributes

float _x
 The x coordinate of the origin.
 
float _y
 The y coordinate of the origin.
 
float _width
 The full width of the rectangle.
 
float _height
 The full height of the rectangle.
 

Detailed Description

Represents a 2D rectangle.

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

nkMaths::Rectangle::Rectangle ( )
noexcept

Default constructor. All members will be set to 0.

◆ Rectangle() [2/2]

nkMaths::Rectangle::Rectangle ( float  x,
float  y,
float  width,
float  height 
)
noexcept

Constructor.

Parameters
xThe x component of the origin.
yThe y component of the origin.
widthThe rectangle width.
heightThe rectangle height.

Member Function Documentation

◆ pointInside()

bool nkMaths::Rectangle::pointInside ( Point  point) const

Checks if a point is inside the rectangle.

Parameters
pointThe point to check against the rectangle.
Returns
If the point is inside (true) or not (false).

◆ operator+()

Rectangle nkMaths::Rectangle::operator+ ( const Rectangle other) const

Overrides adding rectangles. Conceptually, sum components from the other rectangle with the calling one (origin + other.origin, dimensions + other.dimensions).

Parameters
otherThe rectangle to add.

The documentation for this class was generated from the following file: