Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
polyline.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <algorithm>
6#include <vector>
7#include <cassert>
8#include <compare>
9#include <concepts>
10#include <cstddef>
11#include <functional>
12#include <iterator>
13#include <limits>
14#include <optional>
15#include <ostream>
16#include <ranges>
17#include <type_traits>
18#include <utility>
19
20
21namespace pgl {
22
23template <class PointType = Point<>, class Label>
24struct Polyline;
25
27
28template <std::ranges::input_range Range>
29requires detail::is_point_v<std::ranges::range_value_t<Range>>
31
32template <class Number>
33requires (!detail::is_point_v<Number>)
34Polyline(std::initializer_list<Number>) -> Polyline<Point<Number>, NoLabel>;
35
36
68template <class PointType_, class TLabel>
69struct Polyline {
70 using PointType = PointType_;
72 using LabelType = TLabel;
73 static_assert(detail::is_point_v<PointType>, "Polyline requires pgl::Point vertices");
74
75 template <bool Oriented>
76 using BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>>;
77
78 template <bool Oriented>
79 class BoundaryIterator;
80
81 using EdgeIterator = BoundaryIterator<false>;
82 using OrientedEdgeIterator = BoundaryIterator<true>;
83
87 constexpr Polyline() = default;
88
98 template<std::ranges::input_range Range = std::initializer_list<PointType>>
99 requires std::ranges::common_range<Range> &&
100 std::convertible_to<std::ranges::range_value_t<Range>, PointType>
101 constexpr explicit Polyline(Range&& points) {
102 for (const auto& p : points) {
103 points_.push_back(p);
104 }
105 }
106
116 constexpr explicit Polyline(std::initializer_list<NumberType> coords) {
117 assert(coords.size() % 2 == 0);
118 points_.reserve(coords.size() / 2);
119 for (auto it = coords.begin(); it != coords.end(); ) {
120 NumberType x = *it++;
121 NumberType y = *it++;
122 points_.emplace_back(x, y);
123 }
124 }
125
134 template<PointConcept OtherPointType, class OtherLabelType>
135 requires std::constructible_from<PointType, const OtherPointType&>
137 : points_(other.begin(), other.end()), label_(detail::copyLabel<LabelType>(other)) {}
138
147 template <class A = LabelType>
148 requires(detail::has_label_v<A>)
149 constexpr A& label() const {
150 return label_;
151 }
152
158 constexpr const PointType operator[](std::size_t index) const {
159 assert(index < size());
160 return points_[index] + translation_;
161 }
162
174 constexpr PointType get(std::ptrdiff_t index) const {
175 const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(size());
176 return (*this)[static_cast<std::size_t>(((index % n) + n) % n)];
177 }
178
193 template <PointConcept OtherPoint>
194 constexpr void set(std::size_t index, const OtherPoint& point) {
195 assert(index < size());
196 PointType stored(point);
197 stored -= translation_;
198 points_[index] = stored;
199 resetCache();
200 }
201
212 constexpr std::ptrdiff_t index(const PointType& point) const {
213 for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t>(size()); ++i) {
214 if ((*this)[static_cast<std::size_t>(i)] == point) {
215 return i;
216 }
217 }
218 return -1;
219 }
220
235 template <PointConcept OtherPoint>
236 constexpr void insert(std::size_t index, const OtherPoint& point) {
237 assert(index <= size());
238 PointType stored(point);
239 stored -= translation_;
240 points_.insert(points_.begin() + static_cast<std::ptrdiff_t>(index), stored);
241 resetCache();
242 }
243
259 template <std::ranges::input_range Range>
260 requires (!detail::is_point_v<std::remove_cvref_t<Range>>) &&
261 std::convertible_to<std::ranges::range_value_t<Range>, PointType>
262 constexpr void insert(std::size_t index, Range&& points) {
263 assert(index <= size());
264 std::vector<PointType> incoming;
265 for (const auto& p : points) {
266 PointType stored(p);
267 stored -= translation_;
268 incoming.push_back(stored);
269 }
270 points_.insert(points_.begin() + static_cast<std::ptrdiff_t>(index), incoming.begin(),
271 incoming.end());
272 resetCache();
273 }
274
285 template <PointConcept OtherPoint>
286 constexpr void pushBack(const OtherPoint& point) {
287 insert(size(), point);
288 }
289
300 template <std::ranges::input_range Range>
301 requires (!detail::is_point_v<std::remove_cvref_t<Range>>) &&
302 std::convertible_to<std::ranges::range_value_t<Range>, PointType>
303 constexpr void pushBack(Range&& points) {
304 insert(size(), std::forward<Range>(points));
305 }
306
310 constexpr auto begin() const {
311 return Iterator(points_.begin(), translation_);
312 }
313
317 constexpr auto cbegin() const {
318 return Iterator(points_.cbegin(), translation_);
319 }
320
324 constexpr auto end() const {
325 return Iterator(points_.end(), translation_);
326 }
327
331 constexpr auto cend() const {
332 return Iterator(points_.cend(), translation_);
333 }
334
344 constexpr auto operator<=>(const Polyline& other) const {
345 if (auto cmp = size() <=> other.size(); cmp != 0) {
346 return cmp;
347 }
348 const bool reversed = !storedIsCanonical();
349 const bool otherReversed = !other.storedIsCanonical();
350 for (std::size_t i = 0; i < size(); ++i) {
351 if (auto cmp = canonicalAt(i, reversed) <=> other.canonicalAt(i, otherReversed);
352 cmp != 0) {
353 return cmp;
354 }
355 }
356 return std::strong_ordering::equal;
357 }
358
367 constexpr bool operator==(const Polyline& other) const {
368 if (size() != other.size()) {
369 return false;
370 }
371 const bool reversed = !storedIsCanonical();
372 const bool otherReversed = !other.storedIsCanonical();
373 for (std::size_t i = 0; i < size(); ++i) {
374 if (canonicalAt(i, reversed) != other.canonicalAt(i, otherReversed)) {
375 return false;
376 }
377 }
378 return true;
379 }
380
382 template<AnyShapeConcept OtherShape>
383 [[nodiscard]] constexpr bool samePointSet(const OtherShape& other) const;
384
388 constexpr std::size_t size() const {
389 return points_.size();
390 }
391
395 constexpr bool empty() const {
396 return points_.empty();
397 }
398
409 constexpr bool isDegenerate() const {
410 return std::adjacent_find(points_.begin(), points_.end(), std::not_equal_to<>{}) ==
411 points_.end();
412 }
413
422 [[nodiscard]] constexpr bool isPoint() const {
423 return detail::allPointsEqual(points_);
424 }
425
433 [[nodiscard]] constexpr std::optional<PointType> getIfPoint() const {
434 if (!isPoint()) {
435 return std::nullopt;
436 }
437 return points_.front() + translation_;
438 }
439
450 [[nodiscard]] constexpr bool isSegment() const {
451 return detail::pointsSpanSegment(points_);
452 }
453
461 [[nodiscard]] constexpr std::optional<BoundaryType<false>> getIfSegment() const {
462 if (!isSegment()) {
463 return std::nullopt;
464 }
465 return detail::spannedSegment<BoundaryType<false>>(points_) + translation_;
466 }
467
477 [[nodiscard]] constexpr bool isUndefined() const {
478 return empty();
479 }
480
500 template <class Rational = pgl::Rational<pgl::BigInt>>
501 [[nodiscard]] bool isSimple() const;
502
514 constexpr Segment<PointType> diameter() const {
516 }
517
521 constexpr Convex<PointType> convexHull() const {
522 return Convex<PointType>(vertices());
523 }
524
536 constexpr const Rectangle<PointType>& bbox() const;
537
554 template <class ResultNumber = grid_number_t<typename PointType_::NumberType>>
555 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
558
564 template <std::floating_point ResultNumber = double>
566
570 constexpr std::vector<PointType> vertices() const {
571 std::vector<PointType> ret(points_.begin(), points_.end());
572 for (auto& vertex : ret) {
573 vertex += translation_;
574 }
575 return ret;
576 }
577
585 constexpr std::vector<Segment<PointType>> edges() const {
586 std::vector<Segment<PointType>> result;
587 const auto translatedVertices = vertices();
588 for (std::size_t i = 0; i + 1 < translatedVertices.size(); ++i) {
589 result.emplace_back(translatedVertices[i], translatedVertices[i + 1]);
590 }
591 return result;
592 }
593
598 constexpr std::vector<OrientedSegment<PointType>> orientedEdges() const {
599 std::vector<OrientedSegment<PointType>> result;
600 const auto translatedVertices = vertices();
601 for (std::size_t i = 0; i + 1 < translatedVertices.size(); ++i) {
602 result.emplace_back(translatedVertices[i], translatedVertices[i + 1]);
603 }
604 return result;
605 }
606
615 constexpr auto verticesView() const {
616 return std::ranges::subrange(begin(), end());
617 }
618
627 constexpr auto edgesView() const {
628 return std::ranges::subrange(edgesBegin(), edgesEnd());
629 }
630
635 constexpr auto orientedEdgesView() const {
636 return std::ranges::subrange(orientedEdgesBegin(), orientedEdgesEnd());
637 }
638
643 constexpr EdgeIterator edgesBegin() const {
644 return EdgeIterator(this, 0);
645 }
646
651 constexpr EdgeIterator edgesEnd() const {
652 return EdgeIterator(this, edgeCount());
653 }
654
660 return OrientedEdgeIterator(this, 0);
661 }
662
668 return OrientedEdgeIterator(this, edgeCount());
669 }
670
680 template<PointConcept OtherPoint>
681 [[nodiscard]] constexpr bool contains(const OtherPoint& point) const;
682
698 template<SegmentConcept OtherSegment>
699 [[nodiscard]] constexpr bool contains(const OtherSegment& other) const;
700
702 template<OrientedSegmentConcept OtherOrientedSegment>
703 [[nodiscard]] constexpr bool contains(const OtherOrientedSegment& other) const;
704
709 template<LineConcept OtherLine>
710 [[nodiscard]] constexpr bool contains(const OtherLine& other) const;
711
716 template<OrientedLineConcept OtherOrientedLine>
717 [[nodiscard]] constexpr bool contains(const OtherOrientedLine& other) const;
718
723 template<RayConcept OtherRay>
724 [[nodiscard]] constexpr bool contains(const OtherRay& other) const;
725
730 template<HalfplaneConcept OtherHalfplane>
731 [[nodiscard]] constexpr bool contains(const OtherHalfplane& other) const;
732
737 template<RectangleConcept OtherRectangle>
738 [[nodiscard]] constexpr bool contains(const OtherRectangle& other) const;
739
744 template<TriangleConcept OtherTriangle>
745 [[nodiscard]] constexpr bool contains(const OtherTriangle& other) const;
746
751 template<ConvexConcept OtherConvex>
752 [[nodiscard]] constexpr bool contains(const OtherConvex& other) const;
753
761 template<PolygonConcept OtherPolygon>
762 [[nodiscard]] constexpr bool contains(const OtherPolygon& other) const;
763
768 template<DiskConcept OtherDisk>
769 [[nodiscard]] constexpr bool contains(const OtherDisk& other) const;
770
777 template<MonotoneChainConcept OtherChain>
778 [[nodiscard]] constexpr bool contains(const OtherChain& other) const;
779
788 template<PolylineConcept OtherPolyline>
789 [[nodiscard]] constexpr bool contains(const OtherPolyline& other) const;
790
792 template <class EmptyPoint>
793 [[nodiscard]] constexpr bool contains(const EmptyShape<EmptyPoint>&) const {
794 return true;
795 }
796
798 template<PointConcept OtherPoint>
799 [[nodiscard]] constexpr bool contains(const Shape<OtherPoint>& other) const;
800
813 template<PointConcept OtherPoint>
814 [[nodiscard]] constexpr bool boundaryContains(const OtherPoint& point) const;
815
816 // The boundary of a polyline is exactly its two extreme vertices, a finite
817 // point set, so it contains no positive-length or two-dimensional shape.
819 template<SegmentConcept OtherSegment>
820 [[nodiscard]] constexpr bool boundaryContains(const OtherSegment& other) const {
821 return detail::reduceDegenerateToPoint(
822 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
823 }
824
825 template<OrientedSegmentConcept OtherOrientedSegment>
826 [[nodiscard]] constexpr bool boundaryContains(const OtherOrientedSegment& other) const {
827 return detail::reduceDegenerateToPoint(
828 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
829 }
830
831 template<LineConcept OtherLine>
832 [[nodiscard]] constexpr bool boundaryContains(const OtherLine&) const { return false; }
834 template<OrientedLineConcept OtherOrientedLine>
835 [[nodiscard]] constexpr bool boundaryContains(const OtherOrientedLine&) const { return false; }
837 template<RayConcept OtherRay>
838 [[nodiscard]] constexpr bool boundaryContains(const OtherRay&) const { return false; }
840 template<HalfplaneConcept OtherHalfplane>
841 [[nodiscard]] constexpr bool boundaryContains(const OtherHalfplane&) const { return false; }
843 template<RectangleConcept OtherRectangle>
844 [[nodiscard]] constexpr bool boundaryContains(const OtherRectangle& other) const {
845 return detail::reduceDegenerateToPoint(
846 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
847 }
848
849 template<TriangleConcept OtherTriangle>
850 [[nodiscard]] constexpr bool boundaryContains(const OtherTriangle& other) const {
851 return detail::reduceDegenerateToPoint(
852 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
853 }
854
855 template<ConvexConcept OtherConvex>
856 [[nodiscard]] constexpr bool boundaryContains(const OtherConvex& other) const {
857 return detail::reduceDegenerateToPoint(
858 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
859 }
860
861 template<PolygonConcept OtherPolygon>
862 [[nodiscard]] constexpr bool boundaryContains(const OtherPolygon& other) const {
863 return detail::reduceDegenerateToPoint(
864 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
865 }
866
867 template<DiskConcept OtherDisk>
868 [[nodiscard]] constexpr bool boundaryContains(const OtherDisk& other) const {
869 return detail::reduceDegenerateToPoint(
870 other, [this](const auto& vertex) { return this->boundaryContains(vertex); });
871 }
872
873 template<MonotoneChainConcept OtherChain>
874 [[nodiscard]] constexpr bool boundaryContains(const OtherChain& other) const {
875 // The boundary is the two extreme vertices, so only a chain without an
876 // edge fits inside it.
877 return other.empty() || (other.size() == 1 && boundaryContains(other[0]));
878 }
879
880 template<PolylineConcept OtherPolyline>
881 [[nodiscard]] constexpr bool boundaryContains(const OtherPolyline& other) const {
882 // The boundary is the two extreme vertices, so only a polyline
883 // covering at most one point fits inside it.
884 return other.empty() || (other.isDegenerate() && boundaryContains(other[0]));
885 }
886
887 template <class EmptyPoint>
888 [[nodiscard]] constexpr bool boundaryContains(const EmptyShape<EmptyPoint>&) const {
889 return true;
890 }
891
893 template<PointConcept OtherPoint>
894 [[nodiscard]] constexpr bool boundaryContains(const Shape<OtherPoint>& other) const;
895
908 template<PointConcept OtherPoint>
909 [[nodiscard]] constexpr bool interiorContains(const OtherPoint& point) const;
910
921 template<SegmentConcept OtherSegment>
922 [[nodiscard]] constexpr bool interiorContains(const OtherSegment& other) const;
923
925 template<OrientedSegmentConcept OtherOrientedSegment>
926 [[nodiscard]] constexpr bool interiorContains(const OtherOrientedSegment& other) const;
927
929 template<LineConcept OtherLine>
930 [[nodiscard]] constexpr bool interiorContains(const OtherLine& other) const;
931
933 template<OrientedLineConcept OtherOrientedLine>
934 [[nodiscard]] constexpr bool interiorContains(const OtherOrientedLine& other) const;
935
937 template<RayConcept OtherRay>
938 [[nodiscard]] constexpr bool interiorContains(const OtherRay& other) const;
939
941 template<HalfplaneConcept OtherHalfplane>
942 [[nodiscard]] constexpr bool interiorContains(const OtherHalfplane& other) const;
943
945 template<TriangleConcept OtherTriangle>
946 [[nodiscard]] constexpr bool interiorContains(const OtherTriangle& other) const;
947
948 // A polyline is one-dimensional: its relative interior cannot contain any
949 // unbounded or two-dimensional shape.
951 template<RectangleConcept OtherRectangle>
952 [[nodiscard]] constexpr bool interiorContains(const OtherRectangle& other) const {
953 return detail::reduceDegenerateGuarded(
954 other, [this](const auto& carrier) { return this->interiorContains(carrier); });
955 }
956
957 template<ConvexConcept OtherConvex>
958 [[nodiscard]] constexpr bool interiorContains(const OtherConvex& other) const {
959 return detail::reduceDegenerateGuarded(
960 other, [this](const auto& carrier) { return this->interiorContains(carrier); });
961 }
962
963 template<PolygonConcept OtherPolygon>
964 [[nodiscard]] constexpr bool interiorContains(const OtherPolygon& other) const {
965 return detail::reduceDegenerate(
966 other, [this](const auto& carrier) { return this->interiorContains(carrier); });
967 }
968
969 template<DiskConcept OtherDisk>
970 [[nodiscard]] constexpr bool interiorContains(const OtherDisk& other) const {
971 return detail::reduceDegenerate(
972 other, [this](const auto& carrier) { return this->interiorContains(carrier); });
973 }
974
976 template<MonotoneChainConcept OtherChain>
977 [[nodiscard]] constexpr bool interiorContains(const OtherChain& other) const;
978
980 template<PolylineConcept OtherPolyline>
981 [[nodiscard]] constexpr bool interiorContains(const OtherPolyline& other) const;
983 template <class EmptyPoint>
984 [[nodiscard]] constexpr bool interiorContains(const EmptyShape<EmptyPoint>&) const {
985 return true;
986 }
987
989 template<PointConcept OtherPoint>
990 [[nodiscard]] constexpr bool interiorContains(const Shape<OtherPoint>& other) const;
991
997 template<PointConcept OtherPoint>
998 [[nodiscard]] constexpr bool intersects(const OtherPoint& other) const;
999
1012 template<SegmentConcept OtherSegment>
1013 [[nodiscard]] constexpr bool intersects(const OtherSegment& other) const;
1014
1016 template<OrientedSegmentConcept OtherOrientedSegment>
1017 [[nodiscard]] constexpr bool intersects(const OtherOrientedSegment& other) const;
1019 template<LineConcept OtherLine>
1020 [[nodiscard]] constexpr bool intersects(const OtherLine& other) const;
1022 template<OrientedLineConcept OtherOrientedLine>
1023 [[nodiscard]] constexpr bool intersects(const OtherOrientedLine& other) const;
1025 template<RayConcept OtherRay>
1026 [[nodiscard]] constexpr bool intersects(const OtherRay& other) const;
1028 template<HalfplaneConcept OtherHalfplane>
1029 [[nodiscard]] constexpr bool intersects(const OtherHalfplane& other) const;
1031 template<RectangleConcept OtherRectangle>
1032 [[nodiscard]] constexpr bool intersects(const OtherRectangle& other) const;
1034 template<TriangleConcept OtherTriangle>
1035 [[nodiscard]] constexpr bool intersects(const OtherTriangle& other) const;
1037 template<ConvexConcept OtherConvex>
1038 [[nodiscard]] constexpr bool intersects(const OtherConvex& other) const;
1040 template<DiskConcept OtherDisk>
1041 [[nodiscard]] constexpr bool intersects(const OtherDisk& other) const;
1050 template<MonotoneChainConcept OtherChain>
1051 [[nodiscard]] constexpr bool intersects(const OtherChain& other) const;
1052
1064 template<PolylineConcept OtherPolyline>
1065 [[nodiscard]] constexpr bool intersects(const OtherPolyline& other) const;
1066
1068 template <class EmptyPoint>
1069 [[nodiscard]] constexpr bool intersects(const EmptyShape<EmptyPoint>&) const {
1070 return false;
1071 }
1072
1074 template<PointConcept OtherPoint>
1075 [[nodiscard]] constexpr bool intersects(const Shape<OtherPoint>& other) const;
1076
1078 template<typename OtherShape>
1079 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1080 [[nodiscard]] constexpr bool intersects(const OtherShape& other) const {
1081 return other.intersects(*this);
1082 }
1083
1091 template<PointConcept OtherPoint>
1092 [[nodiscard]] constexpr bool interiorsIntersect(const OtherPoint& other) const;
1093
1108 template<SegmentConcept OtherSegment>
1109 [[nodiscard]] constexpr bool interiorsIntersect(const OtherSegment& other) const;
1110
1112 template<OrientedSegmentConcept OtherOrientedSegment>
1113 [[nodiscard]] constexpr bool interiorsIntersect(const OtherOrientedSegment& other) const;
1115 template<LineConcept OtherLine>
1116 [[nodiscard]] constexpr bool interiorsIntersect(const OtherLine& other) const;
1118 template<OrientedLineConcept OtherOrientedLine>
1119 [[nodiscard]] constexpr bool interiorsIntersect(const OtherOrientedLine& other) const;
1121 template<RayConcept OtherRay>
1122 [[nodiscard]] constexpr bool interiorsIntersect(const OtherRay& other) const;
1124 template<HalfplaneConcept OtherHalfplane>
1125 [[nodiscard]] constexpr bool interiorsIntersect(const OtherHalfplane& other) const;
1127 template<RectangleConcept OtherRectangle>
1128 [[nodiscard]] constexpr bool interiorsIntersect(const OtherRectangle& other) const;
1130 template<TriangleConcept OtherTriangle>
1131 [[nodiscard]] constexpr bool interiorsIntersect(const OtherTriangle& other) const;
1133 template<ConvexConcept OtherConvex>
1134 [[nodiscard]] constexpr bool interiorsIntersect(const OtherConvex& other) const;
1136 template<DiskConcept OtherDisk>
1137 [[nodiscard]] constexpr bool interiorsIntersect(const OtherDisk& other) const;
1139 template<MonotoneChainConcept OtherChain>
1140 [[nodiscard]] constexpr bool interiorsIntersect(const OtherChain& other) const;
1141
1150 template<PolylineConcept OtherPolyline>
1151 [[nodiscard]] constexpr bool interiorsIntersect(const OtherPolyline& other) const;
1152
1154 template <class EmptyPoint>
1155 [[nodiscard]] constexpr bool interiorsIntersect(const EmptyShape<EmptyPoint>&) const {
1156 return false;
1157 }
1158
1160 template<PointConcept OtherPoint>
1161 [[nodiscard]] constexpr bool interiorsIntersect(const Shape<OtherPoint>& other) const;
1162
1164 template<typename OtherShape>
1165 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1166 [[nodiscard]] constexpr bool interiorsIntersect(const OtherShape& other) const {
1167 return other.interiorsIntersect(*this);
1168 }
1169
1175 template<PointConcept OtherPoint>
1176 [[nodiscard]] constexpr bool separates(const OtherPoint&) const {
1177 return false;
1178 }
1179
1189 template<SegmentConcept OtherSegment>
1190 [[nodiscard]] constexpr bool separates(const OtherSegment& other) const;
1192 template<OrientedSegmentConcept OtherOrientedSegment>
1193 [[nodiscard]] constexpr bool separates(const OtherOrientedSegment& other) const;
1195 template<LineConcept OtherLine>
1196 [[nodiscard]] constexpr bool separates(const OtherLine& other) const;
1198 template<OrientedLineConcept OtherOrientedLine>
1199 [[nodiscard]] constexpr bool separates(const OtherOrientedLine& other) const;
1201 template<RayConcept OtherRay>
1202 [[nodiscard]] constexpr bool separates(const OtherRay& other) const;
1203
1204 // --- 2-dimensional targets: the region minus the polyline is disconnected
1205 // iff the polyline (clipped to the region) together with the region's
1206 // boundary closes a cycle through the interior. Unlike a monotone chain, a
1207 // self-intersecting polyline can seal a pocket with a loop that never
1208 // leaves the interior, so the traversal-order crosscut scan is replaced by
1209 // a cycle search on the polyline's self-intersection arrangement (see
1210 // detail::polylineSeparatesConvexRegion). ---
1212 template<HalfplaneConcept OtherHalfplane>
1213 [[nodiscard]] constexpr bool separates(const OtherHalfplane& other) const;
1215 template<RectangleConcept OtherRectangle>
1216 [[nodiscard]] constexpr bool separates(const OtherRectangle& other) const;
1218 template<TriangleConcept OtherTriangle>
1219 [[nodiscard]] constexpr bool separates(const OtherTriangle& other) const;
1221 template<DiskConcept OtherDisk>
1222 [[nodiscard]] constexpr bool separates(const OtherDisk& other) const;
1224 template<ConvexConcept OtherConvex>
1225 [[nodiscard]] constexpr bool separates(const OtherConvex& other) const;
1227 template<PolygonConcept OtherPolygon>
1228 [[nodiscard]] constexpr bool separates(const OtherPolygon& other) const;
1235 template<MonotoneChainConcept OtherChain>
1236 [[nodiscard]] constexpr bool separates(const OtherChain& other) const;
1246 template<PolylineConcept OtherPolyline>
1247 [[nodiscard]] constexpr bool separates(const OtherPolyline& other) const;
1248
1250 template<HalfplaneIntersectionConcept OtherRegion>
1251 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1252
1254 template<HalfplaneIntersectionConcept OtherRegion>
1255 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1256
1258 template<HalfplaneIntersectionConcept OtherRegion>
1259 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1260
1262 template<HalfplaneIntersectionConcept OtherRegion>
1263 [[nodiscard]] constexpr bool separates(const OtherRegion& other) const;
1264
1273 template<PolygonWithHolesConcept OtherRegion>
1274 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1275
1282 template<PolygonWithHolesConcept OtherRegion>
1283 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1284
1286 template<PolygonWithHolesConcept OtherRegion>
1287 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1288
1296 template<PolygonWithHolesConcept OtherRegion>
1297 [[nodiscard]] bool separates(const OtherRegion& other) const;
1298
1299 // -------------------------------------------------------------------------
1300 // A set of regions
1301 //
1302 // It outranks every other shape, so the symmetric relations reach it through
1303 // the rank-based forwarders and only the asymmetric ones are answered here.
1304 // A set is the union of its components, so it is contained exactly when
1305 // every component is — no matter what this shape is.
1306
1308 template<PolygonSetConcept OtherSet>
1309 [[nodiscard]] constexpr bool contains(const OtherSet& other) const {
1310 for (const auto& component : other) {
1311 if (!contains(component)) {
1312 return false;
1313 }
1314 }
1315 return true;
1316 }
1317
1319 template<PolygonSetConcept OtherSet>
1320 [[nodiscard]] constexpr bool boundaryContains(const OtherSet& other) const {
1321 for (const auto& component : other) {
1322 if (!boundaryContains(component)) {
1323 return false;
1324 }
1325 }
1326 return true;
1327 }
1328
1330 template<PolygonSetConcept OtherSet>
1331 [[nodiscard]] constexpr bool interiorContains(const OtherSet& other) const {
1332 for (const auto& component : other) {
1333 if (!interiorContains(component)) {
1334 return false;
1335 }
1336 }
1337 return true;
1338 }
1339
1348 template<PolygonSetConcept OtherSet>
1349 [[nodiscard]] bool separates(const OtherSet& other) const;
1351 template <class EmptyPoint>
1352 [[nodiscard]] constexpr bool separates(const EmptyShape<EmptyPoint>&) const {
1353 return false;
1354 }
1355
1357 template<PointConcept OtherPoint>
1358 [[nodiscard]] constexpr bool separates(const Shape<OtherPoint>& other) const;
1359
1361 template<PointConcept OtherPoint>
1362 [[nodiscard]] constexpr bool crosses(const OtherPoint&) const {
1363 return false;
1364 }
1365
1366 template<SegmentConcept OtherSegment>
1367 [[nodiscard]] constexpr bool crosses(const OtherSegment& other) const;
1369 template<OrientedSegmentConcept OtherOrientedSegment>
1370 [[nodiscard]] constexpr bool crosses(const OtherOrientedSegment& other) const;
1372 template<LineConcept OtherLine>
1373 [[nodiscard]] constexpr bool crosses(const OtherLine& other) const;
1375 template<OrientedLineConcept OtherOrientedLine>
1376 [[nodiscard]] constexpr bool crosses(const OtherOrientedLine& other) const;
1378 template<RayConcept OtherRay>
1379 [[nodiscard]] constexpr bool crosses(const OtherRay& other) const;
1381 template<HalfplaneConcept OtherHalfplane>
1382 [[nodiscard]] constexpr bool crosses(const OtherHalfplane& other) const;
1384 template<RectangleConcept OtherRectangle>
1385 [[nodiscard]] constexpr bool crosses(const OtherRectangle& other) const;
1387 template<TriangleConcept OtherTriangle>
1388 [[nodiscard]] constexpr bool crosses(const OtherTriangle& other) const;
1390 template<DiskConcept OtherDisk>
1391 [[nodiscard]] constexpr bool crosses(const OtherDisk& other) const;
1393 template<ConvexConcept OtherConvex>
1394 [[nodiscard]] constexpr bool crosses(const OtherConvex& other) const;
1396 template<MonotoneChainConcept OtherChain>
1397 [[nodiscard]] constexpr bool crosses(const OtherChain& other) const;
1399 template<PolylineConcept OtherPolyline>
1400 [[nodiscard]] constexpr bool crosses(const OtherPolyline& other) const;
1402 template <class EmptyPoint>
1403 [[nodiscard]] constexpr bool crosses(const EmptyShape<EmptyPoint>&) const {
1404 return false;
1405 }
1406
1408 template<PointConcept OtherPoint>
1409 [[nodiscard]] constexpr bool crosses(const Shape<OtherPoint>& other) const;
1410
1412 template<typename OtherShape>
1413 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1414 [[nodiscard]] constexpr bool crosses(const OtherShape& other) const {
1415 return other.crosses(*this);
1416 }
1417
1419 template <class ResultNumber = NumberType, PointConcept OtherPoint>
1420 [[nodiscard]] constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
1421 intersection(const OtherPoint& other) const;
1422
1438 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1439 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1441 intersection(const OtherSegment& other) const;
1443 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1444 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1446 intersection(const OtherOrientedSegment& other) const;
1448 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1449 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1451 intersection(const OtherLine& other) const;
1453 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1454 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1456 intersection(const OtherOrientedLine& other) const;
1458 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1459 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1461 intersection(const OtherRay& other) const;
1463 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1464 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1466 intersection(const OtherHalfplane& other) const;
1468 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1469 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1471 intersection(const OtherRectangle& other) const;
1473 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1474 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1476 intersection(const OtherTriangle& other) const;
1478 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1479 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1481 intersection(const OtherConvex& other) const;
1482
1497 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1498 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1500 intersection(const OtherChain& other) const;
1501
1522 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1523 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1525 intersection(const OtherPolyline& other) const;
1526
1554 template <class ResultNumber = division_result_t<NumberType>, class OtherArea>
1556 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1558 polygonIntersection(const OtherArea& other) const;
1559
1561 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1562 requires (!PointConcept<OtherShape>
1563 && (detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1564 && requires(const OtherShape& o, const Polyline& self) {
1565 o.template intersection<ResultNumber>(self);
1566 })
1567 [[nodiscard]] constexpr auto intersection(const OtherShape& other) const {
1568 return other.template intersection<ResultNumber>(*this);
1569 }
1570
1572 template <class ResultNumber = NumberType, class EmptyPoint>
1573 [[nodiscard]] constexpr EmptyShape<EmptyPoint> intersection(const EmptyShape<EmptyPoint>&) const {
1574 return {};
1575 }
1576
1593 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1594 [[nodiscard]] constexpr auto squaredDistance(const OtherPoint& point) const;
1596 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1597 [[nodiscard]] constexpr auto squaredDistance(const OtherSegment& other) const;
1599 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1600 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedSegment& other) const;
1602 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1603 [[nodiscard]] constexpr auto squaredDistance(const OtherLine& other) const;
1605 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1606 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedLine& other) const;
1608 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1609 [[nodiscard]] constexpr auto squaredDistance(const OtherRay& other) const;
1611 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1612 [[nodiscard]] constexpr auto squaredDistance(const OtherHalfplane& other) const;
1614 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1615 [[nodiscard]] constexpr auto squaredDistance(const OtherRectangle& other) const;
1617 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1618 [[nodiscard]] constexpr auto squaredDistance(const OtherTriangle& other) const;
1620 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1621 [[nodiscard]] constexpr auto squaredDistance(const OtherConvex& other) const;
1623 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1624 [[nodiscard]] constexpr auto squaredDistance(const OtherChain& other) const;
1626 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1627 [[nodiscard]] constexpr auto squaredDistance(const OtherPolyline& other) const;
1628
1636 template <class ResultNumber = double, class DiskPointType, class DiskLabel>
1637 [[nodiscard]] detail::floating_result_t<ResultNumber> squaredDistance(
1638 const Disk<DiskPointType, DiskLabel>& disk) const;
1639
1646 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1647 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1648 && requires(const OtherShape& o, const Polyline& self) {
1649 o.template squaredDistance<ResultNumber>(self);
1650 })
1651 [[nodiscard]] constexpr auto squaredDistance(const OtherShape& other) const {
1652 return other.template squaredDistance<ResultNumber>(*this);
1653 }
1654
1667 template <class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape>
1668 requires detail::ClosestPairConcept<Polyline<PointType_, TLabel>, OtherShape>
1669 [[nodiscard]] constexpr auto closestSegments(const OtherShape& other) const;
1670
1687 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
1688 requires detail::ClosestPointsPairConcept<Polyline<PointType_, TLabel>, OtherShape>
1689 [[nodiscard]] constexpr auto closestPoints(const OtherShape& other) const;
1690
1701 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1702 [[nodiscard]] constexpr auto distanceL1(const OtherPoint& point) const;
1704 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1705 [[nodiscard]] constexpr auto distanceL1(const OtherSegment& other) const;
1707 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1708 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedSegment& other) const;
1710 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1711 [[nodiscard]] constexpr auto distanceL1(const OtherLine& other) const;
1713 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1714 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedLine& other) const;
1716 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1717 [[nodiscard]] constexpr auto distanceL1(const OtherRay& other) const;
1719 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1720 [[nodiscard]] constexpr auto distanceL1(const OtherHalfplane& other) const;
1722 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1723 [[nodiscard]] constexpr auto distanceL1(const OtherRectangle& other) const;
1725 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1726 [[nodiscard]] constexpr auto distanceL1(const OtherTriangle& other) const;
1728 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1729 [[nodiscard]] constexpr auto distanceL1(const OtherConvex& other) const;
1731 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1732 [[nodiscard]] constexpr auto distanceL1(const OtherChain& other) const;
1734 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1735 [[nodiscard]] constexpr auto distanceL1(const OtherPolyline& other) const;
1736
1743 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1744 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1745 && requires(const OtherShape& o, const Polyline& self) {
1746 o.template distanceL1<ResultNumber>(self);
1747 })
1748 [[nodiscard]] constexpr auto distanceL1(const OtherShape& other) const {
1749 return other.template distanceL1<ResultNumber>(*this);
1750 }
1751
1767 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1768 [[nodiscard]] constexpr auto intersection(const Shape<OtherPoint>& other) const {
1769 return other.template intersection<ResultNumber>(*this);
1770 }
1771
1776 template <class ResultNumber = double, PointConcept OtherPoint>
1777 [[nodiscard]] constexpr auto distanceL1(const Shape<OtherPoint>& other) const {
1778 return other.template distanceL1<ResultNumber>(*this);
1779 }
1780
1791 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
1792 [[nodiscard]] constexpr auto distanceLInf(const OtherPoint& point) const;
1794 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1795 [[nodiscard]] constexpr auto distanceLInf(const OtherSegment& other) const;
1797 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1798 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedSegment& other) const;
1800 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1801 [[nodiscard]] constexpr auto distanceLInf(const OtherLine& other) const;
1803 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1804 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedLine& other) const;
1806 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1807 [[nodiscard]] constexpr auto distanceLInf(const OtherRay& other) const;
1809 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1810 [[nodiscard]] constexpr auto distanceLInf(const OtherHalfplane& other) const;
1812 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1813 [[nodiscard]] constexpr auto distanceLInf(const OtherRectangle& other) const;
1815 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1816 [[nodiscard]] constexpr auto distanceLInf(const OtherTriangle& other) const;
1818 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1819 [[nodiscard]] constexpr auto distanceLInf(const OtherConvex& other) const;
1821 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1822 [[nodiscard]] constexpr auto distanceLInf(const OtherChain& other) const;
1824 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1825 [[nodiscard]] constexpr auto distanceLInf(const OtherPolyline& other) const;
1826
1833 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
1834 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
1835 && requires(const OtherShape& o, const Polyline& self) {
1836 o.template distanceLInf<ResultNumber>(self);
1837 })
1838 [[nodiscard]] constexpr auto distanceLInf(const OtherShape& other) const {
1839 return other.template distanceLInf<ResultNumber>(*this);
1840 }
1841
1846 template <class ResultNumber = double, PointConcept OtherPoint>
1847 [[nodiscard]] constexpr auto distanceLInf(const Shape<OtherPoint>& other) const {
1848 return other.template distanceLInf<ResultNumber>(*this);
1849 }
1850
1858 template <class ApproximateNumber = double>
1859 ApproximateNumber length() const;
1860
1862 constexpr auto lengthL1() const;
1863
1865 constexpr auto lengthLInf() const;
1866
1876 template <class ResultNumber = division_result_t<NumberType>>
1877 [[nodiscard]] constexpr Point<ResultNumber> pointInside() const;
1878
1888 [[nodiscard]] constexpr Polyline rotated90(int k = 1) const;
1889
1895 constexpr void rotate90(int k = 1);
1896
1898 template <class OtherNumber>
1899 [[nodiscard]] constexpr Polyline scaledUpX(const OtherNumber scalar) const;
1900
1902 template <class OtherNumber>
1903 constexpr void scaleUpX(const OtherNumber scalar);
1904
1906 template <class OtherNumber>
1907 [[nodiscard]] constexpr Polyline scaledUpY(const OtherNumber scalar) const;
1908
1910 template <class OtherNumber>
1911 constexpr void scaleUpY(const OtherNumber scalar);
1912
1914 template <class OtherNumber>
1915 [[nodiscard]] constexpr Polyline scaledDownX(const OtherNumber scalar) const;
1916
1918 template <class OtherNumber>
1919 constexpr void scaleDownX(const OtherNumber scalar);
1920
1922 template <class OtherNumber>
1923 [[nodiscard]] constexpr Polyline scaledDownY(const OtherNumber scalar) const;
1924
1926 template <class OtherNumber>
1927 constexpr void scaleDownY(const OtherNumber scalar);
1928
1959 template <SegmentConcept OldSegment, SegmentConcept NewSegment>
1960 [[nodiscard]] constexpr bool flippable(const OldSegment& oldEdge, const NewSegment& newEdge) const;
1961
1976 template <SegmentConcept OldSegment, SegmentConcept NewSegment>
1977 [[nodiscard]] constexpr Polyline flipped(const OldSegment& oldEdge, const NewSegment& newEdge) const;
1978
1993 template <SegmentConcept OldSegment, SegmentConcept NewSegment>
1994 constexpr void flip(const OldSegment& oldEdge, const NewSegment& newEdge);
1995
2009 template <class OtherShape>
2011 [[nodiscard]] constexpr auto minkowskiSum(const OtherShape& other) const;
2012
2035 template <class OtherShape>
2037 [[nodiscard]] constexpr auto minkowskiErosion(const OtherShape& other) const;
2038
2070 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2074 minkowskiErosion(const OtherShape& other) const;
2075
2115 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2117 minkowskiSum(const OtherTriangle& other) const;
2118
2120 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2122 minkowskiSum(const OtherRectangle& other) const;
2123
2125 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2127 minkowskiSum(const OtherConvex& other) const;
2128
2142 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2144 minkowskiSum(const OtherPolygon& other) const;
2145
2170 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
2172 minkowskiSum(const OtherRegion& other) const;
2173
2196 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2198 minkowskiSum(const OtherSegment& other) const;
2199
2206 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherSegment>
2208 minkowskiSum(const OtherSegment& other) const;
2209
2234 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2236 minkowskiSum(const OtherPolyline& other) const;
2237
2246 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2248 minkowskiSum(const OtherChain& other) const;
2249
2260 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
2262 minkowskiSum(const OtherSet& other) const;
2263
2269 template<PointConcept OtherPoint>
2270 constexpr Polyline& operator+=(const OtherPoint& translation) {
2271 translation_ += translation;
2272 // A pure translation merely shifts the bounding box, so update the
2273 // cached bbox in place rather than discarding it. The hash, however,
2274 // depends on the absolute vertex positions, so it must be invalidated.
2275 if (!bbox_.empty()) {
2276 bbox_ += translation;
2277 }
2278 hash_ = hashUnset_;
2279 return *this;
2280 }
2281
2287 template<PointConcept OtherPoint>
2288 constexpr Polyline& operator-=(const OtherPoint& translation) {
2289 translation_ -= translation;
2290 if (!bbox_.empty()) {
2291 bbox_ -= translation;
2292 }
2293 hash_ = hashUnset_;
2294 return *this;
2295 }
2296
2304 template <class Scalar>
2305 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2306 constexpr Polyline& operator*=(const Scalar& scalar) {
2307 for (auto& vertex : points_) {
2308 vertex *= scalar;
2309 }
2310 translation_ *= scalar;
2311 resetCache();
2312 return *this;
2313 }
2314
2321 template <class Scalar>
2322 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2323 constexpr Polyline& operator/=(const Scalar& scalar) {
2324 for (auto& vertex : points_) {
2325 vertex /= scalar;
2326 }
2327 translation_ /= scalar;
2328 resetCache();
2329 return *this;
2330 }
2331
2339 template <bool Oriented>
2341 public:
2342 using iterator_category = std::forward_iterator_tag;
2343 using iterator_concept = std::forward_iterator_tag;
2345 using difference_type = std::ptrdiff_t;
2347
2348 constexpr BoundaryIterator() = default;
2349
2350 constexpr value_type operator*() const {
2351 assert(polyline != nullptr);
2352 return polyline->template boundaryAt<Oriented>(index);
2353 }
2354
2356 ++index;
2357 return *this;
2358 }
2359
2361 BoundaryIterator copy(*this);
2362 ++(*this);
2363 return copy;
2364 }
2365
2366 constexpr bool operator==(const BoundaryIterator& other) const = default;
2367
2368 private:
2369 friend struct Polyline;
2370
2371 constexpr BoundaryIterator(const Polyline* polyline_arg, std::size_t index_arg)
2372 : polyline(polyline_arg), index(index_arg) {}
2373
2374 const Polyline* polyline = nullptr;
2375 std::size_t index = 0;
2376 };
2377
2378 private:
2379 std::vector<PointType> points_{};
2380 [[no_unique_address]] mutable LabelType label_{};
2381 PointType translation_{};
2382 // Lazily computed bounding box, invalidated by resetCache() on every
2383 // mutation. The empty rectangle doubles as "not computed yet": a shape
2384 // whose box is genuinely empty has no vertices, so bbox() re-derives it
2385 // with one size check rather than any real work.
2386 mutable Rectangle<PointType> bbox_{};
2387
2388 // Memoized hash, computed lazily by std::hash<Polyline>. hashUnset_
2389 // means "not yet computed"; SIZE_MAX is chosen as the sentinel because it
2390 // is a rare hash output, and the one true hash that would collide with it
2391 // is remapped to hashUnset_ - 1 so the sentinel is never stored as a real
2392 // value. Unlike the bbox, the hash is not translation-invariant, so
2393 // operator+=/-= reset it.
2394 static constexpr std::size_t hashUnset_ = pgl::detail::numeric_limits<std::size_t>::max();
2395 mutable std::size_t hash_ = hashUnset_;
2396 friend struct std::hash<Polyline>;
2397
2398 // Drops the memoized caches; call after any operation that mutates the
2399 // polyline's vertices. A pure translation does not need to drop bbox_ (it
2400 // shifts in place, see operator+=), but it must still reset hash_, which
2401 // depends on the absolute vertex positions.
2402 constexpr void resetCache() const {
2403 bbox_ = {};
2404 hash_ = hashUnset_;
2405 }
2406
2407 constexpr std::size_t edgeCount() const {
2408 return points_.empty() ? 0 : points_.size() - 1;
2409 }
2410
2420 template <class ResultNumber, class OtherShape>
2421 constexpr ResultNumber edgeMinSquaredDistance(const OtherShape& other) const;
2422
2424 template <class ResultNumber, class OtherShape>
2425 constexpr ResultNumber edgeMinDistanceL1(const OtherShape& other) const;
2426
2428 template <class ResultNumber, class OtherShape>
2429 constexpr ResultNumber edgeMinDistanceLInf(const OtherShape& other) const;
2430
2435 template <class ResultNumber, class OtherShape>
2436 constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
2438 edgeFoldIntersection(const OtherShape& other) const;
2439
2451 template <class ResultNumber>
2452 static constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
2454 coalescePieces(std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
2456
2457 template <bool Oriented>
2458 constexpr BoundaryType<Oriented> boundaryAt(std::size_t index) const {
2459 assert(index + 1 < size());
2460 return BoundaryType<Oriented>((*this)[index], (*this)[index + 1]);
2461 }
2462
2470 template <SegmentConcept OldSegment, SegmentConcept NewSegment>
2471 constexpr std::optional<std::vector<PointType>> flipVertices(const OldSegment& oldEdge,
2472 const NewSegment& newEdge) const;
2473
2485 constexpr bool storedIsCanonical() const {
2486 if (points_.size() < 2) {
2487 return true;
2488 }
2489 const auto cmp = points_.front() <=> points_.back();
2490 if (cmp < 0) {
2491 return true;
2492 }
2493 if (cmp > 0) {
2494 return false;
2495 }
2496 // Equal extremes: the tie is broken by the full sequences.
2497 return !std::lexicographical_compare(points_.rbegin(), points_.rend(),
2498 points_.begin(), points_.end());
2499 }
2500
2508 constexpr PointType canonicalAt(std::size_t index, bool reversed) const {
2509 return (*this)[reversed ? size() - 1 - index : index];
2510 }
2511
2512 class Iterator {
2513 private:
2514 using BaseIterator = std::vector<PointType>::const_iterator;
2515 BaseIterator it;
2516 PointType x;
2517
2518 public:
2519 using iterator_category = std::random_access_iterator_tag;
2520 using difference_type = std::ptrdiff_t;
2521 using value_type = PointType;
2522 using pointer = PointType*;
2523 using reference = PointType&;
2524
2525 Iterator() = default;
2526 Iterator(BaseIterator it, PointType x) : it(it), x(x) {}
2527
2528 // Dereference returns value + x
2529 PointType operator*() const {
2530 return *it + x;
2531 }
2532
2533 // Pre-increment
2534 Iterator& operator++() {
2535 ++it;
2536 return *this;
2537 }
2538
2539 // Post-increment
2540 Iterator operator++(int) {
2541 Iterator tmp = *this;
2542 ++it;
2543 return tmp;
2544 }
2545
2546 // Pre-decrement
2547 Iterator& operator--() {
2548 --it;
2549 return *this;
2550 }
2551
2552 // Post-decrement
2553 Iterator operator--(int) {
2554 Iterator tmp = *this;
2555 --it;
2556 return tmp;
2557 }
2558
2559 // Equality comparison
2560 bool operator==(const Iterator& other) const {
2561 return it == other.it;
2562 }
2563
2564 // Other comparisons
2565 auto operator<=>(const Iterator& other) const {
2566 return it <=> other.it;
2567 }
2568
2569 // Addition
2570 Iterator operator+(difference_type n) const {
2571 return Iterator(it + n, x);
2572 }
2573
2574 // Subtraction
2575 Iterator operator-(difference_type n) const {
2576 return Iterator(it - n, x);
2577 }
2578
2579 // Difference
2580 difference_type operator-(const Iterator& other) const {
2581 return it - other.it;
2582 }
2583
2584 // Array subscript operator
2585 PointType operator[](difference_type n) const {
2586 return *(it + n) + x;
2587 }
2588 };
2589}; // struct Polyline
2590
2591// --- asPolyline conversions, defined here now that Polyline is complete ---
2592
2593template <class TPoint, class TLabel>
2596 // The polyline traverses the segment from min() to max().
2597 return Polyline<PointType>(vertices());
2598}
2599
2600template <class PointType_, class TLabel, class Storage>
2603 // The polyline traverses the chain in its lexicographic vertex order.
2604 return Polyline<PointType>(vertices());
2605}
2606
2607template <class PointType, class LabelType, class TranslationNumber, class TranslationLabel>
2609 return polyline + (-translation);
2610}
2611
2612template <class PointType, class LabelType, class Scalar>
2613 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2614constexpr auto operator*(const Polyline<PointType, LabelType>& polyline, const Scalar& scalar) {
2615 using ResultPointType = Point<decltype(std::declval<PointType>().x() * scalar), typename PointType::LabelType>;
2616 Polyline<ResultPointType, LabelType> result(polyline);
2617 result *= scalar;
2618 if constexpr (detail::has_label_v<LabelType>) {
2619 result.label() = LabelType{};
2620 }
2621 return result;
2622}
2623
2624template <class Scalar, class PointType, class LabelType>
2625 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2626constexpr auto operator*(const Scalar& scalar, const Polyline<PointType, LabelType>& polyline) {
2627 return polyline * scalar;
2628}
2629
2630template <class PointType, class LabelType, class Scalar>
2631 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2632constexpr auto operator/(const Polyline<PointType, LabelType>& polyline, const Scalar& scalar) {
2633 using ResultPointType = Point<decltype(std::declval<PointType>().x() / scalar), typename PointType::LabelType>;
2634 Polyline<ResultPointType, LabelType> result(polyline);
2635 result /= scalar;
2636 if constexpr (detail::has_label_v<LabelType>) {
2637 result.label() = LabelType{};
2638 }
2639 return result;
2640}
2641
2642template <class PointType, class LabelType>
2643std::ostream& operator<<(std::ostream& stream, const Polyline<PointType, LabelType>& polyline);
2644
2645} // namespace pgl
std::ptrdiff_t difference_type
Definition polyline.hpp:2345
std::forward_iterator_tag iterator_category
Definition polyline.hpp:2342
value_type reference
Definition polyline.hpp:2346
BoundaryType< Oriented > value_type
Definition polyline.hpp:2344
std::forward_iterator_tag iterator_concept
Definition polyline.hpp:2343
constexpr BoundaryIterator operator++(int)
Definition polyline.hpp:2360
constexpr BoundaryIterator & operator++()
Definition polyline.hpp:2355
constexpr value_type operator*() const
Definition polyline.hpp:2350
constexpr BoundaryIterator()=default
friend struct Polyline
Definition polyline.hpp:2369
constexpr bool operator==(const BoundaryIterator &other) const =default
Bounded polygonal primitives, convex or not.
Definition forward.hpp:373
Shape pairs whose Minkowski sum Pangolin can represent.
Definition forward.hpp:476
Definition forward.hpp:306
Definition forward.hpp:316
Definition forward.hpp:317
Definition forward.hpp:324
Definition arrangement.hpp:67
@ y
Definition intervaltree.hpp:24
@ x
Definition intervaltree.hpp:24
@ vertex
Definition bitmatrix.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
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
Segment() -> Segment< Point<>, NoLabel >
Polyline() -> Polyline< Point<>, NoLabel >
Definition polyline.hpp:2369
Closed convex polygon stored by its vertices.
Definition convex.hpp:170
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition measures.hpp:696
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
constexpr Polyline< PointType > asPolyline() const
Returns the chain as a polyline traversing its vertices in lexicographic order.
Definition polyline.hpp:2602
constexpr std::vector< PointType > vertices() const
Returns the vertices of the chain (translation applied).
Definition monotonechain.hpp:569
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
ERational NumberType
Definition point.hpp:131
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
Open polygonal chain stored in traversal order; may self-intersect.
Definition polyline.hpp:69
constexpr bool crosses(const OtherPolyline &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1022
constexpr auto distanceL1(const OtherConvex &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1366
constexpr OrientedEdgeIterator orientedEdgesBegin() const
Returns an iterator to the first oriented edge.
Definition polyline.hpp:659
constexpr bool intersects(const OtherDisk &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1721
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polyline.hpp:793
constexpr bool isSegment() const
Checks whether the polyline covers exactly one segment of positive length.
Definition polyline.hpp:450
constexpr auto distanceL1(const OtherOrientedLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1321
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2182
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
constexpr bool interiorContains(const OtherOrientedLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1610
constexpr auto distanceLInf(const OtherPoint &point) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1263
constexpr auto distanceLInf(const OtherRay &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1318
constexpr bool interiorsIntersect(const OtherHalfplane &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1984
constexpr bool interiorsIntersect(const OtherDisk &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2012
constexpr bool boundaryContains(const OtherDisk &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:868
constexpr auto intersection(const OtherShape &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition polyline.hpp:1567
constexpr const Rectangle< PointType > & bbox() const
Computes the bounding box of the polyline.
Definition bounding.hpp:515
constexpr bool crosses(const OtherTriangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:998
constexpr bool intersects(const OtherOrientedLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1678
constexpr void scaleUpY(const OtherNumber scalar)
Multiplies the polyline's y-coordinates by a factor in place.
Definition transformations.hpp:2042
bool isSimple() const
Tests whether the polyline is simple (it does not touch or cross itself).
Definition xysweep.hpp:314
constexpr bool separates(const OtherChain &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3935
constexpr void pushBack(Range &&points)
Appends a range of vertices in order.
Definition polyline.hpp:303
constexpr Polyline(const Polyline< OtherPointType, OtherLabelType > &other)
Converts a polyline with compatible vertex type.
Definition polyline.hpp:136
constexpr bool intersects(const OtherRectangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1696
constexpr bool interiorContains(const OtherOrientedSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1598
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherChain &other) const
Returns the regularized Minkowski sum of the two chains (A ⊕ B).
constexpr auto distanceLInf(const OtherShape &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition polyline.hpp:1838
constexpr bool boundaryContains(const OtherChain &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:874
constexpr bool interiorsIntersect(const Shape< OtherPoint > &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2084
constexpr bool intersects(const OtherOrientedSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1643
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > polygonIntersection(const OtherArea &other) const
Returns the intersection with a polygon or a region (A ∩ B), a sequence of points and segments sorted...
Definition intersection.hpp:2987
constexpr auto closestSegments(const OtherShape &other) const
Returns the pair of elements realizing the distance, nothing when the shapes meet.
Definition closest.hpp:398
constexpr auto distanceLInf(const OtherLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1300
constexpr bool separates(const OtherConvex &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3911
constexpr bool intersects(const OtherChain &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1727
constexpr auto squaredDistance(const OtherRay &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1664
constexpr bool interiorsIntersect(const OtherRectangle &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1990
constexpr bool boundaryContains(const OtherHalfplane &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:841
constexpr bool operator==(const Polyline &other) const
Checks equality of two polylines.
Definition polyline.hpp:367
constexpr auto distanceLInf(const OtherRectangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1336
constexpr bool separates(const OtherPoint &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition polyline.hpp:1176
constexpr bool interiorContains(const OtherSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1587
constexpr bool contains(const OtherOrientedSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2197
constexpr void rotate90(int k=1)
Rotates the polyline by 90k degrees around the origin in place.
Definition transformations.hpp:2004
constexpr A & label() const
Returns the polyline label.
Definition polyline.hpp:149
constexpr bool contains(const OtherRectangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2227
constexpr bool interiorContains(const OtherPolyline &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1652
constexpr bool separates(const OtherPolyline &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3472
constexpr Polyline()=default
Creates a polyline with no vertex.
constexpr auto squaredDistance(const OtherOrientedSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1637
constexpr bool separates(const EmptyShape< EmptyPoint > &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition polyline.hpp:1352
constexpr bool contains(const OtherTriangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2244
constexpr bool crosses(const OtherOrientedSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:958
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
constexpr bool intersects(const OtherPolyline &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1752
constexpr Polyline flipped(const OldSegment &oldEdge, const NewSegment &newEdge) const
Returns the polyline with oldEdge flipped to newEdge.
constexpr bool isDegenerate() const
Checks if the polyline is degenerate (all vertices are equal, so it covers at most a single point).
Definition polyline.hpp:409
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:6002
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherPolyline &other) const
Returns the intersection of the two polylines (A ∩ B), a sequence of points and segments sorted by le...
Definition intersection.hpp:2943
constexpr auto distanceLInf(const OtherHalfplane &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1327
constexpr bool boundaryContains(const OtherTriangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:850
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 polyline.hpp:1768
constexpr bool flippable(const OldSegment &oldEdge, const NewSegment &newEdge) const
Tests whether oldEdge can be flipped to newEdge.
Definition transformations.hpp:2156
constexpr bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4693
constexpr bool crosses(const OtherLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:964
constexpr bool separates(const OtherDisk &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3899
constexpr const PointType operator[](std::size_t index) const
Accesses a vertex by index (in traversal order).
Definition polyline.hpp:158
constexpr EdgeIterator edgesEnd() const
Returns an iterator past the last unoriented edge.
Definition polyline.hpp:651
constexpr auto distanceL1(const OtherRectangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1348
constexpr auto squaredDistance(const OtherSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1619
constexpr bool crosses(const OtherChain &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1016
constexpr auto distanceL1(const OtherSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1284
constexpr bool boundaryContains(const OtherPolygon &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:862
detail::floating_result_t< ResultNumber > squaredDistance(const Disk< DiskPointType, DiskLabel > &disk) const
Returns the squared Euclidean distance to a disk.
Definition distance.hpp:1718
constexpr bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polyline.hpp:1331
constexpr std::vector< PointType > vertices() const
Returns the vertices of the polyline (translation applied).
Definition polyline.hpp:570
constexpr bool interiorContains(const OtherPolygon &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polyline.hpp:964
constexpr auto distanceL1(const OtherShape &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition polyline.hpp:1748
constexpr void insert(std::size_t index, Range &&points)
Inserts a range of vertices at the given index, shifting the later vertices back.
Definition polyline.hpp:262
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 polyline.hpp:1777
constexpr Rectangle< Point< ResultNumber > > fbox() const
Computes the floating-point bounding box of the polyline.
Definition bounding.hpp:527
constexpr auto distanceL1(const OtherHalfplane &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1339
constexpr bool contains(const OtherOrientedLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2209
constexpr bool separates(const Shape< OtherPoint > &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3950
constexpr bool crosses(const Shape< OtherPoint > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1028
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherSegment &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2828
constexpr auto squaredDistance(const OtherConvex &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1700
constexpr void scaleUpX(const OtherNumber scalar)
Multiplies the polyline's x-coordinates by a factor in place.
Definition transformations.hpp:2023
constexpr std::ptrdiff_t index(const PointType &point) const
Definition polyline.hpp:212
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:2690
constexpr bool intersects(const OtherTriangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1709
constexpr bool separates(const OtherOrientedSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3800
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherLine &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2844
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition polyline.hpp:1573
constexpr void insert(std::size_t index, const OtherPoint &point)
Inserts a vertex at the given index, shifting the later vertices back.
Definition polyline.hpp:236
constexpr bool interiorsIntersect(const OtherLine &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1896
constexpr auto distanceL1(const OtherRay &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1330
constexpr bool isUndefined() const
Checks whether the polyline is degenerate without covering a point or a segment.
Definition polyline.hpp:477
constexpr bool contains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2301
BoundaryIterator< false > EdgeIterator
Definition polyline.hpp:81
constexpr auto lengthLInf() const
Computes the Chebyshev (LInf) length of the polyline.
Definition measures.hpp:1275
constexpr bool contains(const OtherHalfplane &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2221
constexpr bool interiorsIntersect(const OtherConvex &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2006
constexpr OrientedEdgeIterator orientedEdgesEnd() const
Returns an iterator past the last oriented edge.
Definition polyline.hpp:667
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition polyline.hpp:1155
constexpr bool separates(const OtherTriangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3887
constexpr bool interiorsIntersect(const OtherChain &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2018
constexpr void flip(const OldSegment &oldEdge, const NewSegment &newEdge)
Flips oldEdge to newEdge in place.
Definition transformations.hpp:2172
constexpr auto distanceL1(const OtherPolyline &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1293
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRay &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2860
constexpr void scaleDownX(const OtherNumber scalar)
Divides the polyline's x-coordinates by a divisor in place.
Definition transformations.hpp:2061
constexpr auto distanceLInf(const OtherConvex &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1354
constexpr auto distanceLInf(const OtherChain &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1363
constexpr bool interiorsIntersect(const OtherRay &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1934
TLabel LabelType
Definition polyline.hpp:72
constexpr auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:405
constexpr Polyline & operator+=(const OtherPoint &translation)
Translates the polyline by the given point.
Definition polyline.hpp:2270
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1626
constexpr EdgeIterator edgesBegin() const
Returns an iterator to the first unoriented edge.
Definition polyline.hpp:643
constexpr std::vector< OrientedSegment< PointType > > orientedEdges() const
Returns the oriented edges of the polyline, each directed from vertex i to vertex i + 1 in traversal ...
Definition polyline.hpp:598
constexpr auto begin() const
Definition polyline.hpp:310
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polyline.hpp:1069
constexpr bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polyline.hpp:1309
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherTriangle &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2884
constexpr auto distanceLInf(const OtherOrientedLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1309
constexpr auto squaredDistance(const OtherTriangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1691
constexpr bool interiorContains(const OtherLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1604
constexpr bool intersects(const OtherRay &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1684
constexpr auto distanceLInf(const OtherOrientedSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1291
constexpr Polyline rotated90(int k=1) const
Returns the polyline rotated by 90k degrees around the origin.
Definition transformations.hpp:1994
constexpr PointType get(std::ptrdiff_t index) const
Accesses a vertex by index modulo the vertex count.
Definition polyline.hpp:174
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polyline.hpp:1403
EPoint PointType
Definition polyline.hpp:70
constexpr bool interiorContains(const OtherDisk &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polyline.hpp:970
constexpr bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:1320
constexpr auto end() const
Definition polyline.hpp:324
constexpr bool separates(const OtherPolygon &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3923
bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5750
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2134
constexpr Polyline scaledUpX(const OtherNumber scalar) const
Returns the polyline with its x-coordinates multiplied by a factor.
constexpr bool contains(const OtherSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2151
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherPolygon &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr bool interiorsIntersect(const OtherOrientedLine &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1928
ApproximateNumber length() const
Computes the Euclidean length of the polyline (the sum of its edge lengths).
Definition measures.hpp:1257
constexpr bool interiorContains(const OtherChain &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1640
constexpr bool interiorsIntersect(const OtherPoint &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1848
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherSet &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B), as a set of regions.
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherRectangle &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherConvex &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr Polyline scaledDownX(const OtherNumber scalar) const
Returns the polyline with its x-coordinates divided by a divisor.
constexpr bool crosses(const OtherConvex &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1010
constexpr auto squaredDistance(const OtherHalfplane &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1673
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedSegment &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2836
constexpr auto orientedEdgesView() const
Lazy view counterpart of orientedEdges(); see edgesView().
Definition polyline.hpp:635
constexpr Convex< PointType > convexHull() const
Returns the convex hull of the polyline's vertices.
Definition polyline.hpp:521
constexpr bool contains(const OtherConvex &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2256
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1620
constexpr bool crosses(const OtherSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:952
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by another (A ⊖ B).
Definition minkowskierosion.hpp:638
constexpr auto lengthL1() const
Computes the Manhattan (L1) length of the polyline.
Definition measures.hpp:1266
constexpr auto distanceLInf(const OtherTriangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1345
constexpr bool interiorsIntersect(const OtherOrientedSegment &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1890
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2895
PointType::NumberType NumberType
Definition polyline.hpp:71
constexpr bool boundaryContains(const OtherPoint &point) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1268
constexpr bool interiorsIntersect(const OtherTriangle &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2000
constexpr bool interiorContains(const OtherHalfplane &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1622
constexpr bool contains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2319
constexpr auto distanceL1(const OtherTriangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1357
constexpr auto cend() const
Returns a constant iterator past the last vertex.
Definition polyline.hpp:331
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherPolyline &other) const
Returns the regularized Minkowski sum of the two chains (A ⊕ B).
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherSegment &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr auto squaredDistance(const OtherRectangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1682
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the polyline contains.
Definition lattice.hpp:534
constexpr Point< ResultNumber > pointInside() const
Returns a point inside the polyline.
Definition measures.hpp:1285
constexpr bool boundaryContains(const OtherOrientedSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:826
constexpr bool empty() const
Checks whether the polyline has no vertex.
Definition polyline.hpp:395
constexpr bool interiorContains(const OtherRay &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1616
constexpr bool intersects(const Shape< OtherPoint > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1777
constexpr auto verticesView() const
Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector.
Definition polyline.hpp:615
constexpr bool crosses(const OtherRectangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:988
constexpr bool separates(const OtherRectangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3871
constexpr bool intersects(const OtherHalfplane &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1690
constexpr std::vector< Segment< PointType > > edges() const
Returns the edges of the polyline.
Definition polyline.hpp:585
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherTriangle &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr std::optional< BoundaryType< false > > getIfSegment() const
Returns the segment the polyline collapses to, if it does.
Definition polyline.hpp:461
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > minkowskiErosion(const OtherShape &other) const
Returns the regularized Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B),...
Definition minkowskierosion.hpp:723
constexpr bool interiorsIntersect(const OtherPolyline &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2051
constexpr bool separates(const OtherSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3459
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherHalfplane &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2868
constexpr bool crosses(const OtherOrientedLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:970
constexpr bool boundaryContains(const OtherRectangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:844
constexpr void pushBack(const OtherPoint &point)
Appends a vertex, extending the polyline by one edge.
Definition polyline.hpp:286
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherRegion &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr bool interiorsIntersect(const OtherSegment &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1855
constexpr bool intersects(const OtherLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1672
constexpr bool separates(const OtherRay &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3820
constexpr bool interiorContains(const Shape< OtherPoint > &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1664
constexpr bool separates(const OtherHalfplane &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3865
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherChain &other) const
Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments sorted by l...
Definition intersection.hpp:2900
constexpr bool boundaryContains(const OtherPolyline &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:881
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
constexpr auto distanceL1(const OtherChain &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1375
constexpr bool crosses(const OtherRay &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:976
constexpr auto distanceLInf(const OtherSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1272
constexpr auto squaredDistance(const OtherLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1646
constexpr Polyline(Range &&points)
Creates a polyline from a range of points.
Definition polyline.hpp:101
constexpr auto distanceL1(const OtherPoint &point) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1275
constexpr auto distanceL1(const OtherLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1312
constexpr std::optional< PointType > getIfPoint() const
Returns the point the polyline collapses to, if it does.
Definition polyline.hpp:433
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherConvex &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2892
constexpr auto distanceL1(const OtherOrientedSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1303
constexpr auto squaredDistance(const OtherChain &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1709
constexpr bool crosses(const OtherHalfplane &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:982
BoundaryIterator< true > OrientedEdgeIterator
Definition polyline.hpp:82
constexpr bool separates(const OtherLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3806
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 polyline.hpp:1847
constexpr Polyline(std::initializer_list< NumberType > coords)
Creates a polyline from a flat list of coordinates.
Definition polyline.hpp:116
constexpr auto squaredDistance(const OtherShape &other) const
Returns the squared Euclidean distance to the given shape.
Definition polyline.hpp:1651
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition polyline.hpp:514
constexpr bool contains(const OtherRay &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2215
constexpr bool boundaryContains(const OtherConvex &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:856
constexpr std::size_t size() const
Returns the number of vertices in the polyline.
Definition polyline.hpp:388
constexpr bool contains(const OtherPolygon &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2271
constexpr bool crosses(const OtherDisk &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1004
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:2013
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:888
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRectangle &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2876
constexpr bool interiorContains(const OtherTriangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1628
constexpr auto distanceLInf(const OtherPolyline &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1281
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1774
constexpr auto squaredDistance(const OtherOrientedLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1655
constexpr Polyline scaledUpY(const OtherNumber scalar) const
Returns the polyline with its y-coordinates multiplied by a factor.
constexpr bool interiorContains(const OtherConvex &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polyline.hpp:958
constexpr Polyline scaledDownY(const OtherNumber scalar) const
Returns the polyline with its y-coordinates divided by a divisor.
constexpr bool separates(const OtherOrientedLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3814
constexpr bool interiorContains(const OtherRectangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polyline.hpp:952
constexpr bool contains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2295
constexpr auto operator<=>(const Polyline &other) const
Compares two polylines by their canonical vertex sequences.
Definition polyline.hpp:344
constexpr auto minkowskiSum(const OtherShape &other) const
Returns the Minkowski sum of this shape and another (A ⊕ B).
Definition minkowski.hpp:805
constexpr void scaleDownY(const OtherNumber scalar)
Divides the polyline's y-coordinates by a divisor in place.
Definition transformations.hpp:2080
constexpr bool boundaryContains(const OtherOrientedLine &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:835
constexpr bool crosses(const OtherPoint &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polyline.hpp:1362
constexpr bool boundaryContains(const OtherSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:820
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1610
constexpr bool boundaryContains(const OtherRay &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:838
constexpr bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polyline.hpp:1080
constexpr bool isPoint() const
Checks whether the polyline covers exactly one point.
Definition polyline.hpp:422
constexpr bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polyline.hpp:1414
constexpr bool intersects(const OtherConvex &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1715
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polyline.hpp:984
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedLine &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2852
constexpr bool boundaryContains(const OtherLine &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polyline.hpp:832
constexpr bool contains(const Shape< OtherPoint > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2337
constexpr auto squaredDistance(const OtherPolyline &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1628
constexpr bool contains(const OtherLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2203
constexpr void set(std::size_t index, const OtherPoint &point)
Replaces the vertex at the given index.
Definition polyline.hpp:194
constexpr Polyline & operator-=(const OtherPoint &translation)
Translates the polyline by the negation of the given point.
Definition polyline.hpp:2288
constexpr bool interiorContains(const OtherPoint &point) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1581
constexpr auto cbegin() const
Returns a constant iterator to the first vertex.
Definition polyline.hpp:317
std::conditional_t< Oriented, OrientedSegment< PointType >, Segment< PointType > > BoundaryType
Definition polyline.hpp:76
constexpr bool boundaryContains(const Shape< OtherPoint > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1277
constexpr bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition polyline.hpp:1166
constexpr auto edgesView() const
Returns a lazy view over the edges, materializing each Segment on the fly instead of allocating a vec...
Definition polyline.hpp:627
Axis-aligned rectangle stored by minimum and maximum corners.
Definition rectangle.hpp:75
Unoriented closed segment between two endpoints plus optional segment label.
Definition segment.hpp:58
constexpr std::array< PointType, 2 > vertices() const
Returns the two endpoints in canonical order.
Definition bounding.hpp:93
constexpr Polyline< PointType > asPolyline() const
Returns the segment as a two-vertex polyline.
Definition polyline.hpp:2595
Runtime variant wrapper over the supported primitive shapes.
Definition shape.hpp:160