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. | |
double | calculate_iou (const tc::sdk::rectangle< T > &other) const noexcept |
Calculate Intersection over Union (IoU) with another rectangle. | |
tc::sdk::rectangle< T > | reshape (T input_width, T input_height, T output_width, T output_height) const noexcept |
Transform this rectangle from input coordinate space back to output coordinate space. This method handles the inverse transformation of letterboxing/padding applied during scaling. | |
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 34 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 58 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 72 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Equality operator.
other | the rectangle to compare against. |
Definition at line 94 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Inequality operator.
other | the rectangle to compare against. |
Definition at line 106 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Check if the rectangle is the null.
Definition at line 115 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Width dimension getter.
Definition at line 124 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Height dimension getter.
Definition at line 133 of file rectangle.hpp.
|
inlinenoexcept |
Width coordinate setter. Set the width dimension of the rectangle.
Definition at line 141 of file rectangle.hpp.
|
inlinenoexcept |
Height coordinate setter. Set the height dimension of the rectangle.
Definition at line 149 of file rectangle.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Set the rectangle position.
position | the new top left coordinate of the rectangle. |
Definition at line 168 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Top left coordinate getter.
Definition at line 177 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Top right coordinate getter.
Definition at line 186 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Bottom left coordinate getter.
Definition at line 195 of file rectangle.hpp.
|
inlineconstexprnoexcept |
Bottom right coordinate getter.
Definition at line 204 of file rectangle.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Center getter.
Definition at line 231 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 241 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 254 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 267 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 282 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 295 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 320 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 343 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 354 of file rectangle.hpp.
|
inlinenoexcept |
Calculate Intersection over Union (IoU) with another rectangle.
other | The rectangle to calculate IoU with. |
Definition at line 366 of file rectangle.hpp.
|
inlinenoexcept |
Transform this rectangle from input coordinate space back to output coordinate space. This method handles the inverse transformation of letterboxing/padding applied during scaling.
input_width | The width of the input coordinate space. |
input_height | The height of the input coordinate space. |
output_width | The width of the output coordinate space. |
output_height | The height of the output coordinate space. |
Definition at line 401 of file rectangle.hpp.
|
inlineconstexpr |
Get the rectangle string representation.
Definition at line 461 of file rectangle.hpp.
|
friend |
Output stream operator.
stream | the output stream to write into. |
r | the rectangle object to stream. |
Definition at line 472 of file rectangle.hpp.