17#include <teiacare/sdk/geometry/line.hpp>
18#include <teiacare/sdk/geometry/point.hpp>
19#include <teiacare/sdk/geometry/size.hpp>
20#include <teiacare/sdk/math.hpp>
95 return _position ==
other._position &&
96 _width ==
other._width &&
97 _height ==
other._height;
116 return _width <= 0 && _height <= 0;
223 return _width * _height;
242 return point.
x() > _position.x() &&
243 point.
y() > _position.y() &&
244 point.
x() < _position.x() + _width &&
245 point.
y() < _position.y() + _height;
255 return _position.x() <
other._position.x() &&
256 _position.y() <
other._position.y() &&
257 _position.x() + _width >=
other._position.x() +
other._width &&
258 _position.y() + _height >=
other._position.y() +
other._height;
268 return _position.x() + _width >
other._position.x() &&
269 _position.y() + _height >
other._position.y() &&
270 _position.x() <
other._position.x() +
other._width &&
271 _position.y() <
other._position.y() +
other._height &&
327 auto union_x = tc::sdk::min(_position.x(),
other._position.x());
328 auto union_y = tc::sdk::min(_position.y(),
other._position.y());
366 return std::string(_position.to_string() +
" : (" + std::to_string(_width) +
"x" + std::to_string(_height) +
")");
377 return stream <<
r.to_string();
Thread safe, blocking queue.
2D line specified by a pair of start/end points.
constexpr tc::sdk::point< T > start() const noexcept
Start point getter.
constexpr tc::sdk::point< T > end() const noexcept
End point getter.
bool intersects(tc::sdk::line< T > other) const noexcept
Check if the given line segments intersects the current instance.
2D point specified by a pair of (x,y) coordinates.
constexpr T x() const noexcept
X coordinate getter.
constexpr T y() const noexcept
Y coordinate getter.
2D rectangle specified by a position point (top-left corner) and a pair of width/height dimensions.
constexpr tc::sdk::size< T > size() const noexcept
Size getter.
friend std::ostream & operator<<(std::ostream &stream, const rectangle &r)
Output stream operator.
constexpr tc::sdk::point< T > bottom_right() const noexcept
Bottom right coordinate getter.
constexpr rectangle(const rectangle &)=default
Copy Constructor. Copy a tc::sdk::rectangle instance into another one.
constexpr void set_size(T width, T height) noexcept
Size setter.
constexpr T height() const noexcept
Height dimension getter.
bool contains(tc::sdk::rectangle< T > other) const noexcept
Check if the given rectangle is strictly contained within the current rectangle.
tc::sdk::rectangle< T > get_union(tc::sdk::rectangle< T > other) const noexcept
constexpr T area() const noexcept
Area getter.
constexpr rectangle(T x, T y, T w, T h) noexcept
Constructor. Creates tc::sdk::rectangle instance with given width and height dimensions.
constexpr std::string to_string() const
Get the rectangle string representation.
constexpr bool is_null() const noexcept
Check if the rectangle is the null.
constexpr tc::sdk::point< T > bottom_left() const noexcept
Bottom left coordinate getter.
constexpr void set_position(tc::sdk::point< T > position) noexcept
Set the rectangle position.
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.
rectangle & operator=(const rectangle &)=default
Assignment operator. Assign a tc::sdk::rectangle instance to another one.
bool intersects(tc::sdk::line< T > line) const noexcept
Check if the given line pass through the current rectangle.
void set_width(T width) noexcept
Width coordinate setter. Set the width dimension of the rectangle.
bool contains(tc::sdk::point< T > point) const noexcept
Check if the given point is strictly contained within the current rectangle.
constexpr tc::sdk::point< double > center() const noexcept
Center getter.
constexpr bool operator==(const rectangle &other) const noexcept
Equality operator.
tc::sdk::rectangle< T > get_intersection(tc::sdk::rectangle< T > other) const noexcept
constexpr rectangle()=default
Default Constructor. Creates a default tc::sdk::rectangle instance.
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(rectangle &&)=default
Move Constructor. Copy a tc::sdk::rectangle instance into another one.
void translate(T delta_x, T delta_y) noexcept
Translate the rectangle by a given delta_x and delta_y offsets.
constexpr tc::sdk::point< T > top_right() const noexcept
Top right coordinate getter.
constexpr tc::sdk::point< T > top_left() const noexcept
Top left coordinate getter.
void set_height(T height) noexcept
Height coordinate setter. Set the height dimension of the rectangle.
bool intersects(tc::sdk::rectangle< T > other) const noexcept
Check if the given rectangle overlaps the current rectangle.
constexpr bool operator!=(const rectangle &other) const noexcept
Inequality operator.
constexpr T width() const noexcept
Width dimension getter.
rectangle & operator=(rectangle &&)=default
Move assignment operator. Assign a tc::sdk::rectangle instance to another one.