Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
polygon.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "shape/polyline.hpp"
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 <ranges>
14#include <limits>
15#include <optional>
16#include <ostream>
17#include <span>
18#include <type_traits>
19#include <utility>
20
21
22namespace pgl {
23
24template <class PointType = Point<>, class Label>
25struct Polygon;
26
28
29template <std::ranges::input_range Range>
30requires detail::is_point_v<std::ranges::range_value_t<Range>>
32
33template <class Number>
34requires (!detail::is_point_v<Number>)
35Polygon(std::initializer_list<Number>) -> Polygon<Point<Number>, NoLabel>;
36
37template <class Number>
38requires (!detail::is_point_v<Number>)
39Polygon(std::initializer_list<Number>, bool) -> Polygon<Point<Number>, NoLabel>;
40
41
58template <class PointType_, class TLabel>
59struct Polygon {
60 using PointType = PointType_;
62 using LabelType = TLabel;
63 static_assert(detail::is_point_v<PointType>, "Polygon requires pgl::Point vertices");
64
65 template <bool Oriented>
66 using BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>>;
67
68 template <bool Oriented>
69 class BoundaryIterator;
70
71 using EdgeIterator = BoundaryIterator<false>;
72 using OrientedEdgeIterator = BoundaryIterator<true>;
73
77 constexpr Polygon() = default;
78
90 template<std::ranges::input_range Range = std::initializer_list<PointType>>
91 requires std::ranges::common_range<Range> &&
92 std::convertible_to<std::ranges::range_value_t<Range>, PointType>
93 constexpr explicit Polygon(Range&& points, bool trusted = false) {
94 for (const auto& p : points) {
95 points_.push_back(p);
96 }
97 if (!trusted) {
98 normalize();
99 }
100 }
101
113 constexpr explicit Polygon(std::initializer_list<NumberType> coords, bool trusted = false) {
114 assert(coords.size() % 2 == 0);
115 points_.reserve(coords.size() / 2);
116 for (auto it = coords.begin(); it != coords.end(); ) {
117 NumberType x = *it++;
118 NumberType y = *it++;
119 points_.emplace_back(x, y);
120 }
121 if (!trusted) {
122 normalize();
123 }
124 }
125
135 template<PointConcept OtherPointType, class OtherLabelType>
136 requires(std::constructible_from<PointType, const OtherPointType&>)
138 : points_(other.begin(), other.end()), label_(detail::copyLabel<LabelType>(other)) {}
139
148 template <class A = LabelType>
149 requires(detail::has_label_v<A>)
150 constexpr A& label() const {
151 return label_;
152 }
153
159 constexpr const PointType operator[](std::size_t index) const {
160 assert(index < size());
161 return points_[index] + translation_;
162 }
163
169 constexpr PointType get(std::ptrdiff_t index) const {
170 const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(size());
171 return (*this)[static_cast<std::size_t>(((index % n) + n) % n)];
172 }
173
184 constexpr std::ptrdiff_t index(const PointType& point) const {
185 for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t>(size()); ++i) {
186 if ((*this)[static_cast<std::size_t>(i)] == point) {
187 return i;
188 }
189 }
190 return -1;
191 }
192
196 constexpr auto begin() const {
197 return Iterator(points_.begin(), translation_);
198 }
199
203 constexpr auto cbegin() const {
204 return Iterator(points_.cbegin(), translation_);
205 }
206
210 constexpr auto end() const {
211 return Iterator(points_.end(), translation_);
212 }
213
217 constexpr auto cend() const {
218 return Iterator(points_.cend(), translation_);
219 }
220
224 constexpr auto operator<=>(const Polygon& other) const {
225 if (auto cmp = points_.size() <=> other.points_.size(); cmp != 0) {
226 return cmp;
227 }
228 for (std::size_t i = 0; i < points_.size(); ++i) {
229 if (auto cmp = points_[i] + translation_ <=> other.points_[i] + other.translation_; cmp != 0) {
230 return cmp;
231 }
232 }
233 return std::strong_ordering::equal;
234 }
235
240 constexpr bool operator==(const Polygon& other) const {
241 if (points_.size() != other.points_.size()) {
242 return false;
243 }
244 for (std::size_t i = 0; i < points_.size(); ++i) {
245 if (points_[i] + translation_ != other.points_[i] + other.translation_) {
246 return false;
247 }
248 }
249 return true;
250 }
251
253 template<AnyShapeConcept OtherShape>
254 [[nodiscard]] constexpr bool samePointSet(const OtherShape& other) const;
255
259 constexpr std::size_t size() const {
260 return points_.size();
261 }
262
272 template <class ResultNumber = NumberType>
273 constexpr ResultNumber twiceArea() const {
274 if (points_.size() < 3) {
275 return ResultNumber(0);
276 }
277 return pgl::detail::abs(signedTwiceArea<ResultNumber>());
278 }
279
284 template <class ResultNumber = division_result_t<NumberType>>
285 constexpr auto area() const {
286 ResultNumber result = static_cast<ResultNumber>(twiceArea());
287 return result / ResultNumber(2);
288 }
289
302 [[nodiscard]] constexpr bool empty() const {
303 return points_.empty();
304 }
305
319 constexpr bool isDegenerate() const {
320 return empty() || isPoint() || isSegment() || hasNoArea();
321 }
322
330 [[nodiscard]] constexpr bool isPoint() const {
331 return detail::allPointsEqual(points_);
332 }
333
341 [[nodiscard]] constexpr std::optional<PointType> getIfPoint() const {
342 if (!isPoint()) {
343 return std::nullopt;
344 }
345 return points_.front() + translation_;
346 }
347
358 [[nodiscard]] constexpr bool isSegment() const {
359 return detail::pointsSpanSegment(points_);
360 }
361
369 [[nodiscard]] constexpr std::optional<BoundaryType<false>> getIfSegment() const {
370 if (!isSegment()) {
371 return std::nullopt;
372 }
373 return detail::spannedSegment<BoundaryType<false>>(points_) + translation_;
374 }
375
388 [[nodiscard]] constexpr bool isUndefined() const {
389 // Ordered so the cheap emptiness and point/segment scans reject the
390 // common cases before paying for the full area sum.
391 return !empty() && !isPoint() && !isSegment() && hasNoArea();
392 }
393
407 template <class Rational = pgl::Rational<pgl::BigInt>>
408 [[nodiscard]] bool isSimple() const;
409
423 [[nodiscard]] constexpr bool isConvex() const {
424 const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(size());
425 if (n < 3) {
426 return false;
427 }
428 bool sawPositive = false;
429 bool sawNegative = false;
430 for (std::ptrdiff_t i = 0; i < n; ++i) {
431 const auto turn = orientationSign(get(i), get(i + 1), get(i + 2));
432 if (turn > 0) {
433 sawPositive = true;
434 } else if (turn < 0) {
435 sawNegative = true;
436 }
437 if (sawPositive && sawNegative) {
438 return false;
439 }
440 }
441 return true;
442 }
443
464 [[nodiscard]] constexpr std::size_t chainCount() const {
465 const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(size());
466 if (n < 2) {
467 return 0;
468 }
469 // Matches BoundaryChains exactly, down to how it classifies a repeated
470 // vertex: `ascends` is a strict lexicographic test, so a level edge
471 // counts as descending in both places.
472 std::size_t breaks = 0;
473 bool previous = get(n - 1) < get(0);
474 for (std::ptrdiff_t i = 0; i < n; ++i) {
475 const bool ascends = get(i) < get(i + 1);
476 if (ascends != previous) {
477 ++breaks;
478 }
479 previous = ascends;
480 }
481 return breaks;
482 }
483
504 [[nodiscard]] constexpr std::optional<HalfplaneIntersection<PointType>> getStarShapedKernel() const;
505
515 [[nodiscard]] constexpr bool isStarShaped() const {
516 return getStarShapedKernel().has_value();
517 }
518
530 constexpr Segment<PointType> diameter() const {
532 }
533
537 constexpr Convex<PointType> convexHull() const {
538 return Convex<PointType>(vertices());
539 }
540
553 constexpr const Rectangle<PointType>& bbox() const;
554
571 template <class ResultNumber = grid_number_t<typename PointType_::NumberType>>
572 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
575
581 template <std::floating_point ResultNumber = double>
583
587 constexpr std::vector<PointType> vertices() const {
588 auto ret = points_;
589 for (auto& vertex : ret) {
590 vertex += translation_;
591 }
592 return ret;
593 }
594
598 constexpr std::vector<Segment<PointType>> edges() const {
599 std::vector<Segment<PointType>> result;
600 const auto translatedVertices = vertices();
601 for (std::size_t i = 0; i < translatedVertices.size(); ++i) {
602 const auto& p1 = translatedVertices[i];
603 const auto& p2 = translatedVertices[(i + 1) % translatedVertices.size()];
604 result.emplace_back(p1, p2);
605 }
606 return result;
607 }
608
612 constexpr std::vector<OrientedSegment<PointType>> orientedEdges() const {
613 std::vector<OrientedSegment<PointType>> result;
614 const auto translatedVertices = vertices();
615 for (std::size_t i = 0; i < translatedVertices.size(); ++i) {
616 const auto& p1 = translatedVertices[i];
617 const auto& p2 = translatedVertices[(i + 1) % translatedVertices.size()];
618 result.emplace_back(p1, p2);
619 }
620 return result;
621 }
622
647 [[nodiscard]] Graph<PointType> visibilityGraph() const;
648
668
698
715 [[nodiscard]] std::vector<PointType> visibleVertices(const PointType& query) const;
716
728 [[nodiscard]] std::vector<PointType> clearlyVisibleVertices(const PointType& query) const;
729
758 template <class ResultNumber = division_result_t<NumberType>>
760 const PointType& query) const;
761
770 constexpr auto verticesView() const {
771 return std::ranges::subrange(begin(), end());
772 }
773
782 constexpr auto edgesView() const {
783 return std::ranges::subrange(edgesBegin(), edgesEnd());
784 }
785
790 constexpr auto orientedEdgesView() const {
791 return std::ranges::subrange(orientedEdgesBegin(), orientedEdgesEnd());
792 }
793
798 constexpr EdgeIterator edgesBegin() const {
799 return EdgeIterator(this, 0);
800 }
801
806 constexpr EdgeIterator edgesEnd() const {
807 return EdgeIterator(this, size());
808 }
809
815 return OrientedEdgeIterator(this, 0);
816 }
817
823 return OrientedEdgeIterator(this, size());
824 }
825
835 [[nodiscard]] constexpr PolygonWithHoles<PointType> asPolygonWithHoles() const {
836 return PolygonWithHoles<PointType>(*this);
837 }
838
847 [[nodiscard]] constexpr PolygonSet<PointType> asPolygonSet() const {
849 }
850
856 template <class ResultNumber = division_result_t<NumberType>>
857 constexpr Point<ResultNumber> centroid() const {
858 if (points_.size() < 3) {
860 }
861 // The weights and the area they are divided by are summed in the same
862 // pass and the same type: taken from signedTwiceArea() the divisor
863 // would come back narrowed to NumberType, where an area past the
864 // coordinate range wraps and either sends a perfectly ordinary polygon
865 // down the no-area path or scales the answer by a wrapped divisor.
866 ResultNumber cx = 0;
867 ResultNumber cy = 0;
868 ResultNumber areaTwice = 0;
869 const std::size_t n = points_.size();
870 for (std::size_t i = 0; i < n; ++i) {
871 const auto& p1 = points_[i];
872 const auto& p2 = points_[(i + 1) % n];
873 const ResultNumber cross = detail::asNumber<ResultNumber>(p1.x()) * detail::asNumber<ResultNumber>(p2.y())
874 - detail::asNumber<ResultNumber>(p2.x()) * detail::asNumber<ResultNumber>(p1.y());
875 areaTwice += cross;
876 cx += (detail::asNumber<ResultNumber>(p1.x()) + detail::asNumber<ResultNumber>(p2.x())) * cross;
877 cy += (detail::asNumber<ResultNumber>(p1.y()) + detail::asNumber<ResultNumber>(p2.y())) * cross;
878 }
879 if (areaTwice == ResultNumber(0)) {
881 }
882 const ResultNumber denom = ResultNumber(3) * areaTwice;
883 return Point<ResultNumber>(cx / denom, cy / denom) + static_cast<Point<ResultNumber>>(translation_);
884 }
885
891 template <class ResultNumber = division_result_t<NumberType>>
893 if (points_.empty()) {
894 return Point<ResultNumber>();
895 }
896 ResultNumber cx = 0;
897 ResultNumber cy = 0;
898 for (const auto& vertex : points_) {
899 cx += detail::asNumber<ResultNumber>(vertex.x());
900 cy += detail::asNumber<ResultNumber>(vertex.y());
901 }
902 return Point<ResultNumber>(cx / static_cast<ResultNumber>(points_.size()),
903 cy / static_cast<ResultNumber>(points_.size()))
904 + static_cast<Point<ResultNumber>>(translation_);
905 }
906
926 template <class ResultNumber = division_result_t<NumberType>>
927 [[nodiscard]] constexpr Point<ResultNumber> pointInside() const;
928
937 template <class OtherShape>
938 [[nodiscard]] constexpr bool pointInsideInteriorContainedIn(const OtherShape& shape) const;
939
948 auto triangulation() const;
949
961 template <class SegmentRange>
962 auto triangulation(const SegmentRange& segments) const;
963
978 [[nodiscard]] std::vector<Convex<PointType>> convexPartition() const;
979
1004 [[nodiscard]] std::vector<Convex<PointType>> convexCovering() const;
1005
1026 template <class ResultNumber = grid_number_t<typename PointType_::NumberType>>
1027 requires(std::signed_integral<ResultNumber>)
1028 [[nodiscard]] auto asBitMatrix() const;
1029
1042 template <class PointRange, class SegmentRange>
1043 auto triangulation(const PointRange& points, const SegmentRange& segments) const;
1044
1075 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1077 difference(const OtherPolygon& other) const;
1078
1080 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1082 difference(const OtherConvex& other) const;
1083
1085 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1087 difference(const OtherTriangle& other) const;
1088
1090 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1092 difference(const OtherRectangle& other) const;
1093
1095 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1097 difference(const OtherRegion& other) const;
1098
1108 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1110 difference(const OtherSet& other) const;
1111
1121 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
1123 difference(const OtherIntersection& other) const;
1124
1131 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1133 difference(const OtherHalfplane& other) const;
1134
1160 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1162 regularizedUnion(const OtherPolygon& other) const;
1163
1165 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1167 regularizedUnion(const OtherConvex& other) const;
1168
1170 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1172 regularizedUnion(const OtherTriangle& other) const;
1173
1175 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1177 regularizedUnion(const OtherRectangle& other) const;
1178
1180 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1182 regularizedUnion(const OtherRegion& other) const;
1183
1195 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1196 [[nodiscard]] auto regularizedUnion(const OtherSet& other) const {
1197 return other.template regularizedUnion<ResultNumber>(*this);
1198 }
1199
1218 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1220 symmetricDifference(const OtherPolygon& other) const;
1221
1223 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1225 symmetricDifference(const OtherConvex& other) const;
1226
1228 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1230 symmetricDifference(const OtherTriangle& other) const;
1231
1233 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1235 symmetricDifference(const OtherRectangle& other) const;
1236
1238 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1240 symmetricDifference(const OtherRegion& other) const;
1241
1252 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1253 [[nodiscard]] auto symmetricDifference(const OtherSet& other) const {
1254 return other.template symmetricDifference<ResultNumber>(*this);
1255 }
1256
1295 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1297 minkowskiSum(const OtherPolygon& other) const;
1298
1300 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1302 minkowskiSum(const OtherConvex& other) const;
1303
1305 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1307 minkowskiSum(const OtherTriangle& other) const;
1308
1310 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1312 minkowskiSum(const OtherRectangle& other) const;
1313
1315 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1317 minkowskiSum(const OtherRegion& other) const;
1318
1328 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1330 minkowskiSum(const OtherPolyline& other) const;
1331
1342 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1344 minkowskiSum(const OtherChain& other) const;
1345
1363 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1365 minkowskiSum(const OtherSegment& other) const;
1366
1373 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherSegment>
1375 minkowskiSum(const OtherSegment& other) const;
1376
1387 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1389 minkowskiSum(const OtherSet& other) const;
1390
1399 template<PointConcept OtherPoint>
1400 constexpr bool contains(const OtherPoint& point) const;
1401
1411 template<SegmentConcept OtherSegment>
1412 constexpr bool contains(const OtherSegment& other) const;
1413
1419 template<OrientedSegmentConcept OtherOrientedSegment>
1420 constexpr bool contains(const OtherOrientedSegment& other) const;
1421
1425 template<LineConcept OtherLine>
1426 constexpr bool contains(const OtherLine& other) const;
1427
1431 template<OrientedLineConcept OtherOrientedLine>
1432 constexpr bool contains(const OtherOrientedLine& other) const;
1433
1437 template<RayConcept OtherRay>
1438 constexpr bool contains(const OtherRay& other) const;
1439
1443 template<HalfplaneConcept OtherHalfplane>
1444 constexpr bool contains(const OtherHalfplane& other) const;
1445
1451 template<RectangleConcept OtherRectangle>
1452 constexpr bool contains(const OtherRectangle& other) const;
1453
1459 template<TriangleConcept OtherTriangle>
1460 constexpr bool contains(const OtherTriangle& other) const;
1461
1467 template<ConvexConcept OtherConvex>
1468 constexpr bool contains(const OtherConvex& other) const;
1469
1478 template<PolygonConcept OtherPolygon>
1479 constexpr bool contains(const OtherPolygon& other) const;
1480
1502 template<PolygonConcept OtherPolygon>
1503 constexpr bool containsChainBased(const OtherPolygon& other) const;
1504
1514 template<DiskConcept OtherDisk>
1515 constexpr bool contains(const OtherDisk& other) const;
1516
1520 constexpr bool contains(const Shape<PointType>& other) const;
1521
1522 // The empty set is a subset of every shape, so its containment relations are
1523 // true; symmetric crossing reaches the empty set through the generic
1524 // OtherShape fallback declared below.
1526 template <class EmptyPoint>
1527 [[nodiscard]] constexpr bool contains(const EmptyShape<EmptyPoint>&) const {
1528 return true;
1529 }
1530
1531 template <class EmptyPoint>
1532 [[nodiscard]] constexpr bool boundaryContains(const EmptyShape<EmptyPoint>&) const {
1533 return true;
1534 }
1535
1536 template <class EmptyPoint>
1537 [[nodiscard]] constexpr bool interiorContains(const EmptyShape<EmptyPoint>&) const {
1538 return true;
1539 }
1540
1549 template<PointConcept OtherPoint>
1550 constexpr bool interiorContains(const OtherPoint& point) const;
1551
1560 template<SegmentConcept OtherSegment>
1561 constexpr bool interiorContains(const OtherSegment& other) const;
1562
1572 template<SegmentConcept OtherSegment>
1573 constexpr bool interiorContainsInterior(const OtherSegment& other) const;
1574
1580 template<OrientedSegmentConcept OtherOrientedSegment>
1581 constexpr bool interiorContains(const OtherOrientedSegment& other) const;
1582
1586 template<LineConcept OtherLine>
1587 constexpr bool interiorContains(const OtherLine& other) const;
1588
1592 template<OrientedLineConcept OtherOrientedLine>
1593 constexpr bool interiorContains(const OtherOrientedLine& other) const;
1594
1598 template<RayConcept OtherRay>
1599 constexpr bool interiorContains(const OtherRay& other) const;
1600
1604 template<HalfplaneConcept OtherHalfplane>
1605 constexpr bool interiorContains(const OtherHalfplane& other) const;
1606
1612 template<RectangleConcept OtherRectangle>
1613 constexpr bool interiorContains(const OtherRectangle& other) const;
1614
1620 template<TriangleConcept OtherTriangle>
1621 constexpr bool interiorContains(const OtherTriangle& other) const;
1622
1628 template<ConvexConcept OtherConvex>
1629 constexpr bool interiorContains(const OtherConvex& other) const;
1630
1639 template<PolygonConcept OtherPolygon>
1640 constexpr bool interiorContains(const OtherPolygon& other) const;
1641
1647 template<PointConcept OtherPoint>
1648 constexpr bool boundaryContains(const OtherPoint& point) const;
1649
1658 template<SegmentConcept OtherSegment>
1659 constexpr bool boundaryContains(const OtherSegment& other) const;
1660
1662 template<OrientedSegmentConcept OtherOrientedSegment>
1663 constexpr bool boundaryContains(const OtherOrientedSegment& other) const;
1664
1666 template<LineConcept OtherLine>
1667 constexpr bool boundaryContains(const OtherLine& other) const;
1668
1670 template<OrientedLineConcept OtherOrientedLine>
1671 constexpr bool boundaryContains(const OtherOrientedLine& other) const;
1672
1674 template<RayConcept OtherRay>
1675 constexpr bool boundaryContains(const OtherRay& other) const;
1676
1678 template<HalfplaneConcept OtherHalfplane>
1679 constexpr bool boundaryContains(const OtherHalfplane& other) const;
1680
1686 template<RectangleConcept OtherRectangle>
1687 constexpr bool boundaryContains(const OtherRectangle& other) const;
1688
1694 template<TriangleConcept OtherTriangle>
1695 constexpr bool boundaryContains(const OtherTriangle& other) const;
1696
1700 template<ConvexConcept OtherConvex>
1701 constexpr bool boundaryContains(const OtherConvex& other) const;
1702
1706 template<PolygonConcept OtherPolygon>
1707 constexpr bool boundaryContains(const OtherPolygon& other) const;
1708
1712 template<DiskConcept OtherDisk>
1713 constexpr bool boundaryContains(const OtherDisk& other) const;
1714
1718 template<PointConcept OtherPoint>
1719 constexpr bool boundaryContains(const Shape<OtherPoint>& other) const;
1720
1721 // --- not-yet-implemented predicate pairs (throw); see implementation ---
1723 template<DiskConcept OtherDisk>
1724 [[nodiscard]] constexpr bool interiorContains(const OtherDisk& other) const;
1725
1727 template<PointConcept OtherPoint>
1728 [[nodiscard]] constexpr bool separates(const OtherPoint& other) const;
1729
1731 template<HalfplaneConcept OtherHalfplane>
1732 [[nodiscard]] constexpr bool separates(const OtherHalfplane& other) const;
1733
1735 template<RectangleConcept OtherRectangle>
1736 [[nodiscard]] constexpr bool separates(const OtherRectangle& other) const;
1737
1739 template<TriangleConcept OtherTriangle>
1740 [[nodiscard]] constexpr bool separates(const OtherTriangle& other) const;
1741
1743 template<DiskConcept OtherDisk>
1744 [[nodiscard]] constexpr bool separates(const OtherDisk& other) const;
1745
1747 template<ConvexConcept OtherConvex>
1748 [[nodiscard]] constexpr bool separates(const OtherConvex& other) const;
1749
1751 template<PolygonConcept OtherPolygon>
1752 [[nodiscard]] constexpr bool separates(const OtherPolygon& other) const;
1753
1755 template<MonotoneChainConcept OtherChain>
1756 [[nodiscard]] constexpr bool contains(const OtherChain& other) const;
1757
1759 template<MonotoneChainConcept OtherChain>
1760 [[nodiscard]] constexpr bool boundaryContains(const OtherChain& other) const;
1761
1763 template<MonotoneChainConcept OtherChain>
1764 [[nodiscard]] constexpr bool interiorContains(const OtherChain& other) const;
1765
1767 template<MonotoneChainConcept OtherChain>
1768 [[nodiscard]] constexpr bool intersects(const OtherChain& other) const;
1769
1771 template<MonotoneChainConcept OtherChain>
1772 [[nodiscard]] constexpr bool interiorsIntersect(const OtherChain& other) const;
1773
1783 template<MonotoneChainConcept OtherChain>
1784 [[nodiscard]] constexpr bool separates(const OtherChain& other) const;
1785
1787 template<MonotoneChainConcept OtherChain>
1788 [[nodiscard]] constexpr bool crosses(const OtherChain& other) const;
1789
1791 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1792 [[nodiscard]] constexpr auto squaredDistance(const OtherChain& other) const;
1793
1795 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1796 [[nodiscard]] constexpr auto distanceL1(const OtherChain& other) const;
1797
1799 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1800 [[nodiscard]] constexpr auto distanceLInf(const OtherChain& other) const;
1801
1803 template<PolylineConcept OtherPolyline>
1804 [[nodiscard]] constexpr bool contains(const OtherPolyline& other) const;
1805
1807 template<PolylineConcept OtherPolyline>
1808 [[nodiscard]] constexpr bool boundaryContains(const OtherPolyline& other) const;
1809
1811 template<PolylineConcept OtherPolyline>
1812 [[nodiscard]] constexpr bool interiorContains(const OtherPolyline& other) const;
1813
1815 template<PolylineConcept OtherPolyline>
1816 [[nodiscard]] constexpr bool intersects(const OtherPolyline& other) const;
1817
1819 template<PolylineConcept OtherPolyline>
1820 [[nodiscard]] constexpr bool interiorsIntersect(const OtherPolyline& other) const;
1821
1829 template<PolylineConcept OtherPolyline>
1830 [[nodiscard]] constexpr bool separates(const OtherPolyline& other) const;
1831
1833 template<HalfplaneIntersectionConcept OtherRegion>
1834 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1835
1837 template<HalfplaneIntersectionConcept OtherRegion>
1838 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1839
1841 template<HalfplaneIntersectionConcept OtherRegion>
1842 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1843
1845 template<HalfplaneIntersectionConcept OtherRegion>
1846 [[nodiscard]] constexpr bool separates(const OtherRegion& other) const;
1847
1855 template<PolygonWithHolesConcept OtherRegion>
1856 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1857
1864 template<PolygonWithHolesConcept OtherRegion>
1865 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1866
1868 template<PolygonWithHolesConcept OtherRegion>
1869 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1870
1878 template<PolygonWithHolesConcept OtherRegion>
1879 [[nodiscard]] bool separates(const OtherRegion& other) const;
1880
1881 // -------------------------------------------------------------------------
1882 // A set of regions
1883 //
1884 // It outranks every other shape, so the symmetric relations reach it through
1885 // the rank-based forwarders and only the asymmetric ones are answered here.
1886 // A set is the union of its components, so it is contained exactly when
1887 // every component is — no matter what this shape is.
1888
1890 template<PolygonSetConcept OtherSet>
1891 [[nodiscard]] constexpr bool contains(const OtherSet& other) const {
1892 for (const auto& component : other) {
1893 if (!contains(component)) {
1894 return false;
1895 }
1896 }
1897 return true;
1898 }
1899
1901 template<PolygonSetConcept OtherSet>
1902 [[nodiscard]] constexpr bool boundaryContains(const OtherSet& other) const {
1903 for (const auto& component : other) {
1904 if (!boundaryContains(component)) {
1905 return false;
1906 }
1907 }
1908 return true;
1909 }
1910
1912 template<PolygonSetConcept OtherSet>
1913 [[nodiscard]] constexpr bool interiorContains(const OtherSet& other) const {
1914 for (const auto& component : other) {
1915 if (!interiorContains(component)) {
1916 return false;
1917 }
1918 }
1919 return true;
1920 }
1921
1930 template<PolygonSetConcept OtherSet>
1931 [[nodiscard]] bool separates(const OtherSet& other) const;
1932
1934 template<PolylineConcept OtherPolyline>
1935 [[nodiscard]] constexpr bool crosses(const OtherPolyline& other) const;
1936
1938 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1939 [[nodiscard]] constexpr auto squaredDistance(const OtherPolyline& other) const;
1940
1942 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1943 [[nodiscard]] constexpr auto distanceL1(const OtherPolyline& other) const;
1944
1946 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1947 [[nodiscard]] constexpr auto distanceLInf(const OtherPolyline& other) const;
1948
1949
1955 template<PointConcept OtherPoint>
1956 constexpr bool intersects(const OtherPoint& other) const;
1957
1963 template<SegmentConcept OtherSegment>
1964 constexpr bool intersects(const OtherSegment& other) const;
1965
1971 template<OrientedSegmentConcept OtherOrientedSegment>
1972 constexpr bool intersects(const OtherOrientedSegment& other) const;
1973
1979 template<LineConcept OtherLine>
1980 constexpr bool intersects(const OtherLine& other) const;
1981
1987 template<OrientedLineConcept OtherOrientedLine>
1988 constexpr bool intersects(const OtherOrientedLine& other) const;
1989
1995 template<RayConcept OtherRay>
1996 constexpr bool intersects(const OtherRay& other) const;
1997
2003 template<HalfplaneConcept OtherHalfplane>
2004 constexpr bool intersects(const OtherHalfplane& other) const;
2005
2011 template<RectangleConcept OtherRectangle>
2012 constexpr bool intersects(const OtherRectangle& other) const;
2013
2019 template<TriangleConcept OtherTriangle>
2020 constexpr bool intersects(const OtherTriangle& other) const;
2021
2027 template<ConvexConcept OtherConvex>
2028 constexpr bool intersects(const OtherConvex& other) const;
2029
2037 template<PolygonConcept OtherPolygon>
2038 constexpr bool intersects(const OtherPolygon& other) const;
2039
2055 template<PolygonConcept OtherPolygon>
2056 [[nodiscard]] constexpr bool boundariesIntersect(const OtherPolygon& other) const;
2057
2063 template<PolygonConcept OtherPolygon>
2064 [[nodiscard]] constexpr bool boundariesStrongCross(const OtherPolygon& other) const;
2065
2066
2068 template<DiskConcept OtherDisk>
2069 constexpr bool intersects(const OtherDisk& other) const;
2070
2076 template<PointConcept OtherPoint>
2077 constexpr bool interiorsIntersect(const OtherPoint& other) const;
2078
2084 template<LineConcept OtherLine>
2085 constexpr bool interiorsIntersect(const OtherLine& other) const;
2086
2092 template<OrientedLineConcept OtherOrientedLine>
2093 constexpr bool interiorsIntersect(const OtherOrientedLine& other) const;
2094
2100 template<SegmentConcept OtherSegment>
2101 constexpr bool interiorsIntersect(const OtherSegment& other) const;
2102
2108 template<OrientedSegmentConcept OtherOrientedSegment>
2109 constexpr bool interiorsIntersect(const OtherOrientedSegment& other) const;
2110
2116 template<RayConcept OtherRay>
2117 constexpr bool interiorsIntersect(const OtherRay& other) const;
2118
2124 template<HalfplaneConcept OtherHalfplane>
2125 constexpr bool interiorsIntersect(const OtherHalfplane& other) const;
2126
2132 template<RectangleConcept OtherRectangle>
2133 constexpr bool interiorsIntersect(const OtherRectangle& other) const;
2134
2140 template<TriangleConcept OtherTriangle>
2141 constexpr bool interiorsIntersect(const OtherTriangle& other) const;
2142
2148 template<ConvexConcept OtherConvex>
2149 constexpr bool interiorsIntersect(const OtherConvex& other) const;
2150
2156 template<PolygonConcept OtherPolygon>
2157 constexpr bool interiorsIntersect(const OtherPolygon& other) const;
2158
2160 template<DiskConcept OtherDisk>
2161 constexpr bool interiorsIntersect(const OtherDisk& other) const;
2162
2172 template<SegmentConcept OtherSegment>
2173 constexpr bool separates(const OtherSegment& other) const;
2174
2176 template<OrientedSegmentConcept OtherOrientedSegment>
2177 constexpr bool separates(const OtherOrientedSegment& other) const;
2178
2188 template<RayConcept OtherRay>
2189 constexpr bool separates(const OtherRay& other) const;
2190
2194 template<LineConcept OtherLine>
2195 constexpr bool separates(const OtherLine& other) const;
2196
2198 template<OrientedLineConcept OtherOrientedLine>
2199 constexpr bool separates(const OtherOrientedLine& other) const;
2200
2202 template<PointConcept OtherPoint>
2203 [[nodiscard]] constexpr bool crosses(const OtherPoint&) const;
2204
2206 template<SegmentConcept OtherSegment>
2207 [[nodiscard]] constexpr bool crosses(const OtherSegment& other) const;
2208
2210 template<OrientedSegmentConcept OtherOrientedSegment>
2211 [[nodiscard]] constexpr bool crosses(const OtherOrientedSegment& other) const;
2212
2214 template<RayConcept OtherRay>
2215 [[nodiscard]] constexpr bool crosses(const OtherRay& other) const;
2216
2218 template<LineConcept OtherLine>
2219 [[nodiscard]] constexpr bool crosses(const OtherLine& other) const;
2220
2222 template<OrientedLineConcept OtherOrientedLine>
2223 [[nodiscard]] constexpr bool crosses(const OtherOrientedLine& other) const;
2224
2226 template<HalfplaneConcept OtherHalfplane>
2227 [[nodiscard]] constexpr bool crosses(const OtherHalfplane&) const;
2228
2230 template<RectangleConcept OtherRectangle>
2231 [[nodiscard]] constexpr bool crosses(const OtherRectangle&) const;
2232
2234 template<TriangleConcept OtherTriangle>
2235 [[nodiscard]] constexpr bool crosses(const OtherTriangle&) const;
2236
2238 template<ConvexConcept OtherConvex>
2239 [[nodiscard]] constexpr bool crosses(const OtherConvex&) const;
2240
2242 template<DiskConcept OtherDisk>
2243 [[nodiscard]] constexpr bool crosses(const OtherDisk&) const;
2244
2246 template<PolygonConcept OtherPolygon>
2247 [[nodiscard]] constexpr bool crosses(const OtherPolygon&) const;
2248
2250 template<PointConcept OtherPoint>
2251 [[nodiscard]] constexpr bool crosses(const Shape<OtherPoint>& other) const;
2252
2254 template<PointConcept OtherPoint>
2255 [[nodiscard]] constexpr bool intersects(const Shape<OtherPoint>& other) const;
2256
2258 template<PointConcept OtherPoint>
2259 [[nodiscard]] constexpr bool interiorsIntersect(const Shape<OtherPoint>& other) const;
2260
2262 template<typename OtherShape>
2263 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2264 [[nodiscard]] constexpr bool crosses(const OtherShape& other) const {
2265 return other.crosses(*this);
2266 }
2267
2274 template<typename OtherShape>
2275 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2276 [[nodiscard]] constexpr bool intersects(const OtherShape& other) const {
2277 return other.intersects(*this);
2278 }
2279
2286 template<typename OtherShape>
2287 requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2288 [[nodiscard]] constexpr bool interiorsIntersect(const OtherShape& other) const {
2289 return other.interiorsIntersect(*this);
2290 }
2291
2293 template <class EmptyPoint>
2294 [[nodiscard]] constexpr bool crosses(const EmptyShape<EmptyPoint>&) const {
2295 return false;
2296 }
2297
2299 template <class EmptyPoint>
2300 [[nodiscard]] constexpr bool intersects(const EmptyShape<EmptyPoint>&) const {
2301 return false;
2302 }
2303
2305 template <class EmptyPoint>
2306 [[nodiscard]] constexpr bool interiorsIntersect(const EmptyShape<EmptyPoint>&) const {
2307 return false;
2308 }
2309
2329 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2330 [[nodiscard]] constexpr auto squaredDistance(const OtherPoint& point) const;
2331
2333 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2334 [[nodiscard]] constexpr auto squaredDistance(const OtherSegment& other) const;
2335
2337 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2338 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedSegment& other) const;
2339
2341 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2342 [[nodiscard]] constexpr auto squaredDistance(const OtherLine& other) const;
2343
2345 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2346 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedLine& other) const;
2347
2349 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2350 [[nodiscard]] constexpr auto squaredDistance(const OtherRay& other) const;
2351
2353 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2354 [[nodiscard]] constexpr auto squaredDistance(const OtherHalfplane& other) const;
2355
2357 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2358 [[nodiscard]] constexpr auto squaredDistance(const OtherRectangle& other) const;
2359
2361 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2362 [[nodiscard]] constexpr auto squaredDistance(const OtherTriangle& other) const;
2363
2365 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2366 [[nodiscard]] constexpr auto squaredDistance(const OtherConvex& other) const;
2367
2369 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2370 [[nodiscard]] constexpr auto squaredDistance(const OtherPolygon& other) const;
2371
2378 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2379 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2380 && requires(const OtherShape& o, const Polygon& self) {
2381 o.template squaredDistance<ResultNumber>(self);
2382 })
2383 [[nodiscard]] constexpr auto squaredDistance(const OtherShape& other) const {
2384 return other.template squaredDistance<ResultNumber>(*this);
2385 }
2386
2395 template <class ResultNumber = double, class DiskPointType, class DiskLabel>
2396 [[nodiscard]] detail::floating_result_t<ResultNumber> squaredDistance(
2397 const Disk<DiskPointType, DiskLabel>& disk) const;
2398
2411 template <class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape>
2412 requires detail::ClosestPairConcept<Polygon<PointType_, TLabel>, OtherShape>
2413 [[nodiscard]] constexpr auto closestSegments(const OtherShape& other) const;
2414
2431 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2432 requires detail::ClosestPointsPairConcept<Polygon<PointType_, TLabel>, OtherShape>
2433 [[nodiscard]] constexpr auto closestPoints(const OtherShape& other) const;
2434
2436 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2437 [[nodiscard]] constexpr auto distanceL1(const OtherPoint& point) const;
2438
2440 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2441 [[nodiscard]] constexpr auto distanceL1(const OtherSegment& other) const;
2442
2444 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2445 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedSegment& other) const;
2446
2448 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2449 [[nodiscard]] constexpr auto distanceL1(const OtherLine& other) const;
2450
2452 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2453 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedLine& other) const;
2454
2456 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2457 [[nodiscard]] constexpr auto distanceL1(const OtherRay& other) const;
2458
2460 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2461 [[nodiscard]] constexpr auto distanceL1(const OtherHalfplane& other) const;
2462
2464 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2465 [[nodiscard]] constexpr auto distanceL1(const OtherRectangle& other) const;
2466
2468 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2469 [[nodiscard]] constexpr auto distanceL1(const OtherTriangle& other) const;
2470
2472 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2473 [[nodiscard]] constexpr auto distanceL1(const OtherConvex& other) const;
2474
2476 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2477 [[nodiscard]] constexpr auto distanceL1(const OtherPolygon& other) const;
2478
2485 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2486 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2487 && requires(const OtherShape& o, const Polygon& self) {
2488 o.template distanceL1<ResultNumber>(self);
2489 })
2490 [[nodiscard]] constexpr auto distanceL1(const OtherShape& other) const {
2491 return other.template distanceL1<ResultNumber>(*this);
2492 }
2493
2509 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2510 [[nodiscard]] constexpr auto intersection(const Shape<OtherPoint>& other) const {
2511 return other.template intersection<ResultNumber>(*this);
2512 }
2513
2515 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2516 [[nodiscard]] auto regularizedIntersection(const Shape<OtherPoint>& other) const {
2517 return other.template regularizedIntersection<ResultNumber>(*this);
2518 }
2519
2532 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2533 [[nodiscard]] auto regularizedUnion(const Shape<OtherPoint>& other) const {
2534 return other.template regularizedUnion<ResultNumber>(*this);
2535 }
2536
2551 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2552 [[nodiscard]] auto difference(const Shape<OtherPoint>& other) const {
2553 return Shape<OtherPoint>(*this).template difference<ResultNumber>(other);
2554 }
2555
2569 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2570 [[nodiscard]] auto symmetricDifference(const Shape<OtherPoint>& other) const {
2571 return other.template symmetricDifference<ResultNumber>(*this);
2572 }
2573
2581 template <class ResultNumber = double, PointConcept OtherPoint>
2582 [[nodiscard]] constexpr auto distanceL1(const Shape<OtherPoint>& other) const {
2583 return other.template distanceL1<ResultNumber>(*this);
2584 }
2585
2587 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2588 [[nodiscard]] constexpr auto distanceLInf(const OtherPoint& point) const;
2589
2591 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2592 [[nodiscard]] constexpr auto distanceLInf(const OtherSegment& other) const;
2593
2595 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2596 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedSegment& other) const;
2597
2599 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2600 [[nodiscard]] constexpr auto distanceLInf(const OtherLine& other) const;
2601
2603 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2604 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedLine& other) const;
2605
2607 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2608 [[nodiscard]] constexpr auto distanceLInf(const OtherRay& other) const;
2609
2611 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2612 [[nodiscard]] constexpr auto distanceLInf(const OtherHalfplane& other) const;
2613
2615 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2616 [[nodiscard]] constexpr auto distanceLInf(const OtherRectangle& other) const;
2617
2619 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2620 [[nodiscard]] constexpr auto distanceLInf(const OtherTriangle& other) const;
2621
2623 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2624 [[nodiscard]] constexpr auto distanceLInf(const OtherConvex& other) const;
2625
2627 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2628 [[nodiscard]] constexpr auto distanceLInf(const OtherPolygon& other) const;
2629
2636 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2637 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2638 && requires(const OtherShape& o, const Polygon& self) {
2639 o.template distanceLInf<ResultNumber>(self);
2640 })
2641 [[nodiscard]] constexpr auto distanceLInf(const OtherShape& other) const {
2642 return other.template distanceLInf<ResultNumber>(*this);
2643 }
2644
2646 template <class ResultNumber = double, PointConcept OtherPoint>
2647 [[nodiscard]] constexpr auto distanceLInf(const Shape<OtherPoint>& other) const {
2648 return other.template distanceLInf<ResultNumber>(*this);
2649 }
2650
2659 template <class ResultNumber = NumberType, PointConcept OtherPoint>
2660 [[nodiscard]] constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
2661 intersection(const OtherPoint& other) const;
2662
2686 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2687 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
2688 intersection(const OtherSegment& other) const;
2689
2698 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2699 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
2700 intersection(const OtherOrientedSegment& other) const;
2701
2722 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2723 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
2724 intersection(const OtherLine& other) const;
2725
2734 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2735 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
2736 intersection(const OtherOrientedLine& other) const;
2737
2758 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2759 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>>>
2760 intersection(const OtherRay& other) const;
2761
2783 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2784 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Polyline<Point<ResultNumber, typename PointType::LabelType>>, Polygon<Point<ResultNumber, typename PointType::LabelType>>>>
2785 intersection(const OtherPolygon& other) const;
2786
2798 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2799 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Polyline<Point<ResultNumber, typename PointType::LabelType>>, Polygon<Point<ResultNumber, typename PointType::LabelType>>>>
2800 intersection(const OtherConvex& other) const;
2801
2813 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2814 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Polyline<Point<ResultNumber, typename PointType::LabelType>>, Polygon<Point<ResultNumber, typename PointType::LabelType>>>>
2815 intersection(const OtherTriangle& other) const;
2816
2828 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2829 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Polyline<Point<ResultNumber, typename PointType::LabelType>>, Polygon<Point<ResultNumber, typename PointType::LabelType>>>>
2830 intersection(const OtherRectangle& other) const;
2831
2841 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2842 requires (!PointConcept<OtherShape>
2843 && (detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2844 && requires(const OtherShape& o, const Polygon& self) {
2845 o.template intersection<ResultNumber>(self);
2846 })
2847 [[nodiscard]] auto intersection(const OtherShape& other) const {
2848 return other.template intersection<ResultNumber>(*this);
2849 }
2850
2852 template <class ResultNumber = division_result_t<NumberType>, typename OtherShape>
2853 requires (!PointConcept<OtherShape>
2854 && (detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>)
2855 && requires(const OtherShape& o, const Polygon& self) {
2857 })
2858 [[nodiscard]] auto regularizedIntersection(const OtherShape& other) const {
2859 return other.template regularizedIntersection<ResultNumber>(*this);
2860 }
2861
2863 template <class ResultNumber = NumberType, class EmptyPoint>
2864 [[nodiscard]] constexpr EmptyShape<EmptyPoint> intersection(const EmptyShape<EmptyPoint>&) const {
2865 return {};
2866 }
2867
2890 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2891 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>, Segment<Point<ResultNumber, typename PointType::LabelType>>, Polygon<Point<ResultNumber, typename PointType::LabelType>>>>
2892 intersection(const OtherHalfplane& other) const;
2893
2910 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2911 [[nodiscard]] constexpr auto intersection(const OtherPolyline& other) const;
2912
2928 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2929 [[nodiscard]] constexpr auto intersection(const OtherChain& other) const;
2930
2937 [[nodiscard]] constexpr Polygon rotated90(int k = 1) const;
2938
2944 constexpr void rotate90(int k = 1);
2945
2981 constexpr void untangle();
2982
2984 template <class OtherNumber>
2985 [[nodiscard]] constexpr Polygon scaledUpX(const OtherNumber scalar) const;
2986
2988 template <class OtherNumber>
2989 constexpr void scaleUpX(const OtherNumber scalar);
2990
2992 template <class OtherNumber>
2993 [[nodiscard]] constexpr Polygon scaledUpY(const OtherNumber scalar) const;
2994
2996 template <class OtherNumber>
2997 constexpr void scaleUpY(const OtherNumber scalar);
2998
3000 template <class OtherNumber>
3001 [[nodiscard]] constexpr Polygon scaledDownX(const OtherNumber scalar) const;
3002
3004 template <class OtherNumber>
3005 constexpr void scaleDownX(const OtherNumber scalar);
3006
3008 template <class OtherNumber>
3009 [[nodiscard]] constexpr Polygon scaledDownY(const OtherNumber scalar) const;
3010
3012 template <class OtherNumber>
3013 constexpr void scaleDownY(const OtherNumber scalar);
3014
3028 template <class OtherShape>
3030 [[nodiscard]] constexpr auto minkowskiSum(const OtherShape& other) const;
3031
3055 template <class OtherShape>
3057 [[nodiscard]] constexpr auto minkowskiErosion(const OtherShape& other) const;
3058
3090 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
3094 minkowskiErosion(const OtherShape& other) const;
3095
3101 template<PointConcept OtherPoint>
3102 constexpr Polygon& operator+=(const OtherPoint& translation) {
3103 translation_ += translation;
3104 // A pure translation merely shifts the bounding box, so update the
3105 // cached bbox in place rather than discarding it. The hash, however,
3106 // depends on the absolute vertex positions, so it must be invalidated.
3107 if (!bbox_.empty()) {
3108 bbox_ += translation;
3109 }
3110 hash_ = hashUnset_;
3111 return *this;
3112 }
3113
3119 template<PointConcept OtherPoint>
3120 constexpr Polygon& operator-=(const OtherPoint& translation) {
3121 translation_ -= translation;
3122 if (!bbox_.empty()) {
3123 bbox_ -= translation;
3124 }
3125 hash_ = hashUnset_;
3126 return *this;
3127 }
3128
3135 template <class Scalar>
3136 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3137 constexpr Polygon& operator*=(const Scalar& scalar) {
3138 for (auto& vertex : points_) {
3139 vertex *= scalar;
3140 }
3141 translation_ *= scalar;
3142 normalize();
3143 resetCache();
3144 return *this;
3145 }
3146
3152 template <class Scalar>
3153 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3154 constexpr Polygon& operator/=(const Scalar& scalar) {
3155 for (auto& vertex : points_) {
3156 vertex /= scalar;
3157 }
3158 translation_ /= scalar;
3159 normalize();
3160 resetCache();
3161 return *this;
3162 }
3163
3170 template <bool Oriented>
3172 public:
3173 using iterator_category = std::forward_iterator_tag;
3174 using iterator_concept = std::forward_iterator_tag;
3176 using difference_type = std::ptrdiff_t;
3178
3179 constexpr BoundaryIterator() = default;
3180
3181 constexpr value_type operator*() const {
3182 assert(polygon != nullptr);
3183 return polygon->template boundaryAt<Oriented>(index);
3184 }
3185
3187 ++index;
3188 return *this;
3189 }
3190
3192 BoundaryIterator copy(*this);
3193 ++(*this);
3194 return copy;
3195 }
3196
3197 constexpr bool operator==(const BoundaryIterator& other) const = default;
3198
3199 private:
3200 friend struct Polygon;
3201
3202 constexpr BoundaryIterator(const Polygon* polygon_arg, std::size_t index_arg)
3203 : polygon(polygon_arg), index(index_arg) {}
3204
3205 const Polygon* polygon = nullptr;
3206 std::size_t index = 0;
3207 };
3208
3209 private:
3210 std::vector<PointType> points_{};
3211 [[no_unique_address]] mutable LabelType label_{};
3212 PointType translation_{};
3213 // Lazily computed bounding box, invalidated by resetCache() on every
3214 // mutation. The empty rectangle doubles as "not computed yet": a shape
3215 // whose box is genuinely empty has no vertices, so bbox() re-derives it
3216 // with one size check rather than any real work.
3217 mutable Rectangle<PointType> bbox_{};
3218
3219 // Memoized hash, computed lazily by std::hash<Polygon>. hashUnset_ means "not
3220 // yet computed"; SIZE_MAX is chosen as the sentinel because it is a rare hash
3221 // output, and the one true hash that would collide with it is remapped to
3222 // hashUnset_ - 1 so the sentinel is never stored as a real value. Unlike the
3223 // bbox, the hash is not translation-invariant, so operator+=/-= reset it.
3224 static constexpr std::size_t hashUnset_ = pgl::detail::numeric_limits<std::size_t>::max();
3225 mutable std::size_t hash_ = hashUnset_;
3226 friend struct std::hash<Polygon>;
3227
3228 // Drops the memoized caches; call after any operation that mutates the
3229 // polygon's vertices. A pure translation does not need to drop bbox_ (it
3230 // shifts in place, see operator+=), but it must still reset hash_, which
3231 // depends on the absolute vertex positions.
3232 constexpr void resetCache() const {
3233 bbox_ = {};
3234 hash_ = hashUnset_;
3235 }
3236
3237 // Runtime implementation of untangle(), defined after IntervalTree is
3238 // available. The constexpr front-end keeps the allocation-free pairwise
3239 // implementation for constant evaluation.
3240 void untangleRuntime();
3241
3242 template <bool Oriented>
3243 constexpr BoundaryType<Oriented> boundaryAt(std::size_t index) const {
3244 const auto i = static_cast<std::ptrdiff_t>(index);
3245 return BoundaryType<Oriented>(get(i), get(i + 1));
3246 }
3247
3255 template <class ResultNumber, class OtherShape>
3256 constexpr ResultNumber edgeMinSquaredDistance(const OtherShape& other) const;
3257
3259 template <class ResultNumber, class OtherShape>
3260 constexpr ResultNumber edgeMinDistanceL1(const OtherShape& other) const;
3261
3263 template <class ResultNumber, class OtherShape>
3264 constexpr ResultNumber edgeMinDistanceLInf(const OtherShape& other) const;
3265
3277 template <class ResultNumber = NumberType>
3278 constexpr ResultNumber signedTwiceArea() const {
3279 ResultNumber sum = 0;
3280 const std::size_t n = points_.size();
3281 for (std::size_t i = 0; i < n; ++i) {
3282 const auto& p1 = points_[i];
3283 const auto& p2 = points_[(i + 1) % n];
3284 sum += detail::asNumber<ResultNumber>(p1.x()) * detail::asNumber<ResultNumber>(p2.y())
3285 - detail::asNumber<ResultNumber>(p2.x()) * detail::asNumber<ResultNumber>(p1.y());
3286 }
3287 return sum;
3288 }
3289
3297 constexpr bool hasNoArea() const {
3298 using Exact = detail::promoted_number_t<NumberType>;
3299 return signedTwiceArea<Exact>() == Exact(0);
3300 }
3301
3312 constexpr bool windsClockwise(std::size_t pivot) const {
3313 const std::size_t n = points_.size();
3314 const PointType& vertex = points_[pivot];
3315 std::size_t before = (pivot + n - 1) % n;
3316 while (before != pivot && points_[before] == vertex) {
3317 before = (before + n - 1) % n;
3318 }
3319 std::size_t after = (pivot + 1) % n;
3320 while (after != pivot && points_[after] == vertex) {
3321 after = (after + 1) % n;
3322 }
3323 return orientationSign(points_[before], vertex, points_[after]) < 0;
3324 }
3325
3337 constexpr void normalize() {
3338 if (points_.empty()) {
3339 return;
3340 }
3341 auto minIt = std::min_element(points_.begin(), points_.end());
3342 if (points_.size() >= 3 &&
3343 windsClockwise(static_cast<std::size_t>(minIt - points_.begin()))) {
3344 // Reversing relocates the smallest vertex, so it is found again
3345 // rather than assumed to still sit where it did.
3346 std::reverse(points_.begin(), points_.end());
3347 minIt = std::min_element(points_.begin(), points_.end());
3348 }
3349 std::rotate(points_.begin(), minIt, points_.end());
3350 }
3351
3378 template <class Poly>
3379 class BoundaryChains {
3380 public:
3381 using PT = typename Poly::PointType;
3382 using ChainView = MonotoneChainView<PT>;
3383
3384 explicit BoundaryChains(const Poly& poly) : verts_(poly.vertices()) {
3385 n_ = verts_.size();
3386 buffer_.reserve(2 * n_);
3387
3388 // Edge i (verts_[i] -> verts_[i+1]) ascends lexicographically.
3389 const auto ascends = [&](std::size_t i) { return verts_[i] < verts_[(i + 1) % n_]; };
3390
3391 // Anchor at a break vertex (its incoming edge reverses) so no run
3392 // straddles index 0 ambiguously; record each run's first vertex and
3393 // direction. The run's last vertex is the next run's first.
3394 std::size_t start = 0;
3395 bool broke = false;
3396 for (std::size_t j = 0; j < n_; ++j) {
3397 if (ascends((j + n_ - 1) % n_) != ascends(j)) {
3398 start = j;
3399 broke = true;
3400 break;
3401 }
3402 }
3403 if (!broke) {
3404 // Every edge is level, so all vertices coincide: the boundary
3405 // is a single point and decomposes into no monotone chain. A
3406 // polygon with two or more distinct vertices always reverses
3407 // direction somewhere, so this is the only way to get here.
3408 return;
3409 }
3410 std::size_t i = start;
3411 do {
3412 const bool up = ascends(i);
3413 runs_.push_back({i, up});
3414 std::size_t k = i;
3415 while (ascends(k) == up) {
3416 k = (k + 1) % n_;
3417 }
3418 i = k;
3419 } while (i != start);
3420 }
3421
3422 bool exhausted() const { return produced_ == runs_.size(); }
3423 const std::vector<ChainView>& produced() const { return chains_; }
3424
3425 // Unrolls the next run into the shared buffer and returns its view.
3426 const ChainView& produceNext() {
3427 const auto [begin, up] = runs_[produced_];
3428 const std::size_t end = runs_[(produced_ + 1) % runs_.size()].first; // inclusive
3429 const std::size_t bufStart = buffer_.size();
3430 std::size_t idx = begin;
3431 buffer_.push_back(verts_[idx]);
3432 while (idx != end) {
3433 idx = (idx + 1) % n_;
3434 buffer_.push_back(verts_[idx]);
3435 }
3436 const std::size_t len = buffer_.size() - bufStart;
3437 if (!up) {
3438 std::reverse(buffer_.begin() + static_cast<std::ptrdiff_t>(bufStart), buffer_.end());
3439 }
3440 chains_.emplace_back(std::span<const PT>(buffer_.data() + bufStart, len), /*trusted=*/true);
3441 ++produced_;
3442 return chains_.back();
3443 }
3444
3445 private:
3446 std::vector<PT> verts_; // translated boundary vertices
3447 std::vector<PT> buffer_; // runs unrolled ascending, contiguous
3448 std::vector<std::pair<std::size_t, bool>> runs_; // (first-vertex index, ascending?)
3449 std::vector<ChainView> chains_; // materialized views into buffer_
3450 std::size_t n_ = 0;
3451 std::size_t produced_ = 0;
3452 };
3453
3454 class Iterator {
3455 private:
3456 std::vector<PointType>::const_iterator it;
3457 PointType x;
3458
3459 public:
3460 using iterator_category = std::random_access_iterator_tag;
3461 using difference_type = std::ptrdiff_t;
3462 using value_type = PointType;
3463 using pointer = PointType*;
3464 using reference = PointType&;
3465
3466 Iterator() = default;
3467 Iterator(std::vector<PointType>::const_iterator it, PointType x) : it(it), x(x) {}
3468
3469 // Dereference returns value + x
3470 PointType operator*() const {
3471 return *it + x;
3472 }
3473
3474 // Pre-increment
3475 Iterator& operator++() {
3476 ++it;
3477 return *this;
3478 }
3479
3480 // Post-increment
3481 Iterator operator++(int) {
3482 Iterator tmp = *this;
3483 ++it;
3484 return tmp;
3485 }
3486
3487 // Pre-decrement
3488 Iterator& operator--() {
3489 --it;
3490 return *this;
3491 }
3492
3493 // Post-decrement
3494 Iterator operator--(int) {
3495 Iterator tmp = *this;
3496 --it;
3497 return tmp;
3498 }
3499
3500 // Equality comparison
3501 bool operator==(const Iterator& other) const {
3502 return it == other.it;
3503 }
3504
3505 // Other comparisons
3506 auto operator<=>(const Iterator& other) const {
3507 return it <=> other.it;
3508 }
3509
3510 // Addition
3511 Iterator operator+(difference_type n) const {
3512 return Iterator(it + n, x);
3513 }
3514
3515 // Subtraction
3516 Iterator operator-(difference_type n) const {
3517 return Iterator(it - n, x);
3518 }
3519
3520 // Difference
3521 difference_type operator-(const Iterator& other) const {
3522 return it - other.it;
3523 }
3524
3525 // Array subscript operator
3526 PointType operator[](difference_type n) const {
3527 return *(it + n) + x;
3528 }
3529 };
3530}; // struct Polygon
3531
3532template <class PointType, class LabelType, class TranslationNumber, class TranslationLabel>
3534 return polygon + (-translation);
3535}
3536
3537template <class PointType, class LabelType, class Scalar>
3538 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3539constexpr auto operator*(const Polygon<PointType, LabelType>& polygon, const Scalar& scalar) {
3540 using ResultPointType = Point<decltype(std::declval<PointType>().x() * scalar), typename PointType::LabelType>;
3542 result *= scalar;
3543 if constexpr (detail::has_label_v<LabelType>) {
3544 result.label() = LabelType{};
3545 }
3546 return result;
3547}
3548
3549template <class Scalar, class PointType, class LabelType>
3550 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3551constexpr auto operator*(const Scalar& scalar, const Polygon<PointType, LabelType>& polygon) {
3552 return polygon * scalar;
3553}
3554
3555template <class PointType, class LabelType, class Scalar>
3556 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3557constexpr auto operator/(const Polygon<PointType, LabelType>& polygon, const Scalar& scalar) {
3558 using ResultPointType = Point<decltype(std::declval<PointType>().x() / scalar), typename PointType::LabelType>;
3560 result /= scalar;
3561 if constexpr (detail::has_label_v<LabelType>) {
3562 result.label() = LabelType{};
3563 }
3564 return result;
3565}
3566
3567template <class PointType, class LabelType>
3568std::ostream& operator<<(std::ostream& stream, const Polygon<PointType, LabelType>& polygon);
3569
3570} // namespace pgl
Undirected simple graph stored as adjacency sets.
Definition graph.hpp:38
std::ptrdiff_t difference_type
Definition polygon.hpp:3176
constexpr value_type operator*() const
Definition polygon.hpp:3181
constexpr bool operator==(const BoundaryIterator &other) const =default
friend struct Polygon
Definition polygon.hpp:3200
BoundaryType< Oriented > value_type
Definition polygon.hpp:3175
constexpr BoundaryIterator operator++(int)
Definition polygon.hpp:3191
constexpr BoundaryIterator()=default
constexpr BoundaryIterator & operator++()
Definition polygon.hpp:3186
std::forward_iterator_tag iterator_category
Definition polygon.hpp:3173
value_type reference
Definition polygon.hpp:3177
std::forward_iterator_tag iterator_concept
Definition polygon.hpp:3174
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: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
MonotoneChain< PointType, Label, std::span< const PointType > > MonotoneChainView
A non-owning MonotoneChain that views an external, already canonical (sorted, duplicate-free) contigu...
Definition monotonechain.hpp:2670
constexpr std::partial_ordering orientationSign(const Point< ANumber, ALabel > &a, const Point< BNumber, BLabel > &b, const Point< CNumber, CLabel > &c)
Classifies the orientation of three points.
Definition orientation.hpp:544
Shape(const std::variant< T, Ts... > &) -> Shape< detail::shape_point_type_t< T > >
std::ostream & operator<<(std::ostream &stream, const Point< Number, Label > &point)
Streams a point as (x,y) or label:(x,y).
Definition io.hpp:27
Polygon() -> Polygon< Point<>, NoLabel >
Definition polygon.hpp:3200
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
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
Closed simple polygon stored by its vertices.
Definition polygon.hpp:59
constexpr auto squaredDistance(const OtherChain &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1445
constexpr auto distanceL1(const OtherPoint &point) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:858
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.
constexpr Point< ResultNumber > pointInside() const
Returns a point strictly inside the (simple) polygon.
Definition measures.hpp:1050
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1335
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherTriangle &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr bool boundaryContains(const OtherOrientedSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:891
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherRegion &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr bool crosses(const Shape< OtherPoint > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:710
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherConvex &other) const
Returns the regularized union of the two shapes (A ∪ B).
auto regularizedIntersection(const Shape< OtherPoint > &other) const
Re-dispatches a regularized intersection through a runtime shape.
Definition polygon.hpp:2516
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition polygon.hpp:2306
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRectangle &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:2203
constexpr bool boundaryContains(const OtherPoint &point) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:855
constexpr bool pointInsideInteriorContainedIn(const OtherShape &shape) const
Tests whether some point in this shape's relative interior lies in the strict interior of shape.
Definition measures.hpp:1094
constexpr bool interiorContains(const OtherChain &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1556
constexpr bool intersects(const OtherRectangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1075
constexpr std::optional< PointType > getIfPoint() const
Returns the point the polygon collapses to, if it does.
Definition polygon.hpp:341
constexpr bool crosses(const OtherConvex &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:692
constexpr auto cbegin() const
Returns a constant iterator to the first vertex.
Definition polygon.hpp:203
constexpr bool crosses(const OtherOrientedSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:646
PointType::NumberType NumberType
Definition polygon.hpp:61
constexpr bool interiorsIntersect(const OtherRectangle &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1175
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherTriangle &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr bool contains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2490
constexpr bool crosses(const OtherOrientedLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:664
constexpr Convex< PointType > convexHull() const
Returns the convex hull of the polygon's vertices.
Definition polygon.hpp:537
constexpr bool intersects(const OtherChain &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1596
constexpr auto distanceL1(const OtherOrientedSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:876
constexpr auto distanceL1(const OtherRectangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:921
constexpr auto distanceLInf(const OtherPolyline &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1372
constexpr auto distanceL1(const OtherTriangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:930
constexpr bool separates(const OtherLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1969
constexpr bool crosses(const OtherSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:640
constexpr const Rectangle< PointType > & bbox() const
Computes the bounding box of the polygon.
Definition bounding.hpp:449
constexpr auto distanceLInf(const OtherPoint &point) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:846
constexpr bool boundaryContains(const OtherTriangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:938
constexpr auto operator<=>(const Polygon &other) const
Compares two polygons by their canonical vertex sequences.
Definition polygon.hpp:224
constexpr bool intersects(const OtherOrientedLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1037
Graph< PointType > visibilityGraph() const
Returns the visibility graph of the polygon vertices.
Definition visibilitygraph.hpp:838
constexpr auto distanceLInf(const OtherPolygon &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:936
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherPolygon &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr bool interiorContains(const OtherOrientedSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:986
constexpr bool crosses(const OtherTriangle &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:686
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polygon.hpp:1532
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polygon.hpp:1537
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
constexpr std::size_t chainCount() const
Counts the maximal lexicographically monotone chains the boundary decomposes into,...
Definition polygon.hpp:464
constexpr bool crosses(const OtherChain &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:940
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polygon.hpp:2294
constexpr bool contains(const OtherRay &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1458
constexpr auto squaredDistance(const OtherLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1362
constexpr Polygon(std::initializer_list< NumberType > coords, bool trusted=false)
Creates a polygon from a flat list of coordinates.
Definition polygon.hpp:113
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherPolygon &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr auto distanceL1(const Shape< OtherPoint > &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition polygon.hpp:2582
Graph< PointType > clearVisibilityGraph() const
Returns the clear visibility graph of the polygon vertices.
Definition visibilitygraph.hpp:862
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition polygon.hpp:530
constexpr Polygon scaledUpY(const OtherNumber scalar) const
Returns the polygon with its y-coordinates multiplied by a factor.
constexpr bool boundaryContains(const OtherLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:897
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:2019
constexpr Polygon(Range &&points, bool trusted=false)
Creates a polygon from a range of points.
Definition polygon.hpp:93
std::vector< PointType > clearlyVisibleVertices(const PointType &query) const
The polygon vertices clearly visible from query.
Definition visibilitygraph.hpp:896
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1296
constexpr bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polygon.hpp:2264
constexpr bool intersects(const OtherOrientedSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1007
constexpr bool interiorContains(const OtherDisk &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1347
constexpr std::optional< HalfplaneIntersection< PointType > > getStarShapedKernel() const
Returns the kernel: the set of points that see the whole polygon.
Definition halfplaneintersection.hpp:2649
constexpr std::ptrdiff_t index(const PointType &point) const
Definition polygon.hpp:184
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
constexpr bool intersects(const OtherDisk &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1328
constexpr bool interiorContains(const OtherRay &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1004
constexpr auto intersection(const OtherPolyline &other) const
Returns the intersection with an open polyline (A ∩ B), a sequence of points and segments.
Definition intersection.hpp:3030
constexpr bool crosses(const OtherDisk &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:698
constexpr bool separates(const OtherPolygon &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2673
constexpr bool isUndefined() const
Checks whether the polygon is degenerate without covering a point or a segment.
Definition polygon.hpp:388
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
constexpr bool boundaryContains(const OtherRectangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:921
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherRectangle &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr auto edgesView() const
Returns a lazy view over the edges, materializing each Segment on the fly instead of allocating a vec...
Definition polygon.hpp:782
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:721
constexpr bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4708
constexpr std::optional< BoundaryType< false > > getIfSegment() const
Returns the segment the polygon collapses to, if it does.
Definition polygon.hpp:369
constexpr bool isConvex() const
Tests whether the polygon is convex.
Definition polygon.hpp:423
auto symmetricDifference(const Shape< OtherPoint > &other) const
Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wr...
Definition polygon.hpp:2570
auto triangulation() const
Builds the constrained Delaunay triangulation of this polygon.
Definition triangulation.hpp:6860
constexpr auto distanceL1(const OtherChain &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1121
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherTriangle &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:2196
auto asBitMatrix() const
Rasterizes this polygon into a BitMatrix, one bit per covered cell.
Definition bitmatrix.hpp:2698
constexpr bool interiorContains(const OtherRectangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1018
constexpr bool interiorsIntersect(const OtherOrientedLine &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1026
constexpr bool contains(const OtherOrientedLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1452
constexpr auto squaredDistance(const OtherRay &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1380
constexpr auto orientedEdgesView() const
Lazy view counterpart of orientedEdges(); see edgesView().
Definition polygon.hpp:790
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRay &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1982
auto regularizedUnion(const Shape< OtherPoint > &other) const
Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own reg...
Definition polygon.hpp:2533
bool isSimple() const
Tests whether the polygon is simple (its boundary does not touch or cross itself).
Definition xysweep.hpp:246
constexpr auto distanceL1(const OtherHalfplane &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:912
constexpr Rectangle< Point< ResultNumber > > fbox() const
Computes the floating-point bounding box of the polygon.
Definition bounding.hpp:461
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedLine &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1975
constexpr auto distanceLInf(const OtherOrientedLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:882
constexpr auto squaredDistance(const OtherOrientedSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1353
constexpr bool contains(const OtherTriangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1488
constexpr bool interiorsIntersect(const OtherLine &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1004
constexpr auto distanceLInf(const OtherShape &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition polygon.hpp:2641
constexpr bool crosses(const OtherRectangle &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:676
constexpr bool isPoint() const
Checks whether the polygon covers exactly one point.
Definition polygon.hpp:330
constexpr PolygonSet< PointType > asPolygonSet() const
Returns the polygon as a one-component set of regions.
Definition polygon.hpp:847
constexpr bool interiorsIntersect(const Shape< OtherPoint > &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1383
constexpr bool interiorsIntersect(const OtherOrientedSegment &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1077
constexpr Point< ResultNumber > centroid() const
Computes the area-weighted centroid of the polygon.
Definition polygon.hpp:857
constexpr auto distanceL1(const OtherPolyline &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1384
constexpr bool boundaryContains(const OtherSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:874
constexpr bool intersects(const OtherTriangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1102
constexpr bool boundaryContains(const OtherRay &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:909
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5984
std::conditional_t< Oriented, OrientedSegment< PointType >, Segment< PointType > > BoundaryType
Definition polygon.hpp:66
constexpr bool interiorsIntersect(const OtherSegment &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1032
constexpr bool interiorsIntersect(const OtherConvex &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1191
constexpr bool separates(const OtherConvex &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2667
constexpr bool separates(const OtherHalfplane &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1990
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherRegion &other) const
Returns the regularized union of the two shapes (A ∪ B).
auto regularizedIntersection(const OtherShape &other) const
Forwards a regularized intersection to the shape that owns it.
Definition polygon.hpp:2858
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherPolyline &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherLine &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1967
auto triangulation(const SegmentRange &segments) const
Builds the constrained Delaunay triangulation of this polygon with the given interior constraint segm...
Definition triangulation.hpp:6866
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherSet &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr auto distanceL1(const OtherPolygon &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:948
constexpr auto distanceLInf(const OtherRay &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:891
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherRectangle &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr bool intersects(const OtherHalfplane &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1057
constexpr bool containsChainBased(const OtherPolygon &other) const
Same contract as contains(const OtherPolygon&) const, by the chain-pair strategy alone.
Definition contains.hpp:1587
constexpr bool interiorContains(const OtherTriangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1034
constexpr auto squaredDistance(const OtherHalfplane &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1389
constexpr auto minkowskiSum(const OtherShape &other) const
Returns the Minkowski sum of this shape and another (A ⊕ B).
Definition minkowski.hpp:804
constexpr void scaleUpX(const OtherNumber scalar)
Multiplies the polygon's x-coordinates by a factor in place.
Definition transformations.hpp:1816
constexpr Polygon scaledDownY(const OtherNumber scalar) const
Returns the polygon with its y-coordinates divided by a divisor.
constexpr Polygon()=default
Creates a polygon with no vertex.
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:1942
constexpr auto intersection(const OtherChain &other) const
Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments.
Definition intersection.hpp:3036
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherTriangle &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr bool isSegment() const
Checks whether the polygon covers exactly one segment of positive length.
Definition polygon.hpp:358
constexpr bool intersects(const Shape< OtherPoint > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1172
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1960
constexpr bool crosses(const OtherPoint &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:634
bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5729
constexpr auto squaredDistance(const OtherSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1344
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherConvex &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr void scaleDownY(const OtherNumber scalar)
Divides the polygon's y-coordinates by a divisor in place.
Definition transformations.hpp:1873
constexpr auto distanceL1(const OtherShape &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition polygon.hpp:2490
constexpr auto squaredDistance(const OtherOrientedLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1371
constexpr auto squaredDistance(const OtherConvex &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1416
constexpr bool intersects(const OtherPolyline &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1787
constexpr bool operator==(const Polygon &other) const
Checks equality of two polygons.
Definition polygon.hpp:240
constexpr bool contains(const OtherOrientedSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1440
constexpr bool boundaryContains(const OtherPolyline &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1355
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherRectangle &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygon.hpp:2300
constexpr bool contains(const OtherSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1348
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2194
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 polygon.hpp:2510
constexpr bool interiorsIntersect(const OtherDisk &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1621
constexpr bool contains(const OtherHalfplane &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1464
constexpr auto distanceLInf(const OtherConvex &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:927
constexpr Polygon(const Polygon< OtherPointType, OtherLabelType > &other)
Converts a polygon with compatible vertex type.
Definition polygon.hpp:137
constexpr bool intersects(const OtherLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1013
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherPolygon &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr bool interiorContains(const OtherHalfplane &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1010
constexpr auto distanceLInf(const Shape< OtherPoint > &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition polygon.hpp:2647
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition polygon.hpp:2864
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherConvex &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr EdgeIterator edgesEnd() const
Returns an iterator past the last unoriented edge.
Definition polygon.hpp:806
constexpr bool boundariesIntersect(const OtherPolygon &other) const
Tests whether the two polygon boundaries share at least one point (∂A ∩ ∂B ≠ ∅).
Definition interiorsintersect.hpp:1197
constexpr bool interiorsIntersect(const OtherPolygon &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1278
constexpr auto squaredDistance(const OtherPolygon &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1425
constexpr auto begin() const
Returns a constant iterator to the first vertex.
Definition polygon.hpp:196
constexpr auto distanceLInf(const OtherOrientedSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:864
constexpr auto squaredDistance(const OtherShape &other) const
Returns the squared Euclidean distance to the given shape.
Definition polygon.hpp:2383
constexpr bool separates(const OtherChain &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3213
constexpr bool contains(const OtherRectangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1472
constexpr const PointType operator[](std::size_t index) const
Accesses a vertex by index.
Definition polygon.hpp:159
constexpr bool boundaryContains(const OtherOrientedLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:903
constexpr std::size_t size() const
Returns the number of vertices in the polygon.
Definition polygon.hpp:259
Polygon< Point< ResultNumber > > regularizedVisiblePolygon(const PointType &query) const
The part of the polygon visible from query, regularized.
Definition visibilitygraph.hpp:906
constexpr auto distanceLInf(const OtherSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:855
constexpr bool crosses(const OtherRay &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:652
constexpr auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:419
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherIntersection &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr bool contains(const Shape< PointType > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1675
constexpr bool boundaryContains(const OtherDisk &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:980
constexpr auto distanceLInf(const OtherRectangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:909
constexpr bool boundariesStrongCross(const OtherPolygon &other) const
Tests whether the two polygon boundaries have mononotone chains that strong cross.
Definition interiorsintersect.hpp:1241
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherRegion &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr Polygon & operator-=(const OtherPoint &translation)
Translates the polygon by the negation of the given point.
Definition polygon.hpp:3120
constexpr bool crosses(const OtherLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:658
constexpr bool interiorsIntersect(const OtherTriangle &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1185
constexpr ResultNumber twiceArea() const
Computes twice the (unsigned) area of the polygon via the shoelace formula.
Definition polygon.hpp:273
constexpr A & label() const
Returns the polygon label.
Definition polygon.hpp:150
constexpr bool separates(const OtherOrientedLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1984
constexpr OrientedEdgeIterator orientedEdgesBegin() const
Returns an iterator to the first oriented edge.
Definition polygon.hpp:814
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by another (A ⊖ B).
Definition minkowskierosion.hpp:637
constexpr bool interiorsIntersect(const OtherRay &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1083
constexpr bool crosses(const OtherHalfplane &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:670
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the polygon contains.
Definition lattice.hpp:661
constexpr EdgeIterator edgesBegin() const
Returns an iterator to the first unoriented edge.
Definition polygon.hpp:798
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1786
constexpr bool crosses(const OtherPolygon &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:704
constexpr bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polygon.hpp:1913
constexpr bool separates(const OtherOrientedSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1978
constexpr bool boundaryContains(const OtherHalfplane &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:915
constexpr bool interiorContains(const OtherPoint &point) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:931
std::vector< PointType > visibleVertices(const PointType &query) const
The polygon vertices visible from query.
Definition visibilitygraph.hpp:887
BoundaryIterator< false > EdgeIterator
Definition polygon.hpp:71
constexpr auto closestSegments(const OtherShape &other) const
Returns the pair of elements realizing the distance, nothing when the shapes meet.
Definition closest.hpp:412
BoundaryIterator< true > OrientedEdgeIterator
Definition polygon.hpp:72
constexpr bool interiorContains(const OtherConvex &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1050
constexpr bool interiorContains(const OtherPolygon &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1084
constexpr bool intersects(const OtherConvex &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1125
constexpr std::vector< OrientedSegment< PointType > > orientedEdges() const
Returns the oriented edges of the polygon.
Definition polygon.hpp:612
constexpr bool interiorContainsInterior(const OtherSegment &other) const
Tests whether this shape's interior contains the segment's interior.
Definition interiorcontains.hpp:960
constexpr Polygon & operator+=(const OtherPoint &translation)
Translates the polygon by the given point.
Definition polygon.hpp:3102
constexpr OrientedEdgeIterator orientedEdgesEnd() const
Returns an iterator past the last oriented edge.
Definition polygon.hpp:822
constexpr bool intersects(const OtherPolygon &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1148
constexpr bool contains(const OtherPolygon &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1566
constexpr void untangle()
Makes the polygon simple in place by uncrossing its boundary.
Definition transformations.hpp:1731
EPoint PointType
Definition polygon.hpp:60
constexpr auto distanceL1(const OtherRay &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:903
constexpr bool contains(const OtherConvex &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1503
constexpr void rotate90(int k=1)
Rotates the polygon by 90k degrees around the origin in place.
Definition transformations.hpp:1724
constexpr bool interiorsIntersect(const OtherChain &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1833
constexpr void scaleUpY(const OtherNumber scalar)
Multiplies the polygon's y-coordinates by a factor in place.
Definition transformations.hpp:1835
constexpr auto distanceLInf(const OtherHalfplane &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:900
constexpr auto distanceLInf(const OtherLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:873
constexpr bool interiorContains(const OtherPolyline &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1795
constexpr bool separates(const OtherTriangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2466
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1952
constexpr auto distanceLInf(const OtherTriangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:918
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherConvex &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr std::vector< PointType > vertices() const
Returns the vertices of the polygon (translation applied).
Definition polygon.hpp:587
PolygonWithHoles< 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 OtherPolyline &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1729
constexpr bool separates(const OtherRectangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2456
constexpr bool contains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1657
constexpr bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition polygon.hpp:2288
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherConvex &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:2189
TLabel LabelType
Definition polygon.hpp:62
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherRegion &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
auto triangulation(const PointRange &points, const SegmentRange &segments) const
Builds the constrained Delaunay triangulation of this polygon with the given interior vertices and co...
Definition triangulation.hpp:6872
constexpr auto area() const
Computes the area of the polygon.
Definition polygon.hpp:285
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherHalfplane &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:2210
std::vector< Convex< PointType > > convexPartition() const
Cuts this polygon into convex pieces with disjoint interiors.
Definition triangulation.hpp:6878
constexpr auto squaredDistance(const OtherTriangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1407
constexpr bool interiorContains(const OtherOrientedLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:998
constexpr auto squaredDistance(const OtherRectangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1398
constexpr bool boundaryContains(const OtherChain &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1245
constexpr std::vector< Segment< PointType > > edges() const
Returns the edges of the polygon.
Definition polygon.hpp:598
constexpr auto distanceL1(const OtherOrientedLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:894
constexpr bool separates(const OtherSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1870
constexpr bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polygon.hpp:1902
Graph< PointType > reducedVisibilityGraph() const
Returns the reduced visibility graph of the polygon vertices.
Definition visibilitygraph.hpp:875
constexpr auto distanceL1(const OtherLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:885
auto intersection(const OtherShape &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition polygon.hpp:2847
constexpr bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polygon.hpp:1891
constexpr bool boundaryContains(const OtherPolygon &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:965
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherChain &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2916
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:985
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherHalfplane &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherRectangle &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr auto distanceL1(const OtherConvex &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:939
constexpr bool isStarShaped() const
Tests whether the polygon is star-shaped.
Definition polygon.hpp:515
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:991
constexpr bool separates(const OtherRay &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1936
constexpr PolygonWithHoles< PointType > asPolygonWithHoles() const
Returns the polygon as a hole-free region.
Definition polygon.hpp:835
constexpr auto distanceLInf(const OtherChain &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1109
constexpr bool boundaryContains(const Shape< OtherPoint > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:989
constexpr bool interiorContains(const OtherSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:940
constexpr Polygon scaledUpX(const OtherNumber scalar) const
Returns the polygon with its x-coordinates multiplied by a factor.
constexpr Polygon rotated90(int k=1) const
Returns the polygon rotated by 90k degrees around the origin.
Definition transformations.hpp:1714
constexpr PointType get(std::ptrdiff_t index) const
Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the en...
Definition polygon.hpp:169
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherTriangle &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr bool contains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2109
constexpr auto verticesView() const
Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector.
Definition polygon.hpp:770
constexpr bool crosses(const OtherPolyline &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1038
constexpr bool interiorsIntersect(const OtherHalfplane &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:1120
constexpr bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygon.hpp:2276
constexpr Polygon scaledDownX(const OtherNumber scalar) const
Returns the polygon with its x-coordinates divided by a divisor.
constexpr bool interiorsIntersect(const OtherPoint &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:997
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polygon.hpp:1527
constexpr bool isDegenerate() const
Checks if the polygon is degenerate (has zero area).
Definition polygon.hpp:319
constexpr bool separates(const OtherPolyline &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4032
detail::floating_result_t< ResultNumber > squaredDistance(const Disk< DiskPointType, DiskLabel > &disk) const
Returns the squared Euclidean distance to a disk.
Definition distance.hpp:1434
constexpr bool empty() const
Returns whether the polygon is the empty set of points.
Definition polygon.hpp:302
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherPolygon &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:1990
constexpr bool separates(const OtherPoint &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:1864
constexpr auto cend() const
Returns a constant iterator past the last vertex.
Definition polygon.hpp:217
constexpr bool boundaryContains(const OtherConvex &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:950
constexpr auto end() const
Returns a constant iterator past the last vertex.
Definition polygon.hpp:210
std::vector< Convex< PointType > > convexCovering() const
Covers this polygon with convex hulls derived from triangle cliques.
Definition triangulation.hpp:6883
constexpr bool separates(const OtherDisk &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2472
constexpr Point< ResultNumber > verticesCentroid() const
Computes the centroid of the vertex set (the average of the vertices).
Definition polygon.hpp:892
constexpr bool interiorsIntersect(const OtherPolyline &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2096
auto symmetricDifference(const OtherSet &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
Definition polygon.hpp:1253
auto difference(const Shape< OtherPoint > &other) const
Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper'...
Definition polygon.hpp:2552
constexpr bool contains(const OtherLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1446
auto regularizedUnion(const OtherSet &other) const
Returns the regularized union of the two shapes (A ∪ B).
Definition polygon.hpp:1196
constexpr bool interiorContains(const OtherLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:992
constexpr void scaleDownX(const OtherNumber scalar)
Divides the polygon's x-coordinates by a divisor in place.
Definition transformations.hpp:1854
constexpr bool intersects(const OtherRay &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1043
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherPolygon &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr auto distanceL1(const OtherSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:867
Open polygonal chain stored in traversal order; may self-intersect.
Definition polyline.hpp:69
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
Runtime variant wrapper over the supported primitive shapes.
Definition shape.hpp:160