25template <
class Po
intType = Po
int<>,
class Label,
class Storage>
38template <
class Storage,
class Po
intType>
39concept ownsChainStorage =
requires(Storage& s,
const PointType& p) {
52template <std::ranges::forward_range Range>
53constexpr bool allPointsEqual(
const Range& points) {
54 auto first = std::ranges::begin(points);
55 const auto last = std::ranges::end(points);
59 return std::find_if(std::next(first), last,
60 [&](
const auto& p) {
return p != *first; }) == last;
71template <std::ranges::forward_range Range>
72constexpr bool pointsSpanSegment(
const Range& points) {
73 const auto first = std::ranges::begin(points);
74 const auto last = std::ranges::end(points);
79 const auto second = std::find_if(std::next(first), last,
80 [&](
const auto& p) {
return p != *first; });
84 return std::all_of(std::next(second), last,
85 [&](
const auto& p) {
return collinear(*first, *second, p); });
94template <
class SegmentType, std::ranges::forward_range Range>
95constexpr SegmentType spannedSegment(
const Range& points) {
96 const auto [low, high] = std::ranges::minmax_element(points);
97 return SegmentType(*low, *high);
103template <std::ranges::input_range Range>
104requires detail::is_point_v<std::ranges::range_value_t<Range>>
107template <std::ranges::input_range Range>
108requires detail::is_point_v<std::ranges::range_value_t<Range>>
111template <
class Number>
112requires (!detail::is_point_v<Number>)
115template <
class Number>
116requires (!detail::is_point_v<Number>)
145template <
class Po
intType_,
class TLabel,
class Storage>
155 static_assert(detail::is_point_v<PointType>,
"MonotoneChain requires pgl::Point vertices");
157 template <
bool Oriented>
160 template <
bool Oriented>
161 class BoundaryIterator;
182 template<std::ranges::input_range Range = std::initializer_list<Po
intType>>
183 requires std::ranges::common_range<Range> &&
184 std::convertible_to<std::ranges::range_value_t<Range>,
PointType> &&
185 detail::ownsChainStorage<Storage, PointType>
187 for (
const auto& p : points) {
188 points_.push_back(p);
193 assert(std::is_sorted(points_.begin(), points_.end()) &&
194 std::adjacent_find(points_.begin(), points_.end()) == points_.end());
210 template<std::ranges::contiguous_range Range>
211 requires (!detail::ownsChainStorage<Storage, PointType>) &&
212 std::constructible_from<Storage, Range&&>
214 : points_(std::forward<Range>(points)) {
215 assert(std::is_sorted(points_.begin(), points_.end()) &&
216 std::adjacent_find(points_.begin(), points_.end()) == points_.end());
230 constexpr explicit MonotoneChain(std::initializer_list<NumberType> coords,
bool trusted =
false)
231 requires detail::ownsChainStorage<Storage,
PointType>
233 assert(coords.size() % 2 == 0);
234 points_.reserve(coords.size() / 2);
235 for (
auto it = coords.begin(); it != coords.end(); ) {
238 points_.emplace_back(
x,
y);
243 assert(std::is_sorted(points_.begin(), points_.end()) &&
244 std::adjacent_find(points_.begin(), points_.end()) == points_.end());
256 template<Po
intConcept OtherPo
intType,
class OtherLabelType,
class OtherStorage>
257 requires(std::constructible_from<PointType, const OtherPointType&> &&
258 detail::ownsChainStorage<Storage, PointType>)
260 : points_(other.
begin(), other.
end()), label_(detail::copyLabel<LabelType>(other)) {}
270 template <
class A = LabelType>
271 requires(detail::has_label_v<A>)
283 return points_[
index] + translation_;
298 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(
size());
299 return (*
this)[
static_cast<std::size_t
>(((
index % n) + n) % n)];
313 const PointType query = point - translation_;
314 const auto it = std::lower_bound(points_.begin(), points_.end(), query);
315 if (it != points_.end() && *it == query) {
316 return it - points_.begin();
325 return Iterator(points_.begin(), translation_);
332 return Iterator(std::ranges::begin(points_), translation_);
338 constexpr auto end()
const {
339 return Iterator(points_.end(), translation_);
346 return Iterator(std::ranges::end(points_), translation_);
356 template <
class OtherStorage>
358 if (
auto cmp =
size() <=> other.
size(); cmp != 0) {
361 for (std::size_t i = 0; i <
size(); ++i) {
362 if (
auto cmp = (*
this)[i] <=> other[i]; cmp != 0) {
366 return std::strong_ordering::equal;
373 template <
class OtherStorage>
378 for (std::size_t i = 0; i <
size(); ++i) {
379 if ((*
this)[i] != other[i]) {
387 template<AnyShapeConcept OtherShape>
388 [[nodiscard]]
constexpr bool samePointSet(
const OtherShape& other)
const;
393 constexpr std::size_t
size()
const {
394 return points_.size();
401 return points_.empty();
409 return points_.size() < 2;
422 [[nodiscard]]
constexpr bool isPoint()
const {
423 return detail::allPointsEqual(points_);
433 [[nodiscard]]
constexpr std::optional<PointType>
getIfPoint()
const {
437 return points_.front() + translation_;
451 return detail::pointsSpanSegment(points_);
461 [[nodiscard]]
constexpr std::optional<BoundaryType<false>>
getIfSegment()
const {
465 return detail::spannedSegment<BoundaryType<false>>(points_) + translation_;
494 for (std::size_t i = 1; i < points_.size(); ++i) {
495 if (points_[i - 1].
x() == points_[i].
x()) {
553 template <
class ResultNumber = gr
id_number_t<
typename Po
intType_::NumberType>>
554 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
563 template <std::
floating_po
int ResultNumber =
double>
569 constexpr std::vector<PointType>
vertices()
const {
570 std::vector<PointType> ret(points_.begin(), points_.end());
571 for (
auto&
vertex : ret) {
595 constexpr std::vector<Segment<PointType>>
edges()
const {
596 std::vector<Segment<PointType>> result;
597 const auto translatedVertices =
vertices();
598 for (std::size_t i = 0; i + 1 < translatedVertices.size(); ++i) {
599 result.emplace_back(translatedVertices[i], translatedVertices[i + 1]);
609 std::vector<OrientedSegment<PointType>> result;
610 const auto translatedVertices =
vertices();
611 for (std::size_t i = 0; i + 1 < translatedVertices.size(); ++i) {
612 result.emplace_back(translatedVertices[i], translatedVertices[i + 1]);
626 return std::ranges::subrange(
begin(),
end());
695 requires detail::ownsChainStorage<Storage, PointType>
697 const PointType query = point - translation_;
698 const auto it = std::lower_bound(points_.begin(), points_.end(), query);
699 if (it != points_.end() && *it == query) {
702 points_.insert(it, query);
716 template<std::ranges::input_range Range>
717 requires std::ranges::common_range<Range> &&
718 std::convertible_to<std::ranges::range_value_t<Range>,
PointType> &&
719 detail::ownsChainStorage<Storage, PointType>
721 const std::size_t oldSize = points_.size();
722 for (
const auto& p : points) {
723 points_.push_back(
PointType(p) - translation_);
725 if (points_.size() == oldSize) {
728 std::sort(points_.begin() +
static_cast<std::ptrdiff_t
>(oldSize), points_.end());
729 std::inplace_merge(points_.begin(), points_.begin() +
static_cast<std::ptrdiff_t
>(oldSize), points_.end());
730 points_.erase(std::unique(points_.begin(), points_.end()), points_.end());
749 requires detail::ownsChainStorage<Storage, PointType>
752 points_.erase(points_.begin() +
static_cast<std::ptrdiff_t
>(
index));
773 requires detail::ownsChainStorage<Storage, PointType>
775 const PointType query = point - translation_;
776 const auto it = std::lower_bound(points_.begin(), points_.end(), query);
777 if (it == points_.end() || *it != query) {
800 template <
class OtherNumber>
801 [[nodiscard]]
constexpr std::optional<std::size_t>
indexAtX(
const OtherNumber&
x)
const;
820 template <
class ResultNumber = division_result_t<NumberType>,
class OtherNumber>
821 [[nodiscard]]
constexpr std::optional<ResultNumber>
yAtX(
const OtherNumber&
x)
const;
841 template <Po
intConcept OtherPo
int>
842 [[nodiscard]]
constexpr std::optional<std::size_t>
isStrictlyBelow(
const OtherPoint& point)
const;
858 template <Po
intConcept OtherPo
int>
859 [[nodiscard]]
constexpr std::optional<std::size_t>
isStrictlyAbove(
const OtherPoint& point)
const;
879 template <Po
intConcept OtherPo
int>
880 [[nodiscard]]
constexpr std::optional<std::size_t>
isBelow(
const OtherPoint& point)
const;
895 template <Po
intConcept OtherPo
int>
896 [[nodiscard]]
constexpr std::optional<std::size_t>
isAbove(
const OtherPoint& point)
const;
907 template<Po
intConcept OtherPo
int>
908 [[nodiscard]]
constexpr bool contains(
const OtherPoint& point)
const;
925 template<SegmentConcept OtherSegment>
926 [[nodiscard]]
constexpr bool contains(
const OtherSegment& other)
const;
929 template<OrientedSegmentConcept OtherOrientedSegment>
930 [[nodiscard]]
constexpr bool contains(
const OtherOrientedSegment& other)
const;
936 template<LineConcept OtherLine>
937 [[nodiscard]]
constexpr bool contains(
const OtherLine& other)
const;
943 template<OrientedLineConcept OtherOrientedLine>
944 [[nodiscard]]
constexpr bool contains(
const OtherOrientedLine& other)
const;
950 template<RayConcept OtherRay>
951 [[nodiscard]]
constexpr bool contains(
const OtherRay& other)
const;
957 template<HalfplaneConcept OtherHalfplane>
958 [[nodiscard]]
constexpr bool contains(
const OtherHalfplane& other)
const;
964 template<RectangleConcept OtherRectangle>
965 [[nodiscard]]
constexpr bool contains(
const OtherRectangle& other)
const;
971 template<TriangleConcept OtherTriangle>
972 [[nodiscard]]
constexpr bool contains(
const OtherTriangle& other)
const;
978 template<ConvexConcept OtherConvex>
979 [[nodiscard]]
constexpr bool contains(
const OtherConvex& other)
const;
988 template<PolygonConcept OtherPolygon>
989 [[nodiscard]]
constexpr bool contains(
const OtherPolygon& other)
const;
995 template<DiskConcept OtherDisk>
996 [[nodiscard]]
constexpr bool contains(
const OtherDisk& other)
const;
999 template <
class EmptyPo
int>
1013 template<MonotoneChainConcept OtherChain>
1014 [[nodiscard]]
constexpr bool contains(
const OtherChain& other)
const;
1017 template<Po
intConcept OtherPo
int>
1032 template<Po
intConcept OtherPo
int>
1038 template<SegmentConcept OtherSegment>
1040 return detail::reduceDegenerateToPoint(
1044 template<OrientedSegmentConcept OtherOrientedSegment>
1046 return detail::reduceDegenerateToPoint(
1050 template<LineConcept OtherLine>
1053 template<OrientedLineConcept OtherOrientedLine>
1054 [[nodiscard]]
constexpr bool boundaryContains(
const OtherOrientedLine&)
const {
return false; }
1056 template<RayConcept OtherRay>
1059 template<HalfplaneConcept OtherHalfplane>
1062 template<RectangleConcept OtherRectangle>
1064 return detail::reduceDegenerateToPoint(
1068 template<TriangleConcept OtherTriangle>
1070 return detail::reduceDegenerateToPoint(
1074 template<ConvexConcept OtherConvex>
1076 return detail::reduceDegenerateToPoint(
1080 template<PolygonConcept OtherPolygon>
1082 return detail::reduceDegenerateToPoint(
1086 template<DiskConcept OtherDisk>
1088 return detail::reduceDegenerateToPoint(
1092 template<MonotoneChainConcept OtherChain>
1099 template <
class EmptyPo
int>
1104 template<Po
intConcept OtherPo
int>
1119 template<Po
intConcept OtherPo
int>
1133 template<SegmentConcept OtherSegment>
1137 template<OrientedSegmentConcept OtherOrientedSegment>
1141 template<LineConcept OtherLine>
1145 template<OrientedLineConcept OtherOrientedLine>
1149 template<RayConcept OtherRay>
1153 template<HalfplaneConcept OtherHalfplane>
1157 template<TriangleConcept OtherTriangle>
1163 template<RectangleConcept OtherRectangle>
1165 return detail::reduceDegenerateGuarded(
1166 other, [
this](
const auto& carrier) {
return this->
interiorContains(carrier); });
1169 template<ConvexConcept OtherConvex>
1171 return detail::reduceDegenerateGuarded(
1172 other, [
this](
const auto& carrier) {
return this->
interiorContains(carrier); });
1175 template<PolygonConcept OtherPolygon>
1177 return detail::reduceDegenerate(
1178 other, [
this](
const auto& carrier) {
return this->
interiorContains(carrier); });
1181 template<DiskConcept OtherDisk>
1183 return detail::reduceDegenerate(
1184 other, [
this](
const auto& carrier) {
return this->
interiorContains(carrier); });
1187 template<MonotoneChainConcept OtherChain>
1190 template <
class EmptyPo
int>
1195 template<Po
intConcept OtherPo
int>
1203 template<Po
intConcept OtherPo
int>
1204 [[nodiscard]]
constexpr bool intersects(
const OtherPoint& other)
const;
1219 template<SegmentConcept OtherSegment>
1220 [[nodiscard]]
constexpr bool intersects(
const OtherSegment& other)
const;
1223 template<OrientedSegmentConcept OtherOrientedSegment>
1224 [[nodiscard]]
constexpr bool intersects(
const OtherOrientedSegment& other)
const;
1239 template<MonotoneChainConcept OtherChain>
1240 [[nodiscard]]
constexpr bool intersects(
const OtherChain& other)
const;
1243 template<LineConcept OtherLine>
1244 [[nodiscard]]
constexpr bool intersects(
const OtherLine& other)
const;
1246 template<OrientedLineConcept OtherOrientedLine>
1247 [[nodiscard]]
constexpr bool intersects(
const OtherOrientedLine& other)
const;
1249 template<RayConcept OtherRay>
1250 [[nodiscard]]
constexpr bool intersects(
const OtherRay& other)
const;
1252 template<HalfplaneConcept OtherHalfplane>
1253 [[nodiscard]]
constexpr bool intersects(
const OtherHalfplane& other)
const;
1255 template<RectangleConcept OtherRectangle>
1256 [[nodiscard]]
constexpr bool intersects(
const OtherRectangle& other)
const;
1258 template<TriangleConcept OtherTriangle>
1259 [[nodiscard]]
constexpr bool intersects(
const OtherTriangle& other)
const;
1261 template<ConvexConcept OtherConvex>
1262 [[nodiscard]]
constexpr bool intersects(
const OtherConvex& other)
const;
1264 template<DiskConcept OtherDisk>
1265 [[nodiscard]]
constexpr bool intersects(
const OtherDisk& other)
const;
1268 template <
class EmptyPo
int>
1274 template<Po
intConcept OtherPo
int>
1278 template<
typename OtherShape>
1280 [[nodiscard]]
constexpr bool intersects(
const OtherShape& other)
const {
1281 return other.intersects(*
this);
1291 template<Po
intConcept OtherPo
int>
1309 template<SegmentConcept OtherSegment>
1313 template<OrientedSegmentConcept OtherOrientedSegment>
1317 template<LineConcept OtherLine>
1320 template<OrientedLineConcept OtherOrientedLine>
1323 template<RayConcept OtherRay>
1326 template<HalfplaneConcept OtherHalfplane>
1329 template<RectangleConcept OtherRectangle>
1332 template<TriangleConcept OtherTriangle>
1335 template<ConvexConcept OtherConvex>
1338 template<DiskConcept OtherDisk>
1348 template<MonotoneChainConcept OtherChain>
1352 template <
class EmptyPo
int>
1358 template<Po
intConcept OtherPo
int>
1362 template<
typename OtherShape>
1365 return other.interiorsIntersect(*
this);
1373 template<Po
intConcept OtherPo
int>
1374 [[nodiscard]]
constexpr bool separates(
const OtherPoint&)
const {
1386 template<SegmentConcept OtherSegment>
1387 [[nodiscard]]
constexpr bool separates(
const OtherSegment& other)
const;
1389 template<OrientedSegmentConcept OtherOrientedSegment>
1390 [[nodiscard]]
constexpr bool separates(
const OtherOrientedSegment& other)
const;
1392 template<LineConcept OtherLine>
1393 [[nodiscard]]
constexpr bool separates(
const OtherLine& other)
const;
1395 template<OrientedLineConcept OtherOrientedLine>
1396 [[nodiscard]]
constexpr bool separates(
const OtherOrientedLine& other)
const;
1398 template<RayConcept OtherRay>
1399 [[nodiscard]]
constexpr bool separates(
const OtherRay& other)
const;
1411 template<HalfplaneConcept OtherHalfplane>
1412 [[nodiscard]]
constexpr bool separates(
const OtherHalfplane& other)
const;
1414 template<RectangleConcept OtherRectangle>
1415 [[nodiscard]]
constexpr bool separates(
const OtherRectangle& other)
const;
1417 template<TriangleConcept OtherTriangle>
1418 [[nodiscard]]
constexpr bool separates(
const OtherTriangle& other)
const;
1420 template<DiskConcept OtherDisk>
1421 [[nodiscard]]
constexpr bool separates(
const OtherDisk& other)
const;
1423 template<ConvexConcept OtherConvex>
1424 [[nodiscard]]
constexpr bool separates(
const OtherConvex& other)
const;
1432 template<PolygonConcept OtherPolygon>
1433 [[nodiscard]]
constexpr bool separates(
const OtherPolygon& other)
const;
1444 template<MonotoneChainConcept OtherChain>
1445 [[nodiscard]]
constexpr bool separates(
const OtherChain& other)
const;
1448 template<PolylineConcept OtherPolyline>
1449 [[nodiscard]]
constexpr bool contains(
const OtherPolyline& other)
const;
1452 template<PolylineConcept OtherPolyline>
1456 return other.empty() || (other.isDegenerate() &&
boundaryContains(other[0]));
1460 template<PolylineConcept OtherPolyline>
1469 template<PolylineConcept OtherPolyline>
1470 [[nodiscard]]
constexpr bool separates(
const OtherPolyline& other)
const;
1473 template<HalfplaneIntersectionConcept OtherRegion>
1474 [[nodiscard]]
constexpr bool contains(
const OtherRegion& other)
const;
1477 template<HalfplaneIntersectionConcept OtherRegion>
1481 template<HalfplaneIntersectionConcept OtherRegion>
1485 template<HalfplaneIntersectionConcept OtherRegion>
1486 [[nodiscard]]
constexpr bool separates(
const OtherRegion& other)
const;
1495 template<PolygonWithHolesConcept OtherRegion>
1496 [[nodiscard]]
constexpr bool contains(
const OtherRegion& other)
const;
1504 template<PolygonWithHolesConcept OtherRegion>
1508 template<PolygonWithHolesConcept OtherRegion>
1518 template<PolygonWithHolesConcept OtherRegion>
1519 [[nodiscard]]
bool separates(
const OtherRegion& other)
const;
1530 template<PolygonSetConcept OtherSet>
1531 [[nodiscard]]
constexpr bool contains(
const OtherSet& other)
const {
1532 for (
const auto& component : other) {
1541 template<PolygonSetConcept OtherSet>
1543 for (
const auto& component : other) {
1552 template<PolygonSetConcept OtherSet>
1554 for (
const auto& component : other) {
1570 template<PolygonSetConcept OtherSet>
1574 template <
class EmptyPo
int>
1579 template<Po
intConcept OtherPo
int>
1583 template<Po
intConcept OtherPo
int>
1584 [[nodiscard]]
constexpr bool crosses(
const OtherPoint&)
const {
1588 template<SegmentConcept OtherSegment>
1589 [[nodiscard]]
constexpr bool crosses(
const OtherSegment& other)
const;
1591 template<OrientedSegmentConcept OtherOrientedSegment>
1592 [[nodiscard]]
constexpr bool crosses(
const OtherOrientedSegment& other)
const;
1594 template<LineConcept OtherLine>
1595 [[nodiscard]]
constexpr bool crosses(
const OtherLine& other)
const;
1597 template<OrientedLineConcept OtherOrientedLine>
1598 [[nodiscard]]
constexpr bool crosses(
const OtherOrientedLine& other)
const;
1600 template<RayConcept OtherRay>
1601 [[nodiscard]]
constexpr bool crosses(
const OtherRay& other)
const;
1603 template<HalfplaneConcept OtherHalfplane>
1604 [[nodiscard]]
constexpr bool crosses(
const OtherHalfplane& other)
const;
1606 template<RectangleConcept OtherRectangle>
1607 [[nodiscard]]
constexpr bool crosses(
const OtherRectangle& other)
const;
1609 template<TriangleConcept OtherTriangle>
1610 [[nodiscard]]
constexpr bool crosses(
const OtherTriangle& other)
const;
1612 template<DiskConcept OtherDisk>
1613 [[nodiscard]]
constexpr bool crosses(
const OtherDisk& other)
const;
1615 template<ConvexConcept OtherConvex>
1616 [[nodiscard]]
constexpr bool crosses(
const OtherConvex& other)
const;
1618 template<MonotoneChainConcept OtherChain>
1619 [[nodiscard]]
constexpr bool crosses(
const OtherChain& other)
const;
1621 template <
class EmptyPo
int>
1626 template<Po
intConcept OtherPo
int>
1629 template<
typename OtherShape>
1631 [[nodiscard]]
constexpr bool crosses(
const OtherShape& other)
const {
1632 return other.crosses(*
this);
1648 template<MonotoneChainConcept OtherChain>
1649 [[nodiscard]]
constexpr bool edgesCross(
const OtherChain& other)
const;
1652 template <
class ResultNumber = NumberType, Po
intConcept OtherPo
int>
1653 [[nodiscard]]
constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
1668 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1669 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1673 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1674 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1678 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1679 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1683 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1684 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1688 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1689 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1693 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1694 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1698 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1699 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1703 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1704 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1708 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1709 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1714 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
1716 && (detail::shapeRank<OtherShape> > detail::shapeRank<MonotoneChain>)
1717 &&
requires(
const OtherShape& o,
const MonotoneChain& self) {
1743 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1744 [[nodiscard]]
constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1749 template <
class ResultNumber = NumberType,
class EmptyPo
int>
1770 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1773 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1776 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1779 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1782 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1785 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1788 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1791 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1794 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1797 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1800 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1810 template <
class ResultNumber =
double,
class DiskPo
intType,
class DiskLabel>
1820 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
1821 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<MonotoneChain>)
1822 &&
requires(
const OtherShape& o,
const MonotoneChain& self) {
1841 template <
class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape>
1842 requires detail::ClosestPairConcept<MonotoneChain<PointType_, TLabel, Storage>, OtherShape>
1861 template <
class ResultNumber = division_result_t<NumberType>,
class OtherShape>
1862 requires detail::ClosestPointsPairConcept<MonotoneChain<PointType_, TLabel, Storage>, OtherShape>
1875 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1876 [[nodiscard]]
constexpr auto distanceL1(
const OtherPoint& point)
const;
1878 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1879 [[nodiscard]]
constexpr auto distanceL1(
const OtherSegment& other)
const;
1881 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1882 [[nodiscard]]
constexpr auto distanceL1(
const OtherOrientedSegment& other)
const;
1884 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1885 [[nodiscard]]
constexpr auto distanceL1(
const OtherLine& other)
const;
1887 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1888 [[nodiscard]]
constexpr auto distanceL1(
const OtherOrientedLine& other)
const;
1890 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1891 [[nodiscard]]
constexpr auto distanceL1(
const OtherRay& other)
const;
1893 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1894 [[nodiscard]]
constexpr auto distanceL1(
const OtherHalfplane& other)
const;
1896 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1897 [[nodiscard]]
constexpr auto distanceL1(
const OtherRectangle& other)
const;
1899 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1900 [[nodiscard]]
constexpr auto distanceL1(
const OtherTriangle& other)
const;
1902 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1903 [[nodiscard]]
constexpr auto distanceL1(
const OtherConvex& other)
const;
1905 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1906 [[nodiscard]]
constexpr auto distanceL1(
const OtherChain& other)
const;
1914 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
1915 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<MonotoneChain>)
1916 &&
requires(
const OtherShape& o,
const MonotoneChain& self) {
1919 [[nodiscard]]
constexpr auto distanceL1(
const OtherShape& other)
const {
1938 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1947 template <
class ResultNumber =
double, Po
intConcept OtherPo
int>
1962 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1965 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1966 [[nodiscard]]
constexpr auto distanceLInf(
const OtherSegment& other)
const;
1968 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1969 [[nodiscard]]
constexpr auto distanceLInf(
const OtherOrientedSegment& other)
const;
1971 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1974 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1975 [[nodiscard]]
constexpr auto distanceLInf(
const OtherOrientedLine& other)
const;
1977 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1980 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1981 [[nodiscard]]
constexpr auto distanceLInf(
const OtherHalfplane& other)
const;
1983 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1984 [[nodiscard]]
constexpr auto distanceLInf(
const OtherRectangle& other)
const;
1986 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1987 [[nodiscard]]
constexpr auto distanceLInf(
const OtherTriangle& other)
const;
1989 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1992 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2001 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
2002 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<MonotoneChain>)
2003 &&
requires(
const OtherShape& o,
const MonotoneChain& self) {
2014 template <
class ResultNumber =
double, Po
intConcept OtherPo
int>
2023 template <
class ApproximateNumber =
double>
2041 template <
class ResultNumber = division_result_t<NumberType>>
2052 template <
class OtherShape>
2074 requires detail::ownsChainStorage<Storage,
PointType>;
2077 template <class OtherNumber>
2081 template <class OtherNumber>
2083 requires detail::ownsChainStorage<Storage,
PointType>;
2086 template <class OtherNumber>
2090 template <class OtherNumber>
2092 requires detail::ownsChainStorage<Storage,
PointType>;
2095 template <class OtherNumber>
2099 template <class OtherNumber>
2101 requires detail::ownsChainStorage<Storage,
PointType>;
2104 template <class OtherNumber>
2108 template <class OtherNumber>
2110 requires detail::ownsChainStorage<Storage,
PointType>;
2125 template <class OtherShape>
2151 template <class OtherShape>
2323 && (detail::shapeRank<OtherShape> >
2324 detail::shapeRank<
MonotoneChain<PointType_, TLabel, Storage>>)
2325 && requires(const OtherShape& o, const
MonotoneChain& self) {
2337 template<Po
intConcept OtherPo
int>
2339 translation_ += translation;
2343 if (!bbox_.empty()) {
2344 bbox_ += translation;
2355 template<Po
intConcept OtherPo
int>
2357 translation_ -= translation;
2358 if (!bbox_.empty()) {
2359 bbox_ -= translation;
2372 template <
class Scalar>
2374 detail::ownsChainStorage<Storage, PointType>)
2376 for (
auto&
vertex : points_) {
2379 translation_ *= scalar;
2390 template <
class Scalar>
2392 detail::ownsChainStorage<Storage, PointType>)
2394 for (
auto&
vertex : points_) {
2397 translation_ /= scalar;
2409 template <
bool Oriented>
2421 assert(chain !=
nullptr);
2422 return chain->template boundaryAt<Oriented>(index);
2442 : chain(chain_arg), index(index_arg) {}
2445 std::size_t
index = 0;
2450 [[no_unique_address]]
mutable LabelType label_{};
2456 mutable Rectangle<PointType> bbox_{};
2464 static constexpr std::size_t hashUnset_ = pgl::detail::numeric_limits<std::size_t>::max();
2465 mutable std::size_t hash_ = hashUnset_;
2472 constexpr void resetCache()
const {
2477 constexpr std::size_t edgeCount()
const {
2478 return points_.empty() ? 0 : points_.size() - 1;
2491 template <
class LowNumber,
class HighNumber>
2492 [[nodiscard]]
constexpr std::optional<std::pair<std::size_t, std::size_t>>
2493 edgeWindow(
const LowNumber& xlo,
const HighNumber& xhi)
const;
2504 template <
class ResultNumber,
class OtherShape>
2505 constexpr ResultNumber edgeMinSquaredDistance(
const OtherShape& other)
const;
2508 template <
class ResultNumber,
class OtherShape>
2509 constexpr ResultNumber edgeMinDistanceL1(
const OtherShape& other)
const;
2512 template <
class ResultNumber,
class OtherShape>
2513 constexpr ResultNumber edgeMinDistanceLInf(
const OtherShape& other)
const;
2519 template <
class ResultNumber,
class OtherShape>
2520 constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
2522 edgeFoldIntersection(
const OtherShape& other)
const;
2529 template <
class ResultNumber>
2530 static constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
2543 template <
class OtherShape,
class TouchesBoundary>
2544 constexpr bool separatesOneDimensional(
const OtherShape& other, TouchesBoundary touchesBoundary)
const;
2555 template <
bool OtherIsConvex = true,
class OtherShape>
2556 constexpr bool separatesTwoDimensional(
const OtherShape& other)
const;
2558 template <
bool Oriented>
2568 constexpr void normalize() {
2569 std::sort(points_.begin(), points_.end());
2570 points_.erase(std::unique(points_.begin(), points_.end()), points_.end());
2575 using BaseIterator = std::ranges::iterator_t<const Storage>;
2580 using iterator_category = std::random_access_iterator_tag;
2581 using difference_type = std::ptrdiff_t;
2586 Iterator() =
default;
2587 Iterator(BaseIterator it,
PointType x) : it(it), x(x) {}
2595 Iterator& operator++() {
2601 Iterator operator++(
int) {
2602 Iterator tmp = *
this;
2608 Iterator& operator--() {
2614 Iterator operator--(
int) {
2615 Iterator tmp = *
this;
2621 bool operator==(
const Iterator& other)
const {
2622 return it == other.it;
2626 std::strong_ordering operator<=>(
const Iterator& other)
const {
2627 if (it < other.it) {
2628 return std::strong_ordering::less;
2630 if (it > other.it) {
2631 return std::strong_ordering::greater;
2633 return std::strong_ordering::equal;
2637 Iterator operator+(difference_type n)
const {
2638 return Iterator(it + n, x);
2642 Iterator operator-(difference_type n)
const {
2643 return Iterator(it - n, x);
2647 difference_type operator-(
const Iterator& other)
const {
2648 return it - other.it;
2652 PointType operator[](difference_type n)
const {
2653 return *(it + n) + x;
2669template <
class Po
intType = Po
int<>,
class Label = NoLabel>
2672template <
class Po
intType,
class LabelType,
class Storage,
class TranslationNumber,
class TranslationLabel>
2674 return chain + (-translation);
2677template <
class Po
intType,
class LabelType,
class Storage,
class Scalar>
2678 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2683 if constexpr (detail::has_label_v<LabelType>) {
2684 result.
label() = LabelType{};
2689template <
class Scalar,
class Po
intType,
class LabelType,
class Storage>
2690 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2692 return chain * scalar;
2695template <
class Po
intType,
class LabelType,
class Storage,
class Scalar>
2696 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2701 if constexpr (detail::has_label_v<LabelType>) {
2702 result.
label() = LabelType{};
2707template <
class Po
intType,
class LabelType,
class Storage>
friend struct MonotoneChain
Definition monotonechain.hpp:2439
constexpr value_type operator*() const
Definition monotonechain.hpp:2420
std::ptrdiff_t difference_type
Definition monotonechain.hpp:2415
std::forward_iterator_tag iterator_concept
Definition monotonechain.hpp:2413
constexpr bool operator==(const BoundaryIterator &other) const =default
std::forward_iterator_tag iterator_category
Definition monotonechain.hpp:2412
value_type reference
Definition monotonechain.hpp:2416
BoundaryType< Oriented > value_type
Definition monotonechain.hpp:2414
constexpr BoundaryIterator & operator++()
Definition monotonechain.hpp:2425
constexpr BoundaryIterator()=default
constexpr BoundaryIterator operator++(int)
Definition monotonechain.hpp:2430
Bounded polygonal primitives, convex or not.
Definition forward.hpp:373
Definition forward.hpp:315
Shape pairs whose Minkowski sum Pangolin can represent.
Definition forward.hpp:476
Definition forward.hpp:320
Definition forward.hpp:308
Definition forward.hpp:306
Definition forward.hpp:313
Definition forward.hpp:307
Definition forward.hpp:314
Definition arrangement.hpp:67
@ y
Definition intervaltree.hpp:24
@ x
Definition intervaltree.hpp:24
@ vertex
Definition bitmatrix.hpp:37
typename DivisionResult< Number >::type division_result_t
Convenience alias for DivisionResult.
Definition rational.hpp:1175
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
MonotoneChain() -> MonotoneChain< Point<>, NoLabel >
Definition monotonechain.hpp:2439
constexpr bool collinear(const Point< ANumber, ALabel > &a, const Point< BNumber, BLabel > &b, const Point< CNumber, CLabel > &c)
Tests whether three points are collinear.
Definition orientation.hpp:651
std::ostream & operator<<(std::ostream &stream, const Point< Number, Label > &point)
Streams a point as (x,y) or label:(x,y).
Definition io.hpp:27
Segment() -> Segment< Point<>, NoLabel >
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
Weakly x-monotone polyline stored by lexicographically sorted vertices.
Definition monotonechain.hpp:146
constexpr bool separates(const OtherHalfplane &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3010
constexpr bool interiorsIntersect(const OtherChain &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1771
constexpr bool separates(const OtherSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2974
constexpr bool boundaryContains(const OtherPolyline &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1453
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition monotonechain.hpp:1000
constexpr bool boundaryContains(const OtherConvex &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1075
constexpr bool contains(const OtherLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1863
constexpr bool separates(const OtherPolygon &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3069
constexpr auto distanceLInf(const OtherPoint &point) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1141
constexpr bool intersects(const OtherLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1386
constexpr bool interiorContains(const OtherTriangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1416
constexpr bool boundaryContains(const OtherOrientedSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1045
constexpr bool contains(const OtherTriangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1904
constexpr bool intersects(const OtherOrientedSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1380
constexpr bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4676
constexpr void scaleUpX(const OtherNumber scalar)
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRay &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2648
constexpr bool crosses(const OtherDisk &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:865
constexpr bool separates(const EmptyShape< EmptyPoint > &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition monotonechain.hpp:1575
constexpr bool contains(const OtherRectangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1887
constexpr bool boundaryContains(const OtherRectangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1063
constexpr auto squaredDistance(const OtherShape &other) const
Returns the squared Euclidean distance to the given shape.
Definition monotonechain.hpp:1825
constexpr bool separates(const OtherDisk &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3048
constexpr bool separates(const OtherOrientedSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2982
constexpr bool separates(const Shape< OtherPoint > &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3132
constexpr auto distanceL1(const OtherRectangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1216
constexpr std::optional< std::size_t > isStrictlyAbove(const OtherPoint &point) const
Tests whether the whole chain lies strictly above a point at its x.
Definition atxy.hpp:435
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedLine &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2640
constexpr bool separates(const OtherRay &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3002
constexpr Rectangle< Point< ResultNumber > > fbox() const
Computes the floating-point bounding box of the chain.
Definition bounding.hpp:507
constexpr bool interiorContains(const OtherOrientedLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1398
constexpr auto distanceL1(const OtherShape &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition monotonechain.hpp:1919
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition monotonechain.hpp:513
constexpr OrientedEdgeIterator orientedEdgesBegin() const
Returns an iterator to the first oriented edge.
Definition monotonechain.hpp:669
constexpr bool boundaryContains(const OtherRay &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1057
constexpr Polyline< PointType > asPolyline() const
Returns the chain as a polyline traversing its vertices in lexicographic order.
Definition polyline.hpp:2602
constexpr bool contains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2472
Storage StorageType
Definition monotonechain.hpp:150
constexpr auto distanceLInf(const OtherOrientedSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1159
TLabel LabelType
Definition monotonechain.hpp:149
constexpr auto distanceLInf(const OtherConvex &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1222
constexpr auto distanceLInf(const OtherShape &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition monotonechain.hpp:2006
constexpr auto edgesView() const
Returns a lazy view over the edges, materializing each Segment on the fly instead of allocating a vec...
Definition monotonechain.hpp:637
constexpr auto squaredDistance(const OtherRectangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1540
constexpr bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition monotonechain.hpp:1280
constexpr auto distanceLInf(const Shape< OtherPoint > &other) const
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own dist...
Definition monotonechain.hpp:2015
constexpr auto distanceLInf(const OtherChain &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1231
constexpr auto orientedEdgesView() const
Lazy view counterpart of orientedEdges(); see edgesView().
Definition monotonechain.hpp:645
constexpr bool erase(const PointType &point)
Removes the given point from the chain's vertices.
Definition monotonechain.hpp:772
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5996
constexpr void erase(std::size_t index)
Removes the vertex at the given index (in lexicographic order).
Definition monotonechain.hpp:748
constexpr std::optional< std::size_t > indexAtX(const OtherNumber &x) const
Locates the vertex or edge of the chain at a given x-coordinate.
Definition atxy.hpp:346
constexpr bool separates(const OtherOrientedLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2996
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 monotonechain.hpp:1939
constexpr bool interiorContains(const Shape< OtherPoint > &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1440
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1353
constexpr auto distanceLInf(const OtherOrientedLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1177
constexpr MonotoneChain(Range &&points, bool trusted=false)
Creates a chain from a range of points.
Definition monotonechain.hpp:186
constexpr bool interiorsIntersect(const OtherHalfplane &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1737
constexpr auto distanceLInf(const OtherRay &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1186
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1359
constexpr bool interiorContains(const OtherRectangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition monotonechain.hpp:1164
MonotoneChain< EPoint, TLabel, std::vector< EPoint > > OwningChain
Definition monotonechain.hpp:154
constexpr bool edgesCross(const OtherChain &other) const
Tests whether the two chains have edges that cross.
Definition crosses.hpp:893
constexpr auto distanceL1(const Shape< OtherPoint > &other) const
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own dist...
Definition monotonechain.hpp:1948
PointType::NumberType NumberType
Definition monotonechain.hpp:148
constexpr EdgeIterator edgesBegin() const
Returns an iterator to the first unoriented edge.
Definition monotonechain.hpp:653
constexpr std::optional< std::size_t > isBelow(const OtherPoint &point) const
Tests whether the chain passes weakly below a point.
Definition atxy.hpp:462
EPoint PointType
Definition monotonechain.hpp:147
constexpr auto distanceL1(const OtherTriangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1225
constexpr bool operator==(const MonotoneChain< PointType_, TLabel, OtherStorage > &other) const
Checks equality of two chains.
Definition monotonechain.hpp:374
constexpr auto squaredDistance(const OtherSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1486
constexpr bool interiorContains(const OtherLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1392
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherConvex &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2680
constexpr bool interiorsIntersect(const OtherPoint &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1649
constexpr void scaleDownX(const OtherNumber scalar)
constexpr bool isSegment() const
Checks whether the chain covers exactly one segment of positive length.
Definition monotonechain.hpp:450
constexpr bool interiorsIntersect(const OtherLine &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1719
constexpr bool crosses(const OtherOrientedLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:831
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
constexpr std::ptrdiff_t index(const PointType &point) const
Definition monotonechain.hpp:312
constexpr bool interiorsIntersect(const Shape< OtherPoint > &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1823
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition monotonechain.hpp:1622
constexpr auto distanceL1(const OtherConvex &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1234
constexpr bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition monotonechain.hpp:1531
constexpr auto distanceLInf(const OtherLine &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1168
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedSegment &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2624
constexpr bool boundaryContains(const OtherPoint &point) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1159
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition monotonechain.hpp:1750
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:1296
BoundaryIterator< false > EdgeIterator
Definition monotonechain.hpp:163
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1822
constexpr void insert(const PointType &point)
Extends the chain to contain the given point as a vertex.
Definition monotonechain.hpp:694
constexpr bool interiorsIntersect(const OtherConvex &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1759
constexpr auto squaredDistance(const OtherOrientedLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1513
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1477
constexpr std::size_t size() const
Returns the number of vertices in the chain.
Definition monotonechain.hpp:393
constexpr bool separates(const OtherPoint &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition monotonechain.hpp:1374
constexpr auto minkowskiErosion(const OtherShape &other) const
constexpr bool interiorContains(const OtherPolyline &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1783
constexpr bool empty() const
Checks whether the chain has no vertex.
Definition monotonechain.hpp:400
constexpr OwningChain scaledUpY(const OtherNumber scalar) const
constexpr auto lengthLInf() const
Computes the Chebyshev (LInf) length of the chain.
Definition measures.hpp:1233
constexpr bool interiorContains(const OtherPoint &point) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1371
constexpr bool separates(const OtherTriangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3036
BoundaryIterator< true > OrientedEdgeIterator
Definition monotonechain.hpp:164
constexpr bool isPoint() const
Checks whether the chain covers exactly one point.
Definition monotonechain.hpp:422
constexpr bool boundaryContains(const OtherPolygon &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1081
constexpr auto distanceL1(const OtherChain &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1243
detail::floating_result_t< ResultNumber > squaredDistance(const Disk< DiskPointType, DiskLabel > &disk) const
Returns the squared Euclidean distance to a disk.
Definition distance.hpp:1576
constexpr void scaleDownY(const OtherNumber scalar)
constexpr auto distanceLInf(const OtherTriangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1213
constexpr bool contains(const OtherPolygon &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1931
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
constexpr bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition monotonechain.hpp:1364
constexpr auto squaredDistance(const OtherTriangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1549
constexpr bool intersects(const OtherConvex &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1498
constexpr bool intersects(const Shape< OtherPoint > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1532
constexpr auto verticesView() const
Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector.
Definition monotonechain.hpp:625
constexpr bool contains(const Shape< OtherPoint > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1980
constexpr auto distanceL1(const OtherOrientedLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1189
constexpr auto distanceLInf(const OtherSegment &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1150
constexpr auto intersection(const OtherShape &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition monotonechain.hpp:1720
constexpr MonotoneChain & operator-=(const OtherPoint &translation)
Translates the chain by the negation of the given point.
Definition monotonechain.hpp:2356
constexpr bool crosses(const OtherLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:825
constexpr bool interiorContains(const OtherHalfplane &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1410
constexpr bool isDegenerate() const
Checks if the chain is degenerate (fewer than two vertices, so it has no edge).
Definition monotonechain.hpp:408
constexpr OrientedEdgeIterator orientedEdgesEnd() const
Returns an iterator past the last oriented edge.
Definition monotonechain.hpp:677
constexpr auto distanceLInf(const OtherRectangle &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1204
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1762
constexpr auto distanceL1(const OtherHalfplane &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1207
constexpr bool interiorContains(const OtherChain &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1428
constexpr OwningChain scaledDownX(const OtherNumber scalar) const
constexpr MonotoneChain(const MonotoneChain< OtherPointType, OtherLabelType, OtherStorage > &other)
Converts a chain with compatible vertex type.
Definition monotonechain.hpp:259
constexpr std::vector< PointType > vertices() const
Returns the vertices of the chain (translation applied).
Definition monotonechain.hpp:569
constexpr bool crosses(const OtherRectangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:849
constexpr MonotoneChain & operator+=(const OtherPoint &translation)
Translates the chain by the given point.
Definition monotonechain.hpp:2338
constexpr auto cend() const
Returns a constant iterator past the last vertex.
Definition monotonechain.hpp:345
constexpr bool crosses(const OtherTriangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:859
constexpr auto operator<=>(const MonotoneChain< PointType_, TLabel, OtherStorage > &other) const
Compares two chains by their canonical vertex sequences.
Definition monotonechain.hpp:357
constexpr const Rectangle< PointType > & bbox() const
Computes the bounding box of the chain.
Definition bounding.hpp:495
constexpr bool boundaryContains(const OtherChain &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1093
constexpr bool intersects(const OtherRectangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1454
constexpr bool boundaryContains(const OtherSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1039
auto minkowskiSum(const OtherShape &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
Definition monotonechain.hpp:2328
constexpr bool interiorContains(const OtherOrientedSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1386
constexpr std::vector< Segment< PointType > > edges() const
Returns the edges of the chain.
Definition monotonechain.hpp:595
constexpr OwningChain scaledDownY(const OtherNumber scalar) const
constexpr bool intersects(const OtherChain &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1542
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherLine &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2632
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2874
constexpr Point< ResultNumber > pointInside() const
Returns a point inside the chain.
Definition measures.hpp:1243
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition monotonechain.hpp:1191
constexpr bool crosses(const Shape< OtherPoint > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:883
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition monotonechain.hpp:1269
constexpr auto closestSegments(const OtherShape &other) const
Returns the pair of elements realizing the distance, nothing when the shapes meet.
Definition closest.hpp:384
constexpr auto distanceL1(const OtherPoint &point) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1153
constexpr bool intersects(const OtherDisk &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1515
constexpr MonotoneChain()=default
Creates a chain with no vertex.
constexpr std::optional< std::size_t > isAbove(const OtherPoint &point) const
Tests whether the chain passes weakly above a point.
Definition atxy.hpp:489
constexpr auto squaredDistance(const OtherConvex &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1558
constexpr std::optional< ResultNumber > yAtX(const OtherNumber &x) const
Evaluates the y-coordinate of the chain at a given x-coordinate.
Definition atxy.hpp:378
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition monotonechain.hpp:1353
constexpr bool interiorContains(const OtherDisk &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition monotonechain.hpp:1182
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:2007
constexpr auto squaredDistance(const OtherRay &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1522
constexpr void insert(Range &&points)
Extends the chain to contain all the given points as vertices.
Definition monotonechain.hpp:720
constexpr bool crosses(const OtherConvex &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:871
constexpr bool interiorsIntersect(const OtherOrientedSegment &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1685
constexpr void rotate90(int k=1)
Rotates the chain by 90k degrees around the origin in place.
Definition transformations.hpp:1898
constexpr bool interiorsIntersect(const OtherDisk &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1765
constexpr bool intersects(const OtherRay &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1420
constexpr bool interiorContains(const OtherRay &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1404
constexpr auto distanceL1(const OtherLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1180
constexpr auto distanceL1(const OtherRay &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1198
constexpr MonotoneChain(Range &&points, bool=true)
Creates a non-owning chain viewing an external contiguous range of vertices (view instantiations only...
Definition monotonechain.hpp:213
std::conditional_t< Oriented, OrientedSegment< PointType >, Segment< PointType > > BoundaryType
Definition monotonechain.hpp:158
constexpr bool separates(const OtherConvex &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3057
constexpr bool contains(const OtherSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1831
constexpr bool boundaryContains(const OtherHalfplane &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1060
constexpr std::optional< std::size_t > isStrictlyBelow(const OtherPoint &point) const
Tests whether the whole chain lies strictly below a point at its x.
Definition atxy.hpp:398
bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5741
constexpr bool crosses(const OtherChain &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:877
constexpr bool intersects(const OtherHalfplane &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1437
constexpr bool separates(const OtherLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:2988
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherTriangle &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2672
constexpr auto squaredDistance(const OtherHalfplane &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1531
constexpr bool contains(const OtherHalfplane &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1881
constexpr bool interiorsIntersect(const OtherTriangle &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1753
constexpr bool contains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1961
constexpr bool interiorContains(const OtherPolygon &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition monotonechain.hpp:1176
constexpr bool separates(const OtherPolyline &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4018
constexpr bool interiorContains(const OtherConvex &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition monotonechain.hpp:1170
constexpr auto distanceLInf(const OtherHalfplane &other) const
Returns the Chebyshev (LInf) distance to the given shape.
Definition distancelinf.hpp:1195
constexpr OwningChain rotated90(int k=1) const
Returns the chain rotated by 90k degrees around the origin.
Definition transformations.hpp:1888
constexpr bool interiorsIntersect(const OtherOrientedLine &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1725
constexpr bool intersects(const OtherTriangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1481
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1100
constexpr bool contains(const OtherRay &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1875
constexpr std::optional< BoundaryType< false > > getIfSegment() const
Returns the segment the chain collapses to, if it does.
Definition monotonechain.hpp:461
constexpr auto end() const
Returns a constant iterator past the last vertex.
Definition monotonechain.hpp:338
constexpr bool crosses(const OtherPoint &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition monotonechain.hpp:1584
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherHalfplane &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2656
constexpr EdgeIterator edgesEnd() const
Returns an iterator past the last unoriented edge.
Definition monotonechain.hpp:661
constexpr bool boundaryContains(const OtherTriangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1069
constexpr auto squaredDistance(const OtherLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1504
constexpr bool boundaryContains(const OtherLine &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1051
constexpr bool interiorsIntersect(const OtherRectangle &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1743
constexpr A & label() const
Returns the chain label.
Definition monotonechain.hpp:272
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRectangle &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2664
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:2566
constexpr std::vector< OrientedSegment< PointType > > orientedEdges() const
Returns the oriented edges of the chain, each directed from the lexicographically smaller to the larg...
Definition monotonechain.hpp:608
constexpr bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition monotonechain.hpp:1553
constexpr auto distanceL1(const OtherOrientedSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1171
constexpr auto squaredDistance(const OtherChain &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1567
constexpr const PointType operator[](std::size_t index) const
Accesses a vertex by index (in lexicographic order).
Definition monotonechain.hpp:281
constexpr bool isStrictlyMonotone() const
Tests whether the chain is strictly x-monotone.
Definition monotonechain.hpp:493
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherSegment &other) const
Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and seg...
Definition intersection.hpp:2616
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2170
constexpr auto begin() const
Returns a constant iterator to the first vertex.
Definition monotonechain.hpp:324
constexpr MonotoneChain(std::initializer_list< NumberType > coords, bool trusted=false)
Creates a chain from a flat list of coordinates.
Definition monotonechain.hpp:230
constexpr bool contains(const OtherOrientedSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1857
constexpr PointType get(std::ptrdiff_t index) const
Accesses a vertex by index modulo the vertex count.
Definition monotonechain.hpp:297
constexpr bool separates(const OtherChain &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3083
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the chain contains.
Definition lattice.hpp:523
constexpr bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition monotonechain.hpp:1631
constexpr bool intersects(const OtherOrientedLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1403
constexpr Convex< PointType > convexHull() const
Returns the convex hull of the chain's vertices.
Definition monotonechain.hpp:520
constexpr bool crosses(const OtherHalfplane &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:843
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherChain &other) const
Returns the intersection of the two chains (A ∩ B), a sequence of points and segments sorted by lexic...
Definition intersection.hpp:2435
constexpr bool crosses(const OtherSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:813
constexpr bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1542
constexpr std::optional< PointType > getIfPoint() const
Returns the point the chain collapses to, if it does.
Definition monotonechain.hpp:433
constexpr bool interiorsIntersect(const OtherSegment &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1656
constexpr bool contains(const OtherConvex &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1916
constexpr bool contains(const OtherOrientedLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1869
constexpr bool crosses(const OtherRay &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:837
ApproximateNumber length() const
Computes the Euclidean length of the chain (the sum of its edge lengths).
Definition measures.hpp:1215
constexpr bool interiorContains(const OtherSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1377
constexpr bool boundaryContains(const OtherOrientedLine &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1054
constexpr void scaleUpY(const OtherNumber scalar)
constexpr auto minkowskiSum(const OtherShape &other) const
constexpr auto cbegin() const
Returns a constant iterator to the first vertex.
Definition monotonechain.hpp:331
constexpr auto squaredDistance(const OtherOrientedSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1495
constexpr bool isUndefined() const
Checks whether the chain is degenerate without covering a point or a segment.
Definition monotonechain.hpp:478
constexpr auto distanceL1(const OtherSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1162
constexpr bool contains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1955
constexpr bool boundaryContains(const OtherDisk &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition monotonechain.hpp:1087
constexpr bool separates(const OtherRectangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:3020
constexpr OwningChain scaledUpX(const OtherNumber scalar) const
constexpr bool interiorsIntersect(const OtherRay &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:1731
constexpr auto lengthL1() const
Computes the Manhattan (L1) length of the chain.
Definition measures.hpp:1224
constexpr bool crosses(const OtherOrientedSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:819
constexpr auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:391
constexpr bool boundaryContains(const Shape< OtherPoint > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1168
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 simple polygon stored by its vertices.
Definition polygon.hpp:59
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