2D rectangle specified by a position point (top-left corner) and a pair of width/height dimensions. More...
#include <rectangle.hpp>
Public Member Functions | |
constexpr | rectangle ()=default |
Default Constructor. Creates a default tc::sdk::rectangle instance. | |
constexpr | rectangle (const rectangle &)=default |
Copy Constructor. Copy a tc::sdk::rectangle instance into another one. | |
constexpr | rectangle (rectangle &&)=default |
Move Constructor. Copy a tc::sdk::rectangle instance into another one. | |
constexpr | rectangle (tc::sdk::point< T > position, T w, T h) noexcept |
Constructor. Creates tc::sdk::rectangle instance with given width and height dimensions. | |
constexpr | rectangle (T x, T y, T w, T h) noexcept |
Constructor. Creates tc::sdk::rectangle instance with given width and height dimensions. | |
rectangle & | operator= (const rectangle &)=default |
Assignment operator. Assign a tc::sdk::rectangle instance to another one. | |
rectangle & | operator= (rectangle &&)=default |
Move assignment operator. Assign a tc::sdk::rectangle instance to another one. | |
constexpr bool | operator== (const rectangle &other) const noexcept |
Equality operator. | |
constexpr bool | operator!= (const rectangle &other) const noexcept |
Inequality operator. | |
constexpr bool | is_null () const noexcept |
Check if the rectangle is the null. | |
constexpr T | width () const noexcept |
Width dimension getter. | |
constexpr T | height () const noexcept |
Height dimension getter. | |
void | set_width (T width) noexcept |
Width coordinate setter. Set the width dimension of the rectangle. | |
void | set_height (T height) noexcept |
Height coordinate setter. Set the height dimension of the rectangle. | |
constexpr void | set_size (T width, T height) noexcept |
Size setter. | |
constexpr void | set_position (tc::sdk::point< T > position) noexcept |
Set the rectangle position. | |
constexpr tc::sdk::point< T > | top_left () const noexcept |
Top left coordinate getter. | |
constexpr tc::sdk::point< T > | top_right () const noexcept |
Top right coordinate getter. | |
constexpr tc::sdk::point< T > | bottom_left () const noexcept |
Bottom left coordinate getter. | |
constexpr tc::sdk::point< T > | bottom_right () const noexcept |
Bottom right coordinate getter. | |
constexpr tc::sdk::size< T > | size () const noexcept |
Size getter. | |
constexpr T | area () const noexcept |
Area getter. | |
constexpr tc::sdk::point< double > | center () const noexcept |
Center getter. | |
bool | contains (tc::sdk::point< T > point) const noexcept |
Check if the given point is strictly contained within the current rectangle. | |
bool | contains (tc::sdk::rectangle< T > other) const noexcept |
Check if the given rectangle is strictly contained within the current rectangle. | |
bool | intersects (tc::sdk::rectangle< T > other) const noexcept |
Check if the given rectangle overlaps the current rectangle. | |
bool | intersects (tc::sdk::line< T > line) const noexcept |
Check if the given line pass through the current rectangle. | |
tc::sdk::rectangle< T > | get_intersection (tc::sdk::rectangle< T > other) const noexcept |
tc::sdk::rectangle< T > | get_union (tc::sdk::rectangle< T > other) const noexcept |
void | translate (T delta_x, T delta_y) noexcept |
Translate the rectangle by a given delta_x and delta_y offsets. | |
tc::sdk::rectangle< T > | translated (T delta_x, T delta_y) const noexcept |
Create a copy of the rectangle translated by a given delta_x and delta_y offsets. | |
constexpr std::string | to_string () const |
Get the rectangle string representation. | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const rectangle &r) |
Output stream operator. | |
2D rectangle specified by a position point (top-left corner) and a pair of width/height dimensions.
T | Underlying coordinates and dimensions type |
Definition at line 33 of file rectangle.hpp.
|
inlineexplicitconstexprnoexcept |
Constructor. Creates tc::sdk::rectangle instance with given width and height dimensions.
position | the position of the rectangle (top-left corner). |
w | the width of the rectangle. |
h | the height of the rectangle. |
Definition at line 57 of file rectangle.hpp.
|
inlineexplicitconstexprnoexcept |
Constructor. Creates tc::sdk::rectangle instance with given width and height dimensions.
x | the x coordinate of the rectangle position (top-left corner). |
y | the y coordinate of the rectangle position (top-left corner). |
w | the width of the rectangle. |
h | the height of the rectangle. |
Definition at line 71 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Equality operator.
other | the rectangle to compare against. |
Definition at line 93 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Inequality operator.
other | the rectangle to compare against. |
Definition at line 105 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Check if the rectangle is the null.
Definition at line 114 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Width dimension getter.
Definition at line 123 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Height dimension getter.
Definition at line 132 of file rectangle.hpp.
|
inlinenoexcept |
Width coordinate setter. Set the width dimension of the rectangle.
Definition at line 140 of file rectangle.hpp.
|
inlinenoexcept |
Height coordinate setter. Set the height dimension of the rectangle.
Definition at line 148 of file rectangle.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Set the rectangle position.
position | the new top left coordinate of the rectangle. |
Definition at line 167 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Top left coordinate getter.
Definition at line 176 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Top right coordinate getter.
Definition at line 185 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Bottom left coordinate getter.
Definition at line 194 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Bottom right coordinate getter.
Definition at line 203 of file rectangle.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Center getter.
Definition at line 230 of file rectangle.hpp.
|
inlinenoexcept |
Check if the given point is strictly contained within the current rectangle.
point | The point that is checked. |
Definition at line 240 of file rectangle.hpp.
|
inlinenoexcept |
Check if the given rectangle is strictly contained within the current rectangle.
other | The rectangle that is checked. |
Definition at line 253 of file rectangle.hpp.
|
inlinenoexcept |
Check if the given rectangle overlaps the current rectangle.
other | The rectangle to check the intersection with. |
Definition at line 266 of file rectangle.hpp.
|
inlinenoexcept |
Check if the given line pass through the current rectangle.
line | The line to check the intersection with. |
Definition at line 281 of file rectangle.hpp.
|
inlinenoexcept |
Returns the region that is the overlap between this and another rectangle. If the two rectangles don't overlap, the rectangle returned will be empty.
Definition at line 294 of file rectangle.hpp.
|
inlinenoexcept |
Returns the smallest rectangle that contains both this one and the one passed-in.
If either this or the other rectangle are empty, they will not be counted as part of the resulting region.
Definition at line 319 of file rectangle.hpp.
|
inlinenoexcept |
Translate the rectangle by a given delta_x and delta_y offsets.
delta_x | the offset to be applied on the x direction |
delta_y | the offset to be applied on the y direction |
Definition at line 342 of file rectangle.hpp.
|
inlinenoexcept |
Create a copy of the rectangle translated by a given delta_x and delta_y offsets.
delta_x | the offset to be applied on the x direction |
delta_y | the offset to be applied on the y direction |
Definition at line 353 of file rectangle.hpp.
|
inlineconstexpr |
Get the rectangle string representation.
Definition at line 364 of file rectangle.hpp.
|
friend |
Output stream operator.
stream | the output stream to write into. |
r | the rectangle object to stream. |
Definition at line 375 of file rectangle.hpp.