Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
rectangle.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "shape/ray.hpp"
4
12
13#include <array>
14#include <cassert>
15#include <concepts>
16#include <cstddef>
17#include <iterator>
18#include <ostream>
19#include <ranges>
20#include <stdexcept>
21#include <type_traits>
22#include <optional>
23#include <vector>
24#include <utility>
25#include <variant>
26
27
28namespace pgl {
29
30namespace detail {
31
32template <std::floating_point ResultNumber, class Value>
33constexpr ResultNumber lowerFloatingBound(const Value& value) {
34 if constexpr (requires { value.template lowerBound<ResultNumber>(); }) {
35 return value.template lowerBound<ResultNumber>();
36 } else {
37 return static_cast<ResultNumber>(value);
38 }
39}
40
41template <std::floating_point ResultNumber, class Value>
42constexpr ResultNumber upperFloatingBound(const Value& value) {
43 if constexpr (requires { value.template upperBound<ResultNumber>(); }) {
44 return value.template upperBound<ResultNumber>();
45 } else {
46 return static_cast<ResultNumber>(value);
47 }
48}
49
50} // namespace detail
51
52template <class PointType = Point<>, class Label>
53struct Rectangle;
54
56
57template <class PointType>
59
60template <class Number>
61Rectangle(Number, Number, Number, Number) -> Rectangle<Point<Number>, NoLabel>;
62
63template <std::ranges::input_range Range>
64 requires detail::is_point_v<std::ranges::range_value_t<Range>>
66
74template <class PointType_, class TLabel>
75struct Rectangle {
76 using PointType = PointType_;
77 using NumberType = PointType::NumberType;
78 using LabelType = TLabel;
79
80 static_assert(detail::is_point_v<PointType>, "Rectangle requires pgl::Point corners");
81
87 template <bool Oriented>
88 using BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>>;
89
95 template <bool Oriented>
96 class BoundaryIterator;
97
99 class CornerIterator;
100
103 using size_type = std::size_t;
104 using difference_type = std::ptrdiff_t;
107 using iterator = CornerIterator;
108 using const_iterator = CornerIterator;
109
110 using EdgeIterator = BoundaryIterator<false>;
111 using OrientedEdgeIterator = BoundaryIterator<true>;
112
120 constexpr Rectangle() : points_(emptyCorners()) {}
121
139 constexpr Rectangle(PointType first, PointType second, bool minmax = false) {
140 if (minmax) {
141 if (second.x() < first.x() || second.y() < first.y()) {
142 points_ = emptyCorners();
143 return;
144 }
145 points_[0] = std::move(first);
146 points_[1] = std::move(second);
147 return;
148 }
149
150 const NumberType min_x = second.x() < first.x() ? second.x() : first.x();
151 const NumberType min_y = second.y() < first.y() ? second.y() : first.y();
152 const NumberType max_x = first.x() < second.x() ? second.x() : first.x();
153 const NumberType max_y = first.y() < second.y() ? second.y() : first.y();
154
155 const PointType normalized_min = makeCorner(min_x, min_y);
156 const PointType normalized_max = makeCorner(max_x, max_y);
157
158 if (first == normalized_min && second == normalized_max) {
159 points_[0] = std::move(first);
160 points_[1] = std::move(second);
161 return;
162 }
163
164 if (second == normalized_min && first == normalized_max) {
165 points_[0] = std::move(second);
166 points_[1] = std::move(first);
167 return;
168 }
169
170 points_[0] = normalized_min;
171 points_[1] = normalized_max;
172 }
173
183 constexpr Rectangle(NumberType x1, NumberType y1, NumberType x2, NumberType y2, bool minmax = false)
184 : Rectangle(PointType(x1, y1), PointType(x2, y2), minmax) {}
185
186 template<PointConcept OtherPointType, class OtherLabelType>
187 requires(std::constructible_from<PointType, const OtherPointType&>)
189 : Rectangle(PointType(other.min()), PointType(other.max()), true) {
190 label_ = detail::copyLabel<LabelType>(other);
191 }
192
194 template<PointConcept OtherPointType, class OtherLabelType>
195 requires(std::constructible_from<PointType, const OtherPointType&>)
196 constexpr Rectangle& operator=(const Rectangle<OtherPointType, OtherLabelType>& other) {
197 points_[0] = PointType(other.min());
198 points_[1] = PointType(other.max());
199 label_ = detail::copyLabel<LabelType>(other);
200 return *this;
201 }
202
213 template<std::ranges::input_range Range = std::initializer_list<PointType>>
214 requires std::ranges::common_range<Range> &&
215 std::convertible_to<std::ranges::range_value_t<Range>, PointType>
216 constexpr explicit Rectangle(Range&& points) : Rectangle() {
217 for(const auto &p : points) {
218 insert(p);
219 }
220 }
221
222
233 template <std::ranges::input_range Range>
234 requires(!detail::is_point_v<typename std::ranges::range_value_t<Range>> && requires(const typename std::ranges::range_value_t<Range>& shape) { shape.bbox(); })
235 constexpr explicit Rectangle(Range&& shapes) : Rectangle() {
236 for(const auto &s : shapes) {
237 insert(s);
238 }
239 }
240
255 constexpr PointType operator[](std::size_t index) const {
256 assert(index < size());
257 switch (index) {
258 case 0: return min();
259 case 1: return bottomRight();
260 case 2: return max();
261 default: return topLeft();
262 }
263 }
264
290 [[nodiscard]] constexpr bool empty() const {
291 if constexpr (is_Rational_v<NumberType>) {
292 // Ordering two rationals cross-multiplies, and on an unreduced pair
293 // it reduces first, so the one comparison costs a gcd and two
294 // heap-capable products. Against an integer none of that happens:
295 // `== 0` is the sign of the numerator and `== -1` is the numerator
296 // against `-den`. The zero test leads because it is the cheaper of
297 // the two and it is the one every non-empty rectangle pays for.
298 return points_[0].x() == 0 && points_[1].x() == -1;
299 } else {
300 return points_[1].x() < points_[0].x();
301 }
302 }
303
307 [[nodiscard]] constexpr std::size_t size() const {
308 return empty() ? 0 : 4;
309 }
310
318 constexpr PointType get(std::ptrdiff_t index) const {
319 assert(!empty());
320 const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(size());
321 return (*this)[static_cast<std::size_t>(((index % n) + n) % n)];
322 }
323
330 constexpr std::ptrdiff_t index(const PointType& point) const {
331 for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t>(size()); ++i) {
332 if ((*this)[static_cast<std::size_t>(i)] == point) {
333 return i;
334 }
335 }
336 return -1;
337 }
338
347 constexpr const PointType& min() const {
348 return points_[0];
349 }
350
359 constexpr const PointType& max() const {
360 return points_[1];
361 }
362
368 [[nodiscard]] constexpr auto width() const {
369 using Result = decltype(max().x() - min().x());
370 return empty() ? Result(0) : Result(max().x() - min().x());
371 }
372
378 [[nodiscard]] constexpr auto height() const {
379 using Result = decltype(max().y() - min().y());
380 return empty() ? Result(0) : Result(max().y() - min().y());
381 }
382
390 public:
391 using iterator_category = std::forward_iterator_tag;
393 using difference_type = std::ptrdiff_t;
394 using pointer = void;
396
397 constexpr CornerIterator() = default;
398 constexpr CornerIterator(const Rectangle* rect, std::size_t index)
399 : rect_(rect), index_(index) {}
400
401 constexpr PointType operator*() const {
402 return (*rect_)[index_];
403 }
405 ++index_;
406 return *this;
407 }
408 constexpr CornerIterator operator++(int) {
409 CornerIterator tmp = *this;
410 ++index_;
411 return tmp;
412 }
413 constexpr bool operator==(const CornerIterator&) const = default;
414
415 private:
416 const Rectangle* rect_ = nullptr;
417 std::size_t index_ = 0;
418 };
419
423 constexpr CornerIterator begin() const {
424 return CornerIterator(this, 0);
425 }
426
430 constexpr CornerIterator cbegin() const {
431 return CornerIterator(this, 0);
432 }
433
437 constexpr CornerIterator end() const {
438 return CornerIterator(this, size());
439 }
440
444 constexpr CornerIterator cend() const {
445 return CornerIterator(this, size());
446 }
447
455 constexpr EdgeIterator edgesBegin() const {
456 return EdgeIterator(this, 0);
457 }
458
464 constexpr EdgeIterator edgesEnd() const {
465 return EdgeIterator(this, size());
466 }
467
476 return OrientedEdgeIterator(this, 0);
477 }
478
485 return OrientedEdgeIterator(this, size());
486 }
487
494 constexpr bool operator==(const Rectangle& other) const {
495 return points_ == other.points_;
496 }
497
499 template<AnyShapeConcept OtherShape>
500 [[nodiscard]] constexpr bool samePointSet(const OtherShape& other) const;
501
503 constexpr auto operator<=>(const Rectangle& other) const {
504 return points_ <=> other.points_;
505 }
506
515 template <class A = LabelType>
516 requires(detail::has_label_v<A>)
517 constexpr A& label() const {
518 return label_;
519 }
520
527 template <class ResultNumber = NumberType>
528 [[nodiscard]] constexpr ResultNumber area() const;
529
535 [[nodiscard]] constexpr auto twiceArea() const;
536
544 [[nodiscard]] constexpr bool isDegenerate() const;
545
553 [[nodiscard]] constexpr bool isPoint() const;
554
562 [[nodiscard]] constexpr std::optional<PointType> getIfPoint() const;
563
574 [[nodiscard]] constexpr bool isSegment() const;
575
584 [[nodiscard]] constexpr std::optional<BoundaryType<false>> getIfSegment() const;
585
596 [[nodiscard]] constexpr bool isUndefined() const;
597
603 [[nodiscard]] constexpr Rectangle bbox() const;
604
621 template <class ResultNumber = grid_number_t<typename PointType_::NumberType>>
622 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
625
632 template <std::floating_point ResultNumber = double>
633 [[nodiscard]] constexpr Rectangle<Point<ResultNumber>> fbox() const;
634
644 [[nodiscard]] constexpr std::array<PointType, 4> vertices() const;
645
655 [[nodiscard]] constexpr std::array<Segment<PointType>, 4> edges() const;
656
666 [[nodiscard]] constexpr std::array<OrientedSegment<PointType>, 4> orientedEdges() const;
667
678 [[nodiscard]] constexpr explicit operator Convex<PointType>() const {
679 if (empty()) {
680 return Convex<PointType>();
681 }
682 return Convex<PointType>(*this, !isDegenerate());
683 }
684
690 [[nodiscard]] constexpr Convex<PointType> asConvex() const {
691 return static_cast<Convex<PointType>>(*this);
692 }
693
699 [[nodiscard]] constexpr Convex<PointType> convexHull() const {
700 return asConvex();
701 }
702
714 }
715
725 [[nodiscard]] constexpr explicit operator Polygon<PointType>() const {
726 if (empty()) {
727 return Polygon<PointType>();
728 }
729 return Polygon<PointType>(*this, !isDegenerate());
730 }
731
737 [[nodiscard]] constexpr Polygon<PointType> asPolygon() const {
738 return static_cast<Polygon<PointType>>(*this);
739 }
740
747 [[nodiscard]] constexpr PolygonWithHoles<PointType> asPolygonWithHoles() const {
749 }
750
759 [[nodiscard]] constexpr PolygonSet<PointType> asPolygonSet() const {
761 }
762
771 template<PointConcept OtherPoint>
772 [[nodiscard]] constexpr bool verticesContain(const OtherPoint& point) const;
773
784 template<PointConcept OtherPoint>
785 [[nodiscard]] constexpr bool contains(const OtherPoint& point) const;
786
788 template<LineConcept OtherLine>
789 [[nodiscard]] constexpr bool contains(const OtherLine& other) const;
790
792 template<OrientedLineConcept OtherOrientedLine>
793 [[nodiscard]] constexpr bool contains(const OtherOrientedLine& other) const;
794
796 template<SegmentConcept OtherSegment>
797 [[nodiscard]] constexpr bool contains(const OtherSegment& other) const;
798
800 template<OrientedSegmentConcept OtherOrientedSegment>
801 [[nodiscard]] constexpr bool contains(const OtherOrientedSegment& other) const;
802
804 template<RayConcept OtherRay>
805 [[nodiscard]] constexpr bool contains(const OtherRay& other) const;
806
808 template<HalfplaneConcept OtherHalfplane>
809 [[nodiscard]] constexpr bool contains(const OtherHalfplane& other) const;
810
821 template<RectangleConcept OtherRectangle>
822 [[nodiscard]] constexpr bool contains(const OtherRectangle& other) const;
823
825 template<TriangleConcept OtherTriangle>
826 [[nodiscard]] constexpr bool contains(const OtherTriangle& other) const;
827
829 template<ConvexConcept OtherConvex>
830 [[nodiscard]] constexpr bool contains(const OtherConvex& other) const;
831
833 template<PolygonConcept OtherPolygon>
834 [[nodiscard]] constexpr bool contains(const OtherPolygon& other) const;
835
837 template<DiskConcept OtherDisk>
838 [[nodiscard]] constexpr bool contains(const OtherDisk& other) const;
839
841 [[nodiscard]] constexpr bool contains(const Shape<PointType>& other) const;
842
844 [[nodiscard]] constexpr bool boundaryContains(const Shape<PointType>& other) const;
845
846 // The empty set is a subset of every shape (contained in all of them) and
847 // disjoint from all of them, so containment is true while separation is
848 // false. These overloads let an EmptyShape flow through Shape's variant
849 // dispatch without special-casing.
851 template <class EmptyPoint>
852 [[nodiscard]] constexpr bool contains(const EmptyShape<EmptyPoint>&) const {
853 return true;
854 }
855
856 template <class EmptyPoint>
857 [[nodiscard]] constexpr bool boundaryContains(const EmptyShape<EmptyPoint>&) const {
858 return true;
859 }
860
861 template <class EmptyPoint>
862 [[nodiscard]] constexpr bool interiorContains(const EmptyShape<EmptyPoint>&) const {
863 return true;
864 }
865
866 template <class EmptyPoint>
867 [[nodiscard]] constexpr bool separates(const EmptyShape<EmptyPoint>&) const {
868 return false;
869 }
870
872 template<PointConcept OtherPoint>
873 [[nodiscard]] constexpr bool interiorContains(const OtherPoint& point) const;
874
876 template<LineConcept OtherLine>
877 [[nodiscard]] constexpr bool interiorContains(const OtherLine& other) const;
878
880 template<OrientedLineConcept OtherOrientedLine>
881 [[nodiscard]] constexpr bool interiorContains(const OtherOrientedLine& other) const;
882
884 template<SegmentConcept OtherSegment>
885 [[nodiscard]] constexpr bool interiorContains(const OtherSegment& other) const;
886
888 template<OrientedSegmentConcept OtherOrientedSegment>
889 [[nodiscard]] constexpr bool interiorContains(const OtherOrientedSegment& other) const;
890
892 template<RayConcept OtherRay>
893 [[nodiscard]] constexpr bool interiorContains(const OtherRay& other) const;
894
896 template<HalfplaneConcept OtherHalfplane>
897 [[nodiscard]] constexpr bool interiorContains(const OtherHalfplane& other) const;
898
909 template<RectangleConcept OtherRectangle>
910 [[nodiscard]] constexpr bool interiorContains(const OtherRectangle& other) const;
911
913 template<TriangleConcept OtherTriangle>
914 [[nodiscard]] constexpr bool interiorContains(const OtherTriangle& other) const;
915
924 template<PointConcept OtherPoint>
925 [[nodiscard]] constexpr bool boundaryContains(const OtherPoint& point) const;
926
928 template<SegmentConcept OtherSegment>
929 [[nodiscard]] constexpr bool boundaryContains(const OtherSegment& other) const;
930
932 template<OrientedSegmentConcept OtherOrientedSegment>
933 [[nodiscard]] constexpr bool boundaryContains(const OtherOrientedSegment& other) const;
934
936 template<LineConcept OtherLine>
937 [[nodiscard]] constexpr bool boundaryContains(const OtherLine& other) const;
938
940 template<OrientedLineConcept OtherOrientedLine>
941 [[nodiscard]] constexpr bool boundaryContains(const OtherOrientedLine& other) const;
942
944 template<RayConcept OtherRay>
945 [[nodiscard]] constexpr bool boundaryContains(const OtherRay& other) const;
946
948 template<HalfplaneConcept OtherHalfplane>
949 [[nodiscard]] constexpr bool boundaryContains(const OtherHalfplane& other) const;
950
952 template<RectangleConcept OtherRectangle>
953 [[nodiscard]] constexpr bool boundaryContains(const OtherRectangle& other) const;
954
956 template<TriangleConcept OtherTriangle>
957 [[nodiscard]] constexpr bool boundaryContains(const OtherTriangle& other) const;
958
960 template<ConvexConcept OtherConvex>
961 [[nodiscard]] constexpr bool boundaryContains(const OtherConvex& other) const;
962
964 template<PolygonConcept OtherPolygon>
965 [[nodiscard]] constexpr bool boundaryContains(const OtherPolygon& other) const;
966
968 template<DiskConcept OtherDisk>
969 [[nodiscard]] constexpr bool boundaryContains(const OtherDisk& other) const;
970
981 template<PointConcept OtherPoint>
982 [[nodiscard]] constexpr bool intersects(const OtherPoint& other) const;
983
985 template<RectangleConcept OtherRectangle>
986 [[nodiscard]] constexpr bool intersects(const OtherRectangle& other) const;
987
989 template<LineConcept OtherLine>
990 [[nodiscard]] constexpr bool intersects(const OtherLine& other) const;
991
993 template<OrientedLineConcept OtherOrientedLine>
994 [[nodiscard]] constexpr bool intersects(const OtherOrientedLine& other) const;
995
997 template<SegmentConcept OtherSegment>
998 [[nodiscard]] constexpr bool intersects(const OtherSegment& other) const;
999
1001 template<OrientedSegmentConcept OtherOrientedSegment>
1002 [[nodiscard]] constexpr bool intersects(const OtherOrientedSegment& other) const;
1003
1005 template<RayConcept OtherRay>
1006 [[nodiscard]] constexpr bool intersects(const OtherRay& other) const;
1007
1009 template<HalfplaneConcept OtherHalfplane>
1010 [[nodiscard]] constexpr bool intersects(const OtherHalfplane& other) const;
1011
1013 [[nodiscard]] constexpr bool intersects(const Shape<PointType>& other) const;
1014
1016 template<typename OtherShape>
1017 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1018 [[nodiscard]] constexpr bool intersects(const OtherShape& other) const {
1019 return other.intersects(*this);
1020 }
1021
1023 template <class EmptyPoint>
1024 [[nodiscard]] constexpr bool intersects(const EmptyShape<EmptyPoint>&) const {
1025 return false;
1026 }
1027
1038 template<PointConcept OtherPoint>
1039 [[nodiscard]] constexpr bool interiorsIntersect(const OtherPoint& other) const;
1040
1042 template<RectangleConcept OtherRectangle>
1043 [[nodiscard]] constexpr bool interiorsIntersect(const OtherRectangle& other) const;
1044
1046 template<LineConcept OtherLine>
1047 [[nodiscard]] constexpr bool interiorsIntersect(const OtherLine& other) const;
1048
1050 template<OrientedLineConcept OtherOrientedLine>
1051 [[nodiscard]] constexpr bool interiorsIntersect(const OtherOrientedLine& other) const;
1052
1054 template<SegmentConcept OtherSegment>
1055 [[nodiscard]] constexpr bool interiorsIntersect(const OtherSegment& other) const;
1056
1058 template<OrientedSegmentConcept OtherOrientedSegment>
1059 [[nodiscard]] constexpr bool interiorsIntersect(const OtherOrientedSegment& other) const;
1060
1062 template<RayConcept OtherRay>
1063 [[nodiscard]] constexpr bool interiorsIntersect(const OtherRay& other) const;
1064
1066 template<HalfplaneConcept OtherHalfplane>
1067 [[nodiscard]] constexpr bool interiorsIntersect(const OtherHalfplane& other) const;
1068
1070 template<typename OtherShape>
1071 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1072 [[nodiscard]] constexpr bool interiorsIntersect(const OtherShape& other) const {
1073 return other.interiorsIntersect(*this);
1074 }
1075
1077 template <class EmptyPoint>
1078 [[nodiscard]] constexpr bool interiorsIntersect(const EmptyShape<EmptyPoint>&) const {
1079 return false;
1080 }
1081
1083 [[nodiscard]] constexpr bool interiorsIntersect(const Shape<PointType>& other) const;
1084
1086 template<RectangleConcept OtherRectangle>
1087 [[nodiscard]] constexpr bool separates(const OtherRectangle& other) const;
1088
1090 template<PointConcept OtherPoint>
1091 [[nodiscard]] constexpr bool separates(const OtherPoint& other) const;
1092
1094 template<LineConcept OtherLine>
1095 [[nodiscard]] constexpr bool separates(const OtherLine& other) const;
1096
1098 template<OrientedLineConcept OtherOrientedLine>
1099 [[nodiscard]] constexpr bool separates(const OtherOrientedLine& other) const;
1100
1102 template<SegmentConcept OtherSegment>
1103 [[nodiscard]] constexpr bool separates(const OtherSegment& other) const;
1104
1106 template<OrientedSegmentConcept OtherOrientedSegment>
1107 [[nodiscard]] constexpr bool separates(const OtherOrientedSegment& other) const;
1108
1110 template<RayConcept OtherRay>
1111 [[nodiscard]] constexpr bool separates(const OtherRay& other) const;
1112
1114 template<HalfplaneConcept OtherHalfplane>
1115 [[nodiscard]] constexpr bool separates(const OtherHalfplane& other) const;
1116
1118 template<TriangleConcept OtherTriangle>
1119 [[nodiscard]] constexpr bool separates(const OtherTriangle& other) const;
1120
1122 template<ConvexConcept OtherConvex>
1123 [[nodiscard]] constexpr bool separates(const OtherConvex& other) const;
1124
1126 template<DiskConcept OtherDisk>
1127 [[nodiscard]] constexpr bool separates(const OtherDisk& other) const;
1128
1130 template<PolygonConcept OtherPolygon>
1131 [[nodiscard]] constexpr bool separates(const OtherPolygon& other) const;
1132
1134 template<MonotoneChainConcept OtherChain>
1135 [[nodiscard]] constexpr bool contains(const OtherChain& other) const;
1136
1138 template<MonotoneChainConcept OtherChain>
1139 [[nodiscard]] constexpr bool boundaryContains(const OtherChain& other) const;
1140
1142 template<MonotoneChainConcept OtherChain>
1143 [[nodiscard]] constexpr bool interiorContains(const OtherChain& other) const;
1144
1146 template<MonotoneChainConcept OtherChain>
1147 [[nodiscard]] constexpr bool separates(const OtherChain& other) const;
1148
1150 template<PolylineConcept OtherPolyline>
1151 [[nodiscard]] constexpr bool contains(const OtherPolyline& other) const;
1152
1154 template<PolylineConcept OtherPolyline>
1155 [[nodiscard]] constexpr bool boundaryContains(const OtherPolyline& other) const;
1156
1158 template<PolylineConcept OtherPolyline>
1159 [[nodiscard]] constexpr bool interiorContains(const OtherPolyline& other) const;
1160
1162 template<PolylineConcept OtherPolyline>
1163 [[nodiscard]] constexpr bool separates(const OtherPolyline& other) const;
1164
1166 template<HalfplaneIntersectionConcept OtherRegion>
1167 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1168
1170 template<HalfplaneIntersectionConcept OtherRegion>
1171 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1172
1174 template<HalfplaneIntersectionConcept OtherRegion>
1175 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1176
1178 template<HalfplaneIntersectionConcept OtherRegion>
1179 [[nodiscard]] constexpr bool separates(const OtherRegion& other) const;
1180
1188 template<PolygonWithHolesConcept OtherRegion>
1189 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1190
1197 template<PolygonWithHolesConcept OtherRegion>
1198 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1199
1201 template<PolygonWithHolesConcept OtherRegion>
1202 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1203
1211 template<PolygonWithHolesConcept OtherRegion>
1212 [[nodiscard]] bool separates(const OtherRegion& other) const;
1213
1214 // -------------------------------------------------------------------------
1215 // A set of regions
1216 //
1217 // It outranks every other shape, so the symmetric relations reach it through
1218 // the rank-based forwarders and only the asymmetric ones are answered here.
1219 // A set is the union of its components, so it is contained exactly when
1220 // every component is — no matter what this shape is.
1221
1223 template<PolygonSetConcept OtherSet>
1224 [[nodiscard]] constexpr bool contains(const OtherSet& other) const {
1225 for (const auto& component : other) {
1226 if (!contains(component)) {
1227 return false;
1228 }
1229 }
1230 return true;
1231 }
1232
1234 template<PolygonSetConcept OtherSet>
1235 [[nodiscard]] constexpr bool boundaryContains(const OtherSet& other) const {
1236 for (const auto& component : other) {
1237 if (!boundaryContains(component)) {
1238 return false;
1239 }
1240 }
1241 return true;
1242 }
1243
1245 template<PolygonSetConcept OtherSet>
1246 [[nodiscard]] constexpr bool interiorContains(const OtherSet& other) const {
1247 for (const auto& component : other) {
1248 if (!interiorContains(component)) {
1249 return false;
1250 }
1251 }
1252 return true;
1253 }
1254
1263 template<PolygonSetConcept OtherSet>
1264 [[nodiscard]] bool separates(const OtherSet& other) const;
1265
1267 [[nodiscard]] constexpr bool separates(const Shape<PointType>& other) const;
1268
1269 // --- not-yet-implemented predicate pairs (throw); see implementation ---
1271 template<DiskConcept OtherDisk>
1272 [[nodiscard]] constexpr bool interiorContains(const OtherDisk& other) const;
1273
1275 template<ConvexConcept OtherConvex>
1276 [[nodiscard]] constexpr bool interiorContains(const OtherConvex& other) const;
1277
1279 template<PolygonConcept OtherPolygon>
1280 [[nodiscard]] constexpr bool interiorContains(const OtherPolygon& other) const;
1281
1282
1293 template<RectangleConcept OtherRectangle>
1294 [[nodiscard]] constexpr bool crosses(const OtherRectangle& other) const;
1295
1297 template<PointConcept OtherPoint>
1298 [[nodiscard]] constexpr bool crosses(const OtherPoint& other) const;
1299
1301 template<LineConcept OtherLine>
1302 [[nodiscard]] constexpr bool crosses(const OtherLine& other) const;
1303
1305 template<OrientedLineConcept OtherOrientedLine>
1306 [[nodiscard]] constexpr bool crosses(const OtherOrientedLine& other) const;
1307
1309 template<SegmentConcept OtherSegment>
1310 [[nodiscard]] constexpr bool crosses(const OtherSegment& other) const;
1311
1313 template<OrientedSegmentConcept OtherOrientedSegment>
1314 [[nodiscard]] constexpr bool crosses(const OtherOrientedSegment& other) const;
1315
1317 template<RayConcept OtherRay>
1318 [[nodiscard]] constexpr bool crosses(const OtherRay& other) const;
1319
1321 template<HalfplaneConcept OtherHalfplane>
1322 [[nodiscard]] constexpr bool crosses(const OtherHalfplane& other) const;
1323
1325 template<typename OtherShape>
1326 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1327 [[nodiscard]] constexpr bool crosses(const OtherShape& other) const {
1328 return other.crosses(*this);
1329 }
1330
1332 template <class EmptyPoint>
1333 [[nodiscard]] constexpr bool crosses(const EmptyShape<EmptyPoint>&) const {
1334 return false;
1335 }
1336
1338 [[nodiscard]] constexpr bool crosses(const Shape<PointType>& other) const;
1339
1341 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1342 [[nodiscard]] constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
1343 intersection(const OtherPoint& other) const;
1344
1346 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1347 [[nodiscard]] constexpr std::optional<Rectangle<Point<ResultNumber, typename PointType::LabelType>>>
1348 intersection(const OtherRectangle& other) const;
1349
1351 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1352 [[nodiscard]] constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
1353 intersection(const OtherLine& other) const;
1354
1356 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1357 [[nodiscard]] constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
1358 intersection(const OtherOrientedLine& other) const;
1359
1361 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1362 [[nodiscard]] constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
1363 intersection(const OtherSegment& other) const;
1364
1366 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1367 [[nodiscard]] constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
1368 intersection(const OtherOrientedSegment& other) const;
1369
1371 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1372 [[nodiscard]] constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
1373 intersection(const OtherRay& other) const;
1374
1376 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1377 [[nodiscard]] constexpr auto intersection(const OtherHalfplane& other) const;
1378
1380 template <class ResultNumber = NumberType, HalfplaneIntersectionConcept OtherRegion>
1381 [[nodiscard]] constexpr auto intersection(const OtherRegion& other) const {
1382 return other.template intersection<ResultNumber>(*this);
1383 }
1384
1386 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1387 requires (!PointConcept<OtherShape>
1389 && (detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1390 && requires(const OtherShape& o, const Rectangle& self) {
1391 o.template intersection<ResultNumber>(self);
1392 })
1393 [[nodiscard]] constexpr auto intersection(const OtherShape& other) const {
1394 return other.template intersection<ResultNumber>(*this);
1395 }
1396
1398 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1399 requires (!PointConcept<OtherShape>
1400 && (detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1401 && requires(const OtherShape& o, const Rectangle& self) {
1403 })
1404 [[nodiscard]] constexpr auto regularizedIntersection(const OtherShape& other) const {
1405 return other.template regularizedIntersection<ResultNumber>(*this);
1406 }
1407
1409 template <class ResultNumber = NumberType, class EmptyPoint>
1410 [[nodiscard]] constexpr EmptyShape<EmptyPoint> intersection(const EmptyShape<EmptyPoint>&) const {
1411 return {};
1412 }
1413
1431 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1432 [[nodiscard]] constexpr auto squaredDistance(const OtherPoint& point) const;
1433
1445 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1446 [[nodiscard]] constexpr auto squaredDistance(const OtherLine& other) const;
1447
1449 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1450 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedLine& other) const;
1451
1453 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1454 [[nodiscard]] constexpr auto squaredDistance(const OtherSegment& other) const;
1455
1457 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1458 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedSegment& other) const;
1459
1461 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1462 [[nodiscard]] constexpr auto squaredDistance(const OtherRay& other) const;
1463
1465 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1466 [[nodiscard]] constexpr auto squaredDistance(const OtherHalfplane& other) const;
1467
1479 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1480 [[nodiscard]] constexpr auto squaredDistance(const OtherRectangle& other) const;
1481
1488 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1489 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1490 && requires(const OtherShape& o, const Rectangle& self) {
1491 o.template squaredDistance<ResultNumber>(self);
1492 })
1493 [[nodiscard]] constexpr auto squaredDistance(const OtherShape& other) const {
1494 return other.template squaredDistance<ResultNumber>(*this);
1495 }
1496
1504 template <class ResultNumber = double, class DiskPointType, class DiskLabel>
1505 [[nodiscard]] detail::floating_result_t<ResultNumber> squaredDistance(const Disk<DiskPointType, DiskLabel>& disk) const {
1506 return disk.template squaredDistance<ResultNumber>(*this);
1507 }
1508
1521 template <class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape>
1522 requires detail::ClosestPairConcept<Rectangle<PointType_, TLabel>, OtherShape>
1523 [[nodiscard]] constexpr auto closestSegments(const OtherShape& other) const;
1524
1541 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
1542 requires detail::ClosestPointsPairConcept<Rectangle<PointType_, TLabel>, OtherShape>
1543 [[nodiscard]] constexpr auto closestPoints(const OtherShape& other) const;
1544
1552 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1553 [[nodiscard]] constexpr auto distanceL1(const OtherPoint& point) const;
1554
1556 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1557 [[nodiscard]] constexpr auto distanceL1(const OtherLine& other) const;
1558
1560 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1561 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedLine& other) const;
1562
1564 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1565 [[nodiscard]] constexpr auto distanceL1(const OtherSegment& other) const;
1566
1568 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1569 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedSegment& other) const;
1570
1572 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1573 [[nodiscard]] constexpr auto distanceL1(const OtherRay& other) const;
1574
1576 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1577 [[nodiscard]] constexpr auto distanceL1(const OtherHalfplane& other) const;
1578
1580 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1581 [[nodiscard]] constexpr auto distanceL1(const OtherRectangle& other) const;
1582
1589 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1590 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1591 && requires(const OtherShape& o, const Rectangle& self) {
1592 o.template distanceL1<ResultNumber>(self);
1593 })
1594 [[nodiscard]] constexpr auto distanceL1(const OtherShape& other) const {
1595 return other.template distanceL1<ResultNumber>(*this);
1596 }
1597
1613 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1614 [[nodiscard]] constexpr auto intersection(const Shape<OtherPoint>& other) const {
1615 return other.template intersection<ResultNumber>(*this);
1616 }
1617
1619 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1620 [[nodiscard]] auto regularizedIntersection(const Shape<OtherPoint>& other) const {
1621 return other.template regularizedIntersection<ResultNumber>(*this);
1622 }
1623
1636 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1637 [[nodiscard]] auto regularizedUnion(const Shape<OtherPoint>& other) const {
1638 return other.template regularizedUnion<ResultNumber>(*this);
1639 }
1640
1655 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1656 [[nodiscard]] auto difference(const Shape<OtherPoint>& other) const {
1657 return Shape<OtherPoint>(*this).template difference<ResultNumber>(other);
1658 }
1659
1672 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1673 [[nodiscard]] auto symmetricDifference(const Shape<OtherPoint>& other) const {
1674 return other.template symmetricDifference<ResultNumber>(*this);
1675 }
1676
1685 template <class ResultNumber = double, PointConcept OtherPoint>
1686 [[nodiscard]] constexpr auto distanceL1(const Shape<OtherPoint>& other) const {
1687 return other.template distanceL1<ResultNumber>(*this);
1688 }
1689
1697 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1698 [[nodiscard]] constexpr auto distanceLInf(const OtherPoint& point) const;
1699
1701 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1702 [[nodiscard]] constexpr auto distanceLInf(const OtherLine& other) const;
1703
1705 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1706 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedLine& other) const;
1707
1709 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1710 [[nodiscard]] constexpr auto distanceLInf(const OtherSegment& other) const;
1711
1713 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1714 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedSegment& other) const;
1715
1717 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1718 [[nodiscard]] constexpr auto distanceLInf(const OtherRay& other) const;
1719
1721 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1722 [[nodiscard]] constexpr auto distanceLInf(const OtherHalfplane& other) const;
1723
1725 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1726 [[nodiscard]] constexpr auto distanceLInf(const OtherRectangle& other) const;
1727
1734 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1735 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1736 && requires(const OtherShape& o, const Rectangle& self) {
1737 o.template distanceLInf<ResultNumber>(self);
1738 })
1739 [[nodiscard]] constexpr auto distanceLInf(const OtherShape& other) const {
1740 return other.template distanceLInf<ResultNumber>(*this);
1741 }
1742
1751 template <class ResultNumber = double, PointConcept OtherPoint>
1752 [[nodiscard]] constexpr auto distanceLInf(const Shape<OtherPoint>& other) const {
1753 return other.template distanceLInf<ResultNumber>(*this);
1754 }
1755
1757 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1758 [[nodiscard]] constexpr auto hausdorffDistanceL1(const OtherRectangle& other) const;
1759
1761 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1762 [[nodiscard]] constexpr auto hausdorffDistanceL1(const OtherPoint& point) const;
1763
1765 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1766 [[nodiscard]] constexpr auto hausdorffDistanceL1(const OtherSegment& other) const;
1767
1769 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1770 [[nodiscard]] constexpr auto hausdorffDistanceL1(const OtherOrientedSegment& other) const;
1771
1778 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1779 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1780 && requires(const OtherShape& o, const Rectangle& self) {
1781 o.template hausdorffDistanceL1<ResultNumber>(self);
1782 })
1783 [[nodiscard]] constexpr auto hausdorffDistanceL1(const OtherShape& other) const {
1784 return other.template hausdorffDistanceL1<ResultNumber>(*this);
1785 }
1786
1795 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1796 [[nodiscard]] constexpr auto hausdorffDistanceL1(const Shape<OtherPoint>& other) const {
1797 return other.template hausdorffDistanceL1<ResultNumber>(*this);
1798 }
1799
1801 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1802 [[nodiscard]] constexpr auto hausdorffDistanceLInf(const OtherRectangle& other) const;
1803
1805 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1806 [[nodiscard]] constexpr auto hausdorffDistanceLInf(const OtherPoint& point) const;
1807
1809 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1810 [[nodiscard]] constexpr auto hausdorffDistanceLInf(const OtherSegment& other) const;
1811
1813 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1814 [[nodiscard]] constexpr auto hausdorffDistanceLInf(const OtherOrientedSegment& other) const;
1815
1822 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1823 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1824 && requires(const OtherShape& o, const Rectangle& self) {
1825 o.template hausdorffDistanceLInf<ResultNumber>(self);
1826 })
1827 [[nodiscard]] constexpr auto hausdorffDistanceLInf(const OtherShape& other) const {
1828 return other.template hausdorffDistanceLInf<ResultNumber>(*this);
1829 }
1830
1839 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1840 [[nodiscard]] constexpr auto hausdorffDistanceLInf(const Shape<OtherPoint>& other) const {
1841 return other.template hausdorffDistanceLInf<ResultNumber>(*this);
1842 }
1843
1856 template <class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1857 [[nodiscard]] constexpr auto squaredHausdorffDistance(const OtherRectangle& other) const;
1858
1867 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1868 [[nodiscard]] constexpr auto squaredHausdorffDistance(const OtherPoint& point) const;
1869
1871 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1872 [[nodiscard]] constexpr auto squaredHausdorffDistance(const OtherSegment& other) const;
1873
1875 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1876 [[nodiscard]] constexpr auto squaredHausdorffDistance(const OtherOrientedSegment& other) const;
1877
1884 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1885 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
1886 && requires(const OtherShape& o, const Rectangle& self) {
1888 })
1889 [[nodiscard]] constexpr auto squaredHausdorffDistance(const OtherShape& other) const {
1890 return other.template squaredHausdorffDistance<ResultNumber>(*this);
1891 }
1892
1907 template <PointConcept OtherPoint>
1908 constexpr void insert(const OtherPoint& point);
1909
1920 template <RectangleConcept OtherRectangle>
1921 constexpr void insert(const OtherRectangle& other);
1922
1934 template <class TShape>
1935 requires(!detail::is_point_v<TShape> && !RectangleConcept<TShape> && requires(const TShape& shape) { shape.bbox(); })
1936 constexpr void insert(const TShape& shape);
1937
1947 template<std::ranges::input_range Range = std::initializer_list<PointType>>
1948 requires std::ranges::common_range<Range> &&
1949 std::convertible_to<std::ranges::range_value_t<Range>, PointType> &&
1950 (!requires(const std::remove_cvref_t<Range>& shape) { shape.bbox(); })
1951 constexpr void insert(Range&& range) {
1952 // Defined inline so MSVC can match the constrained overload; the
1953 // overloaded out-of-line form trips MSVC's C2244.
1954 for (const auto& point : range) {
1955 insert(point);
1956 }
1957 }
1958
1969 template <std::ranges::input_range Range>
1970 requires(!detail::is_point_v<typename std::ranges::range_value_t<Range>> && requires(const typename std::ranges::range_value_t<Range>& shape) { shape.bbox(); })
1971 constexpr void insert(Range&& range) {
1972 // Defined inline so MSVC can match the constrained overload; the
1973 // overloaded out-of-line form trips MSVC's C2244.
1974 for (const auto& shape : range) {
1975 insert(shape);
1976 }
1977 }
1978
1987 [[nodiscard]] constexpr Segment<PointType> diameter() const;
1988
1999 template <class ResultNumber = division_result_t<NumberType>>
2000 [[nodiscard]] constexpr Point<ResultNumber> midpoint() const;
2001
2009 template <class ResultNumber = division_result_t<NumberType>>
2010 [[nodiscard]] constexpr Point<ResultNumber> centroid() const;
2011
2020 [[nodiscard]] constexpr Disk<PointType, NoLabel> circumcircle() const;
2021
2028 template <class ResultNumber = division_result_t<NumberType>>
2029 [[nodiscard]] constexpr Point<ResultNumber> center() const;
2030
2042 template <class ResultNumber = division_result_t<NumberType>>
2043 [[nodiscard]] constexpr Point<ResultNumber> pointInside() const;
2044
2053 template <class OtherShape>
2054 [[nodiscard]] constexpr bool pointInsideInteriorContainedIn(const OtherShape& shape) const;
2055
2062 [[nodiscard]] constexpr Rectangle rotated90(int k = 1) const;
2063
2069 constexpr void rotate90(int k = 1);
2070
2072 template <class OtherNumber>
2073 [[nodiscard]] constexpr Rectangle scaledUpX(const OtherNumber scalar) const;
2074
2076 template <class OtherNumber>
2077 constexpr void scaleUpX(const OtherNumber scalar);
2078
2080 template <class OtherNumber>
2081 [[nodiscard]] constexpr Rectangle scaledUpY(const OtherNumber scalar) const;
2082
2084 template <class OtherNumber>
2085 constexpr void scaleUpY(const OtherNumber scalar);
2086
2088 template <class OtherNumber>
2089 [[nodiscard]] constexpr Rectangle scaledDownX(const OtherNumber scalar) const;
2090
2092 template <class OtherNumber>
2093 constexpr void scaleDownX(const OtherNumber scalar);
2094
2096 template <class OtherNumber>
2097 [[nodiscard]] constexpr Rectangle scaledDownY(const OtherNumber scalar) const;
2098
2100 template <class OtherNumber>
2101 constexpr void scaleDownY(const OtherNumber scalar);
2102
2116 template <class OtherShape>
2118 [[nodiscard]] constexpr auto minkowskiSum(const OtherShape& other) const;
2119
2144 template <class OtherShape>
2146 [[nodiscard]] constexpr auto minkowskiErosion(const OtherShape& other) const;
2147
2170 template <class OtherShape>
2173 [[nodiscard]] constexpr auto minkowskiErosion(const OtherShape& other) const;
2174
2185 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2187 && (detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
2188 && requires(const OtherShape& o, const Rectangle& self) {
2189 o.template minkowskiSum<ResultNumber>(self);
2190 })
2191 [[nodiscard]] auto minkowskiSum(const OtherShape& other) const {
2192 return other.template minkowskiSum<ResultNumber>(*this);
2193 }
2194
2210 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2212 regularizedUnion(const OtherRectangle& other) const;
2213
2221 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2222 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
2223 && requires(const OtherShape& o, const Rectangle& self) {
2224 o.template regularizedUnion<ResultNumber>(self);
2225 })
2226 [[nodiscard]] auto regularizedUnion(const OtherShape& other) const {
2227 return other.template regularizedUnion<ResultNumber>(*this);
2228 }
2229
2245 template <class ResultNumber = division_result_t<NumberType>, PolygonalRegionConcept OtherRegion>
2247 difference(const OtherRegion& other) const;
2248
2258 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
2260 difference(const OtherIntersection& other) const;
2261
2268 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2270 difference(const OtherHalfplane& other) const;
2271
2284 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2286 symmetricDifference(const OtherRectangle& other) const;
2287
2295 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2296 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Rectangle>)
2297 && requires(const OtherShape& o, const Rectangle& self) {
2298 o.template symmetricDifference<ResultNumber>(self);
2299 })
2300 [[nodiscard]] auto symmetricDifference(const OtherShape& other) const {
2301 return other.template symmetricDifference<ResultNumber>(*this);
2302 }
2303
2312 template<PointConcept OtherPoint>
2313 constexpr Rectangle& operator+=(const OtherPoint& translation);
2314
2323 template<PointConcept OtherPoint>
2324 constexpr Rectangle& operator-=(const OtherPoint& translation);
2325
2336 template <class Scalar>
2337 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2338 constexpr Rectangle& operator*=(const Scalar& scalar);
2339
2350 template <class Scalar>
2351 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2352 constexpr Rectangle& operator/=(const Scalar& scalar);
2353
2354 template <bool Oriented>
2356 public:
2357 using iterator_category = std::forward_iterator_tag;
2358 using iterator_concept = std::forward_iterator_tag;
2360 using difference_type = std::ptrdiff_t;
2362
2363 constexpr BoundaryIterator() = default;
2364
2365 constexpr value_type operator*() const {
2366 assert(rectangle != nullptr);
2367 return rectangle->template boundaryAt<Oriented>(index);
2368 }
2369
2371 ++index;
2372 return *this;
2373 }
2374
2376 BoundaryIterator copy(*this);
2377 ++(*this);
2378 return copy;
2379 }
2380
2381 constexpr bool operator==(const BoundaryIterator& other) const = default;
2382
2383 private:
2384 friend struct Rectangle;
2385
2386 constexpr BoundaryIterator(const Rectangle* rectangle_arg, std::size_t index_arg)
2387 : rectangle(rectangle_arg), index(index_arg) {}
2388
2389 const Rectangle* rectangle = nullptr;
2390 std::size_t index = 0;
2391 };
2392
2393 private:
2394 static constexpr std::size_t edgeCount = 4;
2395
2396 static constexpr PointType makeCorner(const NumberType& x, const NumberType& y) {
2397 return Point<NumberType, typename PointType::LabelType>(x, y, typename PointType::LabelType{});
2398 }
2399
2406 static constexpr std::array<PointType, 2> emptyCorners() {
2407 return {makeCorner(NumberType(0), NumberType(0)),
2408 makeCorner(NumberType(-1), NumberType(-1))};
2409 }
2410
2416 constexpr PointType bottomRight() const;
2417
2423 constexpr PointType topLeft() const;
2424
2435 template <bool Oriented>
2436 constexpr BoundaryType<Oriented> boundaryAt(std::size_t index) const;
2437
2438 template <class Left, class Right>
2439 static constexpr bool intervalsOverlap(const Left& first_min, const Left& first_max, const Right& second_min, const Right& second_max);
2440
2441 template <class Left, class Right>
2442 static constexpr bool intervalsOverlapStrict(const Left& first_min, const Left& first_max, const Right& second_min, const Right& second_max);
2443
2444 template <class Left, class Right>
2445 static constexpr auto axisDistance(const Left& first_min, const Left& first_max, const Right& second_min, const Right& second_max)
2446 -> std::common_type_t<Left, Right>;
2447
2448 // template <std::ranges::input_range Range>
2449 // requires std::constructible_from<PointType, std::ranges::range_reference_t<Range>>
2450 // constexpr void assignBoundingBox(Range&& points);
2451
2452 std::array<PointType, 2> points_{};
2453 [[no_unique_address]] mutable LabelType label_{};
2454};
2455
2467template <class PointType, class LabelType, class TranslationNumber, class TranslationLabel>
2468constexpr auto operator-(const Rectangle<PointType, LabelType>& rectangle, const Point<TranslationNumber, TranslationLabel>& translation);
2469
2480template <class PointType, class LabelType, class Scalar>
2481 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2482constexpr auto operator*(const Rectangle<PointType, LabelType>& rectangle, const Scalar& scalar);
2483
2494template <class Scalar, class PointType, class LabelType>
2495 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2496constexpr auto operator*(const Scalar& scalar, const Rectangle<PointType, LabelType>& rectangle);
2497
2508template <class PointType, class LabelType, class Scalar>
2509 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2510constexpr auto operator/(const Rectangle<PointType, LabelType>& rectangle, const Scalar& scalar);
2511
2521template <class PointType, class LabelType>
2522std::ostream& operator<<(std::ostream& stream, const Rectangle<PointType, LabelType>& rectangle);
2523
2524} // namespace pgl
constexpr value_type operator*() const
Definition rectangle.hpp:2365
constexpr BoundaryIterator operator++(int)
Definition rectangle.hpp:2375
value_type reference
Definition rectangle.hpp:2361
BoundaryType< Oriented > value_type
Definition rectangle.hpp:2359
std::forward_iterator_tag iterator_category
Definition rectangle.hpp:2357
constexpr BoundaryIterator & operator++()
Definition rectangle.hpp:2370
std::forward_iterator_tag iterator_concept
Definition rectangle.hpp:2358
constexpr BoundaryIterator()=default
friend struct Rectangle
Definition rectangle.hpp:2384
constexpr bool operator==(const BoundaryIterator &other) const =default
std::ptrdiff_t difference_type
Definition rectangle.hpp:2360
constexpr CornerIterator & operator++()
Definition rectangle.hpp:404
constexpr CornerIterator()=default
std::forward_iterator_tag iterator_category
Definition rectangle.hpp:391
constexpr CornerIterator operator++(int)
Definition rectangle.hpp:408
std::ptrdiff_t difference_type
Definition rectangle.hpp:393
PointType value_type
Definition rectangle.hpp:392
void pointer
Definition rectangle.hpp:394
PointType reference
Definition rectangle.hpp:395
constexpr bool operator==(const CornerIterator &) const =default
constexpr PointType operator*() const
Definition rectangle.hpp:401
constexpr CornerIterator(const Rectangle *rect, std::size_t index)
Definition rectangle.hpp:398
Bounded polygonal primitives, convex or not.
Definition forward.hpp:373
Definition forward.hpp:319
Shape pairs whose Minkowski sum Pangolin can represent.
Definition forward.hpp:476
Definition forward.hpp:306
Definition forward.hpp:313
Definition forward.hpp:324
Definition arrangement.hpp:67
HalfplaneIntersection() -> HalfplaneIntersection< Point<>, NoLabel >
Definition halfplaneintersection.hpp:2308
@ y
Definition intervaltree.hpp:24
@ x
Definition intervaltree.hpp:24
Rectangle() -> Rectangle< Point<>, NoLabel >
Definition rectangle.hpp:2384
constexpr bool is_Rational_v
Definition rational.hpp:37
Point() -> Point< int >
constexpr auto operator-(const Point< LeftNumber, LeftLabel > &left, const Point< RightNumber, RightLabel > &right)
Translates a point by the opposite of another point.
Definition transformations.hpp:130
Shape(const std::variant< T, Ts... > &) -> Shape< detail::shape_point_type_t< T > >
std::ostream & operator<<(std::ostream &stream, const Point< Number, Label > &point)
Streams a point as (x,y) or label:(x,y).
Definition io.hpp:27
Public declaration of pgl::Ray.
Closed convex polygon stored by its vertices.
Definition convex.hpp:170
Closed Euclidean disk stored by boundary points plus optional disk label.
Definition disk.hpp:66
The empty set of points in the plane.
Definition emptyshape.hpp:33
Intersection of closed half-planes; convex but possibly unbounded or empty.
Definition halfplaneintersection.hpp:244
Sentinel type used when a point carries no extra label.
Definition point.hpp:31
Two-dimensional point with optional label payload.
Definition point.hpp:129
Set of closed regions with pairwise disjoint interiors.
Definition polygonset.hpp:165
Closed region bounded by one outer simple polygon minus disjoint polygonal holes.
Definition polygonwithholes.hpp:89
Closed simple polygon stored by its vertices.
Definition polygon.hpp:59
Axis-aligned rectangle stored by minimum and maximum corners.
Definition rectangle.hpp:75
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherRectangle &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr auto distanceLInf(const OtherOrientedSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:530
constexpr bool crosses(const Shape< PointType > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:474
constexpr bool separates(const OtherChain &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3185
constexpr bool separates(const OtherTriangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1272
constexpr std::optional< PointType > getIfPoint() const
Returns the point the rectangle collapses to, if it does.
Definition predicates.hpp:881
constexpr PointType get(std::ptrdiff_t index) const
Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the en...
Definition rectangle.hpp:318
constexpr auto closestSegments(const OtherShape &other) const
Returns the pair of elements realizing the distance, nothing when the shapes meet.
Definition closest.hpp:342
constexpr bool contains(const OtherConvex &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:822
constexpr auto distanceLInf(const OtherRay &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:539
constexpr std::optional< Rectangle< Point< ResultNumber, typename PointType::LabelType > > > intersection(const OtherRectangle &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1008
constexpr bool verticesContain(const OtherPoint &point) const
Returns whether a point is one of the rectangle vertices.
Definition predicates.hpp:921
constexpr bool interiorContains(const OtherLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:561
constexpr auto squaredDistance(const OtherOrientedSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:543
constexpr Rectangle rotated90(int k=1) const
Returns the rectangle rotated by 90k degrees around the origin.
Definition transformations.hpp:1157
PointType const_reference
Definition rectangle.hpp:106
constexpr bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition rectangle.hpp:1224
constexpr auto hausdorffDistanceLInf(const OtherRectangle &other) const
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
Definition distancelinf.hpp:982
constexpr CornerIterator cbegin() const
Returns an iterator to the minimum corner.
Definition rectangle.hpp:430
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherIntersection &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherLine &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1029
std::conditional_t< Oriented, OrientedSegment< PointType >, Segment< PointType > > BoundaryType
Definition rectangle.hpp:88
constexpr auto hausdorffDistanceLInf(const OtherSegment &other) const
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
Definition distancelinf.hpp:1002
constexpr bool boundaryContains(const OtherOrientedSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:291
constexpr bool boundaryContains(const OtherConvex &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:380
constexpr auto distanceLInf(const OtherRectangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:573
constexpr auto squaredHausdorffDistance(const OtherRectangle &other) const
Returns the squared Hausdorff distance to another rectangle.
Definition distance.hpp:597
constexpr bool interiorContains(const OtherPoint &point) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:553
CornerIterator const_iterator
Definition rectangle.hpp:108
constexpr HalfplaneIntersection< PointType > asHalfplaneIntersection() const
Returns the rectangle as a half-plane intersection.
Definition rectangle.hpp:712
constexpr bool contains(const OtherRay &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:780
BoundaryIterator< true > OrientedEdgeIterator
Definition rectangle.hpp:111
constexpr void scaleUpY(const OtherNumber scalar)
Multiplies the rectangle's y-coordinates by a factor in place.
Definition transformations.hpp:1202
constexpr auto hausdorffDistanceLInf(const OtherShape &other) const
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
Definition rectangle.hpp:1827
constexpr auto distanceL1(const OtherLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:484
constexpr auto squaredDistance(const OtherShape &other) const
Returns the squared Euclidean distance to the given shape.
Definition rectangle.hpp:1493
constexpr bool interiorsIntersect(const OtherSegment &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:605
constexpr bool separates(const Shape< PointType > &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1360
constexpr Rectangle< Point< ResultNumber > > fbox() const
Returns a bounding box of the rectangle with floating point coordinates.
Definition bounding.hpp:146
constexpr bool crosses(const OtherHalfplane &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:464
constexpr bool contains(const OtherTriangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:812
constexpr bool crosses(const OtherOrientedSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:444
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
constexpr auto hausdorffDistanceLInf(const OtherPoint &point) const
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
Definition distancelinf.hpp:993
constexpr bool isPoint() const
Returns whether the rectangle collapses to a single point.
Definition predicates.hpp:876
constexpr bool contains(const Shape< PointType > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:856
constexpr bool separates(const OtherRectangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1177
constexpr ResultNumber area() const
Returns the rectangle area.
Definition measures.hpp:284
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2792
constexpr bool separates(const OtherConvex &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1306
constexpr PointType operator[](std::size_t index) const
Returns corner index for index in [0, 4).
Definition rectangle.hpp:255
constexpr bool interiorContains(const OtherTriangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:633
constexpr auto distanceL1(const Shape< OtherPoint > &other) const
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own dist...
Definition rectangle.hpp:1686
constexpr auto squaredHausdorffDistance(const OtherOrientedSegment &other) const
Returns the squared Hausdorff distance to a point.
Definition distance.hpp:628
constexpr Point< ResultNumber > midpoint() const
Returns the midpoint of the rectangle.
Definition measures.hpp:304
constexpr Rectangle & operator+=(const OtherPoint &translation)
Translates both stored corners in place.
constexpr bool isDegenerate() const
Returns whether the rectangle has empty interior.
Definition predicates.hpp:869
constexpr auto hausdorffDistanceLInf(const OtherOrientedSegment &other) const
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
Definition distancelinf.hpp:1013
auto symmetricDifference(const Shape< OtherPoint > &other) const
Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wr...
Definition rectangle.hpp:1673
constexpr auto distanceLInf(const OtherOrientedLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:494
constexpr bool separates(const OtherPolyline &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3990
constexpr Point< ResultNumber > pointInside() const
Returns a point inside the rectangle.
Definition measures.hpp:331
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:549
constexpr auto intersection(const OtherHalfplane &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1080
constexpr auto distanceL1(const OtherRay &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:551
constexpr void insert(Range &&range)
Enlarges the rectangle to contain every point in a range of shapes.
Definition rectangle.hpp:1971
bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5707
constexpr auto height() const
Returns the rectangle height.
Definition rectangle.hpp:378
constexpr auto squaredDistance(const OtherLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:485
auto regularizedIntersection(const Shape< OtherPoint > &other) const
Re-dispatches a regularized intersection through a runtime shape.
Definition rectangle.hpp:1620
constexpr bool separates(const OtherDisk &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1324
constexpr bool crosses(const OtherPoint &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:408
constexpr bool interiorsIntersect(const OtherRay &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:631
constexpr Rectangle & operator-=(const OtherPoint &translation)
Translates both stored corners by the opposite vector in place.
constexpr bool boundaryContains(const OtherHalfplane &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:331
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:502
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by another (A ⊖ B).
Definition minkowskierosion.hpp:633
constexpr auto intersection(const OtherRegion &other) const
Adds this rectangle's four constraints to a half-plane intersection without deriving vertices.
Definition rectangle.hpp:1381
constexpr bool intersects(const OtherHalfplane &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:588
constexpr bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition rectangle.hpp:1327
constexpr bool separates(const OtherOrientedLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1217
PointType::NumberType NumberType
Definition rectangle.hpp:77
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1058
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1698
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition rectangle.hpp:1333
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherRectangle &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr bool interiorContains(const OtherDisk &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1302
constexpr OrientedEdgeIterator orientedEdgesEnd() const
Returns an iterator past the last oriented edge.
Definition rectangle.hpp:484
constexpr bool boundaryContains(const OtherTriangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:364
constexpr bool boundaryContains(const OtherPolygon &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1046
constexpr Point< ResultNumber > centroid() const
Returns the centroid of the rectangle.
Definition measures.hpp:313
constexpr Rectangle scaledDownX(const OtherNumber scalar) const
Returns the rectangle with its x-coordinates divided by a divisor.
constexpr Rectangle(PointType first, PointType second, bool minmax=false)
Creates an axis-aligned rectangle from two opposite corners.
Definition rectangle.hpp:139
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedLine &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1040
constexpr bool interiorContains(const OtherRay &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:601
constexpr auto minkowskiSum(const OtherShape &other) const
Returns the Minkowski sum of this shape and another (A ⊕ B).
Definition minkowski.hpp:800
constexpr const PointType & min() const
Definition rectangle.hpp:347
constexpr bool interiorContains(const OtherChain &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1513
PointType value_type
Definition rectangle.hpp:102
constexpr bool operator==(const Rectangle &other) const
Provides lexicographic ordering on (min, max).
Definition rectangle.hpp:494
constexpr bool separates(const OtherHalfplane &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1261
PointType reference
Definition rectangle.hpp:105
constexpr bool separates(const OtherPolygon &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2018
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:1983
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherRegion &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr bool interiorsIntersect(const Shape< PointType > &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:666
constexpr bool intersects(const OtherLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:523
constexpr auto regularizedIntersection(const OtherShape &other) const
Forwards a regularized intersection to the shape that owns it.
Definition rectangle.hpp:1404
constexpr bool empty() const
Returns whether the rectangle is the empty set of points.
Definition rectangle.hpp:290
constexpr std::array< OrientedSegment< PointType >, 4 > orientedEdges() const
Returns the four boundary edges in counterclockwise order.
Definition bounding.hpp:210
constexpr bool interiorContains(const OtherOrientedSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:591
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
auto regularizedUnion(const OtherShape &other) const
Returns the regularized union of the two shapes (A ∪ B).
Definition rectangle.hpp:2226
constexpr bool interiorsIntersect(const OtherPoint &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:551
constexpr PolygonWithHoles< PointType > asPolygonWithHoles() const
Returns the rectangle as a hole-free region.
Definition rectangle.hpp:747
constexpr void rotate90(int k=1)
Rotates the rectangle by 90k degrees around the origin in place.
Definition transformations.hpp:1166
constexpr bool contains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2422
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2094
constexpr bool contains(const OtherHalfplane &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:790
constexpr A & label() const
Returns the rectangle label.
Definition rectangle.hpp:517
constexpr EdgeIterator edgesEnd() const
Returns an iterator past the last edge.
Definition rectangle.hpp:464
constexpr bool interiorsIntersect(const OtherLine &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:573
constexpr std::array< Segment< PointType >, 4 > edges() const
Returns the four edges as unordered segments.
Definition bounding.hpp:199
constexpr auto squaredDistance(const OtherOrientedLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:507
constexpr bool interiorContains(const OtherSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:581
constexpr auto distanceL1(const OtherRectangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:585
constexpr bool isSegment() const
Returns whether the rectangle collapses to a non-degenerate segment.
Definition predicates.hpp:889
constexpr bool interiorContains(const OtherHalfplane &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:611
constexpr auto hausdorffDistanceL1(const OtherSegment &other) const
Returns the Manhattan (L1) Hausdorff distance to the given shape.
Definition distancel1.hpp:1014
constexpr auto hausdorffDistanceLInf(const Shape< OtherPoint > &other) const
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own haus...
Definition rectangle.hpp:1840
auto minkowskiSum(const OtherShape &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
Definition rectangle.hpp:2191
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:474
auto regularizedUnion(const Shape< OtherPoint > &other) const
Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own reg...
Definition rectangle.hpp:1637
constexpr Point< ResultNumber > center() const
Returns the center of the rectangle.
Definition measures.hpp:325
constexpr auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:349
constexpr Rectangle(Range &&shapes)
Creates the bounding box of a range of bounded shapes.
Definition rectangle.hpp:235
constexpr auto squaredHausdorffDistance(const OtherShape &other) const
Returns the squared Hausdorff distance to the given shape.
Definition rectangle.hpp:1889
constexpr bool boundaryContains(const OtherPoint &point) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:267
constexpr void insert(Range &&range)
Enlarges the rectangle so that it contains every point in a range.
Definition rectangle.hpp:1951
constexpr bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition rectangle.hpp:1072
constexpr bool boundaryContains(const OtherSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:281
constexpr Rectangle scaledDownY(const OtherNumber scalar) const
Returns the rectangle with its y-coordinates divided by a divisor.
constexpr PolygonSet< PointType > asPolygonSet() const
Returns the rectangle as a one-component set of regions.
Definition rectangle.hpp:759
constexpr bool crosses(const OtherSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:434
constexpr void scaleDownY(const OtherNumber scalar)
Divides the rectangle's y-coordinates by a divisor in place.
Definition transformations.hpp:1238
constexpr bool separates(const OtherOrientedSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1239
constexpr bool boundaryContains(const OtherDisk &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1056
constexpr auto distanceLInf(const OtherPoint &point) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:461
constexpr bool intersects(const OtherOrientedLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:536
constexpr bool boundaryContains(const OtherPolyline &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1306
constexpr auto distanceL1(const OtherOrientedSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:542
std::size_t size_type
Definition rectangle.hpp:103
constexpr bool crosses(const OtherLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:414
constexpr auto distanceL1(const OtherOrientedLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:506
constexpr auto distanceLInf(const Shape< OtherPoint > &other) const
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own dist...
Definition rectangle.hpp:1752
constexpr bool separates(const OtherPoint &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1201
constexpr void insert(const TShape &shape)
Enlarges the rectangle so that it contains a finite shape.
constexpr std::array< PointType, 4 > vertices() const
Returns the four vertices in counterclockwise order.
Definition bounding.hpp:188
constexpr bool contains(const OtherRectangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:800
constexpr auto twiceArea() const
Returns twice the rectangle area.
Definition measures.hpp:291
constexpr bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition rectangle.hpp:1246
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition rectangle.hpp:862
constexpr Disk< PointType, NoLabel > circumcircle() const
Returns the circumcircle of the rectangle.
Definition measures.hpp:318
constexpr bool boundaryContains(const OtherChain &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1197
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1047
constexpr bool separates(const OtherRay &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1249
constexpr auto hausdorffDistanceL1(const OtherShape &other) const
Returns the Manhattan (L1) Hausdorff distance to the given shape.
Definition rectangle.hpp:1783
constexpr Convex< PointType > asConvex() const
Returns the rectangle as a convex polygon.
Definition rectangle.hpp:690
constexpr auto distanceL1(const OtherShape &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition rectangle.hpp:1594
constexpr bool interiorsIntersect(const OtherHalfplane &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:648
constexpr void scaleDownX(const OtherNumber scalar)
Divides the rectangle's x-coordinates by a divisor in place.
Definition transformations.hpp:1220
constexpr Rectangle(NumberType x1, NumberType y1, NumberType x2, NumberType y2, bool minmax=false)
Creates an axis-aligned rectangle from four coordinates.
Definition rectangle.hpp:183
constexpr bool boundaryContains(const OtherRay &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:321
BoundaryIterator< false > EdgeIterator
Definition rectangle.hpp:110
constexpr bool interiorsIntersect(const OtherOrientedSegment &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:618
constexpr bool contains(const OtherPolygon &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1767
constexpr std::ptrdiff_t index(const PointType &point) const
Definition rectangle.hpp:330
constexpr bool interiorContains(const OtherPolygon &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1312
constexpr Convex< PointType > convexHull() const
Returns the convex hull of the rectangle's vertices.
Definition rectangle.hpp:699
constexpr void insert(const OtherRectangle &other)
Enlarges the rectangle so that it contains another rectangle.
Definition bounding.hpp:353
constexpr auto hausdorffDistanceL1(const OtherPoint &point) const
Returns the Manhattan (L1) Hausdorff distance to the given shape.
Definition distancel1.hpp:1005
constexpr auto squaredDistance(const OtherRay &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:552
constexpr bool crosses(const OtherRay &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:454
constexpr bool boundaryContains(const OtherLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:301
constexpr bool contains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:832
constexpr auto distanceL1(const OtherHalfplane &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:573
constexpr CornerIterator begin() const
Returns an iterator to the minimum corner.
Definition rectangle.hpp:423
constexpr Rectangle scaledUpX(const OtherNumber scalar) const
Returns the rectangle with its x-coordinates multiplied by a factor.
PointType PointType
Definition rectangle.hpp:76
constexpr bool intersects(const Shape< PointType > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:606
constexpr bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4639
constexpr bool interiorsIntersect(const OtherRectangle &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:560
constexpr bool isUndefined() const
Returns whether the rectangle is degenerate without collapsing to a point or to a segment.
Definition predicates.hpp:903
constexpr bool boundaryContains(const Shape< PointType > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1134
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5963
constexpr bool separates(const OtherSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1227
constexpr Rectangle(Range &&points)
Creates the bounding box of a range of points.
Definition rectangle.hpp:216
constexpr Rectangle(const Rectangle< OtherPointType, OtherLabelType > &other)
Definition rectangle.hpp:188
constexpr auto intersection(const Shape< OtherPoint > &other) const
Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersec...
Definition rectangle.hpp:1614
constexpr void scaleUpX(const OtherNumber scalar)
Multiplies the rectangle's x-coordinates by a factor in place.
Definition transformations.hpp:1184
constexpr auto distanceL1(const OtherPoint &point) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:473
constexpr bool pointInsideInteriorContainedIn(const OtherShape &shape) const
Tests whether some point in this shape's relative interior lies in the strict interior of shape.
Definition measures.hpp:337
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B).
constexpr bool contains(const OtherOrientedLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:750
constexpr const PointType & max() const
Definition rectangle.hpp:359
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherHalfplane &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr auto intersection(const OtherShape &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition rectangle.hpp:1393
constexpr bool interiorContains(const OtherOrientedLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:571
constexpr auto squaredHausdorffDistance(const OtherPoint &point) const
Returns the squared Hausdorff distance to a point.
Definition distance.hpp:608
constexpr EdgeIterator edgesBegin() const
Returns an iterator to the first edge.
Definition rectangle.hpp:455
constexpr auto hausdorffDistanceL1(const OtherRectangle &other) const
Returns the Manhattan (L1) Hausdorff distance to the given shape.
Definition distancel1.hpp:994
constexpr auto operator<=>(const Rectangle &other) const
Orders rectangles lexicographically by their (min, max) corners, ignoring the label.
Definition rectangle.hpp:503
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the rectangle contains.
Definition lattice.hpp:546
constexpr std::size_t size() const
Returns the number of corners: 4, or 0 when empty.
Definition rectangle.hpp:307
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition rectangle.hpp:857
constexpr bool boundaryContains(const OtherOrientedLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:311
constexpr bool interiorContains(const OtherPolyline &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1739
constexpr bool intersects(const OtherOrientedSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:559
constexpr Rectangle()
Creates the empty rectangle [(0,0),(-1,-1)].
Definition rectangle.hpp:120
constexpr auto distanceL1(const OtherSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:515
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition rectangle.hpp:852
constexpr bool interiorContains(const OtherConvex &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:643
constexpr OrientedEdgeIterator orientedEdgesBegin() const
Returns an iterator to the first oriented edge.
Definition rectangle.hpp:475
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:728
constexpr CornerIterator cend() const
Returns an iterator past the last corner.
Definition rectangle.hpp:444
constexpr auto hausdorffDistanceL1(const Shape< OtherPoint > &other) const
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own haus...
Definition rectangle.hpp:1796
constexpr bool intersects(const OtherRay &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:569
constexpr bool contains(const OtherOrientedSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:770
constexpr void insert(const OtherPoint &point)
Enlarges the rectangle so that it contains the given point.
Definition bounding.hpp:311
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
constexpr std::optional< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherPoint &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:998
constexpr auto distanceLInf(const OtherLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:472
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition rectangle.hpp:1024
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRay &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1065
constexpr bool crosses(const OtherRectangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:384
detail::floating_result_t< ResultNumber > squaredDistance(const Disk< DiskPointType, DiskLabel > &disk) const
Returns the squared Euclidean distance to a disk.
Definition rectangle.hpp:1505
std::ptrdiff_t difference_type
Definition rectangle.hpp:104
constexpr bool contains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2060
CornerIterator iterator
Definition rectangle.hpp:107
constexpr auto squaredDistance(const OtherRectangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:586
auto difference(const Shape< OtherPoint > &other) const
Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper'...
Definition rectangle.hpp:1656
constexpr auto squaredDistance(const OtherHalfplane &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:574
constexpr auto distanceLInf(const OtherHalfplane &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:561
constexpr auto hausdorffDistanceL1(const OtherOrientedSegment &other) const
Returns the Manhattan (L1) Hausdorff distance to the given shape.
Definition distancel1.hpp:1025
constexpr Rectangle bbox() const
Returns the bounding box of the rectangle.
Definition bounding.hpp:140
constexpr bool contains(const OtherSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:760
constexpr auto distanceLInf(const OtherSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:503
constexpr CornerIterator end() const
Returns an iterator past the last corner.
Definition rectangle.hpp:437
constexpr auto width() const
Returns the rectangle width.
Definition rectangle.hpp:368
constexpr auto distanceLInf(const OtherShape &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition rectangle.hpp:1739
constexpr bool interiorsIntersect(const OtherOrientedLine &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:589
constexpr bool separates(const OtherLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1207
constexpr bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition rectangle.hpp:1235
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition rectangle.hpp:1078
constexpr auto squaredDistance(const OtherSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:516
constexpr std::optional< BoundaryType< false > > getIfSegment() const
Returns the segment the rectangle collapses to, if it does.
Definition predicates.hpp:895
constexpr bool interiorContains(const OtherRectangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:621
constexpr bool contains(const OtherLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:740
constexpr Rectangle scaledUpY(const OtherNumber scalar) const
Returns the rectangle with its y-coordinates multiplied by a factor.
constexpr Segment< PointType > diameter() const
Returns a segment defining a diameter.
Definition measures.hpp:297
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition rectangle.hpp:1410
constexpr bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition rectangle.hpp:1018
constexpr bool crosses(const OtherOrientedLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:424
constexpr auto squaredHausdorffDistance(const OtherSegment &other) const
Returns the squared Hausdorff distance to a point.
Definition distance.hpp:617
constexpr Polygon< PointType > asPolygon() const
Returns the rectangle as a simple polygon.
Definition rectangle.hpp:737
constexpr bool intersects(const OtherRectangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:510
auto symmetricDifference(const OtherShape &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
Definition rectangle.hpp:2300
TLabel LabelType
Definition rectangle.hpp:78
constexpr bool boundaryContains(const OtherRectangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:341
constexpr bool separates(const EmptyShape< EmptyPoint > &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition rectangle.hpp:867
Unoriented closed segment between two endpoints plus optional segment label.
Definition segment.hpp:58
Runtime variant wrapper over the supported primitive shapes.
Definition shape.hpp:160