#include <bn_fixed_rect.h>
template<int Precision>
fixed_rect_t class
Defines a two-dimensional rectangle using fixed point precision and a center point as position.
Constructors, destructors, conversion operators
- fixed_rect_t() defaulted constexpr
- Default constructor.
-
fixed_rect_t(const fixed_
point_ t<Precision>& position, const fixed_ size_ t<Precision>& dimensions) constexpr - Constructor.
-
fixed_rect_t(fixed_
t<Precision> x, fixed_ t<Precision> y, fixed_ t<Precision> width, fixed_ t<Precision> height) constexpr - Constructor.
- fixed_rect_t(const rect& rect) constexpr
- Constructor.
Public functions
-
auto position() const -> const fixed_
point_ t<Precision>& constexpr - Returns the position of the center point of the rectangle.
-
void set_position(const fixed_
point_ t<Precision>& position) constexpr - Sets the position of the center point of the rectangle.
-
void set_position(fixed_
t<Precision> x, fixed_ t<Precision> y) constexpr - Sets the position of the center point of the rectangle.
-
auto dimensions() const -> const fixed_
size_ t<Precision>& constexpr - Returns the size of the rectangle.
-
void set_dimensions(const fixed_
size_ t<Precision>& dimensions) constexpr - Sets the size of the rectangle.
-
void set_dimensions(fixed_
t<Precision> width, fixed_ t<Precision> height) constexpr - Sets the size of the rectangle.
-
auto x() const -> fixed_
t<Precision> constexpr - Returns the horizontal position of the center point of the rectangle.
-
void set_x(fixed_
t<Precision> x) constexpr - Sets the horizontal position of the center point of the rectangle.
-
auto y() const -> fixed_
t<Precision> constexpr - Returns the vertical position of the center point of the rectangle.
-
void set_y(fixed_
t<Precision> y) constexpr - Sets the vertical position of the center point of the rectangle.
-
auto width() const -> fixed_
t<Precision> constexpr - Returns the width of the rectangle.
-
void set_width(fixed_
t<Precision> width) constexpr - Sets the width of the rectangle.
-
auto height() const -> fixed_
t<Precision> constexpr - Returns the height of the rectangle.
-
void set_height(fixed_
t<Precision> height) constexpr - Sets the height of the rectangle.
-
auto top() const -> fixed_
t<Precision> constexpr - Returns the position of the top boundary of the rectangle.
-
auto left() const -> fixed_
t<Precision> constexpr - Returns the position of the left boundary of the rectangle.
-
auto bottom() const -> fixed_
t<Precision> constexpr - Returns the position of the bottom boundary of the rectangle.
-
auto right() const -> fixed_
t<Precision> constexpr - Returns the position of the right boundary of the rectangle.
-
auto top_left() const -> fixed_
point_ t<Precision> constexpr - Returns the position of the top-left corner of the rectangle.
-
auto top_right() const -> fixed_
point_ t<Precision> constexpr - Returns the position of the top-right corner of the rectangle.
-
auto bottom_left() const -> fixed_
point_ t<Precision> constexpr - Returns the position of the bottom-left corner of the rectangle.
-
auto bottom_right() const -> fixed_
point_ t<Precision> constexpr - Returns the position of the bottom-right corner of the rectangle.
-
auto center_x() const -> fixed_
t<Precision> constexpr - Returns the horizontal position of the center point of the rectangle.
-
auto center_y() const -> fixed_
t<Precision> constexpr - Returns the vertical position of the center point of the rectangle.
-
auto center() const -> fixed_
point_ t<Precision> constexpr - Returns the position of the center point of the rectangle.
-
auto contains(const fixed_
point_ t<Precision>& point) const -> bool constexpr - Indicates if the given point is inside the rectangle or not.
-
auto edge_contains(const fixed_
point_ t<Precision>& point) const -> bool constexpr - Indicates if the given point is inside the rectangle or not.
-
auto contains(const fixed_
rect_ t& other) const -> bool constexpr - Indicates if the given rectangle is inside this one or not.
-
auto edge_contains(const fixed_
rect_ t& other) const -> bool constexpr - Indicates if the given rectangle is inside this one or not.
-
auto intersects(const fixed_
rect_ t& other) const -> bool constexpr - Indicates if this rectangle intersects with the given one or not.
-
auto touches(const fixed_
rect_ t& other) const -> bool constexpr - Indicates if this rectangle touches the given one or not.
-
auto multiplication(int value) const -> fixed_
rect_ t constexpr - Returns the multiplication of this rectangle by the given integer value.
-
auto multiplication(fixed_
t<Precision> value) const -> fixed_ rect_ t constexpr - Returns the multiplication of this rectangle by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_multiplication(int value) const -> fixed_
rect_ t constexpr - Returns the multiplication of this rectangle by the given integer value.
-
auto safe_multiplication(fixed_
t<Precision> value) const -> fixed_ rect_ t constexpr - Returns the multiplication of this rectangle by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_multiplication(int value) const -> fixed_
rect_ t constexpr - Returns the multiplication of this rectangle by the given integer value.
-
auto unsafe_multiplication(fixed_
t<Precision> value) const -> fixed_ rect_ t constexpr - Returns the multiplication of this rectangle by the given fixed point value without trying to avoid overflow.
-
auto division(int value) const -> fixed_
rect_ t constexpr - Returns the division of this rectangle by the given integer value.
-
auto division(fixed_
t<Precision> value) const -> fixed_ rect_ t constexpr - Returns the division of this rectangle by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_division(int value) const -> fixed_
rect_ t constexpr - Returns the division of this rectangle by the given integer value.
-
auto safe_division(fixed_
t<Precision> value) const -> fixed_ rect_ t constexpr - Returns the division of this rectangle by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_division(int value) const -> fixed_
rect_ t constexpr - Returns the division of this rectangle by the given integer value.
-
auto unsafe_division(fixed_
t<Precision> value) const -> fixed_ rect_ t constexpr - Returns the division of this rectangle by the given fixed point value without trying to avoid overflow.
-
auto operator*=(int value) -> fixed_
rect_ t& constexpr - Multiplies both width and height of the rectangle by the given factor.
-
auto operator*=(fixed_
t<Precision> value) -> fixed_ rect_ t& constexpr - Multiplies both width and height of the rectangle by the given factor.
-
auto operator/=(int value) -> fixed_
rect_ t& constexpr - Divides both width and height of the rectangle by the given divisor.
-
auto operator/=(fixed_
t<Precision> value) -> fixed_ rect_ t& constexpr - Divides both width and height of the rectangle by the given divisor.
Friends
-
auto operator*(const fixed_
rect_ t& a, int b) -> fixed_ rect_ t constexpr - Returns a multiplied by b.
-
auto operator*(const fixed_
rect_ t& a, fixed_ t<Precision> b) -> fixed_ rect_ t constexpr - Returns a multiplied by b.
-
auto operator/(const fixed_
rect_ t& a, int b) -> fixed_ rect_ t constexpr - Returns a divided by b.
-
auto operator/(const fixed_
rect_ t& a, fixed_ t<Precision> b) -> fixed_ rect_ t constexpr - Returns a divided by b.
-
auto operator==(const fixed_
rect_ t& a, const fixed_ rect_ t& b) -> bool defaulted constexpr - Default equal operator.
Function documentation
template<int Precision>
bn:: fixed_rect_t<Precision>:: fixed_rect_t(const fixed_ point_ t<Precision>& position,
const fixed_ size_ t<Precision>& dimensions) constexpr
Constructor.
Parameters | |
---|---|
position | Position of the center point of the rectangle. |
dimensions | Size of the rectangle. |
template<int Precision>
bn:: fixed_rect_t<Precision>:: fixed_rect_t(fixed_ t<Precision> x,
fixed_ t<Precision> y,
fixed_ t<Precision> width,
fixed_ t<Precision> height) constexpr
Constructor.
Parameters | |
---|---|
x | Horizontal position of the center point of the rectangle. |
y | Vertical position of the center point of the rectangle. |
width | Valid width of the rectangle (>= 0). |
height | Valid height of the rectangle (>= 0). |
template<int Precision>
bn:: fixed_rect_t<Precision>:: fixed_rect_t(const rect& rect) constexpr
Constructor.
Parameters | |
---|---|
rect | Integer rectangle. |
template<int Precision>
void bn:: fixed_rect_t<Precision>:: set_position(fixed_ t<Precision> x,
fixed_ t<Precision> y) constexpr
Sets the position of the center point of the rectangle.
Parameters | |
---|---|
x | Horizontal position of the center point of the rectangle. |
y | Vertical position of the center point of the rectangle. |
template<int Precision>
void bn:: fixed_rect_t<Precision>:: set_dimensions(fixed_ t<Precision> width,
fixed_ t<Precision> height) constexpr
Sets the size of the rectangle.
Parameters | |
---|---|
width | Valid width of the rectangle (>= 0). |
height | Valid height of the rectangle (>= 0). |
template<int Precision>
void bn:: fixed_rect_t<Precision>:: set_height(fixed_ t<Precision> height) constexpr
Sets the height of the rectangle.
Parameters | |
---|---|
height | Valid height (>= 0). |
template<int Precision>
bool bn:: fixed_rect_t<Precision>:: contains(const fixed_ point_ t<Precision>& point) const constexpr
Indicates if the given point is inside the rectangle or not.
If the point is on the edge of the rectangle, it returns false
.
template<int Precision>
bool bn:: fixed_rect_t<Precision>:: edge_contains(const fixed_ point_ t<Precision>& point) const constexpr
Indicates if the given point is inside the rectangle or not.
If the point is on the edge of the rectangle, it returns true
.
template<int Precision>
bool bn:: fixed_rect_t<Precision>:: contains(const fixed_ rect_ t& other) const constexpr
Indicates if the given rectangle is inside this one or not.
If the given rectangle is on the edge of this one, it returns false
.
template<int Precision>
bool bn:: fixed_rect_t<Precision>:: edge_contains(const fixed_ rect_ t& other) const constexpr
Indicates if the given rectangle is inside this one or not.
If the given rectangle is on the edge of this one, it returns true
.
template<int Precision>
bool bn:: fixed_rect_t<Precision>:: intersects(const fixed_ rect_ t& other) const constexpr
Indicates if this rectangle intersects with the given one or not.
Two rectangles intersect if there is at least one point that is within both rectangles, excluding their edges.
template<int Precision>
bool bn:: fixed_rect_t<Precision>:: touches(const fixed_ rect_ t& other) const constexpr
Indicates if this rectangle touches the given one or not.
Two rectangles touch each other if there is at least one point that is within both rectangles, including their edges.
template<int Precision>
fixed_ rect_ t& bn:: fixed_rect_t<Precision>:: operator*=(int value) constexpr
Multiplies both width and height of the rectangle by the given factor.
Parameters | |
---|---|
value | Valid integer multiplication factor (>= 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ rect_ t& bn:: fixed_rect_t<Precision>:: operator*=(fixed_ t<Precision> value) constexpr
Multiplies both width and height of the rectangle by the given factor.
Parameters | |
---|---|
value | Valid fixed point multiplication factor (>= 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ rect_ t& bn:: fixed_rect_t<Precision>:: operator/=(int value) constexpr
Divides both width and height of the rectangle by the given divisor.
Parameters | |
---|---|
value | Valid integer divisor (> 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ rect_ t& bn:: fixed_rect_t<Precision>:: operator/=(fixed_ t<Precision> value) constexpr
Divides both width and height of the rectangle by the given divisor.
Parameters | |
---|---|
value | Valid fixed point divisor (> 0). |
Returns | Reference to this. |