25 static_assert(std::is_floating_point_v<T>,
"Type T must be a floating point type.");
316#include <math/TRectangle2D.hpp>
Class to store and manipulate a rectangle based on floating point values.
Definition TRectangle2D.h:22
TRectangle2D & fromString(const std::string &s) noexcept(false)
Gets rectangle value from the string representation formed like '(left, bottom, right,...
TRectangle2D & inflate(const TVector2D< T > &delta)
Inflates this instance using the passed delta vector (x, y).
TVector2D< T > topRight() const
Gets the top-right corner of the rectangle as a vector.
T height() const
Gets the height of the rectangle.
TRectangle2D normalized() const
Gets a normalized instance of this instance so that top-right and bottom-left are correct.
TRectangle2D movedTo(T x, T y)
Gets a moved instance from this instance where left-bottom represented by the passed values x and y h...
TVector2D< T > bottomLeft() const
Gets the bottom-left corner of the rectangle as a vector.
std::string toString() const
Gets the string representation of the rectangle formed like '(left, bottom, right,...
TRectangle2D & offset(T dx, T dy)
Offsets this instance by the passed values x and y keeping the same size.
T width() const
Gets the width of the rectangle.
bool touches(const TRectangle2D &other) const
Returns true when the passed rectangle overlaps with this rectangle.
TRectangle2D operator|(const TRectangle2D &other) const
Gets an instance of the combined rectangle containing both rectangles.
static constexpr auto tolerance
Tolerance for when comparing in the equal operator. Used as: std::fabs(x1 - x2) < tolerance.
Definition TRectangle2D.h:277
bool operator!=(const TRectangle2D &) const
Call the isEqual() function to compare.
TRectangle2D offsetBy(T dx, T dy) const
Gets an instance offset by the passed values x and y keeping the same size.
TRectangle2D & assignWidthHeight(T left, T bottom, T w, T h)
Assigns new coordinates using position x, y, width and height values.
union sf::TRectangle2D::data_type _data
T area() const
Gets the area formed by the rectangles width and height.
TRectangle2D & operator&=(const TRectangle2D &other)
Sets this instance to the overlapping part of both rectangles.
T value_type
Type accessible when implemented.
Definition TRectangle2D.h:29
TRectangle2D & assign(T left, T bottom, T right, T top)
Assigns new coordinate values.
TRectangle2D & operator|=(const TRectangle2D &other)
Sets this instance to the combined rectangle containing both rectangles.
TVector2D< T >::data_type::point_type point_type
Use the same point type as the one of the 2D vector.
Definition TRectangle2D.h:283
TRectangle2D(const TRectangle2D &rect)
Copy constructor.
TRectangle2D(T left, T bottom, T right, T top)
Initializing constructor.
void clear()
Empties the rectangle setting it to the initial state.
bool isEmpty() const
Tests if all values are near zero according the tolerance value.
TRectangle2D & operator+=(const TVector2D< T > &delta)
Offsets this instance using the passed delta vector as a positive.
TRectangle2D & normalize()
Normalizes this instance so that top-right and bottom-left are correct.
TRectangle2D(const TRectangle2D &&rect) noexcept
Move constructor.
bool contains(const TVector2D< T > &point) const
Returns true when the passed point represented by a vector resides within this rectangle.
TVector2D< T > topLeft() const
Gets the top-left corner of the rectangle as a vector.
bool contains(const TRectangle2D &other) const
Returns true when the passed rectangle resides within this rectangle.
TRectangle2D()=default
Default constructor.
TRectangle2D & assign(const TVector2D< T > &loLeft, const TVector2D< T > &upRight)
Assigns new coordinate using two points.
TRectangle2D inflatedBy(T dx, T dy) const
Gets an inflated rectangle using the passed delta values for x and y.
bool isEqual(const TRectangle2D &other, T tol=tolerance) const
Compare passes rectangle with this instance taking the tolerance value in to account.
TRectangle2D & assignWidthHeight(const TVector2D< T > &bottom_left, const TVector2D< T > &size)
Assigns new coordinates using position and size vector.
bool operator==(const TRectangle2D &) const
Call the isEqual() function to compare.
TVector2D< T > center() const
Gets the center of the rectangle as vector.
TRectangle2D & assign(const TRectangle2D &)
Assigns new values from the passed instance.
TVector2D< T > bottomRight() const
Gets the bottom-right corner of the rectangle as a vector.
TRectangle2D operator&(const TRectangle2D &other) const
Gets an instance of the overlapping part of both rectangles.
TRectangle2D inflatedBy(const TVector2D< T > &delta) const
Gets inflated instance using the passed delta vector (x, y).
TRectangle2D & inflate(T dx, T dy)
Inflates this instance using the passed delta values for x and y.
TRectangle2D(std::initializer_list< T > list)
Initializer list constructor.
TRectangle2D & moveTo(T x, T y)
Moves this instance to a different left-bottom represented by the passed values x and y having the sa...
TRectangle2D & operator-=(const TVector2D< T > &delta)
Offsets this instance using the passed delta vector as a negative.
TVector2D< T > Size() const
Gets the height and width of the rectangle as a vector.
TRectangle2D(const TVector2D< T > &loLeft, const TVector2D< T > &upRight)
Initializing constructor using two points.
2-dimensional vector for math operations.
Definition TVector2D.h:23
Definition Application.h:10
_GII_FUNC std::istream & operator>>(std::istream &is, ResultData &)
Stream operator for setting up this instance with a setup std::string.
_GII_FUNC std::ostream & operator<<(std::ostream &os, const ResultData &)
Stream operator for the setup std::string.
Definition TVector2D.h:337
Rectangle structure for binary storage purposes.
Definition TRectangle2D.h:288
point_type pt[2]
Definition TRectangle2D.h:290
struct sf::TRectangle2D::data_type::@2 rect
T right
Definition TRectangle2D.h:295
T bottom
Definition TRectangle2D.h:294
T top
Definition TRectangle2D.h:296
T array[4]
Definition TRectangle2D.h:289
T left
Definition TRectangle2D.h:293