33namespace pgl::detail {
47template <HalfplaneConcept H>
48constexpr int pseudoAngleHalf(
const H& h) {
49 const auto& s = h.source();
50 const auto& t = h.target();
52 return t.y() > s.y() ? 0 : 1;
54 return t.x() > s.x() ? 0 : 1;
65template <HalfplaneConcept HA, HalfplaneConcept HB>
66constexpr std::partial_ordering directionCross(
const HA& a,
const HB& b) {
67 return crossSign(a.source(), a.target(), b.source(), b.target());
76template <HalfplaneConcept HA, HalfplaneConcept HB>
77constexpr bool directionLess(
const HA& a,
const HB& b) {
78 const int halfA = pseudoAngleHalf(a);
79 const int halfB = pseudoAngleHalf(b);
83 return directionCross(a, b) > 0;
89template <HalfplaneConcept HA, HalfplaneConcept HB>
90constexpr std::partial_ordering directionDot(
const HA& a,
const HB& b) {
91 return dotSign(a.source(), a.target(), b.source(), b.target());
99template <HalfplaneConcept HF, HalfplaneConcept HT, HalfplaneConcept HX>
100constexpr bool arcContainsDirection(
const HF& from,
const HT& to,
const HX&
x) {
101 const auto crossFrom = directionCross(from,
x);
105 if (crossFrom == 0 && directionDot(from,
x) <= 0) {
108 const auto crossTo = directionCross(
x, to);
112 if (crossTo == 0 && directionDot(to,
x) <= 0) {
121template <HalfplaneConcept HA, HalfplaneConcept HB>
122constexpr bool directionEqual(
const HA& a,
const HB& b) {
123 return pseudoAngleHalf(a) == pseudoAngleHalf(b) && directionCross(a, b) == 0;
138template <HalfplaneConcept H1, HalfplaneConcept H2, HalfplaneConcept H3>
139constexpr auto boundaryLinesDeterminant(
const H1& h1,
const H2& h2,
const H3& h3) {
140 using Common = std::common_type_t<typename H1::NumberType, typename H2::NumberType, typename H3::NumberType>;
141 using C = promoted_number_t<promoted_number_t<Common>>;
142 const auto row = [](
const auto& h) {
143 const C sx =
static_cast<C
>(h.source().
x());
144 const C sy =
static_cast<C
>(h.source().
y());
145 const C tx =
static_cast<C
>(h.target().
x());
146 const C ty =
static_cast<C
>(h.target().
y());
147 struct Row { C ax, ay, b; };
148 return Row{ty - sy, sx - tx, sx * ty - sy * tx};
150 const auto r1 = row(h1);
151 const auto r2 = row(h2);
152 const auto r3 = row(h3);
153 return r1.ax * (r2.ay * r3.b - r3.ay * r2.b)
154 - r1.ay * (r2.ax * r3.b - r3.ax * r2.b)
155 + r1.b * (r2.ax * r3.ay - r3.ax * r2.ay);
166template <HalfplaneConcept H1, HalfplaneConcept H2, HalfplaneConcept H3>
167constexpr int vertexSide(
const H1& h1,
const H2& h2,
const H3& h3) {
168 const auto det = boundaryLinesDeterminant(h1, h2, h3);
169 const auto zero =
decltype(det){};
170 const int detSign = det > zero ? 1 : det < zero ? -1 : 0;
171 return detSign * signOf(directionCross(h1, h2));
179template <
class Po
intType = Po
int<>,
class Label>
184template <HalfplaneConcept H>
187template <std::ranges::input_range Range>
188 requires detail::is_halfplane_v<std::ranges::range_value_t<Range>>
191template <std::ranges::input_range Range>
192 requires detail::is_halfplane_v<std::ranges::range_value_t<Range>>
195template <RectangleConcept R>
198template <TriangleConcept T>
201template <ConvexConcept C>
204template <Po
intConcept P>
207template <SegmentConcept S>
210template <LineConcept L>
243template <
class Po
intType_,
class TLabel>
250 static_assert(detail::is_point_v<PointType>,
"HalfplaneIntersection requires pgl::Point defining points");
260 template <HalfplaneConcept OtherHalfplane>
286 template <std::ranges::input_range Range = std::initializer_list<HalfplaneType>>
287 requires std::convertible_to<std::ranges::range_value_t<Range>,
HalfplaneType> &&
288 (!detail::is_halfplane_intersection_v<Range>)
292 halfplanes_.push_back(h);
309 template <RectangleConcept OtherRectangle>
311 if (rectangle.empty()) {
320 canonicalizeSorted();
323 if (lo.x() == hi.x() || lo.y() == hi.y()) {
326 buildSegmentSlab(lo, hi);
327 canonicalizeSorted();
345 template <TriangleConcept OtherTriangle>
347 if (
const auto vertex = triangle.getIfPoint()) {
350 canonicalizeSorted();
353 if (
const auto carrier = triangle.getIfSegment()) {
357 canonicalizeSorted();
362 for (std::size_t i = 0; i < 3; ++i) {
365 canonicalizeSorted();
374 template <ConvexConcept OtherConvex>
376 const std::size_t n = convex.size();
381 if (convex.isDegenerate()) {
389 buildSegmentSlab(a, b);
391 canonicalizeSorted();
394 for (std::size_t i = 0; i < n; ++i) {
397 canonicalizeSorted();
406 template <Po
intConcept OtherPo
int>
409 canonicalizeSorted();
419 template <SegmentConcept OtherSegment>
426 buildSegmentSlab(a, b);
428 canonicalizeSorted();
438 template <LineConcept OtherLine>
446 canonicalizeSorted();
452 template <Po
intConcept OtherPo
intType,
class OtherLabelType>
453 requires(std::constructible_from<PointType, const OtherPointType&>)
456 halfplanes_.reserve(other.
size());
457 for (
const auto& h : other) {
460 label_ = detail::copyLabel<LabelType>(other);
464 template <Po
intConcept OtherPo
intType,
class OtherLabelType>
465 requires(std::constructible_from<PointType, const OtherPointType&>)
468 halfplanes_.reserve(other.
size());
469 for (
const auto& h : other) {
472 empty_ = other.empty();
473 degenerate_ = empty_ ? false : other.isDegenerate();
474 label_ = detail::copyLabel<LabelType>(other);
485 template <
class A = LabelType>
486 requires(detail::has_label_v<A>)
508 template <HalfplaneConcept OtherHalfplane>
509 constexpr bool insert(
const OtherHalfplane& other) {
517 if (halfplanes_.empty()) {
518 halfplanes_.push_back(h);
523 const SupStatus supremum = supStatus(h);
524 if (supremum == SupStatus::below || supremum == SupStatus::on) {
530 const SupStatus infimum = supStatus(h.
opposite());
531 if (infimum == SupStatus::below) {
538 if (infimum == SupStatus::on) {
541 std::size_t pos = linearLowerBound(h);
542 if (pos < halfplanes_.size() && detail::directionEqual(halfplanes_[pos], h)) {
545 halfplanes_[pos] = h;
547 if (pos > halfplanes_.size()) {
548 pos = halfplanes_.size();
550 halfplanes_.insert(halfplanes_.begin() +
static_cast<std::ptrdiff_t
>(pos), h);
557 while (halfplanes_.size() >= 3) {
558 const std::size_t s1 = nextIndex(pos);
559 const std::size_t s2 = nextIndex(s1);
563 if (detail::directionCross(halfplanes_[pos], halfplanes_[s2]) > 0 &&
564 detail::vertexSide(halfplanes_[pos], halfplanes_[s2], halfplanes_[s1]) >= 0) {
565 halfplanes_.erase(halfplanes_.begin() +
static_cast<std::ptrdiff_t
>(s1));
573 while (halfplanes_.size() >= 3) {
574 const std::size_t p1 = prevIndex(pos);
575 const std::size_t p2 = prevIndex(p1);
579 if (detail::directionCross(halfplanes_[p2], halfplanes_[pos]) > 0 &&
580 detail::vertexSide(halfplanes_[p2], halfplanes_[pos], halfplanes_[p1]) >= 0) {
581 halfplanes_.erase(halfplanes_.begin() +
static_cast<std::ptrdiff_t
>(p1));
596 constexpr std::size_t
size()
const {
597 return halfplanes_.size();
606 return halfplanes_[
index];
614 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(
size());
615 return (*
this)[
static_cast<std::size_t
>(((
index % n) + n) % n)];
625 const std::size_t pos = linearLowerBound(halfplane);
626 if (pos <
size() && halfplanes_[pos] == halfplane) {
627 return static_cast<std::ptrdiff_t
>(pos);
638 constexpr auto begin()
const {
return halfplanes_.cbegin(); }
640 constexpr auto cbegin()
const {
return halfplanes_.cbegin(); }
642 constexpr auto end()
const {
return halfplanes_.cend(); }
644 constexpr auto cend()
const {
return halfplanes_.cend(); }
657 return !empty_ && halfplanes_.empty();
665 return empty_ || degenerate_;
712 [[nodiscard]]
constexpr bool isLine()
const;
722 [[nodiscard]]
constexpr std::optional<Line<PointType>>
getIfLine()
const;
733 [[nodiscard]]
constexpr bool isRay()
const;
747 template <
class ResultNumber = division_result_t<NumberType>>
748 [[nodiscard]]
constexpr std::optional<Ray<Point<ResultNumber, typename PointType::LabelType>>>
775 template <
class ResultNumber = division_result_t<NumberType>>
776 [[nodiscard]]
constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
798 template <
class ResultNumber = division_result_t<NumberType>>
799 [[nodiscard]]
constexpr std::optional<Segment<Point<ResultNumber, typename PointType::LabelType>>>
815 const std::size_t n =
size();
819 for (std::size_t i = 0; i < n; ++i) {
820 if (!(detail::directionCross(halfplanes_[i], halfplanes_[nextIndex(i)]) > 0)) {
837 const std::size_t n =
size();
841 std::size_t count = 0;
842 for (std::size_t i = 0; i < n; ++i) {
843 if (detail::directionCross(halfplanes_[i], halfplanes_[nextIndex(i)]) > 0) {
855 if (empty_ ||
size() < 2) {
858 return detail::directionCross(halfplanes_[i], halfplanes_[nextIndex(i)]) > 0;
874 template <
class ResultNumber = division_result_t<NumberType>>
878 halfplanes_[nextIndex(i)].asLine());
879 assert(isec && isec->index() == 0);
880 return std::get<0>(*isec);
889 template <
class ResultNumber = division_result_t<NumberType>>
890 constexpr std::vector<Point<ResultNumber, typename PointType::LabelType>>
vertices()
const {
891 std::vector<Point<ResultNumber, typename PointType::LabelType>> result;
892 if (empty_ ||
size() < 2) {
895 for (std::size_t i = 0; i <
size(); ++i) {
915 template <
class ResultNumber = division_result_t<NumberType>>
916 constexpr std::variant<Segment<Point<ResultNumber, typename PointType::LabelType>>,
921 assert(!empty_ && i <
size());
922 const std::size_t prev = prevIndex(i);
923 const bool hasStart =
size() >= 2 && detail::directionCross(halfplanes_[prev], halfplanes_[i]) > 0;
925 const auto& h = halfplanes_[i];
926 if (hasStart && hasEnd) {
929 const ResultPoint source(h.source());
930 const ResultPoint target(h.target());
931 const ResultNumber dx = target.x() - source.x();
932 const ResultNumber dy = target.y() - source.y();
935 return Ray<ResultPoint>(start, ResultPoint(start.x() + dx, start.y() + dy));
939 return Ray<ResultPoint>(finish, ResultPoint(finish.x() - dx, finish.y() - dy));
954 template <
class ResultNumber = division_result_t<NumberType>>
960 throw std::logic_error(
"HalfplaneIntersection::asConvex requires a bounded region");
971 template <
class ResultNumber = division_result_t<NumberType>>
985 if (empty_ != other.empty_) {
991 if (halfplanes_.size() != other.halfplanes_.size()) {
994 for (std::size_t i = 0; i < halfplanes_.size(); ++i) {
995 if (!(halfplanes_[i] == other.halfplanes_[i])) {
1003 template<AnyShapeConcept OtherShape>
1010 if (
auto cmp = empty_ <=> other.empty_; cmp != 0) {
1014 return std::strong_ordering::equal;
1016 if (
auto cmp = halfplanes_.size() <=> other.halfplanes_.size(); cmp != 0) {
1019 for (std::size_t i = 0; i < halfplanes_.size(); ++i) {
1020 if (
auto cmp = halfplanes_[i] <=> other.halfplanes_[i]; cmp != 0) {
1024 return std::strong_ordering::equal;
1037 template <
class ResultNumber = division_result_t<NumberType>>
1056 template <
class ResultNumber = gr
id_number_t<
typename Po
intType_::NumberType>>
1057 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
1066 template <std::
floating_po
int ResultNumber =
double>
1090 template <
class OtherShape>
1117 template <
class OtherShape>
1122 template <Po
intConcept OtherPo
int>
1126 template <Po
intConcept OtherPo
int>
1130 template <
class Scalar>
1135 template <
class Scalar>
1146 template <
class OtherNumber>
1150 template <
class OtherNumber>
1154 template <
class OtherNumber>
1158 template <
class OtherNumber>
1162 template <
class OtherNumber>
1166 template <
class OtherNumber>
1170 template <
class OtherNumber>
1174 template <
class OtherNumber>
1180 template <Po
intConcept OtherPo
int>
1181 [[nodiscard]]
constexpr bool contains(
const OtherPoint& point)
const;
1184 template <SegmentConcept OtherSegment>
1185 [[nodiscard]]
constexpr bool contains(
const OtherSegment& other)
const;
1188 template <OrientedSegmentConcept OtherOrientedSegment>
1189 [[nodiscard]]
constexpr bool contains(
const OtherOrientedSegment& other)
const;
1192 template <LineConcept OtherLine>
1193 [[nodiscard]]
constexpr bool contains(
const OtherLine& other)
const;
1196 template <OrientedLineConcept OtherOrientedLine>
1197 [[nodiscard]]
constexpr bool contains(
const OtherOrientedLine& other)
const;
1200 template <RayConcept OtherRay>
1201 [[nodiscard]]
constexpr bool contains(
const OtherRay& other)
const;
1204 template <HalfplaneConcept OtherHalfplane>
1205 [[nodiscard]]
constexpr bool contains(
const OtherHalfplane& other)
const;
1208 template <RectangleConcept OtherRectangle>
1209 [[nodiscard]]
constexpr bool contains(
const OtherRectangle& other)
const;
1212 template <TriangleConcept OtherTriangle>
1213 [[nodiscard]]
constexpr bool contains(
const OtherTriangle& other)
const;
1216 template <DiskConcept OtherDisk>
1217 [[nodiscard]]
constexpr bool contains(
const OtherDisk& other)
const;
1220 template <ConvexConcept OtherConvex>
1221 [[nodiscard]]
constexpr bool contains(
const OtherConvex& other)
const;
1224 template <MonotoneChainConcept OtherChain>
1225 [[nodiscard]]
constexpr bool contains(
const OtherChain& other)
const;
1228 template <PolylineConcept OtherPolyline>
1229 [[nodiscard]]
constexpr bool contains(
const OtherPolyline& other)
const;
1232 template <PolygonConcept OtherPolygon>
1233 [[nodiscard]]
constexpr bool contains(
const OtherPolygon& other)
const;
1236 template <HalfplaneIntersectionConcept OtherRegion>
1237 [[nodiscard]]
constexpr bool contains(
const OtherRegion& other)
const;
1240 template <Po
intConcept OtherPo
int>
1244 template <SegmentConcept OtherSegment>
1248 template <OrientedSegmentConcept OtherOrientedSegment>
1252 template <LineConcept OtherLine>
1256 template <OrientedLineConcept OtherOrientedLine>
1260 template <RayConcept OtherRay>
1264 template <HalfplaneConcept OtherHalfplane>
1268 template <RectangleConcept OtherRectangle>
1272 template <TriangleConcept OtherTriangle>
1276 template <DiskConcept OtherDisk>
1280 template <ConvexConcept OtherConvex>
1284 template <MonotoneChainConcept OtherChain>
1288 template <PolylineConcept OtherPolyline>
1292 template <PolygonConcept OtherPolygon>
1296 template <HalfplaneIntersectionConcept OtherRegion>
1300 template <Po
intConcept OtherPo
int>
1304 template <SegmentConcept OtherSegment>
1308 template <OrientedSegmentConcept OtherOrientedSegment>
1312 template <LineConcept OtherLine>
1316 template <OrientedLineConcept OtherOrientedLine>
1320 template <RayConcept OtherRay>
1324 template <HalfplaneConcept OtherHalfplane>
1328 template <RectangleConcept OtherRectangle>
1332 template <TriangleConcept OtherTriangle>
1336 template <DiskConcept OtherDisk>
1340 template <ConvexConcept OtherConvex>
1344 template <MonotoneChainConcept OtherChain>
1348 template <PolylineConcept OtherPolyline>
1352 template <PolygonConcept OtherPolygon>
1356 template <HalfplaneIntersectionConcept OtherRegion>
1360 template <Po
intConcept OtherPo
int>
1361 [[nodiscard]]
constexpr bool intersects(
const OtherPoint& other)
const;
1364 template <SegmentConcept OtherSegment>
1365 [[nodiscard]]
constexpr bool intersects(
const OtherSegment& other)
const;
1368 template <OrientedSegmentConcept OtherOrientedSegment>
1369 [[nodiscard]]
constexpr bool intersects(
const OtherOrientedSegment& other)
const;
1372 template <LineConcept OtherLine>
1373 [[nodiscard]]
constexpr bool intersects(
const OtherLine& other)
const;
1376 template <OrientedLineConcept OtherOrientedLine>
1377 [[nodiscard]]
constexpr bool intersects(
const OtherOrientedLine& other)
const;
1380 template <RayConcept OtherRay>
1381 [[nodiscard]]
constexpr bool intersects(
const OtherRay& other)
const;
1384 template <HalfplaneConcept OtherHalfplane>
1385 [[nodiscard]]
constexpr bool intersects(
const OtherHalfplane& other)
const;
1388 template <RectangleConcept OtherRectangle>
1389 [[nodiscard]]
constexpr bool intersects(
const OtherRectangle& other)
const;
1392 template <TriangleConcept OtherTriangle>
1393 [[nodiscard]]
constexpr bool intersects(
const OtherTriangle& other)
const;
1396 template <DiskConcept OtherDisk>
1397 [[nodiscard]]
constexpr bool intersects(
const OtherDisk& other)
const;
1400 template <ConvexConcept OtherConvex>
1401 [[nodiscard]]
constexpr bool intersects(
const OtherConvex& other)
const;
1404 template <MonotoneChainConcept OtherChain>
1405 [[nodiscard]]
constexpr bool intersects(
const OtherChain& other)
const;
1408 template <PolylineConcept OtherPolyline>
1409 [[nodiscard]]
constexpr bool intersects(
const OtherPolyline& other)
const;
1412 template <PolygonConcept OtherPolygon>
1413 [[nodiscard]]
constexpr bool intersects(
const OtherPolygon& other)
const;
1416 template <HalfplaneIntersectionConcept OtherRegion>
1417 [[nodiscard]]
constexpr bool intersects(
const OtherRegion& other)
const;
1420 template <Po
intConcept OtherPo
int>
1424 template <SegmentConcept OtherSegment>
1428 template <OrientedSegmentConcept OtherOrientedSegment>
1432 template <LineConcept OtherLine>
1436 template <OrientedLineConcept OtherOrientedLine>
1440 template <RayConcept OtherRay>
1444 template <HalfplaneConcept OtherHalfplane>
1448 template <RectangleConcept OtherRectangle>
1452 template <TriangleConcept OtherTriangle>
1456 template <DiskConcept OtherDisk>
1460 template <ConvexConcept OtherConvex>
1464 template <MonotoneChainConcept OtherChain>
1468 template <PolylineConcept OtherPolyline>
1472 template <PolygonConcept OtherPolygon>
1476 template <HalfplaneIntersectionConcept OtherRegion>
1480 template <Po
intConcept OtherPo
int>
1481 [[nodiscard]]
constexpr bool separates(
const OtherPoint& other)
const;
1484 template <SegmentConcept OtherSegment>
1485 [[nodiscard]]
constexpr bool separates(
const OtherSegment& other)
const;
1488 template <OrientedSegmentConcept OtherOrientedSegment>
1489 [[nodiscard]]
constexpr bool separates(
const OtherOrientedSegment& other)
const;
1492 template <LineConcept OtherLine>
1493 [[nodiscard]]
constexpr bool separates(
const OtherLine& other)
const;
1496 template <OrientedLineConcept OtherOrientedLine>
1497 [[nodiscard]]
constexpr bool separates(
const OtherOrientedLine& other)
const;
1500 template <RayConcept OtherRay>
1501 [[nodiscard]]
constexpr bool separates(
const OtherRay& other)
const;
1504 template <HalfplaneConcept OtherHalfplane>
1505 [[nodiscard]]
constexpr bool separates(
const OtherHalfplane& other)
const;
1508 template <RectangleConcept OtherRectangle>
1509 [[nodiscard]]
constexpr bool separates(
const OtherRectangle& other)
const;
1512 template <TriangleConcept OtherTriangle>
1513 [[nodiscard]]
constexpr bool separates(
const OtherTriangle& other)
const;
1516 template <DiskConcept OtherDisk>
1517 [[nodiscard]]
constexpr bool separates(
const OtherDisk& other)
const;
1520 template <ConvexConcept OtherConvex>
1521 [[nodiscard]]
constexpr bool separates(
const OtherConvex& other)
const;
1524 template <MonotoneChainConcept OtherChain>
1525 [[nodiscard]]
constexpr bool separates(
const OtherChain& other)
const;
1528 template <PolylineConcept OtherPolyline>
1529 [[nodiscard]]
constexpr bool separates(
const OtherPolyline& other)
const;
1532 template <PolygonConcept OtherPolygon>
1533 [[nodiscard]]
constexpr bool separates(
const OtherPolygon& other)
const;
1536 template <HalfplaneIntersectionConcept OtherRegion>
1537 [[nodiscard]]
constexpr bool separates(
const OtherRegion& other)
const;
1546 template <PolygonWithHolesConcept OtherHoledRegion>
1547 [[nodiscard]]
constexpr bool contains(
const OtherHoledRegion& other)
const;
1555 template <PolygonWithHolesConcept OtherHoledRegion>
1559 template <PolygonWithHolesConcept OtherHoledRegion>
1569 template <PolygonWithHolesConcept OtherHoledRegion>
1570 [[nodiscard]]
bool separates(
const OtherHoledRegion& other)
const;
1581 template<PolygonSetConcept OtherSet>
1582 [[nodiscard]]
constexpr bool contains(
const OtherSet& other)
const {
1583 for (
const auto& component : other) {
1592 template<PolygonSetConcept OtherSet>
1594 for (
const auto& component : other) {
1603 template<PolygonSetConcept OtherSet>
1605 for (
const auto& component : other) {
1621 template<PolygonSetConcept OtherSet>
1625 template <Po
intConcept OtherPo
int>
1626 [[nodiscard]]
constexpr bool crosses(
const OtherPoint& other)
const;
1629 template <SegmentConcept OtherSegment>
1630 [[nodiscard]]
constexpr bool crosses(
const OtherSegment& other)
const;
1633 template <OrientedSegmentConcept OtherOrientedSegment>
1634 [[nodiscard]]
constexpr bool crosses(
const OtherOrientedSegment& other)
const;
1637 template <LineConcept OtherLine>
1638 [[nodiscard]]
constexpr bool crosses(
const OtherLine& other)
const;
1641 template <OrientedLineConcept OtherOrientedLine>
1642 [[nodiscard]]
constexpr bool crosses(
const OtherOrientedLine& other)
const;
1645 template <RayConcept OtherRay>
1646 [[nodiscard]]
constexpr bool crosses(
const OtherRay& other)
const;
1649 template <HalfplaneConcept OtherHalfplane>
1650 [[nodiscard]]
constexpr bool crosses(
const OtherHalfplane& other)
const;
1653 template <RectangleConcept OtherRectangle>
1654 [[nodiscard]]
constexpr bool crosses(
const OtherRectangle& other)
const;
1657 template <TriangleConcept OtherTriangle>
1658 [[nodiscard]]
constexpr bool crosses(
const OtherTriangle& other)
const;
1661 template <DiskConcept OtherDisk>
1662 [[nodiscard]]
constexpr bool crosses(
const OtherDisk& other)
const;
1665 template <ConvexConcept OtherConvex>
1666 [[nodiscard]]
constexpr bool crosses(
const OtherConvex& other)
const;
1669 template <MonotoneChainConcept OtherChain>
1670 [[nodiscard]]
constexpr bool crosses(
const OtherChain& other)
const;
1673 template <PolylineConcept OtherPolyline>
1674 [[nodiscard]]
constexpr bool crosses(
const OtherPolyline& other)
const;
1677 template <PolygonConcept OtherPolygon>
1678 [[nodiscard]]
constexpr bool crosses(
const OtherPolygon& other)
const;
1681 template <HalfplaneIntersectionConcept OtherRegion>
1682 [[nodiscard]]
constexpr bool crosses(
const OtherRegion& other)
const;
1690 template <
typename OtherShape>
1692 detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>)
1693 [[nodiscard]]
constexpr bool intersects(
const OtherShape& other)
const {
1694 return other.intersects(*
this);
1703 template <
typename OtherShape>
1705 detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>)
1707 return other.interiorsIntersect(*
this);
1716 template <
typename OtherShape>
1718 detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection> &&
1720 [[nodiscard]]
constexpr bool crosses(
const OtherShape& other)
const {
1721 return other.crosses(*
this);
1726 template <
class EmptyPo
int>
1731 template <
class EmptyPo
int>
1736 template <
class EmptyPo
int>
1741 template <
class EmptyPo
int>
1746 template <
class EmptyPo
int>
1751 template <
class EmptyPo
int>
1756 template <
class EmptyPo
int>
1761 template <
class ResultNumber = NumberType,
class EmptyPo
int>
1770 template <Po
intConcept OtherPo
int>
1774 template <Po
intConcept OtherPo
int>
1778 template <Po
intConcept OtherPo
int>
1782 template <Po
intConcept OtherPo
int>
1786 template <Po
intConcept OtherPo
int>
1790 template <Po
intConcept OtherPo
int>
1794 template <Po
intConcept OtherPo
int>
1798 template <
class ResultNumber = NumberType, Po
intConcept OtherPo
int>
1799 [[nodiscard]]
constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
1803 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1804 [[nodiscard]]
constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1811 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1812 [[nodiscard]]
constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1819 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1820 [[nodiscard]]
constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1825 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1826 [[nodiscard]]
constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1831 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1832 [[nodiscard]]
constexpr std::optional<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1846 template <
class ResultNumber = NumberType, HalfplaneConcept OtherHalfplane>
1859 template <
class ResultNumber = NumberType, RectangleConcept OtherRectangle>
1868 template <
class ResultNumber = NumberType, TriangleConcept OtherTriangle>
1877 template <
class ResultNumber = NumberType, ConvexConcept OtherConvex>
1885 template <
class ResultNumber = NumberType, HalfplaneIntersectionConcept OtherRegion>
1921 template <
class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1922 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1936 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
1938 (detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>) &&
1947 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
1949 && (detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>)
1965 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1969 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1973 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1977 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1981 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1985 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1989 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1993 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1997 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2001 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2005 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2009 template <
class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2013 template <
class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2023 template <
class ResultNumber =
double, DiskConcept OtherDisk>
2024 [[nodiscard]] detail::floating_result_t<ResultNumber>
squaredDistance(
const OtherDisk& other)
const;
2027 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherRegion>
2045 template <
class ResultNumber = division_result_t<NumberType>,
class OtherShape>
2046 requires detail::ClosestPointsPairConcept<HalfplaneIntersection<PointType_, TLabel>, OtherShape>
2050 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
2051 [[nodiscard]]
constexpr auto distanceL1(
const OtherPoint& other)
const;
2054 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2055 [[nodiscard]]
constexpr auto distanceL1(
const OtherSegment& other)
const;
2058 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2059 [[nodiscard]]
constexpr auto distanceL1(
const OtherOrientedSegment& other)
const;
2062 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2063 [[nodiscard]]
constexpr auto distanceL1(
const OtherLine& other)
const;
2066 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2067 [[nodiscard]]
constexpr auto distanceL1(
const OtherOrientedLine& other)
const;
2070 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2071 [[nodiscard]]
constexpr auto distanceL1(
const OtherRay& other)
const;
2074 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2075 [[nodiscard]]
constexpr auto distanceL1(
const OtherHalfplane& other)
const;
2078 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2079 [[nodiscard]]
constexpr auto distanceL1(
const OtherRectangle& other)
const;
2082 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2083 [[nodiscard]]
constexpr auto distanceL1(
const OtherTriangle& other)
const;
2086 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2087 [[nodiscard]]
constexpr auto distanceL1(
const OtherConvex& other)
const;
2090 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2091 [[nodiscard]]
constexpr auto distanceL1(
const OtherChain& other)
const;
2094 template <
class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2095 [[nodiscard]]
constexpr auto distanceL1(
const OtherPolyline& other)
const;
2098 template <
class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2099 [[nodiscard]]
constexpr auto distanceL1(
const OtherPolygon& other)
const;
2102 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherRegion>
2103 [[nodiscard]]
constexpr auto distanceL1(
const OtherRegion& other)
const;
2120 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
2126 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
2135 template <
class ResultNumber =
double, Po
intConcept OtherPo
int>
2141 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
2145 template <
class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2146 [[nodiscard]]
constexpr auto distanceLInf(
const OtherSegment& other)
const;
2149 template <
class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2150 [[nodiscard]]
constexpr auto distanceLInf(
const OtherOrientedSegment& other)
const;
2153 template <
class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2157 template <
class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2158 [[nodiscard]]
constexpr auto distanceLInf(
const OtherOrientedLine& other)
const;
2161 template <
class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2165 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2166 [[nodiscard]]
constexpr auto distanceLInf(
const OtherHalfplane& other)
const;
2169 template <
class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2170 [[nodiscard]]
constexpr auto distanceLInf(
const OtherRectangle& other)
const;
2173 template <
class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2174 [[nodiscard]]
constexpr auto distanceLInf(
const OtherTriangle& other)
const;
2177 template <
class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2181 template <
class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2185 template <
class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2186 [[nodiscard]]
constexpr auto distanceLInf(
const OtherPolyline& other)
const;
2189 template <
class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2190 [[nodiscard]]
constexpr auto distanceLInf(
const OtherPolygon& other)
const;
2193 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherRegion>
2200 template <
class ResultNumber =
double, Po
intConcept OtherPo
int>
2209 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
2210 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>) &&
2219 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
2220 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>) &&
2224 [[nodiscard]]
constexpr auto distanceL1(
const OtherShape& other)
const {
2229 template <
class ResultNumber = division_result_t<NumberType>,
typename OtherShape>
2230 requires ((detail::shapeRank<OtherShape> > detail::shapeRank<HalfplaneIntersection>) &&
2250 template <
class ResultNumber = division_result_t<NumberType>>
2257 template <
class ResultNumber = division_result_t<NumberType>>
2258 [[nodiscard]]
constexpr auto area()
const;
2270 template <
class ResultNumber = division_result_t<NumberType>>
2283 template <
class ResultNumber = division_result_t<NumberType>>
2292 template <
class OtherShape>
2296 std::vector<HalfplaneType> halfplanes_{};
2297 bool empty_ =
false;
2298 bool degenerate_ =
false;
2299 [[no_unique_address]]
mutable LabelType label_{};
2303 static constexpr std::size_t hashUnset_ = pgl::detail::numeric_limits<std::size_t>::max();
2304 mutable std::size_t hash_ = hashUnset_;
2307 template <
class OtherPo
intType,
class OtherLabelType>
2310 constexpr void resetCache()
const {
2314 constexpr std::size_t nextIndex(std::size_t i)
const {
2315 return i + 1 < halfplanes_.size() ? i + 1 : 0;
2318 constexpr std::size_t prevIndex(std::size_t i)
const {
2319 return i == 0 ? halfplanes_.size() - 1 : i - 1;
2324 constexpr void buildPointSlab(
const PointType& p) {
2341 const PointType aPerp(a.x() - dy, a.y() + dx);
2342 const PointType bPerp(b.x() - dy, b.y() + dx);
2352 constexpr void canonicalizeSorted() {
2353 std::sort(halfplanes_.begin(), halfplanes_.end(),
2360 template <HalfplaneConcept Query>
2361 constexpr std::size_t linearLowerBound(
const Query& query)
const {
2362 const auto it = std::lower_bound(
2363 halfplanes_.begin(), halfplanes_.end(), query,
2364 [](
const HalfplaneType& element,
const Query& value) { return detail::directionLess(element, value); });
2365 return static_cast<std::size_t
>(it - halfplanes_.begin());
2370 template <HalfplaneConcept Query>
2371 constexpr std::size_t linearUpperBound(
const Query& query)
const {
2372 const auto it = std::upper_bound(
2373 halfplanes_.begin(), halfplanes_.end(), query,
2374 [](
const Query& value,
const HalfplaneType& element) { return detail::directionLess(value, element); });
2375 return static_cast<std::size_t
>(it - halfplanes_.begin());
2380 template <HalfplaneConcept Query>
2381 constexpr std::ptrdiff_t sameDirectionIndex(
const Query& query)
const {
2382 const std::size_t pos = linearLowerBound(query);
2383 if (pos < halfplanes_.size() && detail::directionEqual(halfplanes_[pos], query)) {
2384 return static_cast<std::ptrdiff_t
>(pos);
2395 template <HalfplaneConcept Query>
2396 constexpr std::pair<std::size_t, std::size_t> leftArc(
const Query& query)
const {
2397 const std::size_t n = halfplanes_.size();
2398 std::size_t lo = linearUpperBound(query);
2402 std::size_t hi = linearLowerBound(query.opposite());
2406 std::size_t count = (hi + n - lo) % n;
2407 if (count == 0 && detail::directionCross(query, halfplanes_[lo]) > 0) {
2417 template <HalfplaneConcept Query>
2418 constexpr std::ptrdiff_t exitConstraint(
const Query& query)
const {
2419 const auto [lo, count] = leftArc(query);
2423 const std::size_t n = halfplanes_.size();
2429 std::size_t first = 0;
2430 std::size_t last = count - 1;
2431 while (first < last) {
2432 const std::size_t mid = first + (last - first) / 2;
2433 const std::size_t i = (lo + mid) % n;
2434 const std::size_t j = (lo + mid + 1) % n;
2435 if (detail::vertexSide(halfplanes_[i], halfplanes_[j], query) < 0) {
2441 return static_cast<std::ptrdiff_t
>((lo + first) % n);
2446 template <Po
intConcept OtherPo
int>
2447 constexpr std::partial_ordering constraintSide(std::size_t i,
const OtherPoint& point)
const {
2448 return orientationSign(halfplanes_[i].source(), halfplanes_[i].target(), point);
2451 enum class SupStatus { unbounded, above, on, below };
2459 template <HalfplaneConcept Query>
2460 constexpr SupStatus supStatus(
const Query& query)
const {
2461 const std::size_t n = halfplanes_.size();
2464 const std::size_t pos = linearUpperBound(query);
2465 const std::size_t predIdx = (pos == 0 ? n : pos) - 1;
2466 const auto& pred = halfplanes_[predIdx];
2467 if (detail::directionEqual(pred, query)) {
2470 const auto side =
orientationSign(query.source(), query.target(), pred.source());
2472 return SupStatus::below;
2474 return side == 0 ? SupStatus::on : SupStatus::above;
2476 const std::size_t succIdx = pos == n ? 0 : pos;
2477 if (succIdx == predIdx) {
2478 return SupStatus::unbounded;
2480 if (!(detail::directionCross(pred, halfplanes_[succIdx]) > 0)) {
2483 return SupStatus::unbounded;
2485 const int side = detail::vertexSide(pred, halfplanes_[succIdx], query);
2487 return SupStatus::below;
2489 return side == 0 ? SupStatus::on : SupStatus::above;
2499 bool onParallelBoundary =
false;
2500 std::ptrdiff_t entry = -1;
2501 std::ptrdiff_t exit = -1;
2504 template <HalfplaneConcept Query>
2505 constexpr ClipResult clipLine(
const Query& query)
const {
2507 const auto reversed = query.opposite();
2509 for (
const std::ptrdiff_t parallelIdx : {sameDirectionIndex(query), sameDirectionIndex(reversed)}) {
2510 if (parallelIdx >= 0) {
2511 const auto side = constraintSide(
static_cast<std::size_t
>(parallelIdx), query.source());
2513 result.empty =
true;
2517 result.onParallelBoundary =
true;
2521 result.exit = exitConstraint(query);
2522 result.entry = exitConstraint(reversed);
2523 if (result.entry >= 0 && result.exit >= 0) {
2527 const auto det = detail::boundaryLinesDeterminant(
2528 halfplanes_[
static_cast<std::size_t
>(result.entry)],
2529 halfplanes_[
static_cast<std::size_t
>(result.exit)], query);
2530 if (det >
decltype(det){}) {
2531 result.empty =
true;
2539 template <HalfplaneConcept Query>
2540 constexpr bool clipHasLength(
const ClipResult& clip,
const Query& query)
const {
2544 if (clip.entry < 0 || clip.exit < 0) {
2547 const auto det = detail::boundaryLinesDeterminant(
2548 halfplanes_[
static_cast<std::size_t
>(clip.entry)],
2549 halfplanes_[
static_cast<std::size_t
>(clip.exit)], query);
2550 return det <
decltype(det){};
2556 template <Po
intConcept OtherPo
int>
2557 constexpr int pointStatus(
const OtherPoint& point)
const {
2561 if (halfplanes_.empty()) {
2564 using OtherNumber =
typename OtherPoint::NumberType;
2566 const QueryPoint base(point.x(), point.y());
2569 const std::ptrdiff_t candidates[4] = {
2570 exitConstraint(upward), exitConstraint(upward.opposite()),
2571 sameDirectionIndex(upward), sameDirectionIndex(upward.opposite())};
2572 for (
const std::ptrdiff_t idx : candidates) {
2576 const auto side = constraintSide(
static_cast<std::size_t
>(idx), point);
2591 template <HalfplaneConcept Query>
2592 constexpr bool recessionContains(
const Query& query,
bool strict =
false)
const {
2593 if (halfplanes_.empty()) {
2598 const auto [lo, count] = leftArc(query);
2606 return sameDirectionIndex(query) < 0 && sameDirectionIndex(query.opposite()) < 0;
2615 constexpr std::vector<std::pair<HalfplaneType, HalfplaneType>> recessionArcs()
const {
2616 std::vector<std::pair<HalfplaneType, HalfplaneType>> arcs;
2617 const std::size_t n = halfplanes_.size();
2618 for (std::size_t i = 0; i < n; ++i) {
2619 const std::size_t j = nextIndex(i);
2620 const auto cross = detail::directionCross(halfplanes_[i], halfplanes_[j]);
2625 const bool wide = cross <= 0;
2630 arcs.emplace_back(halfplanes_[i], halfplanes_[j].opposite());
2647template <
class Po
intType_,
class TLabel>
2648constexpr std::optional<HalfplaneIntersection<PointType_>>
2652 return RegionType(*
vertex);
2655 return RegionType(*carrier);
2661 return std::nullopt;
2664 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(
size());
2665 for (std::ptrdiff_t i = 0; i < n; ++i) {
2668 if (source == target) {
2672 if (kernel.empty()) {
2673 return std::nullopt;
2682template <
class Po
intType,
class LabelType,
class TranslationNumber,
class TranslationLabel>
2685 return region + (-translation);
2694template <
class Po
intType,
class LabelType,
class Scalar>
2695 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2700 if constexpr (detail::has_label_v<LabelType>) {
2701 result.
label() = LabelType{};
2707template <
class Scalar,
class Po
intType,
class LabelType>
2708 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2710 return region * scalar;
2718template <
class Po
intType,
class LabelType,
class Scalar>
2719 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2724 if constexpr (detail::has_label_v<LabelType>) {
2725 result.
label() = LabelType{};
2730template <
class Po
intType,
class LabelType>
Shape pairs whose Minkowski sum Pangolin can represent.
Definition forward.hpp:476
Definition forward.hpp:306
Definition arrangement.hpp:67
HalfplaneIntersection() -> HalfplaneIntersection< Point<>, NoLabel >
Definition halfplaneintersection.hpp:2308
@ y
Definition intervaltree.hpp:24
@ x
Definition intervaltree.hpp:24
@ vertex
Definition bitmatrix.hpp:37
Line() -> Line< Point<>, NoLabel >
constexpr std::partial_ordering dotSign(const Point< ANumber, ALabel > &a, const Point< BNumber, BLabel > &b)
Tells if the angle between two vectors is acute, right, or obtuse.
Definition orientation.hpp:688
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
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
constexpr std::partial_ordering crossSign(const Point< UNumber, ULabel > &u, const Point< VNumber, VLabel > &v)
Classifies the turn from one vector to another.
Definition orientation.hpp:583
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 >
Halfplane() -> Halfplane< Point<>, NoLabel >
Ray() -> Ray< Point<>, NoLabel >
Closed convex polygon stored by its vertices.
Definition convex.hpp:170
The empty set of points in the plane.
Definition emptyshape.hpp:33
Intersection of closed half-planes; convex but possibly unbounded or empty.
Definition halfplaneintersection.hpp:244
constexpr bool crosses(const OtherConvex &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1119
constexpr bool crosses(const OtherOrientedSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1065
constexpr Rectangle< Point< ResultNumber, typename PointType::LabelType > > bbox() const
Computes the bounding box of the region.
Definition bounding.hpp:538
constexpr bool boundaryContains(const OtherConvex &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1496
constexpr bool separates(const OtherRectangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4165
constexpr bool intersects(const OtherOrientedLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1862
constexpr bool boundaryContains(const Shape< OtherPoint > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1585
constexpr auto minkowskiSum(const OtherShape &other) const
Returns the Minkowski sum of this shape and another (A ⊕ B).
Definition minkowski.hpp:808
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by another (A ⊖ B).
Definition minkowskierosion.hpp:641
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2511
constexpr bool boundaryContains(const OtherDisk &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1486
constexpr bool interiorContains(const OtherSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1824
constexpr bool intersects(const OtherRectangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1901
constexpr bool crosses(const OtherDisk &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1113
constexpr bool crosses(const OtherLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1071
detail::floating_result_t< ResultNumber > squaredDistance(const OtherDisk &other) const
Returns the squared Euclidean distance to the given disk.
Definition distance.hpp:1799
constexpr bool boundaryContains(const OtherHalfplane &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1454
constexpr bool interiorContains(const OtherChain &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1940
constexpr auto distanceLInf(const OtherShape &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition halfplaneintersection.hpp:2234
constexpr bool intersects(const OtherOrientedSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1843
constexpr bool boundaryContains(const OtherOrientedLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1430
constexpr auto operator<=>(const HalfplaneIntersection &other) const
Provides an ordering compatible with operator==.
Definition halfplaneintersection.hpp:1009
constexpr bool crosses(const OtherPoint &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1052
constexpr auto distanceL1(const Shape< OtherPoint > &other) const
Returns the Manhattan (L1) distance to the given shape, using symmetry to re-dispatch through the wra...
Definition halfplaneintersection.hpp:2136
constexpr auto squaredDistance(const OtherPoint &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1780
constexpr bool contains(const OtherLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2530
constexpr bool boundaryContains(const OtherPolygon &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1547
constexpr HalfplaneIntersection< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherTriangle &other) const
Returns the intersection with a triangle, as a half-plane intersection.
Definition intersection.hpp:3371
constexpr HalfplaneIntersection(Range &&halfplanes, bool trusted=false)
Creates the intersection of a range of half-planes.
Definition halfplaneintersection.hpp:289
constexpr auto distanceL1(const OtherTriangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1440
Halfplane< PointType > HalfplaneType
Definition halfplaneintersection.hpp:248
constexpr HalfplaneIntersection rotated90(int k=1) const
Returns the region rotated by 90k degrees around the origin.
Definition transformations.hpp:2460
constexpr auto cend() const
Returns a constant iterator past the last half-plane.
Definition halfplaneintersection.hpp:644
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition halfplaneintersection.hpp:1757
constexpr bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition halfplaneintersection.hpp:1720
constexpr bool contains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2605
constexpr std::optional< Segment< Point< ResultNumber, typename PointType::LabelType > > > getIfSegment() const
Returns the segment the region collapses to, if it is one.
Definition predicates.hpp:1243
constexpr bool interiorContains(const OtherConvex &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1929
constexpr bool contains(const OtherSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2517
constexpr bool interiorsIntersect(const OtherRectangle &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2205
constexpr std::ptrdiff_t index(const HalfplaneType &halfplane) const
Definition halfplaneintersection.hpp:624
constexpr HalfplaneIntersection(const OtherLine &line)
Creates the degenerate region consisting of a line.
Definition halfplaneintersection.hpp:439
constexpr bool contains(const OtherRay &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2553
constexpr bool crosses(const OtherChain &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1125
constexpr bool interiorContains(const OtherPolyline &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1951
constexpr void scaleDownX(const OtherNumber scalar)
Divides the region's x-coordinates by a divisor in place.
Definition transformations.hpp:2521
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Ray< Point< ResultNumber, typename PointType::LabelType > >, Line< 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:3195
constexpr auto distanceLInf(const Shape< OtherPoint > &other) const
Returns the Chebyshev (L∞) distance to the given shape, using symmetry to re-dispatch through the wra...
Definition halfplaneintersection.hpp:2201
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition halfplaneintersection.hpp:1737
constexpr bool empty() const
Returns whether the region is the empty set.
Definition halfplaneintersection.hpp:649
constexpr auto distanceL1(const OtherHalfplane &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1438
constexpr auto distanceL1(const OtherRectangle &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1439
constexpr auto squaredDistance(const OtherOrientedLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1784
constexpr auto distanceL1(const OtherShape &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition halfplaneintersection.hpp:2224
constexpr bool separates(const OtherPolygon &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4250
constexpr auto squaredDistance(const OtherChain &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1790
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition halfplaneintersection.hpp:1732
constexpr bool isHalfplane() const
Returns whether the region is exactly one closed half-plane.
Definition predicates.hpp:1152
constexpr HalfplaneIntersection & operator-=(const OtherPoint &translation)
Translates the region by the negation of the given point in place.
constexpr bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition halfplaneintersection.hpp:1693
constexpr auto squaredDistance(const OtherPolyline &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1791
constexpr bool contains(const OtherConvex &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2625
constexpr bool vertexExists(std::size_t i) const
Returns whether the half-plane pair (i, i+1) (cyclically) defines a vertex of the region.
Definition halfplaneintersection.hpp:854
constexpr HalfplaneIntersection(const OtherTriangle &triangle)
Creates the region of a triangle as three half-planes.
Definition halfplaneintersection.hpp:346
constexpr auto distanceLInf(const OtherSegment &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1422
constexpr auto squaredDistance(const OtherShape &other) const
Returns the squared Euclidean distance to the given shape.
Definition halfplaneintersection.hpp:2214
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2674
constexpr std::vector< Point< ResultNumber, typename PointType::LabelType > > vertices() const
Returns every vertex of the region, in pair-index order (for a bounded region: counterclockwise).
Definition halfplaneintersection.hpp:890
constexpr auto distanceLInf(const OtherOrientedLine &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1425
constexpr bool separates(const OtherPolyline &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4280
TLabel LabelType
Definition halfplaneintersection.hpp:247
constexpr auto distanceLInf(const OtherPoint &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1421
constexpr bool interiorsIntersect(const OtherPolygon &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2285
constexpr HalfplaneIntersection(const OtherPoint &point)
Creates the degenerate region consisting of a single point.
Definition halfplaneintersection.hpp:407
constexpr HalfplaneIntersection scaledDownX(const OtherNumber scalar) const
Returns the region with its x-coordinates divided by a divisor.
constexpr bool crosses(const OtherSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1059
constexpr bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition halfplaneintersection.hpp:1593
constexpr auto squaredDistance(const OtherOrientedSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1782
constexpr bool boundaryContains(const OtherRay &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1436
constexpr bool interiorContains(const OtherLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1838
constexpr bool separates(const OtherDisk &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4232
constexpr auto area() const
Returns the area of the region.
Definition measures.hpp:1325
constexpr bool crosses(const OtherRay &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1083
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Ray< Point< ResultNumber, typename PointType::LabelType > >, Line< 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:3139
constexpr void scaleDownY(const OtherNumber scalar)
Divides the region's y-coordinates by a divisor in place.
Definition transformations.hpp:2539
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:3269
constexpr bool contains(const OtherHalfplane &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2569
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition halfplaneintersection.hpp:1762
constexpr bool intersects(const OtherPolyline &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1964
constexpr HalfplaneIntersection< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherHalfplane &other) const
Returns the intersection with a half-plane, as a half-plane intersection.
Definition intersection.hpp:3333
constexpr auto distanceLInf(const OtherChain &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1431
constexpr bool boundaryContains(const OtherSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1385
constexpr bool interiorContains(const OtherRay &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1860
constexpr auto distanceLInf(const OtherConvex &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1430
constexpr HalfplaneIntersection(const OtherHalfplane &halfplane)
Creates the region bounded by a single half-plane.
Definition halfplaneintersection.hpp:261
constexpr bool interiorContains(const OtherTriangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1907
constexpr bool interiorsIntersect(const OtherOrientedSegment &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2145
constexpr auto squaredDistance(const OtherTriangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1788
constexpr bool intersects(const OtherConvex &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1919
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the region contains.
Definition lattice.hpp:673
constexpr bool intersects(const OtherHalfplane &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1887
constexpr bool intersects(const OtherTriangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1913
constexpr auto squaredDistance(const OtherPolygon &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1792
constexpr bool interiorContains(const OtherPoint &point) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1816
constexpr HalfplaneIntersection scaledDownY(const OtherNumber scalar) const
Returns the region with its y-coordinates divided by a divisor.
constexpr auto distanceL1(const OtherRay &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1437
constexpr auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:482
constexpr HalfplaneIntersection scaledUpX(const OtherNumber scalar) const
Returns the region with its x-coordinates multiplied by a factor.
constexpr void rotate90(int k=1)
Rotates the region by 90k degrees around the origin in place.
Definition transformations.hpp:2467
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1814
constexpr bool separates(const OtherRay &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4094
constexpr bool isSegment() const
Returns whether the region is a segment of positive length.
Definition predicates.hpp:1232
constexpr bool interiorsIntersect(const OtherRay &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2171
constexpr A & label() const
Returns the label.
Definition halfplaneintersection.hpp:487
constexpr bool isBounded() const
Returns whether the region is bounded.
Definition halfplaneintersection.hpp:811
constexpr HalfplaneIntersection(const HalfplaneIntersection< OtherPointType, OtherLabelType > &other)
Converts a half-plane intersection with a compatible point type.
Definition halfplaneintersection.hpp:454
constexpr bool separates(const OtherLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4073
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 with a simple polygon (A ∩ B), as components.
Definition intersection.hpp:3440
minkowskiErosionPoint_t< A, B > PointType
Definition halfplaneintersection.hpp:245
constexpr bool separates(const OtherChain &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4268
constexpr bool contains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2637
constexpr bool boundaryContains(const OtherLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1414
constexpr auto distanceL1(const OtherOrientedSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1434
constexpr bool interiorContains(const OtherOrientedSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1832
constexpr bool separates(const OtherSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4058
constexpr bool isDegenerate() const
Returns whether the region has empty interior (it is empty or lower-dimensional: a line,...
Definition halfplaneintersection.hpp:664
PointType::NumberType NumberType
Definition halfplaneintersection.hpp:246
constexpr bool contains(const OtherOrientedLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2547
constexpr bool interiorContains(const OtherHalfplane &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1877
constexpr auto squaredDistance(const OtherLine &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1783
constexpr auto squaredDistance(const OtherRegion &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1823
constexpr auto squaredDistance(const OtherSegment &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1781
constexpr auto squaredDistance(const OtherRay &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1785
constexpr void scaleUpY(const OtherNumber scalar)
Multiplies the region's y-coordinates by a factor in place.
Definition transformations.hpp:2503
constexpr bool boundaryContains(const OtherPoint &point) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1376
constexpr std::optional< Ray< Point< ResultNumber, typename PointType::LabelType > > > getIfRay() const
Returns the ray the region equals, if it is one.
Definition predicates.hpp:1194
constexpr bool contains(const OtherTriangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2599
constexpr bool interiorContains(const Shape< OtherPoint > &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1997
constexpr bool interiorsIntersect(const OtherPoint &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2111
constexpr bool crosses(const OtherTriangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1107
constexpr Convex< Point< ResultNumber, typename PointType::LabelType > > asConvex() const
Returns the region as a convex polygon.
Definition halfplaneintersection.hpp:955
constexpr bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition halfplaneintersection.hpp:1604
constexpr bool intersects(const OtherRegion &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2003
constexpr bool contains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2649
constexpr bool interiorContains(const OtherDisk &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1913
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:3126
constexpr HalfplaneIntersection(const OtherConvex &convex)
Creates the region of a convex polygon as its edge half-planes.
Definition halfplaneintersection.hpp:375
constexpr bool intersects(const Shape< OtherPoint > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2014
constexpr bool interiorsIntersect(const OtherTriangle &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2220
constexpr bool crosses(const OtherPolyline &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1131
constexpr bool boundaryContains(const OtherChain &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1513
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:6017
constexpr bool contains(const OtherRectangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2581
constexpr bool intersects(const OtherLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1849
constexpr bool interiorsIntersect(const OtherChain &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2255
constexpr bool separates(const Shape< OtherPoint > &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4542
constexpr auto distanceLInf(const OtherPolyline &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1432
constexpr std::size_t size() const
Returns the number of stored (non-redundant) half-planes.
Definition halfplaneintersection.hpp:596
constexpr bool interiorContains(const OtherOrientedLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1854
constexpr std::size_t vertexCount() const
Returns the number of vertices of the region.
Definition halfplaneintersection.hpp:833
constexpr const HalfplaneType & operator[](std::size_t index) const
Accesses a stored half-plane by index, in boundary (counterclockwise pseudo-angle) order.
Definition halfplaneintersection.hpp:604
constexpr auto distanceL1(const OtherLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1435
constexpr bool interiorsIntersect(const OtherDisk &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2238
constexpr auto distanceLInf(const OtherRay &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1426
constexpr auto distanceL1(const OtherConvex &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1441
constexpr auto distanceL1(const OtherPolyline &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1443
auto regularizedIntersection(const Shape< OtherPoint > &other) const
Re-dispatches a regularized intersection through a runtime shape.
Definition halfplaneintersection.hpp:2127
constexpr bool separates(const OtherOrientedSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4067
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition halfplaneintersection.hpp:1727
constexpr auto cbegin() const
Returns a constant iterator to the first half-plane, in boundary order.
Definition halfplaneintersection.hpp:640
constexpr bool separates(const OtherTriangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4187
constexpr bool isPoint() const
Returns whether the region is a single point.
Definition predicates.hpp:1212
constexpr bool boundaryContains(const OtherRectangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1462
friend struct HalfplaneIntersection
Definition halfplaneintersection.hpp:2308
constexpr bool operator==(const HalfplaneIntersection &other) const
Tests equality of the stored regions.
Definition halfplaneintersection.hpp:984
constexpr auto distanceLInf(const OtherOrientedSegment &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1423
constexpr bool separates(const OtherPoint &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4050
constexpr bool interiorsIntersect(const OtherRegion &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2304
constexpr bool pointInsideInteriorContainedIn(const OtherShape &shape) const
Tests whether an exact interior witness of this region lies in the interior of the given shape.
Definition measures.hpp:1400
constexpr bool crosses(const OtherOrientedLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1077
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition intersection.hpp:3203
constexpr bool intersects(const OtherPolygon &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1981
constexpr std::optional< HalfplaneType > getIfHalfplane() const
Returns the half-plane the region equals, if it is one.
Definition predicates.hpp:1158
constexpr bool separates(const OtherOrientedLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4088
constexpr bool separates(const OtherHalfplane &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4113
constexpr const HalfplaneType & get(std::ptrdiff_t index) const
Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the en...
Definition halfplaneintersection.hpp:613
constexpr bool contains(const OtherHoledRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3340
constexpr bool isRay() const
Returns whether the region is exactly one ray.
Definition predicates.hpp:1184
constexpr bool isLine() const
Returns whether the region is exactly one line.
Definition predicates.hpp:1166
constexpr HalfplaneIntersection scaledUpY(const OtherNumber scalar) const
Returns the region with its y-coordinates multiplied by a factor.
constexpr bool interiorsIntersect(const OtherSegment &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2118
constexpr bool separates(const OtherConvex &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4205
constexpr auto twiceArea() const
Returns twice the area of the region.
Definition measures.hpp:1313
constexpr bool insert(const OtherHalfplane &other)
Intersects the region with one more half-plane.
Definition halfplaneintersection.hpp:509
constexpr HalfplaneIntersection()=default
Creates the whole plane (the intersection of no half-planes).
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1569
constexpr bool boundaryContains(const OtherHoledRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:2073
constexpr std::vector< HalfplaneType > halfplanes() const
Definition halfplaneintersection.hpp:633
auto intersection(const OtherShape &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition halfplaneintersection.hpp:1942
constexpr bool boundaryContains(const OtherPolyline &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1530
constexpr bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition halfplaneintersection.hpp:1706
constexpr bool intersects(const OtherRay &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1868
constexpr bool crosses(const Shape< OtherPoint > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1149
constexpr HalfplaneIntersection & operator+=(const OtherPoint &translation)
Translates the region by the given point in place.
constexpr auto distanceL1(const OtherOrientedLine &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1436
constexpr HalfplaneIntersection< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherRectangle &other) const
Returns the intersection with a rectangle, as a half-plane intersection.
Definition intersection.hpp:3345
constexpr bool interiorsIntersect(const OtherOrientedLine &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2165
constexpr HalfplaneIntersection< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherConvex &other) const
Returns the intersection with a convex polygon, as a half-plane intersection.
Definition intersection.hpp:3383
constexpr bool contains(const OtherPolygon &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2661
auto regularizedIntersection(const OtherShape &other) const
Forwards a regularized intersection to the shape that owns it.
Definition halfplaneintersection.hpp:1953
constexpr bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition halfplaneintersection.hpp:1582
constexpr HalfplaneIntersection(const OtherRectangle &rectangle)
Creates the region of a rectangle as four half-planes.
Definition halfplaneintersection.hpp:310
constexpr bool boundaryContains(const OtherOrientedSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1408
constexpr auto distanceL1(const OtherChain &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1442
constexpr auto distanceLInf(const OtherRegion &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1439
constexpr auto squaredDistance(const OtherRectangle &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1787
constexpr bool intersects(const OtherDisk &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1928
constexpr bool interiorsIntersect(const OtherLine &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2151
constexpr Convex< Point< ResultNumber, typename PointType::LabelType > > convexHull() const
Returns the region's convex hull.
Definition halfplaneintersection.hpp:972
constexpr bool crosses(const OtherPolygon &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1137
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1808
constexpr bool contains(const OtherOrientedSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2524
constexpr auto distanceL1(const OtherRegion &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1450
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition halfplaneintersection.hpp:1742
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 halfplaneintersection.hpp:2121
constexpr bool intersects(const OtherChain &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1947
constexpr bool interiorsIntersect(const OtherConvex &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2229
constexpr auto distanceLInf(const OtherTriangle &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1429
bool separates(const OtherHoledRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5773
constexpr Point< ResultNumber > centroid() const
Returns the centroid of the region.
Definition measures.hpp:1337
constexpr bool separates(const EmptyShape< EmptyPoint > &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition halfplaneintersection.hpp:1752
constexpr bool interiorContains(const OtherRectangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1888
constexpr auto distanceLInf(const OtherHalfplane &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1427
constexpr auto end() const
Returns a constant iterator past the last half-plane.
Definition halfplaneintersection.hpp:642
constexpr bool interiorContains(const OtherPolygon &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1962
constexpr bool interiorsIntersect(const OtherHalfplane &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2189
constexpr bool interiorsIntersect(const Shape< OtherPoint > &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2316
constexpr bool interiorContains(const OtherHoledRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2553
constexpr HalfplaneIntersection(const OtherSegment &segment)
Creates the degenerate region consisting of a segment.
Definition halfplaneintersection.hpp:420
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:1975
constexpr auto squaredDistance(const OtherHalfplane &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1786
constexpr Point< ResultNumber > pointInside() const
Returns a representative point of the region: a point of its interior when the region is full-dimensi...
Definition measures.hpp:1350
constexpr bool crosses(const OtherRectangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1097
constexpr auto distanceLInf(const OtherLine &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1424
constexpr bool boundaryContains(const OtherTriangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1478
constexpr std::variant< Segment< Point< ResultNumber, typename PointType::LabelType > >, Ray< Point< ResultNumber, typename PointType::LabelType > >, Line< Point< ResultNumber, typename PointType::LabelType > > > edge(std::size_t i) const
Returns the boundary contribution of half-plane i as a typed one-dimensional shape.
Definition halfplaneintersection.hpp:919
constexpr bool crosses(const OtherRegion &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1143
constexpr auto distanceL1(const OtherPolygon &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1444
constexpr bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:4515
constexpr Rectangle< Point< ResultNumber > > fbox() const
Computes the floating-point bounding box of the region.
Definition bounding.hpp:623
constexpr HalfplaneIntersection< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherRegion &other) const
Returns the intersection with another half-plane intersection.
Definition intersection.hpp:3403
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Ray< 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:3278
constexpr Point< ResultNumber, typename PointType::LabelType > vertex(std::size_t i) const
Definition halfplaneintersection.hpp:875
constexpr auto squaredDistance(const OtherConvex &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1789
constexpr auto distanceLInf(const OtherRectangle &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1428
constexpr auto distanceLInf(const OtherPolygon &other) const
Returns the Chebyshev (L∞) distance to the given shape.
Definition distancelinf.hpp:1433
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:2025
constexpr std::optional< Line< PointType > > getIfLine() const
Returns the line the region equals, if it is one.
Definition predicates.hpp:1174
constexpr auto begin() const
Returns a constant iterator to the first half-plane, in boundary order.
Definition halfplaneintersection.hpp:638
constexpr bool contains(const Shape< OtherPoint > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2693
constexpr auto distanceL1(const OtherPoint &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1432
constexpr auto distanceL1(const OtherSegment &other) const
Returns the Manhattan (L1) distance to the given shape.
Definition distancel1.hpp:1433
constexpr bool interiorsIntersect(const OtherPolyline &other) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition interiorsintersect.hpp:2271
constexpr bool isUndefined() const
Returns whether the region is undefined.
Definition halfplaneintersection.hpp:678
constexpr bool crosses(const OtherHalfplane &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1089
constexpr bool isPlane() const
Returns whether the region is the whole plane (no half-planes).
Definition halfplaneintersection.hpp:656
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Definition halfplaneintersection.hpp:1747
constexpr std::optional< Point< ResultNumber, typename PointType::LabelType > > getIfPoint() const
Returns the point the region collapses to, if it is one.
Definition predicates.hpp:1223
constexpr void scaleUpX(const OtherNumber scalar)
Multiplies the region's x-coordinates by a factor in place.
Definition transformations.hpp:2485
Closed half-plane defined by an oriented boundary line.
Definition halfplane.hpp:51
constexpr Halfplane opposite() const
Returns the complementary half-plane with reversed boundary orientation.
Definition halfplane.hpp:223
constexpr bool isUndefined() const
Returns whether the half-plane is degenerate without collapsing to a point or to a segment.
Definition predicates.hpp:957
Unoriented infinite line.
Definition line.hpp:52
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
Closed simple polygon stored by its vertices.
Definition polygon.hpp:59
constexpr std::optional< PointType > getIfPoint() const
Returns the point the polygon collapses to, if it does.
Definition polygon.hpp:341
constexpr std::optional< HalfplaneIntersection< PointType > > getStarShapedKernel() const
Returns the kernel: the set of points that see the whole polygon.
Definition halfplaneintersection.hpp:2649
constexpr bool isUndefined() const
Checks whether the polygon is degenerate without covering a point or a segment.
Definition polygon.hpp:388
constexpr std::optional< BoundaryType< false > > getIfSegment() const
Returns the segment the polygon collapses to, if it does.
Definition polygon.hpp:369
constexpr std::size_t size() const
Returns the number of vertices in the polygon.
Definition polygon.hpp:259
PointType_ PointType
Definition polygon.hpp:60
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
constexpr bool empty() const
Returns whether the polygon is the empty set of points.
Definition polygon.hpp:302
Open polygonal chain stored in traversal order; may self-intersect.
Definition polyline.hpp:69
Half-infinite line starting from one source point plus optional ray label.
Definition ray.hpp:51
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