55 case SegmentSegmentIntersection::Kind::NONE:
return "NONE";
56 case SegmentSegmentIntersection::Kind::POINT:
return "POINT";
57 case SegmentSegmentIntersection::Kind::OVERLAP:
return "OVERLAP";
67 cout <<
"Case: " << name <<
'\n';
74 if (result.
kind == SegmentSegmentIntersection::Kind::POINT)
76 else if (result.
kind == SegmentSegmentIntersection::Kind::OVERLAP)
87 cout <<
"[Aleph Geometry Example] Dedicated O(1) Segment-Segment Intersection\n";
88 cout <<
"====================================================================\n\n";
96 const auto result =
pair_ix(a, b);
98 assert(result.kind == SegmentSegmentIntersection::Kind::POINT);
106 const auto result =
pair_ix(a, b);
107 print_case(
"Endpoint touching", a, b, result);
108 assert(result.kind == SegmentSegmentIntersection::Kind::POINT);
116 const auto result =
pair_ix(a, b);
117 print_case(
"Collinear overlap", a, b, result);
118 assert(result.kind == SegmentSegmentIntersection::Kind::OVERLAP);
119 assert(result.overlap.get_src_point() ==
Point(2, 0));
120 assert(result.overlap.get_tgt_point() ==
Point(5, 0));
127 const auto result =
pair_ix(a, b);
129 assert(result.kind == SegmentSegmentIntersection::Kind::NONE);
138 print_case(
"Free function exact rational", a, b, result);
139 assert(result.kind == SegmentSegmentIntersection::Kind::POINT);
144 cout <<
"STATUS: OK\n";
Represents a point with rectangular coordinates in a 2D plane.
std::string to_string() const
Returns a string representation of the point as "(x,y)".
Dedicated exact intersection for a single pair of segments.
Kind
Types of intersection between two segments.
Represents a line segment between two points.
const Point & get_tgt_point() const noexcept
Gets the target point of the segment.
const Point & get_src_point() const noexcept
Gets the source point of the segment.
Computational geometry algorithms.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
SegmentSegmentIntersection::Result segment_segment_intersection(const Segment &s1, const Segment &s2)
Convenience free-function wrapper for SegmentSegmentIntersection.
static void print_case(const char *name, const Segment &a, const Segment &b, const SegmentSegmentIntersection::Result &result)
static const char * kind_str(SegmentSegmentIntersection::Kind kind)
Detailed result of a segment-segment intersection test.
Point point
The intersection point (if kind is POINT).
Segment overlap
The overlap segment (if kind is OVERLAP).
Kind kind
Type of intersection.