]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/polygon/detail/voronoi_predicates.hpp
b6314d35901871405fd5e8e18ca41da35c88bb51
[ceph.git] / ceph / src / boost / boost / polygon / detail / voronoi_predicates.hpp
1 // Boost.Polygon library detail/voronoi_predicates.hpp header file
2
3 // Copyright Andrii Sydorchuk 2010-2012.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7
8 // See http://www.boost.org for updates, documentation, and revision history.
9
10 #ifndef BOOST_POLYGON_DETAIL_VORONOI_PREDICATES
11 #define BOOST_POLYGON_DETAIL_VORONOI_PREDICATES
12
13 #include <utility>
14
15 #include "voronoi_robust_fpt.hpp"
16
17 namespace boost {
18 namespace polygon {
19 namespace detail {
20
21 // Predicate utilities. Operates with the coordinate types that could
22 // be converted to the 32-bit signed integer without precision loss.
23 template <typename CTYPE_TRAITS>
24 class voronoi_predicates {
25 public:
26 typedef typename CTYPE_TRAITS::int_type int_type;
27 typedef typename CTYPE_TRAITS::int_x2_type int_x2_type;
28 typedef typename CTYPE_TRAITS::uint_x2_type uint_x2_type;
29 typedef typename CTYPE_TRAITS::big_int_type big_int_type;
30 typedef typename CTYPE_TRAITS::fpt_type fpt_type;
31 typedef typename CTYPE_TRAITS::efpt_type efpt_type;
32 typedef typename CTYPE_TRAITS::ulp_cmp_type ulp_cmp_type;
33 typedef typename CTYPE_TRAITS::to_fpt_converter_type to_fpt_converter;
34 typedef typename CTYPE_TRAITS::to_efpt_converter_type to_efpt_converter;
35
36 enum {
37 ULPS = 64,
38 ULPSx2 = 128
39 };
40
41 template <typename Point>
42 static bool is_vertical(const Point& point1, const Point& point2) {
43 return point1.x() == point2.x();
44 }
45
46 template <typename Site>
47 static bool is_vertical(const Site& site) {
48 return is_vertical(site.point0(), site.point1());
49 }
50
51 // Compute robust cross_product: a1 * b2 - b1 * a2.
52 // It was mathematically proven that the result is correct
53 // with epsilon relative error equal to 1EPS.
54 static fpt_type robust_cross_product(int_x2_type a1_,
55 int_x2_type b1_,
56 int_x2_type a2_,
57 int_x2_type b2_) {
58 static to_fpt_converter to_fpt;
59 uint_x2_type a1 = static_cast<uint_x2_type>(is_neg(a1_) ? -a1_ : a1_);
60 uint_x2_type b1 = static_cast<uint_x2_type>(is_neg(b1_) ? -b1_ : b1_);
61 uint_x2_type a2 = static_cast<uint_x2_type>(is_neg(a2_) ? -a2_ : a2_);
62 uint_x2_type b2 = static_cast<uint_x2_type>(is_neg(b2_) ? -b2_ : b2_);
63
64 uint_x2_type l = a1 * b2;
65 uint_x2_type r = b1 * a2;
66
67 if (is_neg(a1_) ^ is_neg(b2_)) {
68 if (is_neg(a2_) ^ is_neg(b1_))
69 return (l > r) ? -to_fpt(l - r) : to_fpt(r - l);
70 else
71 return -to_fpt(l + r);
72 } else {
73 if (is_neg(a2_) ^ is_neg(b1_))
74 return to_fpt(l + r);
75 else
76 return (l < r) ? -to_fpt(r - l) : to_fpt(l - r);
77 }
78 }
79
80 struct orientation_test {
81 public:
82 // Represents orientation test result.
83 enum Orientation {
84 RIGHT = -1,
85 COLLINEAR = 0,
86 LEFT = 1
87 };
88
89 // Value is a determinant of two vectors (e.g. x1 * y2 - x2 * y1).
90 // Return orientation based on the sign of the determinant.
91 template <typename T>
92 static Orientation eval(T value) {
93 if (is_zero(value)) return COLLINEAR;
94 return (is_neg(value)) ? RIGHT : LEFT;
95 }
96
97 static Orientation eval(int_x2_type dif_x1_,
98 int_x2_type dif_y1_,
99 int_x2_type dif_x2_,
100 int_x2_type dif_y2_) {
101 return eval(robust_cross_product(dif_x1_, dif_y1_, dif_x2_, dif_y2_));
102 }
103
104 template <typename Point>
105 static Orientation eval(const Point& point1,
106 const Point& point2,
107 const Point& point3) {
108 int_x2_type dx1 = static_cast<int_x2_type>(point1.x()) -
109 static_cast<int_x2_type>(point2.x());
110 int_x2_type dx2 = static_cast<int_x2_type>(point2.x()) -
111 static_cast<int_x2_type>(point3.x());
112 int_x2_type dy1 = static_cast<int_x2_type>(point1.y()) -
113 static_cast<int_x2_type>(point2.y());
114 int_x2_type dy2 = static_cast<int_x2_type>(point2.y()) -
115 static_cast<int_x2_type>(point3.y());
116 return eval(robust_cross_product(dx1, dy1, dx2, dy2));
117 }
118 };
119 typedef orientation_test ot;
120
121 template <typename Point>
122 class point_comparison_predicate {
123 public:
124 typedef Point point_type;
125
126 bool operator()(const point_type& lhs, const point_type& rhs) const {
127 if (lhs.x() == rhs.x())
128 return lhs.y() < rhs.y();
129 return lhs.x() < rhs.x();
130 }
131 };
132
133 template <typename Site, typename Circle>
134 class event_comparison_predicate {
135 public:
136 typedef Site site_type;
137 typedef Circle circle_type;
138
139 bool operator()(const site_type& lhs, const site_type& rhs) const {
140 if (lhs.x0() != rhs.x0())
141 return lhs.x0() < rhs.x0();
142 if (!lhs.is_segment()) {
143 if (!rhs.is_segment())
144 return lhs.y0() < rhs.y0();
145 if (is_vertical(rhs))
146 return lhs.y0() <= rhs.y0();
147 return true;
148 } else {
149 if (is_vertical(rhs)) {
150 if (is_vertical(lhs))
151 return lhs.y0() < rhs.y0();
152 return false;
153 }
154 if (is_vertical(lhs))
155 return true;
156 if (lhs.y0() != rhs.y0())
157 return lhs.y0() < rhs.y0();
158 return ot::eval(lhs.point1(), lhs.point0(), rhs.point1()) == ot::LEFT;
159 }
160 }
161
162 bool operator()(const site_type& lhs, const circle_type& rhs) const {
163 typename ulp_cmp_type::Result xCmp =
164 ulp_cmp(to_fpt(lhs.x0()), to_fpt(rhs.lower_x()), ULPS);
165 return xCmp == ulp_cmp_type::LESS;
166 }
167
168 bool operator()(const circle_type& lhs, const site_type& rhs) const {
169 typename ulp_cmp_type::Result xCmp =
170 ulp_cmp(to_fpt(lhs.lower_x()), to_fpt(rhs.x0()), ULPS);
171 return xCmp == ulp_cmp_type::LESS;
172 }
173
174 bool operator()(const circle_type& lhs, const circle_type& rhs) const {
175 if (lhs.lower_x() != rhs.lower_x()) {
176 return lhs.lower_x() < rhs.lower_x();
177 }
178 return lhs.y() < rhs.y();
179 }
180
181 private:
182 ulp_cmp_type ulp_cmp;
183 to_fpt_converter to_fpt;
184 };
185
186 template <typename Site>
187 class distance_predicate {
188 public:
189 typedef Site site_type;
190 typedef typename site_type::point_type point_type;
191
192 // Returns true if a horizontal line going through a new site intersects
193 // right arc at first, else returns false. If horizontal line goes
194 // through intersection point of the given two arcs returns false also.
195 bool operator()(const site_type& left_site,
196 const site_type& right_site,
197 const point_type& new_point) const {
198 if (!left_site.is_segment()) {
199 if (!right_site.is_segment()) {
200 return pp(left_site, right_site, new_point);
201 } else {
202 return ps(left_site, right_site, new_point, false);
203 }
204 } else {
205 if (!right_site.is_segment()) {
206 return ps(right_site, left_site, new_point, true);
207 } else {
208 return ss(left_site, right_site, new_point);
209 }
210 }
211 }
212
213 private:
214 // Represents the result of the epsilon robust predicate. If the
215 // result is undefined some further processing is usually required.
216 enum kPredicateResult {
217 LESS = -1,
218 UNDEFINED = 0,
219 MORE = 1
220 };
221
222 // Robust predicate, avoids using high-precision libraries.
223 // Returns true if a horizontal line going through the new point site
224 // intersects right arc at first, else returns false. If horizontal line
225 // goes through intersection point of the given two arcs returns false.
226 bool pp(const site_type& left_site,
227 const site_type& right_site,
228 const point_type& new_point) const {
229 const point_type& left_point = left_site.point0();
230 const point_type& right_point = right_site.point0();
231 if (left_point.x() > right_point.x()) {
232 if (new_point.y() <= left_point.y())
233 return false;
234 } else if (left_point.x() < right_point.x()) {
235 if (new_point.y() >= right_point.y())
236 return true;
237 } else {
238 return static_cast<int_x2_type>(left_point.y()) +
239 static_cast<int_x2_type>(right_point.y()) <
240 static_cast<int_x2_type>(new_point.y()) * 2;
241 }
242
243 fpt_type dist1 = find_distance_to_point_arc(left_site, new_point);
244 fpt_type dist2 = find_distance_to_point_arc(right_site, new_point);
245
246 // The undefined ulp range is equal to 3EPS + 3EPS <= 6ULP.
247 return dist1 < dist2;
248 }
249
250 bool ps(const site_type& left_site, const site_type& right_site,
251 const point_type& new_point, bool reverse_order) const {
252 kPredicateResult fast_res = fast_ps(
253 left_site, right_site, new_point, reverse_order);
254 if (fast_res != UNDEFINED) {
255 return fast_res == LESS;
256 }
257
258 fpt_type dist1 = find_distance_to_point_arc(left_site, new_point);
259 fpt_type dist2 = find_distance_to_segment_arc(right_site, new_point);
260
261 // The undefined ulp range is equal to 3EPS + 7EPS <= 10ULP.
262 return reverse_order ^ (dist1 < dist2);
263 }
264
265 bool ss(const site_type& left_site,
266 const site_type& right_site,
267 const point_type& new_point) const {
268 // Handle temporary segment sites.
269 if (left_site.sorted_index() == right_site.sorted_index()) {
270 return ot::eval(
271 left_site.point0(), left_site.point1(), new_point) == ot::LEFT;
272 }
273
274 fpt_type dist1 = find_distance_to_segment_arc(left_site, new_point);
275 fpt_type dist2 = find_distance_to_segment_arc(right_site, new_point);
276
277 // The undefined ulp range is equal to 7EPS + 7EPS <= 14ULP.
278 return dist1 < dist2;
279 }
280
281 fpt_type find_distance_to_point_arc(
282 const site_type& site, const point_type& point) const {
283 fpt_type dx = to_fpt(site.x()) - to_fpt(point.x());
284 fpt_type dy = to_fpt(site.y()) - to_fpt(point.y());
285 // The relative error is at most 3EPS.
286 return (dx * dx + dy * dy) / (to_fpt(2.0) * dx);
287 }
288
289 fpt_type find_distance_to_segment_arc(
290 const site_type& site, const point_type& point) const {
291 if (is_vertical(site)) {
292 return (to_fpt(site.x()) - to_fpt(point.x())) * to_fpt(0.5);
293 } else {
294 const point_type& segment0 = site.point0();
295 const point_type& segment1 = site.point1();
296 fpt_type a1 = to_fpt(segment1.x()) - to_fpt(segment0.x());
297 fpt_type b1 = to_fpt(segment1.y()) - to_fpt(segment0.y());
298 fpt_type k = get_sqrt(a1 * a1 + b1 * b1);
299 // Avoid subtraction while computing k.
300 if (!is_neg(b1)) {
301 k = to_fpt(1.0) / (b1 + k);
302 } else {
303 k = (k - b1) / (a1 * a1);
304 }
305 // The relative error is at most 7EPS.
306 return k * robust_cross_product(
307 static_cast<int_x2_type>(segment1.x()) -
308 static_cast<int_x2_type>(segment0.x()),
309 static_cast<int_x2_type>(segment1.y()) -
310 static_cast<int_x2_type>(segment0.y()),
311 static_cast<int_x2_type>(point.x()) -
312 static_cast<int_x2_type>(segment0.x()),
313 static_cast<int_x2_type>(point.y()) -
314 static_cast<int_x2_type>(segment0.y()));
315 }
316 }
317
318 kPredicateResult fast_ps(
319 const site_type& left_site, const site_type& right_site,
320 const point_type& new_point, bool reverse_order) const {
321 const point_type& site_point = left_site.point0();
322 const point_type& segment_start = right_site.point0();
323 const point_type& segment_end = right_site.point1();
324
325 if (ot::eval(segment_start, segment_end, new_point) != ot::RIGHT)
326 return (!right_site.is_inverse()) ? LESS : MORE;
327
328 fpt_type dif_x = to_fpt(new_point.x()) - to_fpt(site_point.x());
329 fpt_type dif_y = to_fpt(new_point.y()) - to_fpt(site_point.y());
330 fpt_type a = to_fpt(segment_end.x()) - to_fpt(segment_start.x());
331 fpt_type b = to_fpt(segment_end.y()) - to_fpt(segment_start.y());
332
333 if (is_vertical(right_site)) {
334 if (new_point.y() < site_point.y() && !reverse_order)
335 return MORE;
336 else if (new_point.y() > site_point.y() && reverse_order)
337 return LESS;
338 return UNDEFINED;
339 } else {
340 typename ot::Orientation orientation = ot::eval(
341 static_cast<int_x2_type>(segment_end.x()) -
342 static_cast<int_x2_type>(segment_start.x()),
343 static_cast<int_x2_type>(segment_end.y()) -
344 static_cast<int_x2_type>(segment_start.y()),
345 static_cast<int_x2_type>(new_point.x()) -
346 static_cast<int_x2_type>(site_point.x()),
347 static_cast<int_x2_type>(new_point.y()) -
348 static_cast<int_x2_type>(site_point.y()));
349 if (orientation == ot::LEFT) {
350 if (!right_site.is_inverse())
351 return reverse_order ? LESS : UNDEFINED;
352 return reverse_order ? UNDEFINED : MORE;
353 }
354 }
355
356 fpt_type fast_left_expr = a * (dif_y + dif_x) * (dif_y - dif_x);
357 fpt_type fast_right_expr = (to_fpt(2.0) * b) * dif_x * dif_y;
358 typename ulp_cmp_type::Result expr_cmp =
359 ulp_cmp(fast_left_expr, fast_right_expr, 4);
360 if (expr_cmp != ulp_cmp_type::EQUAL) {
361 if ((expr_cmp == ulp_cmp_type::MORE) ^ reverse_order)
362 return reverse_order ? LESS : MORE;
363 return UNDEFINED;
364 }
365 return UNDEFINED;
366 }
367
368 private:
369 ulp_cmp_type ulp_cmp;
370 to_fpt_converter to_fpt;
371 };
372
373 template <typename Node>
374 class node_comparison_predicate {
375 public:
376 typedef Node node_type;
377 typedef typename Node::site_type site_type;
378 typedef typename site_type::point_type point_type;
379 typedef typename point_type::coordinate_type coordinate_type;
380 typedef point_comparison_predicate<point_type> point_comparison_type;
381 typedef distance_predicate<site_type> distance_predicate_type;
382
383 // Compares nodes in the balanced binary search tree. Nodes are
384 // compared based on the y coordinates of the arcs intersection points.
385 // Nodes with less y coordinate of the intersection point go first.
386 // Comparison is only called during the new site events processing.
387 // That's why one of the nodes will always lie on the sweepline and may
388 // be represented as a straight horizontal line.
389 bool operator() (const node_type& node1,
390 const node_type& node2) const {
391 // Get x coordinate of the rightmost site from both nodes.
392 const site_type& site1 = get_comparison_site(node1);
393 const site_type& site2 = get_comparison_site(node2);
394 const point_type& point1 = get_comparison_point(site1);
395 const point_type& point2 = get_comparison_point(site2);
396
397 if (point1.x() < point2.x()) {
398 // The second node contains a new site.
399 return distance_predicate_(
400 node1.left_site(), node1.right_site(), point2);
401 } else if (point1.x() > point2.x()) {
402 // The first node contains a new site.
403 return !distance_predicate_(
404 node2.left_site(), node2.right_site(), point1);
405 } else {
406 // This checks were evaluated experimentally.
407 if (site1.sorted_index() == site2.sorted_index()) {
408 // Both nodes are new (inserted during same site event processing).
409 return get_comparison_y(node1) < get_comparison_y(node2);
410 } else if (site1.sorted_index() < site2.sorted_index()) {
411 std::pair<coordinate_type, int> y1 = get_comparison_y(node1, false);
412 std::pair<coordinate_type, int> y2 = get_comparison_y(node2, true);
413 if (y1.first != y2.first) return y1.first < y2.first;
414 return (!site1.is_segment()) ? (y1.second < 0) : false;
415 } else {
416 std::pair<coordinate_type, int> y1 = get_comparison_y(node1, true);
417 std::pair<coordinate_type, int> y2 = get_comparison_y(node2, false);
418 if (y1.first != y2.first) return y1.first < y2.first;
419 return (!site2.is_segment()) ? (y2.second > 0) : true;
420 }
421 }
422 }
423
424 private:
425 // Get the newer site.
426 const site_type& get_comparison_site(const node_type& node) const {
427 if (node.left_site().sorted_index() > node.right_site().sorted_index()) {
428 return node.left_site();
429 }
430 return node.right_site();
431 }
432
433 const point_type& get_comparison_point(const site_type& site) const {
434 return point_comparison_(site.point0(), site.point1()) ?
435 site.point0() : site.point1();
436 }
437
438 // Get comparison pair: y coordinate and direction of the newer site.
439 std::pair<coordinate_type, int> get_comparison_y(
440 const node_type& node, bool is_new_node = true) const {
441 if (node.left_site().sorted_index() ==
442 node.right_site().sorted_index()) {
443 return std::make_pair(node.left_site().y0(), 0);
444 }
445 if (node.left_site().sorted_index() > node.right_site().sorted_index()) {
446 if (!is_new_node &&
447 node.left_site().is_segment() &&
448 is_vertical(node.left_site())) {
449 return std::make_pair(node.left_site().y0(), 1);
450 }
451 return std::make_pair(node.left_site().y1(), 1);
452 }
453 return std::make_pair(node.right_site().y0(), -1);
454 }
455
456 point_comparison_type point_comparison_;
457 distance_predicate_type distance_predicate_;
458 };
459
460 template <typename Site>
461 class circle_existence_predicate {
462 public:
463 typedef typename Site::point_type point_type;
464 typedef Site site_type;
465
466 bool ppp(const site_type& site1,
467 const site_type& site2,
468 const site_type& site3) const {
469 return ot::eval(site1.point0(),
470 site2.point0(),
471 site3.point0()) == ot::RIGHT;
472 }
473
474 bool pps(const site_type& site1,
475 const site_type& site2,
476 const site_type& site3,
477 int segment_index) const {
478 if (segment_index != 2) {
479 typename ot::Orientation orient1 = ot::eval(
480 site1.point0(), site2.point0(), site3.point0());
481 typename ot::Orientation orient2 = ot::eval(
482 site1.point0(), site2.point0(), site3.point1());
483 if (segment_index == 1 && site1.x0() >= site2.x0()) {
484 if (orient1 != ot::RIGHT)
485 return false;
486 } else if (segment_index == 3 && site2.x0() >= site1.x0()) {
487 if (orient2 != ot::RIGHT)
488 return false;
489 } else if (orient1 != ot::RIGHT && orient2 != ot::RIGHT) {
490 return false;
491 }
492 } else {
493 return (site3.point0() != site1.point0()) ||
494 (site3.point1() != site2.point0());
495 }
496 return true;
497 }
498
499 bool pss(const site_type& site1,
500 const site_type& site2,
501 const site_type& site3,
502 int point_index) const {
503 if (site2.sorted_index() == site3.sorted_index()) {
504 return false;
505 }
506 if (point_index == 2) {
507 if (!site2.is_inverse() && site3.is_inverse())
508 return false;
509 if (site2.is_inverse() == site3.is_inverse() &&
510 ot::eval(site2.point0(),
511 site1.point0(),
512 site3.point1()) != ot::RIGHT)
513 return false;
514 }
515 return true;
516 }
517
518 bool sss(const site_type& site1,
519 const site_type& site2,
520 const site_type& site3) const {
521 return (site1.sorted_index() != site2.sorted_index()) &&
522 (site2.sorted_index() != site3.sorted_index());
523 }
524 };
525
526 template <typename Site, typename Circle>
527 class mp_circle_formation_functor {
528 public:
529 typedef typename Site::point_type point_type;
530 typedef Site site_type;
531 typedef Circle circle_type;
532 typedef robust_sqrt_expr<big_int_type, efpt_type, to_efpt_converter>
533 robust_sqrt_expr_type;
534
535 void ppp(const site_type& site1,
536 const site_type& site2,
537 const site_type& site3,
538 circle_type& circle,
539 bool recompute_c_x = true,
540 bool recompute_c_y = true,
541 bool recompute_lower_x = true) {
542 big_int_type dif_x[3], dif_y[3], sum_x[2], sum_y[2];
543 dif_x[0] = static_cast<int_x2_type>(site1.x()) -
544 static_cast<int_x2_type>(site2.x());
545 dif_x[1] = static_cast<int_x2_type>(site2.x()) -
546 static_cast<int_x2_type>(site3.x());
547 dif_x[2] = static_cast<int_x2_type>(site1.x()) -
548 static_cast<int_x2_type>(site3.x());
549 dif_y[0] = static_cast<int_x2_type>(site1.y()) -
550 static_cast<int_x2_type>(site2.y());
551 dif_y[1] = static_cast<int_x2_type>(site2.y()) -
552 static_cast<int_x2_type>(site3.y());
553 dif_y[2] = static_cast<int_x2_type>(site1.y()) -
554 static_cast<int_x2_type>(site3.y());
555 sum_x[0] = static_cast<int_x2_type>(site1.x()) +
556 static_cast<int_x2_type>(site2.x());
557 sum_x[1] = static_cast<int_x2_type>(site2.x()) +
558 static_cast<int_x2_type>(site3.x());
559 sum_y[0] = static_cast<int_x2_type>(site1.y()) +
560 static_cast<int_x2_type>(site2.y());
561 sum_y[1] = static_cast<int_x2_type>(site2.y()) +
562 static_cast<int_x2_type>(site3.y());
563 fpt_type inv_denom = to_fpt(0.5) / to_fpt(static_cast<big_int_type>(
564 dif_x[0] * dif_y[1] - dif_x[1] * dif_y[0]));
565 big_int_type numer1 = dif_x[0] * sum_x[0] + dif_y[0] * sum_y[0];
566 big_int_type numer2 = dif_x[1] * sum_x[1] + dif_y[1] * sum_y[1];
567
568 if (recompute_c_x || recompute_lower_x) {
569 big_int_type c_x = numer1 * dif_y[1] - numer2 * dif_y[0];
570 circle.x(to_fpt(c_x) * inv_denom);
571
572 if (recompute_lower_x) {
573 // Evaluate radius of the circle.
574 big_int_type sqr_r = (dif_x[0] * dif_x[0] + dif_y[0] * dif_y[0]) *
575 (dif_x[1] * dif_x[1] + dif_y[1] * dif_y[1]) *
576 (dif_x[2] * dif_x[2] + dif_y[2] * dif_y[2]);
577 fpt_type r = get_sqrt(to_fpt(sqr_r));
578
579 // If c_x >= 0 then lower_x = c_x + r,
580 // else lower_x = (c_x * c_x - r * r) / (c_x - r).
581 // To guarantee epsilon relative error.
582 if (!is_neg(circle.x())) {
583 if (!is_neg(inv_denom)) {
584 circle.lower_x(circle.x() + r * inv_denom);
585 } else {
586 circle.lower_x(circle.x() - r * inv_denom);
587 }
588 } else {
589 big_int_type numer = c_x * c_x - sqr_r;
590 fpt_type lower_x = to_fpt(numer) * inv_denom / (to_fpt(c_x) + r);
591 circle.lower_x(lower_x);
592 }
593 }
594 }
595
596 if (recompute_c_y) {
597 big_int_type c_y = numer2 * dif_x[0] - numer1 * dif_x[1];
598 circle.y(to_fpt(c_y) * inv_denom);
599 }
600 }
601
602 // Recompute parameters of the circle event using high-precision library.
603 void pps(const site_type& site1,
604 const site_type& site2,
605 const site_type& site3,
606 int segment_index,
607 circle_type& c_event,
608 bool recompute_c_x = true,
609 bool recompute_c_y = true,
610 bool recompute_lower_x = true) {
611 big_int_type cA[4], cB[4];
612 big_int_type line_a = static_cast<int_x2_type>(site3.y1()) -
613 static_cast<int_x2_type>(site3.y0());
614 big_int_type line_b = static_cast<int_x2_type>(site3.x0()) -
615 static_cast<int_x2_type>(site3.x1());
616 big_int_type segm_len = line_a * line_a + line_b * line_b;
617 big_int_type vec_x = static_cast<int_x2_type>(site2.y()) -
618 static_cast<int_x2_type>(site1.y());
619 big_int_type vec_y = static_cast<int_x2_type>(site1.x()) -
620 static_cast<int_x2_type>(site2.x());
621 big_int_type sum_x = static_cast<int_x2_type>(site1.x()) +
622 static_cast<int_x2_type>(site2.x());
623 big_int_type sum_y = static_cast<int_x2_type>(site1.y()) +
624 static_cast<int_x2_type>(site2.y());
625 big_int_type teta = line_a * vec_x + line_b * vec_y;
626 big_int_type denom = vec_x * line_b - vec_y * line_a;
627
628 big_int_type dif0 = static_cast<int_x2_type>(site3.y1()) -
629 static_cast<int_x2_type>(site1.y());
630 big_int_type dif1 = static_cast<int_x2_type>(site1.x()) -
631 static_cast<int_x2_type>(site3.x1());
632 big_int_type A = line_a * dif1 - line_b * dif0;
633 dif0 = static_cast<int_x2_type>(site3.y1()) -
634 static_cast<int_x2_type>(site2.y());
635 dif1 = static_cast<int_x2_type>(site2.x()) -
636 static_cast<int_x2_type>(site3.x1());
637 big_int_type B = line_a * dif1 - line_b * dif0;
638 big_int_type sum_AB = A + B;
639
640 if (is_zero(denom)) {
641 big_int_type numer = teta * teta - sum_AB * sum_AB;
642 denom = teta * sum_AB;
643 cA[0] = denom * sum_x * 2 + numer * vec_x;
644 cB[0] = segm_len;
645 cA[1] = denom * sum_AB * 2 + numer * teta;
646 cB[1] = 1;
647 cA[2] = denom * sum_y * 2 + numer * vec_y;
648 fpt_type inv_denom = to_fpt(1.0) / to_fpt(denom);
649 if (recompute_c_x)
650 c_event.x(to_fpt(0.25) * to_fpt(cA[0]) * inv_denom);
651 if (recompute_c_y)
652 c_event.y(to_fpt(0.25) * to_fpt(cA[2]) * inv_denom);
653 if (recompute_lower_x) {
654 c_event.lower_x(to_fpt(0.25) * to_fpt(sqrt_expr_.eval2(cA, cB)) *
655 inv_denom / get_sqrt(to_fpt(segm_len)));
656 }
657 return;
658 }
659
660 big_int_type det = (teta * teta + denom * denom) * A * B * 4;
661 fpt_type inv_denom_sqr = to_fpt(1.0) / to_fpt(denom);
662 inv_denom_sqr *= inv_denom_sqr;
663
664 if (recompute_c_x || recompute_lower_x) {
665 cA[0] = sum_x * denom * denom + teta * sum_AB * vec_x;
666 cB[0] = 1;
667 cA[1] = (segment_index == 2) ? -vec_x : vec_x;
668 cB[1] = det;
669 if (recompute_c_x) {
670 c_event.x(to_fpt(0.5) * to_fpt(sqrt_expr_.eval2(cA, cB)) *
671 inv_denom_sqr);
672 }
673 }
674
675 if (recompute_c_y || recompute_lower_x) {
676 cA[2] = sum_y * denom * denom + teta * sum_AB * vec_y;
677 cB[2] = 1;
678 cA[3] = (segment_index == 2) ? -vec_y : vec_y;
679 cB[3] = det;
680 if (recompute_c_y) {
681 c_event.y(to_fpt(0.5) * to_fpt(sqrt_expr_.eval2(&cA[2], &cB[2])) *
682 inv_denom_sqr);
683 }
684 }
685
686 if (recompute_lower_x) {
687 cB[0] = cB[0] * segm_len;
688 cB[1] = cB[1] * segm_len;
689 cA[2] = sum_AB * (denom * denom + teta * teta);
690 cB[2] = 1;
691 cA[3] = (segment_index == 2) ? -teta : teta;
692 cB[3] = det;
693 c_event.lower_x(to_fpt(0.5) * to_fpt(sqrt_expr_.eval4(cA, cB)) *
694 inv_denom_sqr / get_sqrt(to_fpt(segm_len)));
695 }
696 }
697
698 // Recompute parameters of the circle event using high-precision library.
699 void pss(const site_type& site1,
700 const site_type& site2,
701 const site_type& site3,
702 int point_index,
703 circle_type& c_event,
704 bool recompute_c_x = true,
705 bool recompute_c_y = true,
706 bool recompute_lower_x = true) {
707 big_int_type a[2], b[2], c[2], cA[4], cB[4];
708 const point_type& segm_start1 = site2.point1();
709 const point_type& segm_end1 = site2.point0();
710 const point_type& segm_start2 = site3.point0();
711 const point_type& segm_end2 = site3.point1();
712 a[0] = static_cast<int_x2_type>(segm_end1.x()) -
713 static_cast<int_x2_type>(segm_start1.x());
714 b[0] = static_cast<int_x2_type>(segm_end1.y()) -
715 static_cast<int_x2_type>(segm_start1.y());
716 a[1] = static_cast<int_x2_type>(segm_end2.x()) -
717 static_cast<int_x2_type>(segm_start2.x());
718 b[1] = static_cast<int_x2_type>(segm_end2.y()) -
719 static_cast<int_x2_type>(segm_start2.y());
720 big_int_type orientation = a[1] * b[0] - a[0] * b[1];
721 if (is_zero(orientation)) {
722 fpt_type denom = to_fpt(2.0) * to_fpt(
723 static_cast<big_int_type>(a[0] * a[0] + b[0] * b[0]));
724 c[0] = b[0] * (static_cast<int_x2_type>(segm_start2.x()) -
725 static_cast<int_x2_type>(segm_start1.x())) -
726 a[0] * (static_cast<int_x2_type>(segm_start2.y()) -
727 static_cast<int_x2_type>(segm_start1.y()));
728 big_int_type dx = a[0] * (static_cast<int_x2_type>(site1.y()) -
729 static_cast<int_x2_type>(segm_start1.y())) -
730 b[0] * (static_cast<int_x2_type>(site1.x()) -
731 static_cast<int_x2_type>(segm_start1.x()));
732 big_int_type dy = b[0] * (static_cast<int_x2_type>(site1.x()) -
733 static_cast<int_x2_type>(segm_start2.x())) -
734 a[0] * (static_cast<int_x2_type>(site1.y()) -
735 static_cast<int_x2_type>(segm_start2.y()));
736 cB[0] = dx * dy;
737 cB[1] = 1;
738
739 if (recompute_c_y) {
740 cA[0] = b[0] * ((point_index == 2) ? 2 : -2);
741 cA[1] = a[0] * a[0] * (static_cast<int_x2_type>(segm_start1.y()) +
742 static_cast<int_x2_type>(segm_start2.y())) -
743 a[0] * b[0] * (static_cast<int_x2_type>(segm_start1.x()) +
744 static_cast<int_x2_type>(segm_start2.x()) -
745 static_cast<int_x2_type>(site1.x()) * 2) +
746 b[0] * b[0] * (static_cast<int_x2_type>(site1.y()) * 2);
747 fpt_type c_y = to_fpt(sqrt_expr_.eval2(cA, cB));
748 c_event.y(c_y / denom);
749 }
750
751 if (recompute_c_x || recompute_lower_x) {
752 cA[0] = a[0] * ((point_index == 2) ? 2 : -2);
753 cA[1] = b[0] * b[0] * (static_cast<int_x2_type>(segm_start1.x()) +
754 static_cast<int_x2_type>(segm_start2.x())) -
755 a[0] * b[0] * (static_cast<int_x2_type>(segm_start1.y()) +
756 static_cast<int_x2_type>(segm_start2.y()) -
757 static_cast<int_x2_type>(site1.y()) * 2) +
758 a[0] * a[0] * (static_cast<int_x2_type>(site1.x()) * 2);
759
760 if (recompute_c_x) {
761 fpt_type c_x = to_fpt(sqrt_expr_.eval2(cA, cB));
762 c_event.x(c_x / denom);
763 }
764
765 if (recompute_lower_x) {
766 cA[2] = is_neg(c[0]) ? -c[0] : c[0];
767 cB[2] = a[0] * a[0] + b[0] * b[0];
768 fpt_type lower_x = to_fpt(sqrt_expr_.eval3(cA, cB));
769 c_event.lower_x(lower_x / denom);
770 }
771 }
772 return;
773 }
774 c[0] = b[0] * segm_end1.x() - a[0] * segm_end1.y();
775 c[1] = a[1] * segm_end2.y() - b[1] * segm_end2.x();
776 big_int_type ix = a[0] * c[1] + a[1] * c[0];
777 big_int_type iy = b[0] * c[1] + b[1] * c[0];
778 big_int_type dx = ix - orientation * site1.x();
779 big_int_type dy = iy - orientation * site1.y();
780 if (is_zero(dx) && is_zero(dy)) {
781 fpt_type denom = to_fpt(orientation);
782 fpt_type c_x = to_fpt(ix) / denom;
783 fpt_type c_y = to_fpt(iy) / denom;
784 c_event = circle_type(c_x, c_y, c_x);
785 return;
786 }
787
788 big_int_type sign = ((point_index == 2) ? 1 : -1) *
789 (is_neg(orientation) ? 1 : -1);
790 cA[0] = a[1] * -dx + b[1] * -dy;
791 cA[1] = a[0] * -dx + b[0] * -dy;
792 cA[2] = sign;
793 cA[3] = 0;
794 cB[0] = a[0] * a[0] + b[0] * b[0];
795 cB[1] = a[1] * a[1] + b[1] * b[1];
796 cB[2] = a[0] * a[1] + b[0] * b[1];
797 cB[3] = (a[0] * dy - b[0] * dx) * (a[1] * dy - b[1] * dx) * -2;
798 fpt_type temp = to_fpt(
799 sqrt_expr_evaluator_pss4<big_int_type, efpt_type>(cA, cB));
800 fpt_type denom = temp * to_fpt(orientation);
801
802 if (recompute_c_y) {
803 cA[0] = b[1] * (dx * dx + dy * dy) - iy * (dx * a[1] + dy * b[1]);
804 cA[1] = b[0] * (dx * dx + dy * dy) - iy * (dx * a[0] + dy * b[0]);
805 cA[2] = iy * sign;
806 fpt_type cy = to_fpt(
807 sqrt_expr_evaluator_pss4<big_int_type, efpt_type>(cA, cB));
808 c_event.y(cy / denom);
809 }
810
811 if (recompute_c_x || recompute_lower_x) {
812 cA[0] = a[1] * (dx * dx + dy * dy) - ix * (dx * a[1] + dy * b[1]);
813 cA[1] = a[0] * (dx * dx + dy * dy) - ix * (dx * a[0] + dy * b[0]);
814 cA[2] = ix * sign;
815
816 if (recompute_c_x) {
817 fpt_type cx = to_fpt(
818 sqrt_expr_evaluator_pss4<big_int_type, efpt_type>(cA, cB));
819 c_event.x(cx / denom);
820 }
821
822 if (recompute_lower_x) {
823 cA[3] = orientation * (dx * dx + dy * dy) * (is_neg(temp) ? -1 : 1);
824 fpt_type lower_x = to_fpt(
825 sqrt_expr_evaluator_pss4<big_int_type, efpt_type>(cA, cB));
826 c_event.lower_x(lower_x / denom);
827 }
828 }
829 }
830
831 // Recompute parameters of the circle event using high-precision library.
832 void sss(const site_type& site1,
833 const site_type& site2,
834 const site_type& site3,
835 circle_type& c_event,
836 bool recompute_c_x = true,
837 bool recompute_c_y = true,
838 bool recompute_lower_x = true) {
839 big_int_type a[3], b[3], c[3], cA[4], cB[4];
840 // cA - corresponds to the cross product.
841 // cB - corresponds to the squared length.
842 a[0] = static_cast<int_x2_type>(site1.x1()) -
843 static_cast<int_x2_type>(site1.x0());
844 a[1] = static_cast<int_x2_type>(site2.x1()) -
845 static_cast<int_x2_type>(site2.x0());
846 a[2] = static_cast<int_x2_type>(site3.x1()) -
847 static_cast<int_x2_type>(site3.x0());
848
849 b[0] = static_cast<int_x2_type>(site1.y1()) -
850 static_cast<int_x2_type>(site1.y0());
851 b[1] = static_cast<int_x2_type>(site2.y1()) -
852 static_cast<int_x2_type>(site2.y0());
853 b[2] = static_cast<int_x2_type>(site3.y1()) -
854 static_cast<int_x2_type>(site3.y0());
855
856 c[0] = static_cast<int_x2_type>(site1.x0()) *
857 static_cast<int_x2_type>(site1.y1()) -
858 static_cast<int_x2_type>(site1.y0()) *
859 static_cast<int_x2_type>(site1.x1());
860 c[1] = static_cast<int_x2_type>(site2.x0()) *
861 static_cast<int_x2_type>(site2.y1()) -
862 static_cast<int_x2_type>(site2.y0()) *
863 static_cast<int_x2_type>(site2.x1());
864 c[2] = static_cast<int_x2_type>(site3.x0()) *
865 static_cast<int_x2_type>(site3.y1()) -
866 static_cast<int_x2_type>(site3.y0()) *
867 static_cast<int_x2_type>(site3.x1());
868
869 for (int i = 0; i < 3; ++i)
870 cB[i] = a[i] * a[i] + b[i] * b[i];
871
872 for (int i = 0; i < 3; ++i) {
873 int j = (i+1) % 3;
874 int k = (i+2) % 3;
875 cA[i] = a[j] * b[k] - a[k] * b[j];
876 }
877 fpt_type denom = to_fpt(sqrt_expr_.eval3(cA, cB));
878
879 if (recompute_c_y) {
880 for (int i = 0; i < 3; ++i) {
881 int j = (i+1) % 3;
882 int k = (i+2) % 3;
883 cA[i] = b[j] * c[k] - b[k] * c[j];
884 }
885 fpt_type c_y = to_fpt(sqrt_expr_.eval3(cA, cB));
886 c_event.y(c_y / denom);
887 }
888
889 if (recompute_c_x || recompute_lower_x) {
890 cA[3] = 0;
891 for (int i = 0; i < 3; ++i) {
892 int j = (i+1) % 3;
893 int k = (i+2) % 3;
894 cA[i] = a[j] * c[k] - a[k] * c[j];
895 if (recompute_lower_x) {
896 cA[3] = cA[3] + cA[i] * b[i];
897 }
898 }
899
900 if (recompute_c_x) {
901 fpt_type c_x = to_fpt(sqrt_expr_.eval3(cA, cB));
902 c_event.x(c_x / denom);
903 }
904
905 if (recompute_lower_x) {
906 cB[3] = 1;
907 fpt_type lower_x = to_fpt(sqrt_expr_.eval4(cA, cB));
908 c_event.lower_x(lower_x / denom);
909 }
910 }
911 }
912
913 private:
914 // Evaluates A[3] + A[0] * sqrt(B[0]) + A[1] * sqrt(B[1]) +
915 // A[2] * sqrt(B[3] * (sqrt(B[0] * B[1]) + B[2])).
916 template <typename _int, typename _fpt>
917 _fpt sqrt_expr_evaluator_pss4(_int *A, _int *B) {
918 _int cA[4], cB[4];
919 if (is_zero(A[3])) {
920 _fpt lh = sqrt_expr_.eval2(A, B);
921 cA[0] = 1;
922 cB[0] = B[0] * B[1];
923 cA[1] = B[2];
924 cB[1] = 1;
925 _fpt rh = sqrt_expr_.eval1(A+2, B+3) *
926 get_sqrt(sqrt_expr_.eval2(cA, cB));
927 if ((!is_neg(lh) && !is_neg(rh)) || (!is_pos(lh) && !is_pos(rh)))
928 return lh + rh;
929 cA[0] = A[0] * A[0] * B[0] + A[1] * A[1] * B[1] -
930 A[2] * A[2] * B[3] * B[2];
931 cB[0] = 1;
932 cA[1] = A[0] * A[1] * 2 - A[2] * A[2] * B[3];
933 cB[1] = B[0] * B[1];
934 _fpt numer = sqrt_expr_.eval2(cA, cB);
935 return numer / (lh - rh);
936 }
937 cA[0] = 1;
938 cB[0] = B[0] * B[1];
939 cA[1] = B[2];
940 cB[1] = 1;
941 _fpt rh = sqrt_expr_.eval1(A+2, B+3) * get_sqrt(sqrt_expr_.eval2(cA, cB));
942 cA[0] = A[0];
943 cB[0] = B[0];
944 cA[1] = A[1];
945 cB[1] = B[1];
946 cA[2] = A[3];
947 cB[2] = 1;
948 _fpt lh = sqrt_expr_.eval3(cA, cB);
949 if ((!is_neg(lh) && !is_neg(rh)) || (!is_pos(lh) && !is_pos(rh)))
950 return lh + rh;
951 cA[0] = A[3] * A[0] * 2;
952 cA[1] = A[3] * A[1] * 2;
953 cA[2] = A[0] * A[0] * B[0] + A[1] * A[1] * B[1] +
954 A[3] * A[3] - A[2] * A[2] * B[2] * B[3];
955 cA[3] = A[0] * A[1] * 2 - A[2] * A[2] * B[3];
956 cB[3] = B[0] * B[1];
957 _fpt numer = sqrt_expr_evaluator_pss3<_int, _fpt>(cA, cB);
958 return numer / (lh - rh);
959 }
960
961 template <typename _int, typename _fpt>
962 // Evaluates A[0] * sqrt(B[0]) + A[1] * sqrt(B[1]) +
963 // A[2] + A[3] * sqrt(B[0] * B[1]).
964 // B[3] = B[0] * B[1].
965 _fpt sqrt_expr_evaluator_pss3(_int *A, _int *B) {
966 _int cA[2], cB[2];
967 _fpt lh = sqrt_expr_.eval2(A, B);
968 _fpt rh = sqrt_expr_.eval2(A+2, B+2);
969 if ((!is_neg(lh) && !is_neg(rh)) || (!is_pos(lh) && !is_pos(rh)))
970 return lh + rh;
971 cA[0] = A[0] * A[0] * B[0] + A[1] * A[1] * B[1] -
972 A[2] * A[2] - A[3] * A[3] * B[0] * B[1];
973 cB[0] = 1;
974 cA[1] = (A[0] * A[1] - A[2] * A[3]) * 2;
975 cB[1] = B[3];
976 _fpt numer = sqrt_expr_.eval2(cA, cB);
977 return numer / (lh - rh);
978 }
979
980 robust_sqrt_expr_type sqrt_expr_;
981 to_fpt_converter to_fpt;
982 };
983
984 template <typename Site, typename Circle>
985 class lazy_circle_formation_functor {
986 public:
987 typedef robust_fpt<fpt_type> robust_fpt_type;
988 typedef robust_dif<robust_fpt_type> robust_dif_type;
989 typedef typename Site::point_type point_type;
990 typedef Site site_type;
991 typedef Circle circle_type;
992 typedef mp_circle_formation_functor<site_type, circle_type>
993 exact_circle_formation_functor_type;
994
995 void ppp(const site_type& site1,
996 const site_type& site2,
997 const site_type& site3,
998 circle_type& c_event) {
999 fpt_type dif_x1 = to_fpt(site1.x()) - to_fpt(site2.x());
1000 fpt_type dif_x2 = to_fpt(site2.x()) - to_fpt(site3.x());
1001 fpt_type dif_y1 = to_fpt(site1.y()) - to_fpt(site2.y());
1002 fpt_type dif_y2 = to_fpt(site2.y()) - to_fpt(site3.y());
1003 fpt_type orientation = robust_cross_product(
1004 static_cast<int_x2_type>(site1.x()) -
1005 static_cast<int_x2_type>(site2.x()),
1006 static_cast<int_x2_type>(site2.x()) -
1007 static_cast<int_x2_type>(site3.x()),
1008 static_cast<int_x2_type>(site1.y()) -
1009 static_cast<int_x2_type>(site2.y()),
1010 static_cast<int_x2_type>(site2.y()) -
1011 static_cast<int_x2_type>(site3.y()));
1012 robust_fpt_type inv_orientation(to_fpt(0.5) / orientation, to_fpt(2.0));
1013 fpt_type sum_x1 = to_fpt(site1.x()) + to_fpt(site2.x());
1014 fpt_type sum_x2 = to_fpt(site2.x()) + to_fpt(site3.x());
1015 fpt_type sum_y1 = to_fpt(site1.y()) + to_fpt(site2.y());
1016 fpt_type sum_y2 = to_fpt(site2.y()) + to_fpt(site3.y());
1017 fpt_type dif_x3 = to_fpt(site1.x()) - to_fpt(site3.x());
1018 fpt_type dif_y3 = to_fpt(site1.y()) - to_fpt(site3.y());
1019 robust_dif_type c_x, c_y;
1020 c_x += robust_fpt_type(dif_x1 * sum_x1 * dif_y2, to_fpt(2.0));
1021 c_x += robust_fpt_type(dif_y1 * sum_y1 * dif_y2, to_fpt(2.0));
1022 c_x -= robust_fpt_type(dif_x2 * sum_x2 * dif_y1, to_fpt(2.0));
1023 c_x -= robust_fpt_type(dif_y2 * sum_y2 * dif_y1, to_fpt(2.0));
1024 c_y += robust_fpt_type(dif_x2 * sum_x2 * dif_x1, to_fpt(2.0));
1025 c_y += robust_fpt_type(dif_y2 * sum_y2 * dif_x1, to_fpt(2.0));
1026 c_y -= robust_fpt_type(dif_x1 * sum_x1 * dif_x2, to_fpt(2.0));
1027 c_y -= robust_fpt_type(dif_y1 * sum_y1 * dif_x2, to_fpt(2.0));
1028 robust_dif_type lower_x(c_x);
1029 lower_x -= robust_fpt_type(get_sqrt(
1030 (dif_x1 * dif_x1 + dif_y1 * dif_y1) *
1031 (dif_x2 * dif_x2 + dif_y2 * dif_y2) *
1032 (dif_x3 * dif_x3 + dif_y3 * dif_y3)), to_fpt(5.0));
1033 c_event = circle_type(
1034 c_x.dif().fpv() * inv_orientation.fpv(),
1035 c_y.dif().fpv() * inv_orientation.fpv(),
1036 lower_x.dif().fpv() * inv_orientation.fpv());
1037 bool recompute_c_x = c_x.dif().ulp() > ULPS;
1038 bool recompute_c_y = c_y.dif().ulp() > ULPS;
1039 bool recompute_lower_x = lower_x.dif().ulp() > ULPS;
1040 if (recompute_c_x || recompute_c_y || recompute_lower_x) {
1041 exact_circle_formation_functor_.ppp(
1042 site1, site2, site3, c_event,
1043 recompute_c_x, recompute_c_y, recompute_lower_x);
1044 }
1045 }
1046
1047 void pps(const site_type& site1,
1048 const site_type& site2,
1049 const site_type& site3,
1050 int segment_index,
1051 circle_type& c_event) {
1052 fpt_type line_a = to_fpt(site3.y1()) - to_fpt(site3.y0());
1053 fpt_type line_b = to_fpt(site3.x0()) - to_fpt(site3.x1());
1054 fpt_type vec_x = to_fpt(site2.y()) - to_fpt(site1.y());
1055 fpt_type vec_y = to_fpt(site1.x()) - to_fpt(site2.x());
1056 robust_fpt_type teta(robust_cross_product(
1057 static_cast<int_x2_type>(site3.y1()) -
1058 static_cast<int_x2_type>(site3.y0()),
1059 static_cast<int_x2_type>(site3.x0()) -
1060 static_cast<int_x2_type>(site3.x1()),
1061 static_cast<int_x2_type>(site2.x()) -
1062 static_cast<int_x2_type>(site1.x()),
1063 static_cast<int_x2_type>(site2.y()) -
1064 static_cast<int_x2_type>(site1.y())), to_fpt(1.0));
1065 robust_fpt_type A(robust_cross_product(
1066 static_cast<int_x2_type>(site3.y0()) -
1067 static_cast<int_x2_type>(site3.y1()),
1068 static_cast<int_x2_type>(site3.x0()) -
1069 static_cast<int_x2_type>(site3.x1()),
1070 static_cast<int_x2_type>(site3.y1()) -
1071 static_cast<int_x2_type>(site1.y()),
1072 static_cast<int_x2_type>(site3.x1()) -
1073 static_cast<int_x2_type>(site1.x())), to_fpt(1.0));
1074 robust_fpt_type B(robust_cross_product(
1075 static_cast<int_x2_type>(site3.y0()) -
1076 static_cast<int_x2_type>(site3.y1()),
1077 static_cast<int_x2_type>(site3.x0()) -
1078 static_cast<int_x2_type>(site3.x1()),
1079 static_cast<int_x2_type>(site3.y1()) -
1080 static_cast<int_x2_type>(site2.y()),
1081 static_cast<int_x2_type>(site3.x1()) -
1082 static_cast<int_x2_type>(site2.x())), to_fpt(1.0));
1083 robust_fpt_type denom(robust_cross_product(
1084 static_cast<int_x2_type>(site1.y()) -
1085 static_cast<int_x2_type>(site2.y()),
1086 static_cast<int_x2_type>(site1.x()) -
1087 static_cast<int_x2_type>(site2.x()),
1088 static_cast<int_x2_type>(site3.y1()) -
1089 static_cast<int_x2_type>(site3.y0()),
1090 static_cast<int_x2_type>(site3.x1()) -
1091 static_cast<int_x2_type>(site3.x0())), to_fpt(1.0));
1092 robust_fpt_type inv_segm_len(to_fpt(1.0) /
1093 get_sqrt(line_a * line_a + line_b * line_b), to_fpt(3.0));
1094 robust_dif_type t;
1095 if (ot::eval(denom) == ot::COLLINEAR) {
1096 t += teta / (robust_fpt_type(to_fpt(8.0)) * A);
1097 t -= A / (robust_fpt_type(to_fpt(2.0)) * teta);
1098 } else {
1099 robust_fpt_type det = ((teta * teta + denom * denom) * A * B).sqrt();
1100 if (segment_index == 2) {
1101 t -= det / (denom * denom);
1102 } else {
1103 t += det / (denom * denom);
1104 }
1105 t += teta * (A + B) / (robust_fpt_type(to_fpt(2.0)) * denom * denom);
1106 }
1107 robust_dif_type c_x, c_y;
1108 c_x += robust_fpt_type(to_fpt(0.5) *
1109 (to_fpt(site1.x()) + to_fpt(site2.x())));
1110 c_x += robust_fpt_type(vec_x) * t;
1111 c_y += robust_fpt_type(to_fpt(0.5) *
1112 (to_fpt(site1.y()) + to_fpt(site2.y())));
1113 c_y += robust_fpt_type(vec_y) * t;
1114 robust_dif_type r, lower_x(c_x);
1115 r -= robust_fpt_type(line_a) * robust_fpt_type(site3.x0());
1116 r -= robust_fpt_type(line_b) * robust_fpt_type(site3.y0());
1117 r += robust_fpt_type(line_a) * c_x;
1118 r += robust_fpt_type(line_b) * c_y;
1119 if (r.pos().fpv() < r.neg().fpv())
1120 r = -r;
1121 lower_x += r * inv_segm_len;
1122 c_event = circle_type(
1123 c_x.dif().fpv(), c_y.dif().fpv(), lower_x.dif().fpv());
1124 bool recompute_c_x = c_x.dif().ulp() > ULPS;
1125 bool recompute_c_y = c_y.dif().ulp() > ULPS;
1126 bool recompute_lower_x = lower_x.dif().ulp() > ULPS;
1127 if (recompute_c_x || recompute_c_y || recompute_lower_x) {
1128 exact_circle_formation_functor_.pps(
1129 site1, site2, site3, segment_index, c_event,
1130 recompute_c_x, recompute_c_y, recompute_lower_x);
1131 }
1132 }
1133
1134 void pss(const site_type& site1,
1135 const site_type& site2,
1136 const site_type& site3,
1137 int point_index,
1138 circle_type& c_event) {
1139 const point_type& segm_start1 = site2.point1();
1140 const point_type& segm_end1 = site2.point0();
1141 const point_type& segm_start2 = site3.point0();
1142 const point_type& segm_end2 = site3.point1();
1143 fpt_type a1 = to_fpt(segm_end1.x()) - to_fpt(segm_start1.x());
1144 fpt_type b1 = to_fpt(segm_end1.y()) - to_fpt(segm_start1.y());
1145 fpt_type a2 = to_fpt(segm_end2.x()) - to_fpt(segm_start2.x());
1146 fpt_type b2 = to_fpt(segm_end2.y()) - to_fpt(segm_start2.y());
1147 bool recompute_c_x, recompute_c_y, recompute_lower_x;
1148 robust_fpt_type orientation(robust_cross_product(
1149 static_cast<int_x2_type>(segm_end1.y()) -
1150 static_cast<int_x2_type>(segm_start1.y()),
1151 static_cast<int_x2_type>(segm_end1.x()) -
1152 static_cast<int_x2_type>(segm_start1.x()),
1153 static_cast<int_x2_type>(segm_end2.y()) -
1154 static_cast<int_x2_type>(segm_start2.y()),
1155 static_cast<int_x2_type>(segm_end2.x()) -
1156 static_cast<int_x2_type>(segm_start2.x())), to_fpt(1.0));
1157 if (ot::eval(orientation) == ot::COLLINEAR) {
1158 robust_fpt_type a(a1 * a1 + b1 * b1, to_fpt(2.0));
1159 robust_fpt_type c(robust_cross_product(
1160 static_cast<int_x2_type>(segm_end1.y()) -
1161 static_cast<int_x2_type>(segm_start1.y()),
1162 static_cast<int_x2_type>(segm_end1.x()) -
1163 static_cast<int_x2_type>(segm_start1.x()),
1164 static_cast<int_x2_type>(segm_start2.y()) -
1165 static_cast<int_x2_type>(segm_start1.y()),
1166 static_cast<int_x2_type>(segm_start2.x()) -
1167 static_cast<int_x2_type>(segm_start1.x())), to_fpt(1.0));
1168 robust_fpt_type det(
1169 robust_cross_product(
1170 static_cast<int_x2_type>(segm_end1.x()) -
1171 static_cast<int_x2_type>(segm_start1.x()),
1172 static_cast<int_x2_type>(segm_end1.y()) -
1173 static_cast<int_x2_type>(segm_start1.y()),
1174 static_cast<int_x2_type>(site1.x()) -
1175 static_cast<int_x2_type>(segm_start1.x()),
1176 static_cast<int_x2_type>(site1.y()) -
1177 static_cast<int_x2_type>(segm_start1.y())) *
1178 robust_cross_product(
1179 static_cast<int_x2_type>(segm_end1.y()) -
1180 static_cast<int_x2_type>(segm_start1.y()),
1181 static_cast<int_x2_type>(segm_end1.x()) -
1182 static_cast<int_x2_type>(segm_start1.x()),
1183 static_cast<int_x2_type>(site1.y()) -
1184 static_cast<int_x2_type>(segm_start2.y()),
1185 static_cast<int_x2_type>(site1.x()) -
1186 static_cast<int_x2_type>(segm_start2.x())),
1187 to_fpt(3.0));
1188 robust_dif_type t;
1189 t -= robust_fpt_type(a1) * robust_fpt_type((
1190 to_fpt(segm_start1.x()) + to_fpt(segm_start2.x())) * to_fpt(0.5) -
1191 to_fpt(site1.x()));
1192 t -= robust_fpt_type(b1) * robust_fpt_type((
1193 to_fpt(segm_start1.y()) + to_fpt(segm_start2.y())) * to_fpt(0.5) -
1194 to_fpt(site1.y()));
1195 if (point_index == 2) {
1196 t += det.sqrt();
1197 } else {
1198 t -= det.sqrt();
1199 }
1200 t /= a;
1201 robust_dif_type c_x, c_y;
1202 c_x += robust_fpt_type(to_fpt(0.5) * (
1203 to_fpt(segm_start1.x()) + to_fpt(segm_start2.x())));
1204 c_x += robust_fpt_type(a1) * t;
1205 c_y += robust_fpt_type(to_fpt(0.5) * (
1206 to_fpt(segm_start1.y()) + to_fpt(segm_start2.y())));
1207 c_y += robust_fpt_type(b1) * t;
1208 robust_dif_type lower_x(c_x);
1209 if (is_neg(c)) {
1210 lower_x -= robust_fpt_type(to_fpt(0.5)) * c / a.sqrt();
1211 } else {
1212 lower_x += robust_fpt_type(to_fpt(0.5)) * c / a.sqrt();
1213 }
1214 recompute_c_x = c_x.dif().ulp() > ULPS;
1215 recompute_c_y = c_y.dif().ulp() > ULPS;
1216 recompute_lower_x = lower_x.dif().ulp() > ULPS;
1217 c_event =
1218 circle_type(c_x.dif().fpv(), c_y.dif().fpv(), lower_x.dif().fpv());
1219 } else {
1220 robust_fpt_type sqr_sum1(get_sqrt(a1 * a1 + b1 * b1), to_fpt(2.0));
1221 robust_fpt_type sqr_sum2(get_sqrt(a2 * a2 + b2 * b2), to_fpt(2.0));
1222 robust_fpt_type a(robust_cross_product(
1223 static_cast<int_x2_type>(segm_end1.x()) -
1224 static_cast<int_x2_type>(segm_start1.x()),
1225 static_cast<int_x2_type>(segm_end1.y()) -
1226 static_cast<int_x2_type>(segm_start1.y()),
1227 static_cast<int_x2_type>(segm_start2.y()) -
1228 static_cast<int_x2_type>(segm_end2.y()),
1229 static_cast<int_x2_type>(segm_end2.x()) -
1230 static_cast<int_x2_type>(segm_start2.x())), to_fpt(1.0));
1231 if (!is_neg(a)) {
1232 a += sqr_sum1 * sqr_sum2;
1233 } else {
1234 a = (orientation * orientation) / (sqr_sum1 * sqr_sum2 - a);
1235 }
1236 robust_fpt_type or1(robust_cross_product(
1237 static_cast<int_x2_type>(segm_end1.y()) -
1238 static_cast<int_x2_type>(segm_start1.y()),
1239 static_cast<int_x2_type>(segm_end1.x()) -
1240 static_cast<int_x2_type>(segm_start1.x()),
1241 static_cast<int_x2_type>(segm_end1.y()) -
1242 static_cast<int_x2_type>(site1.y()),
1243 static_cast<int_x2_type>(segm_end1.x()) -
1244 static_cast<int_x2_type>(site1.x())), to_fpt(1.0));
1245 robust_fpt_type or2(robust_cross_product(
1246 static_cast<int_x2_type>(segm_end2.x()) -
1247 static_cast<int_x2_type>(segm_start2.x()),
1248 static_cast<int_x2_type>(segm_end2.y()) -
1249 static_cast<int_x2_type>(segm_start2.y()),
1250 static_cast<int_x2_type>(segm_end2.x()) -
1251 static_cast<int_x2_type>(site1.x()),
1252 static_cast<int_x2_type>(segm_end2.y()) -
1253 static_cast<int_x2_type>(site1.y())), to_fpt(1.0));
1254 robust_fpt_type det = robust_fpt_type(to_fpt(2.0)) * a * or1 * or2;
1255 robust_fpt_type c1(robust_cross_product(
1256 static_cast<int_x2_type>(segm_end1.y()) -
1257 static_cast<int_x2_type>(segm_start1.y()),
1258 static_cast<int_x2_type>(segm_end1.x()) -
1259 static_cast<int_x2_type>(segm_start1.x()),
1260 static_cast<int_x2_type>(segm_end1.y()),
1261 static_cast<int_x2_type>(segm_end1.x())), to_fpt(1.0));
1262 robust_fpt_type c2(robust_cross_product(
1263 static_cast<int_x2_type>(segm_end2.x()) -
1264 static_cast<int_x2_type>(segm_start2.x()),
1265 static_cast<int_x2_type>(segm_end2.y()) -
1266 static_cast<int_x2_type>(segm_start2.y()),
1267 static_cast<int_x2_type>(segm_end2.x()),
1268 static_cast<int_x2_type>(segm_end2.y())), to_fpt(1.0));
1269 robust_fpt_type inv_orientation =
1270 robust_fpt_type(to_fpt(1.0)) / orientation;
1271 robust_dif_type t, b, ix, iy;
1272 ix += robust_fpt_type(a2) * c1 * inv_orientation;
1273 ix += robust_fpt_type(a1) * c2 * inv_orientation;
1274 iy += robust_fpt_type(b1) * c2 * inv_orientation;
1275 iy += robust_fpt_type(b2) * c1 * inv_orientation;
1276
1277 b += ix * (robust_fpt_type(a1) * sqr_sum2);
1278 b += ix * (robust_fpt_type(a2) * sqr_sum1);
1279 b += iy * (robust_fpt_type(b1) * sqr_sum2);
1280 b += iy * (robust_fpt_type(b2) * sqr_sum1);
1281 b -= sqr_sum1 * robust_fpt_type(robust_cross_product(
1282 static_cast<int_x2_type>(segm_end2.x()) -
1283 static_cast<int_x2_type>(segm_start2.x()),
1284 static_cast<int_x2_type>(segm_end2.y()) -
1285 static_cast<int_x2_type>(segm_start2.y()),
1286 static_cast<int_x2_type>(-site1.y()),
1287 static_cast<int_x2_type>(site1.x())), to_fpt(1.0));
1288 b -= sqr_sum2 * robust_fpt_type(robust_cross_product(
1289 static_cast<int_x2_type>(segm_end1.x()) -
1290 static_cast<int_x2_type>(segm_start1.x()),
1291 static_cast<int_x2_type>(segm_end1.y()) -
1292 static_cast<int_x2_type>(segm_start1.y()),
1293 static_cast<int_x2_type>(-site1.y()),
1294 static_cast<int_x2_type>(site1.x())), to_fpt(1.0));
1295 t -= b;
1296 if (point_index == 2) {
1297 t += det.sqrt();
1298 } else {
1299 t -= det.sqrt();
1300 }
1301 t /= (a * a);
1302 robust_dif_type c_x(ix), c_y(iy);
1303 c_x += t * (robust_fpt_type(a1) * sqr_sum2);
1304 c_x += t * (robust_fpt_type(a2) * sqr_sum1);
1305 c_y += t * (robust_fpt_type(b1) * sqr_sum2);
1306 c_y += t * (robust_fpt_type(b2) * sqr_sum1);
1307 if (t.pos().fpv() < t.neg().fpv()) {
1308 t = -t;
1309 }
1310 robust_dif_type lower_x(c_x);
1311 if (is_neg(orientation)) {
1312 lower_x -= t * orientation;
1313 } else {
1314 lower_x += t * orientation;
1315 }
1316 recompute_c_x = c_x.dif().ulp() > ULPS;
1317 recompute_c_y = c_y.dif().ulp() > ULPS;
1318 recompute_lower_x = lower_x.dif().ulp() > ULPS;
1319 c_event = circle_type(
1320 c_x.dif().fpv(), c_y.dif().fpv(), lower_x.dif().fpv());
1321 }
1322 if (recompute_c_x || recompute_c_y || recompute_lower_x) {
1323 exact_circle_formation_functor_.pss(
1324 site1, site2, site3, point_index, c_event,
1325 recompute_c_x, recompute_c_y, recompute_lower_x);
1326 }
1327 }
1328
1329 void sss(const site_type& site1,
1330 const site_type& site2,
1331 const site_type& site3,
1332 circle_type& c_event) {
1333 robust_fpt_type a1(to_fpt(site1.x1()) - to_fpt(site1.x0()));
1334 robust_fpt_type b1(to_fpt(site1.y1()) - to_fpt(site1.y0()));
1335 robust_fpt_type c1(robust_cross_product(
1336 site1.x0(), site1.y0(),
1337 site1.x1(), site1.y1()), to_fpt(1.0));
1338
1339 robust_fpt_type a2(to_fpt(site2.x1()) - to_fpt(site2.x0()));
1340 robust_fpt_type b2(to_fpt(site2.y1()) - to_fpt(site2.y0()));
1341 robust_fpt_type c2(robust_cross_product(
1342 site2.x0(), site2.y0(),
1343 site2.x1(), site2.y1()), to_fpt(1.0));
1344
1345 robust_fpt_type a3(to_fpt(site3.x1()) - to_fpt(site3.x0()));
1346 robust_fpt_type b3(to_fpt(site3.y1()) - to_fpt(site3.y0()));
1347 robust_fpt_type c3(robust_cross_product(
1348 site3.x0(), site3.y0(),
1349 site3.x1(), site3.y1()), to_fpt(1.0));
1350
1351 robust_fpt_type len1 = (a1 * a1 + b1 * b1).sqrt();
1352 robust_fpt_type len2 = (a2 * a2 + b2 * b2).sqrt();
1353 robust_fpt_type len3 = (a3 * a3 + b3 * b3).sqrt();
1354 robust_fpt_type cross_12(robust_cross_product(
1355 static_cast<int_x2_type>(site1.x1()) -
1356 static_cast<int_x2_type>(site1.x0()),
1357 static_cast<int_x2_type>(site1.y1()) -
1358 static_cast<int_x2_type>(site1.y0()),
1359 static_cast<int_x2_type>(site2.x1()) -
1360 static_cast<int_x2_type>(site2.x0()),
1361 static_cast<int_x2_type>(site2.y1()) -
1362 static_cast<int_x2_type>(site2.y0())), to_fpt(1.0));
1363 robust_fpt_type cross_23(robust_cross_product(
1364 static_cast<int_x2_type>(site2.x1()) -
1365 static_cast<int_x2_type>(site2.x0()),
1366 static_cast<int_x2_type>(site2.y1()) -
1367 static_cast<int_x2_type>(site2.y0()),
1368 static_cast<int_x2_type>(site3.x1()) -
1369 static_cast<int_x2_type>(site3.x0()),
1370 static_cast<int_x2_type>(site3.y1()) -
1371 static_cast<int_x2_type>(site3.y0())), to_fpt(1.0));
1372 robust_fpt_type cross_31(robust_cross_product(
1373 static_cast<int_x2_type>(site3.x1()) -
1374 static_cast<int_x2_type>(site3.x0()),
1375 static_cast<int_x2_type>(site3.y1()) -
1376 static_cast<int_x2_type>(site3.y0()),
1377 static_cast<int_x2_type>(site1.x1()) -
1378 static_cast<int_x2_type>(site1.x0()),
1379 static_cast<int_x2_type>(site1.y1()) -
1380 static_cast<int_x2_type>(site1.y0())), to_fpt(1.0));
1381
1382 // denom = cross_12 * len3 + cross_23 * len1 + cross_31 * len2.
1383 robust_dif_type denom;
1384 denom += cross_12 * len3;
1385 denom += cross_23 * len1;
1386 denom += cross_31 * len2;
1387
1388 // denom * r = (b2 * c_x - a2 * c_y - c2 * denom) / len2.
1389 robust_dif_type r;
1390 r -= cross_12 * c3;
1391 r -= cross_23 * c1;
1392 r -= cross_31 * c2;
1393
1394 robust_dif_type c_x;
1395 c_x += a1 * c2 * len3;
1396 c_x -= a2 * c1 * len3;
1397 c_x += a2 * c3 * len1;
1398 c_x -= a3 * c2 * len1;
1399 c_x += a3 * c1 * len2;
1400 c_x -= a1 * c3 * len2;
1401
1402 robust_dif_type c_y;
1403 c_y += b1 * c2 * len3;
1404 c_y -= b2 * c1 * len3;
1405 c_y += b2 * c3 * len1;
1406 c_y -= b3 * c2 * len1;
1407 c_y += b3 * c1 * len2;
1408 c_y -= b1 * c3 * len2;
1409
1410 robust_dif_type lower_x = c_x + r;
1411
1412 robust_fpt_type denom_dif = denom.dif();
1413 robust_fpt_type c_x_dif = c_x.dif() / denom_dif;
1414 robust_fpt_type c_y_dif = c_y.dif() / denom_dif;
1415 robust_fpt_type lower_x_dif = lower_x.dif() / denom_dif;
1416
1417 bool recompute_c_x = c_x_dif.ulp() > ULPS;
1418 bool recompute_c_y = c_y_dif.ulp() > ULPS;
1419 bool recompute_lower_x = lower_x_dif.ulp() > ULPS;
1420 c_event = circle_type(c_x_dif.fpv(), c_y_dif.fpv(), lower_x_dif.fpv());
1421 if (recompute_c_x || recompute_c_y || recompute_lower_x) {
1422 exact_circle_formation_functor_.sss(
1423 site1, site2, site3, c_event,
1424 recompute_c_x, recompute_c_y, recompute_lower_x);
1425 }
1426 }
1427
1428 private:
1429 exact_circle_formation_functor_type exact_circle_formation_functor_;
1430 to_fpt_converter to_fpt;
1431 };
1432
1433 template <typename Site,
1434 typename Circle,
1435 typename CEP = circle_existence_predicate<Site>,
1436 typename CFF = lazy_circle_formation_functor<Site, Circle> >
1437 class circle_formation_predicate {
1438 public:
1439 typedef Site site_type;
1440 typedef Circle circle_type;
1441 typedef CEP circle_existence_predicate_type;
1442 typedef CFF circle_formation_functor_type;
1443
1444 // Create a circle event from the given three sites.
1445 // Returns true if the circle event exists, else false.
1446 // If exists circle event is saved into the c_event variable.
1447 bool operator()(const site_type& site1, const site_type& site2,
1448 const site_type& site3, circle_type& circle) {
1449 if (!site1.is_segment()) {
1450 if (!site2.is_segment()) {
1451 if (!site3.is_segment()) {
1452 // (point, point, point) sites.
1453 if (!circle_existence_predicate_.ppp(site1, site2, site3))
1454 return false;
1455 circle_formation_functor_.ppp(site1, site2, site3, circle);
1456 } else {
1457 // (point, point, segment) sites.
1458 if (!circle_existence_predicate_.pps(site1, site2, site3, 3))
1459 return false;
1460 circle_formation_functor_.pps(site1, site2, site3, 3, circle);
1461 }
1462 } else {
1463 if (!site3.is_segment()) {
1464 // (point, segment, point) sites.
1465 if (!circle_existence_predicate_.pps(site1, site3, site2, 2))
1466 return false;
1467 circle_formation_functor_.pps(site1, site3, site2, 2, circle);
1468 } else {
1469 // (point, segment, segment) sites.
1470 if (!circle_existence_predicate_.pss(site1, site2, site3, 1))
1471 return false;
1472 circle_formation_functor_.pss(site1, site2, site3, 1, circle);
1473 }
1474 }
1475 } else {
1476 if (!site2.is_segment()) {
1477 if (!site3.is_segment()) {
1478 // (segment, point, point) sites.
1479 if (!circle_existence_predicate_.pps(site2, site3, site1, 1))
1480 return false;
1481 circle_formation_functor_.pps(site2, site3, site1, 1, circle);
1482 } else {
1483 // (segment, point, segment) sites.
1484 if (!circle_existence_predicate_.pss(site2, site1, site3, 2))
1485 return false;
1486 circle_formation_functor_.pss(site2, site1, site3, 2, circle);
1487 }
1488 } else {
1489 if (!site3.is_segment()) {
1490 // (segment, segment, point) sites.
1491 if (!circle_existence_predicate_.pss(site3, site1, site2, 3))
1492 return false;
1493 circle_formation_functor_.pss(site3, site1, site2, 3, circle);
1494 } else {
1495 // (segment, segment, segment) sites.
1496 if (!circle_existence_predicate_.sss(site1, site2, site3))
1497 return false;
1498 circle_formation_functor_.sss(site1, site2, site3, circle);
1499 }
1500 }
1501 }
1502 if (lies_outside_vertical_segment(circle, site1) ||
1503 lies_outside_vertical_segment(circle, site2) ||
1504 lies_outside_vertical_segment(circle, site3)) {
1505 return false;
1506 }
1507 return true;
1508 }
1509
1510 private:
1511 bool lies_outside_vertical_segment(
1512 const circle_type& c, const site_type& s) {
1513 if (!s.is_segment() || !is_vertical(s)) {
1514 return false;
1515 }
1516 fpt_type y0 = to_fpt(s.is_inverse() ? s.y1() : s.y0());
1517 fpt_type y1 = to_fpt(s.is_inverse() ? s.y0() : s.y1());
1518 return ulp_cmp(c.y(), y0, ULPS) == ulp_cmp_type::LESS ||
1519 ulp_cmp(c.y(), y1, ULPS) == ulp_cmp_type::MORE;
1520 }
1521
1522 private:
1523 to_fpt_converter to_fpt;
1524 ulp_cmp_type ulp_cmp;
1525 circle_existence_predicate_type circle_existence_predicate_;
1526 circle_formation_functor_type circle_formation_functor_;
1527 };
1528 };
1529 } // detail
1530 } // polygon
1531 } // boost
1532
1533 #endif // BOOST_POLYGON_DETAIL_VORONOI_PREDICATES