54 cout <<
"[Aleph Geometry Example] " << title <<
"\n";
55 cout <<
"============================================================\n";
62 for (
auto it = pts.
get_it(); it.has_curr(); it.next_ne())
65 assert(arr.
size() >= 2);
66 Geom_Number best = arr(0).distance_squared_to(arr(1));
70 for (
size_t i = 0; i < arr.
size(); ++i)
71 for (
size_t j = i + 1; j < arr.
size(); ++j)
72 if (
const Geom_Number d2 = arr(i).distance_squared_to(arr(j)); d2 < best)
97 const auto r = cp(pts);
99 cout <<
"Closest pair: (" <<
r.first.get_x() <<
", " <<
r.first.get_y() <<
") and "
100 <<
"(" <<
r.second.get_x() <<
", " <<
r.second.get_y() <<
")" << endl;
101 cout <<
"distance^2 = " <<
r.distance_squared << endl;
105 cout <<
"Brute-force distance^2 = " << brute_d2 << endl;
107 assert(
r.distance_squared == brute_d2);
108 cout <<
"Validation OK: divide-and-conquer matches brute force." << endl;
114 const auto r_dup = cp(dup);
115 assert(r_dup.distance_squared == 0);
116 cout <<
"Duplicate-point scenario validated: distance^2 = 0." << endl;
117 cout <<
"STATUS: OK" << endl;
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
T & append(const T &data)
Append a copy of data
Closest pair of points via divide and conquer.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Represents a point with rectangular coordinates in a 2D plane.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
static void print_banner(const char *title)
static Geom_Number brute_distance_squared(const DynList< Point > &pts, Point &out_a, Point &out_b)
Computational geometry algorithms.
Main namespace for Aleph-w library functions.