5#ifndef NIRT_RECT_HPP_INCLUDED
6#define NIRT_RECT_HPP_INCLUDED
8#include <nirtcpp/core/engine/nirt_types.hpp>
9#include <nirtcpp/core/engine/dimension2d.hpp>
10#include <nirtcpp/core/engine/position2d.hpp>
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
T getArea() const
Get the surface area of the box in squared units.
Definition aabbox3d.hpp:142
Rectangle template.
Definition rect.hpp:27
T getArea() const
Returns size of rectangle.
Definition rect.hpp:102
rect(const position2d< T > &upperLeft, const position2d< T > &lowerRight)
Constructor with two corners.
Definition rect.hpp:38
rect< T > & operator+=(const position2d< T > &pos)
move right by given numbers
Definition rect.hpp:59
rect(const position2d< T > &pos, const dimension2d< U > &size)
Constructor with upper left corner and dimension.
Definition rect.hpp:43
T getWidth() const
Get width of rectangle.
Definition rect.hpp:193
bool constrainTo(const rect< T > &other)
Moves this rectangle to fit inside another one.
Definition rect.hpp:156
dimension2d< T > getSize() const
Get the dimensions of the rectangle.
Definition rect.hpp:240
rect< T > & operator-=(const position2d< T > &pos)
move left by given numbers
Definition rect.hpp:74
rect(const dimension2d< U > &size)
Constructor with upper left at 0,0 and lower right using dimension.
Definition rect.hpp:48
rect< T > operator+(const position2d< T > &pos) const
move right by given numbers
Definition rect.hpp:52
rect()
Default constructor creating empty rectangle at (0,0)
Definition rect.hpp:31
bool isRectCollided(const rect< T > &other) const
Check if the rectangle collides with another rectangle.
Definition rect.hpp:121
T getHeight() const
Get height of rectangle.
Definition rect.hpp:199
rect< T > operator-(const position2d< T > &pos) const
move left by given numbers
Definition rect.hpp:67
void addInternalPoint(T x, T y)
Adds a point to the bounding rectangle.
Definition rect.hpp:260
void clipAgainst(const rect< T > &other)
Clips this rectangle with another one.
Definition rect.hpp:131
position2d< T > LowerRightCorner
Lower right corner.
Definition rect.hpp:276
void repair()
If the lower right corner of the rect is smaller then the upper left, the points are swapped.
Definition rect.hpp:205
bool isValid() const
Returns if the rect is valid to draw.
Definition rect.hpp:225
bool operator==(const rect< T > &other) const
equality operator
Definition rect.hpp:82
void addInternalPoint(const position2d< T > &p)
Adds a point to the rectangle.
Definition rect.hpp:250
position2d< T > UpperLeftCorner
Upper left corner.
Definition rect.hpp:274
rect(T x, T y, T x2, T y2)
Constructor with two corners.
Definition rect.hpp:34
bool operator<(const rect< T > &other) const
compares size of rectangles
Definition rect.hpp:96
bool isPointInside(const position2d< T > &pos) const
Returns if a 2d point is within this rectangle.
Definition rect.hpp:110
position2d< T > getCenter() const
Get the center of the rectangle.
Definition rect.hpp:232
bool operator!=(const rect< T > &other) const
inequality operator
Definition rect.hpp:89
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11