60 cout <<
"[Aleph Geometry Example] " << title <<
"\n";
61 cout <<
"============================================================\n";
68 case Orientation::CCW:
return "Counter-Clockwise";
69 case Orientation::CW:
return "Clockwise";
70 case Orientation::COLLINEAR:
return "Collinear";
79 case InCircleResult::INSIDE:
return "INSIDE";
80 case InCircleResult::ON_CIRCLE:
return "ON_CIRCLE";
81 case InCircleResult::OUTSIDE:
return "OUTSIDE";
82 case InCircleResult::DEGENERATE:
return "DEGENERATE";
92 cout <<
"=== Scenario 1: Orientation Classification ===" <<
endl;
94 cout <<
"Classifying triples of points as CCW, CW, or Collinear using" <<
endl;
95 cout <<
"exact rational arithmetic (no floating-point error)." <<
endl;
98 Point a(0, 0), b(4, 0), c(2, 3);
99 cout <<
" Triple (0,0)-(4,0)-(2,3): "
103 cout <<
" Triple (0,0)-(2,3)-(4,0): "
107 Point d(1, 1), e(2, 2), f(3, 3);
108 cout <<
" Triple (1,1)-(2,2)-(3,3): "
120 cout <<
"=== Scenario 2: Segment Intersection Detection ===" <<
endl;
126 cout <<
" X-cross (0,0)-(4,4) vs (0,4)-(4,0): "
133 cout <<
" T-shaped (0,0)-(6,0) vs (3,0)-(3,5): "
140 cout <<
" Parallel (0,0)-(4,0) vs (0,2)-(4,2): "
147 cout <<
" Collinear overlap (0,0)-(3,0) vs (2,0)-(5,0): "
154 cout <<
" Disjoint (0,0)-(1,1) vs (5,5)-(6,7): "
159 cout <<
" 4-point API (0,0)-(2,2) vs (0,2)-(2,0): "
161 ?
"INTERSECT" :
"no") <<
endl;
172 cout <<
"=== Scenario 3: Exact Intersection Points ===" <<
endl;
174 cout <<
"All intersection points are computed in exact rational arithmetic" <<
endl;
175 cout <<
"(mpq_class), so there is no floating-point rounding error." <<
endl;
182 cout <<
" (0,0)-(2,2) x (0,2)-(2,0) = " << p1.
to_string() <<
endl;
189 cout <<
" (0,0)-(3,0) x (1,1)-(2,-1) = " << p2.
to_string()
190 <<
" [exact: x=" << p2.
get_x() <<
"]" <<
endl;
198 cout <<
" (0,0)-(7,2) x (0,3)-(3,0) = " << p3.
to_string()
199 <<
" [exact: x=" << p3.
get_x() <<
" y=" << p3.
get_y() <<
"]" <<
endl;
207 cout <<
" Vertical x=3 x diagonal y=x: " << p4.
to_string() <<
endl;
218 cout <<
"=== Scenario 4: Road Network Crossing Analysis ===" <<
endl;
220 cout <<
"Given a small network of road segments, detect which pairs cross." <<
endl;
234 const size_t n =
roads.size();
236 for (
size_t i = 0; i < n; ++i)
237 for (
size_t j = i + 1; j < n; ++j)
240 if (
roads[i].seg.is_parallel_with(
roads[j].seg))
242 cout <<
" " <<
roads[i].name <<
" overlaps with "
243 <<
roads[j].name <<
" (collinear)" <<
endl;
248 cout <<
" " <<
roads[i].name <<
" crosses " <<
roads[j].name
249 <<
" at " <<
ix.to_string() <<
endl;
264 cout <<
" All crossing points verified with exact arithmetic." <<
endl;
273 cout <<
"=== Scenario 5: in_circle() in a Delaunay Context ===" <<
endl;
275 cout <<
"Checking local Delaunay legality using exact in-circle predicates." <<
endl;
278 const Point a(0, 0), b(4, 0), c(0, 4);
287 assert(
r1 == InCircleResult::INSIDE);
288 assert(r2 == InCircleResult::OUTSIDE);
298 const auto dt = delaunay(
pts);
300 cout <<
" Delaunay triangles built from the same predicate logic: "
301 <<
dt.triangles.size() <<
endl;
318 cout <<
"All scenarios completed successfully." <<
endl;
319 cout <<
"STATUS: OK" <<
endl;
Simple dynamic array with automatic resizing and functional operations.
T & append(const T &data)
Append a copy of data
Exact Delaunay triangulation using the Bowyer-Watson incremental algorithm.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Represents a point with rectangular coordinates in a 2D plane.
const Geom_Number & get_x() const noexcept
Gets the x-coordinate value.
std::string to_string() const
Returns a string representation of the point as "(x,y)".
const Geom_Number & get_y() const noexcept
Gets the y-coordinate value.
Represents a line segment between two points.
Computational geometry algorithms.
Orientation
Classification of three-point orientation.
bool segments_intersect(const Segment &s1, const Segment &s2)
Return true if segments s1 and s2 intersect (including endpoints).
InCircleResult in_circle(const Point &a, const Point &b, const Point &c, const Point &p)
Classify point p against circumcircle of triangle (a,b,c), exactly.
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.
Point segment_intersection_point(const Segment &s1, const Segment &s2)
Compute the exact intersection point of segments s1 and s2.
InCircleResult
Classification of a point with respect to a triangle circumcircle.
Orientation orientation(const Point &a, const Point &b, const Point &c)
Return the orientation of the triple (a, b, c).
2D point and geometric utilities.
void scenario_in_circle_in_delaunay_context()
void scenario_exact_intersection()
void scenario_orientation()
void scenario_intersection_detection()
static const char * in_circle_str(InCircleResult r)
static void print_banner(const char *title)
static const char * orientation_str(Orientation o)
void scenario_road_network()