|
CeresEngine 0.2.0
A game development framework
|
Represents a 2D rectangle using real values. More...
#include <CeresEngine/Math/Rect.hpp>
Public Member Functions | |
| TRect2 ()=default | |
| TRect2 (const TPoint2< T > &origin, const TSize2< T > &size) | |
| TRect2 (const TPoint2< T > ¢er, const TRect2Edge< T > &edge) | |
| TRect2 (T x, T y, T width, T height) | |
| bool | contains (const TPoint2< T > &point) const |
| Returns true if the rectangle contains the provided point. | |
| bool | contains (const TRect2< T > &rect) const |
| bool | overlaps (const TRect2 &other) const |
| Returns true if the rectangle overlaps the provided rectangle. | |
| void | encapsulate (const TRect2 &other) |
| Extends this rectangle so that the provided rectangle is completely contained within it. | |
| void | clip (const TRect2 &clipRect) |
| Clips current rectangle so that it does not overlap the provided rectangle. | |
| TRect2 | intersection (const TRect2 &other) const |
| bool | fullyContained (const TRect2 &other) const |
| TRect2 | inset (const TRect2Edge< T > &insets) const |
| TRect2 | inset (T value) const |
| TRect2 | outset (const TRect2Edge< T > &insets) const |
| TRect2 | outset (T value) const |
| void | transform (const TMatrix4< T > &matrix) |
| Transforms the bounds by the given matrix. | |
| void | transform (const TMatrix3< T > &matrix) |
| Transforms the bounds by the given matrix. | |
| TPoint2< T > | getCenter () const |
| Center of the rectangle. | |
| TSize2< T > | getHalfSize () const |
| Extents of the rectangle (distance from center to one of the corners) | |
| TPoint2< T > | getTopLeft () const |
| void | setTopLeft (const TPoint2< T > &topLeft) |
| TPoint2< T > | getTopRight () const |
| void | setTopRight (const TPoint2< T > &topRight) |
| TPoint2< T > | getBottomLeft () const |
| void | setBottomLeft (const TPoint2< T > &bottomLeft) |
| TPoint2< T > | getBottomRight () const |
| void | setBottomRight (const TPoint2< T > &bottomRight) |
Static Public Member Functions | |
| static TRect2 | fromCenterAndSize (const TPoint2< T > ¢er, const TSize2< T > &size) |
| Creates a new 2D rect by passing the center and it's size. | |
| static TRect2 | fromCenterAndSize (const TPoint2< T > ¢er, T size) |
| Creates a new 2D rect by passing the center and it's size. | |
| static Vector< TRect2 > | getIntersectionGroups (const Vector< TRect2 > &rects) |
Computes a set of non-intersecting rects that enclose all given rects. | |
Public Attributes | |
| TPoint2< T > | origin = TPoint2<T>(0.0, 0.0) |
| TSize2< T > | size = TSize2<T>(0.0, 0.0) |
Friends | |
| bool | operator== (const TRect2 &lhs, const TRect2 &rhs) |
| bool | operator!= (const TRect2 &lhs, const TRect2 &rhs) |
| template<std::size_t I> | |
| T & | get (TRect2 &rect) noexcept |
| Gets a value from the rectangle. | |
| template<std::size_t I> | |
| const T & | get (const TRect2 &rect) noexcept |
| Gets a value from the rectangle. | |
Represents a 2D rectangle using real values.
Rectangle is represented with an origin in top left and width/height.
|
default |
|
inline |
| Math::TRect2< T >::TRect2 | ( | const TPoint2< T > & | center, |
| const TRect2Edge< T > & | edge | ||
| ) |
|
inline |
| void Math::TRect2< T >::clip | ( | const TRect2< T > & | clipRect | ) |
Clips current rectangle so that it does not overlap the provided rectangle.
| bool Math::TRect2< T >::contains | ( | const TPoint2< T > & | point | ) | const |
Returns true if the rectangle contains the provided point.
| bool Math::TRect2< T >::contains | ( | const TRect2< T > & | rect | ) | const |
| void Math::TRect2< T >::encapsulate | ( | const TRect2< T > & | other | ) |
Extends this rectangle so that the provided rectangle is completely contained within it.
|
inlinestatic |
Creates a new 2D rect by passing the center and it's size.
|
inlinestatic |
Creates a new 2D rect by passing the center and it's size.
| bool Math::TRect2< T >::fullyContained | ( | const TRect2< T > & | other | ) | const |
|
inline |
|
inline |
| TPoint2< T > Math::TRect2< T >::getCenter | ( | ) | const |
Center of the rectangle.
| TSize2< T > Math::TRect2< T >::getHalfSize | ( | ) | const |
Extents of the rectangle (distance from center to one of the corners)
|
static |
Computes a set of non-intersecting rects that enclose all given rects.
| rects | The rectangles to compute the smaller non-intersecting rectangle set. |
|
inline |
|
inline |
| TRect2 Math::TRect2< T >::inset | ( | const TRect2Edge< T > & | insets | ) | const |
|
inline |
| TRect2 Math::TRect2< T >::intersection | ( | const TRect2< T > & | other | ) | const |
| TRect2 Math::TRect2< T >::outset | ( | const TRect2Edge< T > & | insets | ) | const |
|
inline |
| bool Math::TRect2< T >::overlaps | ( | const TRect2< T > & | other | ) | const |
Returns true if the rectangle overlaps the provided rectangle.
Also returns true if the rectangles are contained within each other completely (no intersecting edges).
|
inline |
|
inline |
|
inline |
|
inline |
| void Math::TRect2< T >::transform | ( | const TMatrix3< T > & | matrix | ) |
Transforms the bounds by the given matrix.
Resulting value is an axis aligned rectangle encompassing the transformed points.
| void Math::TRect2< T >::transform | ( | const TMatrix4< T > & | matrix | ) |
Transforms the bounds by the given matrix.
Resulting value is an axis aligned rectangle encompassing the transformed points.
Gets a value from the rectangle.
| I | The parameter index to fetched from the rect. |
| rect | The rect to fetch the I-th parameter from. |
I-th parameter from rect. Gets a value from the rectangle.
| I | The parameter index to fetched from the rect. |
| rect | The rect to fetch the I-th parameter from. |
I-th parameter from rect. | TPoint2<T> Math::TRect2< T >::origin = TPoint2<T>(0.0, 0.0) |
| TSize2<T> Math::TRect2< T >::size = TSize2<T>(0.0, 0.0) |