41template <
class ResultNumber,
class Self,
class OtherShape>
42constexpr ResultNumber maxVertexSquaredDistance(
const Self& self,
const OtherShape& other) {
43 const auto self_vertices = self.vertices();
44 ResultNumber worst = other.template squaredDistance<ResultNumber>(self_vertices[0]);
45 for (std::size_t index = 1; index < self_vertices.size(); ++index) {
46 const ResultNumber current = other.template squaredDistance<ResultNumber>(self_vertices[index]);
47 if (worst < current) {
59template <
class Number,
class Label>
60template <
class ResultNumber, Po
intConcept OtherPo
int>
62 const ResultNumber dx = detail::asNumber<ResultNumber>(
x()) - detail::asNumber<ResultNumber>(other.x());
63 const ResultNumber dy = detail::asNumber<ResultNumber>(
y()) - detail::asNumber<ResultNumber>(other.y());
64 return dx * dx + dy * dy;
67template <
class Number,
class Label>
68template <
class ApproximateNumber, Po
intConcept OtherPo
int>
73template <
class Number,
class Label>
74template <
class ResultNumber, Po
intConcept OtherPo
int>
76 const ResultNumber dx = detail::asNumber<ResultNumber>(
x()) - detail::asNumber<ResultNumber>(other.x());
77 const ResultNumber dy = detail::asNumber<ResultNumber>(
y()) - detail::asNumber<ResultNumber>(other.y());
78 return pgl::detail::abs(dx) + pgl::detail::abs(dy);
81template <
class Number,
class Label>
82template <
class ResultNumber, Po
intConcept OtherPo
int>
84 const ResultNumber dx = detail::asNumber<ResultNumber>(
x()) - detail::asNumber<ResultNumber>(other.x());
85 const ResultNumber dy = detail::asNumber<ResultNumber>(
y()) - detail::asNumber<ResultNumber>(other.y());
86 return std::max(pgl::detail::abs(dx), pgl::detail::abs(dy));
89template <
class Number,
class Label>
90template <
class ResultNumber, Po
intConcept OtherPo
int>
98template <
class Po
intType,
class LabelType>
99template <
class ResultNumber, Po
intConcept OtherPo
int>
105 const auto ab = b - a;
106 const auto ap = p - a;
107 const auto bp = p - b;
108 const auto squared_length = ab * ab;
110 if (squared_length == 0) {
121 return static_cast<ResultNumber
>(ap * ap);
125 return static_cast<ResultNumber
>(bp * bp);
128 const ResultNumber twice_triangle_area = ab.
x() * ap.y() - ab.y() * ap.x();
129 return static_cast<ResultNumber
>((twice_triangle_area * twice_triangle_area) / squared_length);
132template <
class Po
intType,
class LabelType>
133template <
class ResultNumber, SegmentConcept OtherSegment>
136 return ResultNumber{};
144 const auto best_from_this = this_min_to_other < this_max_to_other ? this_min_to_other : this_max_to_other;
145 const auto best_from_other = other_min_to_this < other_max_to_this ? other_min_to_this : other_max_to_this;
147 return best_from_this < best_from_other ? best_from_this : best_from_other;
150template <
class Po
intType,
class LabelType>
151template <
class ResultNumber, SegmentConcept OtherSegment>
158 const auto worst_from_this = this_min_to_other > this_max_to_other ? this_min_to_other : this_max_to_other;
159 const auto worst_from_other = other_min_to_this > other_max_to_this ? other_min_to_this : other_max_to_this;
161 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
164template <
class Po
intType,
class LabelType>
165template <
class ResultNumber, Po
intConcept OtherPo
int>
170 return detail::maxVertexSquaredDistance<ResultNumber>(*
this, point);
176template <
class Po
intType,
class LabelType>
177template <
class ResultNumber, Po
intConcept OtherPo
int>
182template <
class Po
intType,
class LabelType>
183template <
class ResultNumber, SegmentConcept OtherSegment>
188template <
class Po
intType,
class LabelType>
189template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
195template <
class Po
intType,
class LabelType>
196template <
class ResultNumber, SegmentConcept OtherSegment>
201template <
class Po
intType,
class LabelType>
202template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
208template <
class Po
intType,
class LabelType>
209template <
class ResultNumber, Po
intConcept OtherPo
int>
217template <
class Po
intType,
class LabelType>
218template <
class ResultNumber, Po
intConcept OtherPo
int>
227 const auto ab = b - a;
228 const auto ap = p - a;
229 const ResultNumber twice_triangle_area = ab.
x() * ap.y() - ab.y() * ap.x();
230 const ResultNumber squared_length = ab * ab;
231 return static_cast<ResultNumber
>((twice_triangle_area * twice_triangle_area) / squared_length);
234template <
class Po
intType,
class LabelType>
235template <
class ResultNumber, LineConcept OtherLine>
238 return ResultNumber{};
244template <
class Po
intType,
class LabelType>
245template <
class ResultNumber, SegmentConcept OtherSegment>
248 return ResultNumber{};
253 return source_distance < target_distance ? source_distance : target_distance;
256template <
class Po
intType,
class LabelType>
257template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
265template <
class Po
intType,
class LabelType>
266template <
class ResultNumber, Po
intConcept OtherPo
int>
271template <
class Po
intType,
class LabelType>
272template <
class ResultNumber, LineConcept OtherLine>
277template <
class Po
intType,
class LabelType>
278template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
283template <
class Po
intType,
class LabelType>
284template <
class ResultNumber, SegmentConcept OtherSegment>
289template <
class Po
intType,
class LabelType>
290template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
298template <
class Po
intType,
class LabelType>
299template <
class ResultNumber, Po
intConcept OtherPo
int>
308 const auto ab = b - a;
309 const auto ap = p - a;
310 const auto squared_length = ab * ab;
312 if (squared_length == 0) {
313 return static_cast<ResultNumber
>(ap * ap);
319 return static_cast<ResultNumber
>(ap * ap);
322 const ResultNumber twice_triangle_area = ab.
x() * ap.y() - ab.y() * ap.x();
323 return static_cast<ResultNumber
>((twice_triangle_area * twice_triangle_area) / squared_length);
326template <
class Po
intType,
class LabelType>
327template <
class ResultNumber, LineConcept OtherLine>
330 return ResultNumber{};
336template <
class Po
intType,
class LabelType>
337template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
340 return ResultNumber{};
346template <
class Po
intType,
class LabelType>
347template <
class ResultNumber, SegmentConcept OtherSegment>
350 return ResultNumber{};
356 const auto best_from_segment = other_min_to_this < other_max_to_this ? other_min_to_this : other_max_to_this;
357 return source_to_other < best_from_segment ? source_to_other : best_from_segment;
360template <
class Po
intType,
class LabelType>
361template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
364 return ResultNumber{};
370 const auto best_from_segment = other_source_to_this < other_target_to_this ? other_source_to_this : other_target_to_this;
371 return source_to_other < best_from_segment ? source_to_other : best_from_segment;
374template <
class Po
intType,
class LabelType>
375template <
class ResultNumber, RayConcept OtherRay>
378 return ResultNumber{};
383 return this_source_to_other < other_source_to_this ? this_source_to_other : other_source_to_this;
389template <
class Po
intType,
class LabelType>
390template <
class ResultNumber, Po
intConcept OtherPo
int>
393 return ResultNumber{};
398template <
class Po
intType,
class LabelType>
399template <
class ResultNumber, SegmentConcept OtherSegment>
402 return ResultNumber{};
407template <
class Po
intType,
class LabelType>
408template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
411 return ResultNumber{};
416template <
class Po
intType,
class LabelType>
417template <
class ResultNumber, LineConcept OtherLine>
420 return ResultNumber{};
425template <
class Po
intType,
class LabelType>
426template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
429 return ResultNumber{};
434template <
class Po
intType,
class LabelType>
435template <
class ResultNumber, RayConcept OtherRay>
438 return ResultNumber{};
443template <
class Po
intType,
class LabelType>
444template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
447 return ResultNumber{};
455template <
class Po
intType,
class LabelType>
456template <
class Left,
class Right>
457constexpr auto Rectangle<PointType, LabelType>::axisDistance(
const Left& first_min,
const Left& first_max,
const Right& second_min,
const Right& second_max)
458 -> std::common_type_t<Left, Right> {
459 using Distance = std::common_type_t<Left, Right>;
461 if (first_max < second_min) {
462 return static_cast<Distance
>(second_min) -
static_cast<Distance
>(first_max);
465 if (second_max < first_min) {
466 return static_cast<Distance
>(first_min) -
static_cast<Distance
>(second_max);
472template <
class Po
intType,
class LabelType>
473template <
class ResultNumber, Po
intConcept OtherPo
int>
478 const ResultNumber dx =
static_cast<ResultNumber
>(axisDistance(
min().
x(),
max().
x(), point.x(), point.x()));
479 const ResultNumber dy =
static_cast<ResultNumber
>(axisDistance(
min().
y(),
max().
y(), point.y(), point.y()));
480 return dx * dx + dy * dy;
483template <
class Po
intType,
class LabelType>
484template <
class ResultNumber, LineConcept OtherLine>
490 return ResultNumber{};
493 const auto rectangle_vertices =
vertices();
495 for (std::size_t
index = 1;
index < rectangle_vertices.size(); ++
index) {
497 if (current_distance < best_distance) {
498 best_distance = current_distance;
502 return best_distance;
505template <
class Po
intType,
class LabelType>
506template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
514template <
class Po
intType,
class LabelType>
515template <
class ResultNumber, SegmentConcept OtherSegment>
521 return ResultNumber{};
526 if (other_max_distance < best_distance) {
527 best_distance = other_max_distance;
530 const auto rectangle_edges =
edges();
531 for (
const auto&
edge : rectangle_edges) {
533 if (current_distance < best_distance) {
534 best_distance = current_distance;
538 return best_distance;
541template <
class Po
intType,
class LabelType>
542template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
550template <
class Po
intType,
class LabelType>
551template <
class ResultNumber, RayConcept OtherRay>
557 return ResultNumber{};
561 const auto rectangle_edges =
edges();
562 for (
const auto&
edge : rectangle_edges) {
564 if (current_distance < best_distance) {
565 best_distance = current_distance;
569 return best_distance;
572template <
class Po
intType,
class LabelType>
573template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
579 return ResultNumber{};
584template <
class Po
intType,
class LabelType>
585template <
class ResultNumber, RectangleConcept OtherRectangle>
590 const ResultNumber dx =
static_cast<ResultNumber
>(axisDistance(
min().
x(),
max().
x(), other.min().x(), other.max().x()));
591 const ResultNumber dy =
static_cast<ResultNumber
>(axisDistance(
min().
y(),
max().
y(), other.min().y(), other.max().y()));
592 return dx * dx + dy * dy;
595template <
class Po
intType,
class LabelType>
596template <
class ResultNumber, RectangleConcept OtherRectangle>
601 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
602 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
603 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
606template <
class Po
intType,
class LabelType>
607template <
class ResultNumber, Po
intConcept OtherPo
int>
612 return detail::maxVertexSquaredDistance<ResultNumber>(*
this, point);
615template <
class Po
intType,
class LabelType>
616template <
class ResultNumber, SegmentConcept OtherSegment>
621 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
622 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
623 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
626template <
class Po
intType,
class LabelType>
627template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
632 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
633 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
634 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
640template <
class Po
intType,
class LabelType>
641template <
class ResultNumber,
class OtherShape>
642constexpr ResultNumber Triangle<PointType, LabelType>::edgeMinSquaredDistance(
const OtherShape& other)
const {
643 const auto triangle_edges = edges();
644 auto best = triangle_edges[0].template squaredDistance<ResultNumber>(other);
645 for (std::size_t index = 1; index < triangle_edges.size(); ++index) {
646 const auto current = triangle_edges[index].template squaredDistance<ResultNumber>(other);
647 if (current < best) {
654template <
class Po
intType,
class LabelType>
655template <
class ResultNumber,
class OtherShape>
656constexpr ResultNumber Triangle<PointType, LabelType>::vertexMinSquaredDistance(
const OtherShape& other)
const {
657 const auto triangle_vertices = vertices();
658 auto best = other.template squaredDistance<ResultNumber>(triangle_vertices[0]);
659 for (std::size_t index = 1; index < triangle_vertices.size(); ++index) {
660 const auto current = other.template squaredDistance<ResultNumber>(triangle_vertices[index]);
661 if (current < best) {
668template <
class Po
intType,
class LabelType>
669template <
class ResultNumber, Po
intConcept OtherPo
int>
672 return ResultNumber{};
674 return this->
template edgeMinSquaredDistance<ResultNumber>(point);
677template <
class Po
intType,
class LabelType>
678template <
class ResultNumber, SegmentConcept OtherSegment>
681 return ResultNumber{};
683 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
686template <
class Po
intType,
class LabelType>
687template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
690 return ResultNumber{};
692 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
695template <
class Po
intType,
class LabelType>
696template <
class ResultNumber, LineConcept OtherLine>
699 return ResultNumber{};
701 return this->
template vertexMinSquaredDistance<ResultNumber>(other);
704template <
class Po
intType,
class LabelType>
705template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
708 return ResultNumber{};
710 return this->
template vertexMinSquaredDistance<ResultNumber>(other);
713template <
class Po
intType,
class LabelType>
714template <
class ResultNumber, RayConcept OtherRay>
717 return ResultNumber{};
719 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
722template <
class Po
intType,
class LabelType>
723template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
726 return ResultNumber{};
731template <
class Po
intType,
class LabelType>
732template <
class ResultNumber, RectangleConcept OtherRectangle>
735 return ResultNumber{};
737 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
740template <
class Po
intType,
class LabelType>
741template <
class ResultNumber, TriangleConcept OtherTriangle>
744 return ResultNumber{};
746 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
749template <
class Po
intType,
class LabelType>
750template <
class ResultNumber, Po
intConcept OtherPo
int>
752 return detail::maxVertexSquaredDistance<ResultNumber>(*
this, point);
755template <
class Po
intType,
class LabelType>
756template <
class ResultNumber, SegmentConcept OtherSegment>
758 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
759 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
760 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
763template <
class Po
intType,
class LabelType>
764template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
766 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
767 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
768 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
771template <
class Po
intType,
class LabelType>
772template <
class ResultNumber, RectangleConcept OtherRectangle>
774 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
775 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
776 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
779template <
class Po
intType,
class LabelType>
780template <
class ResultNumber, TriangleConcept OtherTriangle>
782 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
783 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
784 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
789template <
class Po
intType_,
class LabelType>
790template <
class ResultNumber, Po
intConcept OtherPo
int>
795 using Num = detail::dot_coordinate_t<NumberType, typename OtherPoint::NumberType>;
797 return ResultNumber{};
800 auto edgeVector =
edges();
802 for (
auto & e : edgeVector) {
804 if (current < best) {
811 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(
size());
812 const auto V = [
this](std::ptrdiff_t i) {
return get(i); };
813 const auto facing = [&](std::ptrdiff_t i) {
819 const Num sx = detail::asNumber<Num>(V(0).
x()) + detail::asNumber<Num>(V(1).
x()) + detail::asNumber<Num>(V(2).
x());
820 const Num sy = detail::asNumber<Num>(V(0).
y()) + detail::asNumber<Num>(V(1).
y()) + detail::asNumber<Num>(V(2).
y());
821 const Num bx = Num{3} * detail::asNumber<Num>(point.x()) - sx;
822 const Num by = Num{3} * detail::asNumber<Num>(point.y()) - sy;
827 const auto dSign = [&](std::ptrdiff_t k) ->
int {
828 const Num ax = Num{3} * detail::asNumber<Num>(V(k).
x()) - sx;
829 const Num ay = Num{3} * detail::asNumber<Num>(V(k).
y()) - sy;
830 const Num cross = ax * by - ay * bx;
831 return (cross > Num{0}) - (cross < Num{0});
836 const auto gDot = [&](std::ptrdiff_t k) {
837 return detail::asNumber<Num>(V(k).
x()) * by - detail::asNumber<Num>(V(k).
y()) * bx;
839 const auto indices = std::views::iota(std::ptrdiff_t{0}, n);
840 const std::ptrdiff_t mPos = *detail::cyclicMax(
841 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return gDot(k); });
842 const std::ptrdiff_t mNeg = *detail::cyclicMax(
843 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return -gDot(k); });
845 const auto wrap = [n](std::ptrdiff_t a) {
return ((a % n) + n) % n; };
849 const auto lastWhile =
850 [&](std::ptrdiff_t from, std::ptrdiff_t step, std::ptrdiff_t len,
auto pred) {
851 std::ptrdiff_t lo = 0, hi = len;
853 const std::ptrdiff_t mid = (lo + hi + 1) / 2;
854 if (pred(from + step * mid)) {
864 const std::ptrdiff_t anchor = mPos + lastWhile(mPos, 1, wrap(mNeg - mPos),
865 [&](std::ptrdiff_t k) {
return dSign(k) > 0; });
867 const std::ptrdiff_t back = mNeg + lastWhile(mNeg, 1, wrap(mPos - mNeg),
868 [&](std::ptrdiff_t k) {
return dSign(k) < 0; });
871 const std::ptrdiff_t hiEdge = anchor + lastWhile(anchor, 1, wrap(back - anchor), facing);
872 const std::ptrdiff_t loEdge = anchor - lastWhile(anchor, -1, wrap(anchor - back), facing);
875 const auto edgeDist = [&](std::ptrdiff_t i) {
878 std::ptrdiff_t lo = 0, hi = hiEdge - loEdge;
880 const std::ptrdiff_t mid = (lo + hi) / 2;
881 if (edgeDist(loEdge + mid) < edgeDist(loEdge + mid + 1)) {
887 return edgeDist(loEdge + lo);
890template <
class Po
intType_,
class LabelType>
891template <
class ResultNumber, SegmentConcept OtherSegment>
894 return ResultNumber{};
898 auto edgeVector =
edges();
900 for (
auto& e : edgeVector) {
902 if (current < best) {
912 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(
size());
916 if (from_max < best) {
928 const auto support = [&](std::ptrdiff_t i) {
931 const auto indices = std::views::iota(std::ptrdiff_t{0}, n);
932 const std::ptrdiff_t hi = *detail::cyclicMax(
933 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return support(k); });
934 const std::ptrdiff_t lo = *detail::cyclicMax(
935 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return -support(k); });
938 if (from_hi < best) {
942 if (from_lo < best) {
949template <
class Po
intType_,
class LabelType>
950template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
956template <
class Po
intType_,
class LabelType>
957template <
class ResultNumber, ConvexConcept OtherConvex>
960 return ResultNumber{};
967 const auto minOverEdges = [](
const auto& source,
const auto& target) {
968 const auto edgeVector = source.edges();
970 for (
const auto&
edge : edgeVector) {
972 if (current < best) {
980 return minOverEdges(*
this, other);
982 return minOverEdges(other, *
this);
985template <
class Po
intType_,
class LabelType>
986template <
class ResultNumber, TriangleConcept OtherTriangle>
991template <
class Po
intType_,
class LabelType>
992template <
class ResultNumber, RectangleConcept OtherRectangle>
997template <
class Po
intType_,
class LabelType>
998template <
class ResultNumber, LineConcept OtherLine>
1001 return ResultNumber{};
1006 for (std::ptrdiff_t i = 1; i < static_cast<std::ptrdiff_t>(
size()); ++i) {
1008 if (current < best) {
1022 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(
size());
1025 const auto support = [&](std::ptrdiff_t i) {
1028 const auto indices = std::views::iota(std::ptrdiff_t{0}, n);
1029 const std::ptrdiff_t hi = *detail::cyclicMax(
1030 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return support(k); });
1031 const std::ptrdiff_t lo = *detail::cyclicMax(
1032 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return -support(k); });
1036 return from_hi < from_lo ? from_hi : from_lo;
1039template <
class Po
intType_,
class LabelType>
1040template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
1045template <
class Po
intType_,
class LabelType>
1046template <
class ResultNumber, RayConcept OtherRay>
1049 return ResultNumber{};
1053 auto edgeVector =
edges();
1055 for (
const auto& e : edgeVector) {
1057 if (current < best) {
1069 const std::ptrdiff_t n =
static_cast<std::ptrdiff_t
>(size());
1071 ResultNumber best = this->
template squaredDistance<ResultNumber>(other.source());
1073 const PointType a(other.source());
1074 const PointType b(other.target());
1075 const auto support = [&](std::ptrdiff_t i) {
1078 const auto indices = std::views::iota(std::ptrdiff_t{0}, n);
1079 const std::ptrdiff_t hi = *detail::cyclicMax(
1080 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return support(k); });
1081 const std::ptrdiff_t lo = *detail::cyclicMax(
1082 indices.begin(), indices.end(), [&](std::ptrdiff_t k) { return -support(k); });
1084 const ResultNumber from_hi = other.template squaredDistance<ResultNumber>(get(hi));
1085 if (from_hi < best) {
1088 const ResultNumber from_lo = other.template squaredDistance<ResultNumber>(get(lo));
1089 if (from_lo < best) {
1096template <
class Po
intType_,
class LabelType>
1097template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
1100 return ResultNumber{};
1108template <
class Po
intType_,
class LabelType>
1109template <
class ResultNumber, Po
intConcept OtherPo
int>
1111 return detail::maxVertexSquaredDistance<ResultNumber>(*
this, point);
1114template <
class Po
intType_,
class LabelType>
1115template <
class ResultNumber, SegmentConcept OtherSegment>
1117 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
1118 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
1119 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
1122template <
class Po
intType_,
class LabelType>
1123template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
1125 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
1126 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
1127 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
1130template <
class Po
intType_,
class LabelType>
1131template <
class ResultNumber, RectangleConcept OtherRectangle>
1133 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
1134 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
1135 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
1138template <
class Po
intType_,
class LabelType>
1139template <
class ResultNumber, TriangleConcept OtherTriangle>
1141 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
1142 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
1143 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
1146template <
class Po
intType_,
class LabelType>
1147template <
class ResultNumber, ConvexConcept OtherConvex>
1149 const auto worst_from_this = detail::maxVertexSquaredDistance<ResultNumber>(*
this, other);
1150 const auto worst_from_other = detail::maxVertexSquaredDistance<ResultNumber>(other, *
this);
1151 return worst_from_this > worst_from_other ? worst_from_this : worst_from_other;
1171template <
class Float =
double,
class DiskType,
class OtherShape>
1172Float diskExteriorSquaredDistance(
const DiskType& disk,
const OtherShape& other) {
1174 std::sqrt(other.template squaredDistance<Float>(disk.template center<Float>()))
1175 - disk.template radius<Float>();
1181template <
class Po
intType_,
class LabelType>
1182template <
class ResultNumber, DiskConcept OtherDisk>
1184 const OtherDisk& other)
const {
1185 using Float = detail::floating_result_t<ResultNumber>;
1189 return detail::diskExteriorSquaredDistance<Float>(other, *
this);
1192template <
class Po
intType_,
class TLabel>
1193template <
class ResultNumber, Po
intConcept OtherPo
int>
1195 const OtherPoint& point)
const {
1196 using Float = detail::floating_result_t<ResultNumber>;
1210template <
class Po
intType_,
class TLabel>
1211template <
class ResultNumber, SegmentConcept OtherSegment>
1213 const OtherSegment& other)
const {
1214 using Float = detail::floating_result_t<ResultNumber>;
1218 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1221template <
class Po
intType_,
class TLabel>
1222template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
1224 const OtherOrientedSegment& other)
const {
1225 using Float = detail::floating_result_t<ResultNumber>;
1229 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1232template <
class Po
intType_,
class TLabel>
1233template <
class ResultNumber, LineConcept OtherLine>
1235 const OtherLine& other)
const {
1236 using Float = detail::floating_result_t<ResultNumber>;
1240 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1243template <
class Po
intType_,
class TLabel>
1244template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
1246 const OtherOrientedLine& other)
const {
1247 using Float = detail::floating_result_t<ResultNumber>;
1251 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1254template <
class Po
intType_,
class TLabel>
1255template <
class ResultNumber, RayConcept OtherRay>
1257 const OtherRay& other)
const {
1258 using Float = detail::floating_result_t<ResultNumber>;
1262 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1265template <
class Po
intType_,
class TLabel>
1266template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
1268 const OtherHalfplane& other)
const {
1269 using Float = detail::floating_result_t<ResultNumber>;
1273 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1276template <
class Po
intType_,
class TLabel>
1277template <
class ResultNumber, RectangleConcept OtherRectangle>
1279 const OtherRectangle& other)
const {
1280 using Float = detail::floating_result_t<ResultNumber>;
1284 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1287template <
class Po
intType_,
class TLabel>
1288template <
class ResultNumber, TriangleConcept OtherTriangle>
1290 const OtherTriangle& other)
const {
1291 using Float = detail::floating_result_t<ResultNumber>;
1295 return detail::diskExteriorSquaredDistance<Float>(*
this, other);
1298template <
class Po
intType_,
class TLabel>
1299template <
class ResultNumber, DiskConcept OtherDisk>
1301 const OtherDisk& other)
const {
1302 using Float = detail::floating_result_t<ResultNumber>;
1319template <
class Po
intType_,
class TLabel>
1320template <
class ResultNumber,
class OtherShape>
1321constexpr ResultNumber Polygon<PointType_, TLabel>::edgeMinSquaredDistance(
const OtherShape& other)
const {
1322 const auto boundaryEdges = edges();
1323 ResultNumber best = boundaryEdges[0].template squaredDistance<ResultNumber>(other);
1324 for (std::size_t index = 1; index < boundaryEdges.size(); ++index) {
1325 const ResultNumber current = boundaryEdges[index].template squaredDistance<ResultNumber>(other);
1326 if (current < best) {
1333template <
class Po
intType_,
class TLabel>
1334template <
class ResultNumber, Po
intConcept OtherPo
int>
1337 return ResultNumber{};
1339 return this->
template edgeMinSquaredDistance<ResultNumber>(point);
1342template <
class Po
intType_,
class TLabel>
1343template <
class ResultNumber, SegmentConcept OtherSegment>
1346 return ResultNumber{};
1348 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1351template <
class Po
intType_,
class TLabel>
1352template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
1355 return ResultNumber{};
1357 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1360template <
class Po
intType_,
class TLabel>
1361template <
class ResultNumber, LineConcept OtherLine>
1364 return ResultNumber{};
1366 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1369template <
class Po
intType_,
class TLabel>
1370template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
1373 return ResultNumber{};
1375 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1378template <
class Po
intType_,
class TLabel>
1379template <
class ResultNumber, RayConcept OtherRay>
1382 return ResultNumber{};
1384 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1387template <
class Po
intType_,
class TLabel>
1388template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
1391 return ResultNumber{};
1393 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1396template <
class Po
intType_,
class TLabel>
1397template <
class ResultNumber, RectangleConcept OtherRectangle>
1400 return ResultNumber{};
1402 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1405template <
class Po
intType_,
class TLabel>
1406template <
class ResultNumber, TriangleConcept OtherTriangle>
1409 return ResultNumber{};
1411 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1414template <
class Po
intType_,
class TLabel>
1415template <
class ResultNumber, ConvexConcept OtherConvex>
1418 return ResultNumber{};
1420 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1423template <
class Po
intType_,
class TLabel>
1424template <
class ResultNumber, PolygonConcept OtherPolygon>
1427 return ResultNumber{};
1429 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1432template <
class Po
intType_,
class TLabel>
1433template <
class ResultNumber,
class DiskPo
intType,
class DiskLabel>
1436 using Float = detail::floating_result_t<ResultNumber>;
1440 return detail::diskExteriorSquaredDistance<Float>(disk, *
this);
1443template <
class Po
intType_,
class TLabel>
1444template <
class ResultNumber, MonotoneChainConcept OtherChain>
1447 return ResultNumber{};
1449 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1455template <
class Po
intType,
class LabelType,
class Storage>
1456template <
class ResultNumber,
class OtherShape>
1457constexpr ResultNumber MonotoneChain<PointType, LabelType, Storage>::edgeMinSquaredDistance(
const OtherShape& other)
const {
1458 assert(size() >= 1);
1462 return (*
this)[0].template squaredDistance<ResultNumber>(other);
1464 ResultNumber best = this->
template boundaryAt<false>(0).template squaredDistance<ResultNumber>(other);
1465 for (std::size_t index = 1; index + 1 < size(); ++index) {
1466 const ResultNumber current =
1467 this->
template boundaryAt<false>(index).template squaredDistance<ResultNumber>(other);
1468 if (current < best) {
1475template <
class Po
intType,
class LabelType,
class Storage>
1476template <
class ResultNumber, Po
intConcept OtherPo
int>
1479 return ResultNumber{};
1481 return this->
template edgeMinSquaredDistance<ResultNumber>(point);
1484template <
class Po
intType,
class LabelType,
class Storage>
1485template <
class ResultNumber, SegmentConcept OtherSegment>
1488 return ResultNumber{};
1490 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1493template <
class Po
intType,
class LabelType,
class Storage>
1494template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
1497 return ResultNumber{};
1499 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1502template <
class Po
intType,
class LabelType,
class Storage>
1503template <
class ResultNumber, LineConcept OtherLine>
1506 return ResultNumber{};
1508 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1511template <
class Po
intType,
class LabelType,
class Storage>
1512template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
1515 return ResultNumber{};
1517 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1520template <
class Po
intType,
class LabelType,
class Storage>
1521template <
class ResultNumber, RayConcept OtherRay>
1524 return ResultNumber{};
1526 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1529template <
class Po
intType,
class LabelType,
class Storage>
1530template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
1533 return ResultNumber{};
1535 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1538template <
class Po
intType,
class LabelType,
class Storage>
1539template <
class ResultNumber, RectangleConcept OtherRectangle>
1542 return ResultNumber{};
1544 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1547template <
class Po
intType,
class LabelType,
class Storage>
1548template <
class ResultNumber, TriangleConcept OtherTriangle>
1551 return ResultNumber{};
1553 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1556template <
class Po
intType,
class LabelType,
class Storage>
1557template <
class ResultNumber, ConvexConcept OtherConvex>
1560 return ResultNumber{};
1562 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1565template <
class Po
intType,
class LabelType,
class Storage>
1566template <
class ResultNumber, MonotoneChainConcept OtherChain>
1569 return ResultNumber{};
1571 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1574template <
class Po
intType,
class LabelType,
class Storage>
1575template <
class ResultNumber,
class DiskPo
intType,
class DiskLabel>
1578 using Float = detail::floating_result_t<ResultNumber>;
1582 return detail::diskExteriorSquaredDistance<Float>(disk, *
this);
1588template <
class Po
intType,
class LabelType>
1589template <
class ResultNumber,
class OtherShape>
1590constexpr ResultNumber Polyline<PointType, LabelType>::edgeMinSquaredDistance(
const OtherShape& other)
const {
1591 assert(size() >= 1);
1595 return (*
this)[0].template squaredDistance<ResultNumber>(other);
1597 ResultNumber best = this->
template boundaryAt<false>(0).template squaredDistance<ResultNumber>(other);
1598 for (std::size_t index = 1; index + 1 < size(); ++index) {
1599 const ResultNumber current =
1600 this->
template boundaryAt<false>(index).template squaredDistance<ResultNumber>(other);
1601 if (current < best) {
1608template <
class Po
intType,
class LabelType>
1609template <
class ResultNumber, Po
intConcept OtherPo
int>
1612 return ResultNumber{};
1614 return this->
template edgeMinSquaredDistance<ResultNumber>(point);
1617template <
class Po
intType,
class LabelType>
1618template <
class ResultNumber, SegmentConcept OtherSegment>
1621 return ResultNumber{};
1623 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1626template <
class Po
intType,
class LabelType>
1627template <
class ResultNumber, PolylineConcept OtherPolyline>
1630 return ResultNumber{};
1632 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1635template <
class Po
intType,
class LabelType>
1636template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
1639 return ResultNumber{};
1641 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1644template <
class Po
intType,
class LabelType>
1645template <
class ResultNumber, LineConcept OtherLine>
1648 return ResultNumber{};
1650 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1653template <
class Po
intType,
class LabelType>
1654template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
1657 return ResultNumber{};
1659 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1662template <
class Po
intType,
class LabelType>
1663template <
class ResultNumber, RayConcept OtherRay>
1666 return ResultNumber{};
1668 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1671template <
class Po
intType,
class LabelType>
1672template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
1675 return ResultNumber{};
1677 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1680template <
class Po
intType,
class LabelType>
1681template <
class ResultNumber, RectangleConcept OtherRectangle>
1684 return ResultNumber{};
1686 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1689template <
class Po
intType,
class LabelType>
1690template <
class ResultNumber, TriangleConcept OtherTriangle>
1693 return ResultNumber{};
1695 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1698template <
class Po
intType,
class LabelType>
1699template <
class ResultNumber, ConvexConcept OtherConvex>
1702 return ResultNumber{};
1704 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1707template <
class Po
intType,
class LabelType>
1708template <
class ResultNumber, MonotoneChainConcept OtherChain>
1711 return ResultNumber{};
1713 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1716template <
class Po
intType,
class LabelType>
1717template <
class ResultNumber,
class DiskPo
intType,
class DiskLabel>
1720 using Float = detail::floating_result_t<ResultNumber>;
1724 return detail::diskExteriorSquaredDistance<Float>(disk, *
this);
1727template <
class Po
intType_,
class TLabel>
1728template <
class ResultNumber, PolylineConcept OtherPolyline>
1731 return ResultNumber{};
1733 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1749template <
class ResultNumber,
class Region,
class Other>
1750constexpr ResultNumber regionEdgesSquaredDistance(
const Region& region,
const Other& other) {
1751 ResultNumber best{};
1753 for (std::size_t i = 0; i < region.size(); ++i) {
1754 const ResultNumber current = std::visit(
1755 [&other](
const auto& piece) {
1756 return static_cast<ResultNumber
>(piece.template squaredDistance<ResultNumber>(other));
1759 if (!has || current < best) {
1769#define PGL_HPI_SQUARED_DISTANCE(ConceptName, ArgType) \
1770 template <class PointType, class LabelType> \
1771 template <class ResultNumber, ConceptName ArgType> \
1772 constexpr auto HalfplaneIntersection<PointType, LabelType>::squaredDistance( \
1773 const ArgType& other) const { \
1774 if (intersects(other)) { \
1775 return ResultNumber{}; \
1777 return detail::regionEdgesSquaredDistance<ResultNumber>(*this, other); \
1794#undef PGL_HPI_SQUARED_DISTANCE
1796template <
class Po
intType,
class LabelType>
1797template <
class ResultNumber, DiskConcept OtherDisk>
1798detail::floating_result_t<ResultNumber>
1800 using Float = detail::floating_result_t<ResultNumber>;
1806 using E = detail::region_exact_number_t<NumberType>;
1809 for (std::size_t i = 0; i <
size(); ++i) {
1810 const Float current = std::visit(
1813 if (!has || current < best) {
1821template <
class Po
intType,
class LabelType>
1822template <
class ResultNumber, HalfplaneIntersectionConcept OtherRegion>
1827 return ResultNumber{};
1829 return detail::regionEdgesSquaredDistance<ResultNumber>(*
this, other);
1839template <
class Po
intType,
class LabelType>
1840template <
class ResultNumber,
class OtherShape>
1841constexpr ResultNumber PolygonWithHoles<PointType, LabelType>::edgeMinSquaredDistance(
const OtherShape& other)
const {
1842 ResultNumber best{};
1843 bool seeded =
false;
1844 anyBoundaryEdge([&](
const auto&
edge) {
1845 const ResultNumber current =
edge.template squaredDistance<ResultNumber>(other);
1846 if (!seeded || current < best) {
1855template <
class Po
intType,
class LabelType>
1856template <
class ResultNumber, Po
intConcept OtherPo
int>
1859 return ResultNumber{};
1861 return this->
template edgeMinSquaredDistance<ResultNumber>(point);
1864template <
class Po
intType,
class LabelType>
1865template <
class ResultNumber, SegmentConcept OtherSegment>
1868 return ResultNumber{};
1870 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1873template <
class Po
intType,
class LabelType>
1874template <
class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
1877 return ResultNumber{};
1879 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1882template <
class Po
intType,
class LabelType>
1883template <
class ResultNumber, LineConcept OtherLine>
1886 return ResultNumber{};
1888 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1891template <
class Po
intType,
class LabelType>
1892template <
class ResultNumber, OrientedLineConcept OtherOrientedLine>
1895 return ResultNumber{};
1897 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1900template <
class Po
intType,
class LabelType>
1901template <
class ResultNumber, RayConcept OtherRay>
1904 return ResultNumber{};
1906 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1909template <
class Po
intType,
class LabelType>
1910template <
class ResultNumber, HalfplaneConcept OtherHalfplane>
1913 return ResultNumber{};
1915 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1918template <
class Po
intType,
class LabelType>
1919template <
class ResultNumber, RectangleConcept OtherRectangle>
1922 return ResultNumber{};
1924 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1927template <
class Po
intType,
class LabelType>
1928template <
class ResultNumber, TriangleConcept OtherTriangle>
1931 return ResultNumber{};
1933 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1936template <
class Po
intType,
class LabelType>
1937template <
class ResultNumber, ConvexConcept OtherConvex>
1940 return ResultNumber{};
1942 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1945template <
class Po
intType,
class LabelType>
1946template <
class ResultNumber, PolygonConcept OtherPolygon>
1949 return ResultNumber{};
1951 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1957template <
class Po
intType,
class LabelType>
1958template <
class ResultNumber, PolygonWithHolesConcept OtherRegion>
1961 return ResultNumber{};
1963 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1966template <
class Po
intType,
class LabelType>
1967template <
class ResultNumber, MonotoneChainConcept OtherChain>
1970 return ResultNumber{};
1972 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1975template <
class Po
intType,
class LabelType>
1976template <
class ResultNumber, PolylineConcept OtherPolyline>
1979 return ResultNumber{};
1981 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1987template <
class Po
intType,
class LabelType>
1988template <
class ResultNumber, HalfplaneIntersectionConcept OtherIntersection>
1991 return ResultNumber{};
1993 return this->
template edgeMinSquaredDistance<ResultNumber>(other);
1999template <
class Po
intType,
class LabelType>
2000template <
class ResultNumber, DiskConcept OtherDisk>
2001detail::floating_result_t<ResultNumber>
2003 using Float = detail::floating_result_t<ResultNumber>;
2004 if (other.isDegenerate()) {
2012 return detail::diskExteriorSquaredDistance<Float>(other, *
this);
2023template <
class Po
intType,
class LabelType>
2024template <
class ResultNumber, detail::SetOperandConcept OtherShape>
2031template <
class Po
intType,
class LabelType>
2032template <
class ResultNumber, PolygonSetConcept OtherSet>
2034 ResultNumber best{};
2035 bool seeded =
false;
2038 if (!seeded || current < best) {
Definition forward.hpp:315
Definition forward.hpp:312
Definition forward.hpp:309
Definition forward.hpp:320
Definition forward.hpp:310
Definition forward.hpp:308
Definition forward.hpp:306
Definition forward.hpp:316
Definition forward.hpp:321
Definition forward.hpp:311
Definition forward.hpp:313
Definition forward.hpp:307
Definition forward.hpp:314
#define PGL_HPI_SQUARED_DISTANCE(ConceptName, ArgType)
Definition distance.hpp:1769
Implementations of the 'intersection' predicate.
Definition arrangement.hpp:67
@ y
Definition intervaltree.hpp:24
@ x
Definition intervaltree.hpp:24
@ edge
Definition bitmatrix.hpp:37
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 orientationDeterminant(const Point< ANumber, ALabel > &a, const Point< BNumber, BLabel > &b, const Point< CNumber, CLabel > &c)
Returns the signed orientation determinant of three points.
Definition orientation.hpp:518
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:716
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 convex.hpp:289
constexpr auto squaredHausdorffDistance(const OtherPoint &point) const
Returns the squared Hausdorff distance to the given shape.
Definition distance.hpp:1110
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:791
constexpr std::vector< Segment< PointType > > edges() const
Returns the edges of the convex polygon.
Definition convex.hpp:529
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1135
size_t size() const
Returns the number of vertices in the convex polygon.
Definition convex.hpp:840
PointType_ PointType
Definition convex.hpp:171
Closed Euclidean disk stored by boundary points plus optional disk label.
Definition disk.hpp:66
constexpr Point< ResultNumber, PointLabelType > center() const
Returns the center (circumcenter of the three boundary points) in an explicitly chosen coordinate typ...
Definition disk.hpp:284
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:904
constexpr bool contains(const OtherPoint &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:1015
detail::floating_result_t< ResultNumber > squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance from this disk to a point.
Definition distance.hpp:1194
constexpr ResultNumber radius() const
Returns the radius.
Definition disk.hpp:333
constexpr auto squaredDistance(const OtherPoint &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1780
constexpr std::size_t size() const
Returns the number of stored (non-redundant) half-planes.
Definition halfplaneintersection.hpp:596
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1808
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:391
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:622
constexpr Line< PointType > asLine() const
Returns the boundary line without orientation.
Definition halfplane.hpp:318
constexpr const PointType & max() const
Returns the largest stored defining point.
Definition line.hpp:189
constexpr const PointType & min() const
Returns the smallest stored defining point.
Definition line.hpp:180
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:312
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:219
constexpr bool isDegenerate() const
Returns whether the defining points coincide.
Definition predicates.hpp:451
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1353
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1477
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:267
constexpr Line< PointType > asLine() const
Returns the line without orientation.
Definition orientedline.hpp:321
constexpr auto squaredHausdorffDistance(const OtherSegment &other) const
Returns the squared Hausdorff distance to another unordered segment.
Definition distance.hpp:197
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:178
Two-dimensional point with optional label payload.
Definition point.hpp:129
ApproximateNumber distance(const OtherPoint &other) const
Returns the Euclidean distance to another point.
Definition distance.hpp:69
constexpr auto distanceLInf(const OtherPoint &other) const
Returns the Chebyshev distance to another point.
Definition distance.hpp:83
constexpr auto squaredHausdorffDistance(const OtherPoint &other) const
Returns the squared Hausdorff distance to another point.
Definition distance.hpp:91
constexpr auto squaredDistance(const OtherPoint &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:61
static constexpr std::size_t size()
Definition point.hpp:246
constexpr const NumberType & x() const
Returns the x coordinate.
Definition point.hpp:193
constexpr auto distanceL1(const OtherPoint &other) const
Returns the Manhattan distance to another point.
Definition distance.hpp:75
auto squaredDistance(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:2025
constexpr const ComponentType & component(std::size_t index) const
Accesses a component by index.
Definition polygonset.hpp:271
PolygonWithHoles< PointType > ComponentType
Definition polygonset.hpp:169
constexpr bool intersects(const OtherPoint &point) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygonwithholes.hpp:1649
constexpr auto squaredDistance(const OtherPoint &point) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1857
constexpr auto squaredDistance(const OtherChain &other) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1445
constexpr bool intersects(const OtherChain &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1596
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:1620
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:1610
constexpr bool isDegenerate() const
Returns whether the defining points coincide.
Definition predicates.hpp:727
constexpr const PointType & target() const
Returns the second stored point defining the direction.
Definition ray.hpp:193
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:300
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:409
constexpr const PointType & source() const
Returns the source point of the ray.
Definition ray.hpp:181
constexpr auto squaredHausdorffDistance(const OtherRectangle &other) const
Returns the squared Hausdorff distance to another rectangle.
Definition distance.hpp:597
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:502
constexpr const PointType & min() const
Returns the minimum corner (min x, min y).
Definition rectangle.hpp:347
constexpr bool empty() const
Returns whether the rectangle is the empty set of points.
Definition rectangle.hpp:290
constexpr std::array< Segment< PointType >, 4 > edges() const
Returns the four edges as unordered segments.
Definition bounding.hpp:199
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:474
constexpr std::array< PointType, 4 > vertices() const
Returns the four vertices in counterclockwise order.
Definition bounding.hpp:188
constexpr std::ptrdiff_t index(const PointType &point) const
Returns the smallest index i with (*this)[i] == point, or -1 if no corner equals point.
Definition rectangle.hpp:330
constexpr const PointType & max() const
Returns the maximum corner (max x, max y).
Definition rectangle.hpp:359
Unoriented closed segment between two endpoints plus optional segment label.
Definition segment.hpp:58
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:48
constexpr const PointType & max() const
Returns the largest stored endpoint.
Definition segment.hpp:199
constexpr const PointType & min() const
Returns the smallest stored endpoint.
Definition segment.hpp:190
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:100
constexpr auto squaredHausdorffDistance(const OtherSegment &other) const
Returns the squared Hausdorff distance to another segment.
Definition distance.hpp:152
constexpr auto squaredHausdorffDistance(const OtherPoint &point) const
Returns the squared Hausdorff distance to the given shape.
Definition distance.hpp:751
constexpr auto squaredDistance(const OtherPoint &point) const
Returns the squared Euclidean distance to the given shape.
Definition distance.hpp:670
constexpr bool intersects(const OtherPoint &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:134