|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
An axis-aligned rectangle. More...
#include <point.H>
Public Member Functions | |
| bool | operator== (const Rectangle &r) const noexcept |
| Checks for exact equality between two rectangles. | |
| bool | operator!= (const Rectangle &r) const noexcept |
| Checks for inequality between two rectangles. | |
| const Geom_Number & | get_xmin () const |
| Gets the minimum x-coordinate. | |
| const Geom_Number & | get_ymin () const |
| Gets the minimum y-coordinate. | |
| const Geom_Number & | get_xmax () const |
| Gets the maximum x-coordinate. | |
| const Geom_Number & | get_ymax () const |
| Gets the maximum y-coordinate. | |
| Rectangle () | |
| Default constructor. | |
| Rectangle (const Geom_Number &xmin, const Geom_Number &ymin, const Geom_Number &xmax, const Geom_Number &ymax) | |
| Constructs a rectangle from four coordinates. | |
| void | set_rect (const Geom_Number &xmin, const Geom_Number &ymin, const Geom_Number &xmax, const Geom_Number &ymax) |
| Sets the coordinates of the rectangle. | |
| Geom_Number | width () const noexcept |
| Calculates the width of the rectangle. | |
| Geom_Number | height () const noexcept |
| Calculates the height of the rectangle. | |
| Geom_Number | area () const noexcept |
| Calculates the area of the rectangle. | |
| Geom_Number | perimeter () const noexcept |
| Calculates the perimeter of the rectangle. | |
| Point | center () const noexcept |
| Calculates the center point of the rectangle. | |
| std::array< Point, 4 > | corners () const noexcept |
| Gets the four corners of the rectangle. | |
| bool | intersects (const Rectangle &that) const noexcept |
| Checks if this axis-aligned rectangle intersects another one. | |
| Geom_Number | distance_squared_to (const Point &p) const noexcept |
| Calculates the squared Euclidean distance from the rectangle to a point. | |
| Geom_Number | distance_to (const Point &p) const |
| Calculates the Euclidean distance from the rectangle to a point. | |
| bool | contains (const Point &p) const noexcept |
| Checks if this axis-aligned rectangle contains a point. | |
| std::string | to_string () const |
| Returns a string representation of the rectangle. | |
Private Attributes | |
| Geom_Number | xmin_ |
| Geom_Number | ymin_ |
| Geom_Number | xmax_ |
| Geom_Number | ymax_ |
An axis-aligned rectangle.
Stored as (xmin, ymin, xmax, ymax) with the invariant that xmin <= xmax and ymin <= ymax must hold.
|
inline |
|
inline |
Constructs a rectangle from four coordinates.
| xmin | The minimum x-coordinate. |
| ymin | The minimum y-coordinate. |
| xmax | The maximum x-coordinate. |
| ymax | The maximum y-coordinate. |
| std::out_of_range | if xmin > xmax or ymin > ymax. |
Definition at line 1788 of file point.H.
References ah_range_error_if, Aleph::divide_and_conquer_partition_dp(), xmax_, xmin_, ymax_, and ymin_.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Calculates the squared Euclidean distance from the rectangle to a point.
| p | The point. |
p to the closest point on this rectangle. Returns 0 if the point is inside. Definition at line 1871 of file point.H.
References xmax_, xmin_, ymax_, and ymin_.
Referenced by distance_to().
|
inline |
Calculates the Euclidean distance from the rectangle to a point.
| p | The point. |
p to the closest point on this rectangle. Definition at line 1892 of file point.H.
References distance_squared_to(), and sqrt().
|
inline |
Gets the maximum x-coordinate.
Definition at line 1768 of file point.H.
References xmax_.
Referenced by Aleph::AABBTree::boxes_overlap(), TEST_F(), Aleph::AABBTree::union_bbox(), Aleph::visualize_range_tree_query(), and K2Tree< T >::Node::xmax().
|
inline |
Gets the minimum x-coordinate.
Definition at line 1764 of file point.H.
References xmin_.
Referenced by Aleph::AABBTree::boxes_overlap(), TEST_F(), Aleph::AABBTree::union_bbox(), Aleph::visualize_range_tree_query(), and K2Tree< T >::Node::xmin().
|
inline |
Gets the maximum y-coordinate.
Definition at line 1770 of file point.H.
References ymax_.
Referenced by Aleph::AABBTree::boxes_overlap(), TEST_F(), Aleph::AABBTree::union_bbox(), Aleph::visualize_range_tree_query(), and K2Tree< T >::Node::ymax().
|
inline |
Gets the minimum y-coordinate.
Definition at line 1766 of file point.H.
References ymin_.
Referenced by Aleph::AABBTree::boxes_overlap(), TEST_F(), Aleph::AABBTree::union_bbox(), Aleph::visualize_range_tree_query(), and K2Tree< T >::Node::ymin().
|
inlinenoexcept |
Checks if this axis-aligned rectangle intersects another one.
| that | The other rectangle. |
true if they overlap, false otherwise. Definition at line 1859 of file point.H.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), and ymin_.
Checks for inequality between two rectangles.
| r | The other rectangle to compare. |
true if any coordinate is different. Definition at line 1758 of file point.H.
References Aleph::divide_and_conquer_partition_dp(), and r.
|
inlinenoexcept |
|
inline |
Sets the coordinates of the rectangle.
| xmin | The minimum x-coordinate. |
| ymin | The minimum y-coordinate. |
| xmax | The maximum x-coordinate. |
| ymax | The maximum y-coordinate. |
| std::out_of_range | if xmin > xmax or ymin > ymax. |
Definition at line 1803 of file point.H.
References ah_range_error_if, Aleph::divide_and_conquer_partition_dp(), xmax_, xmin_, ymax_, and ymin_.
Referenced by K2Tree< T >::Node::set_rect(), K2Tree< T >::Node::set_rect(), and TEST_F().
|
inline |
|
inlinenoexcept |
|
private |
Definition at line 1739 of file point.H.
Referenced by Rectangle(), center(), contains(), corners(), distance_squared_to(), get_xmax(), operator==(), set_rect(), to_string(), and width().
|
private |
Definition at line 1738 of file point.H.
Referenced by Rectangle(), center(), contains(), corners(), distance_squared_to(), get_xmin(), operator==(), set_rect(), to_string(), and width().
|
private |
Definition at line 1739 of file point.H.
Referenced by Rectangle(), center(), contains(), corners(), distance_squared_to(), get_ymax(), height(), operator==(), set_rect(), and to_string().
|
private |
Definition at line 1738 of file point.H.
Referenced by Rectangle(), center(), contains(), corners(), distance_squared_to(), get_ymin(), height(), intersects(), operator==(), set_rect(), and to_string().