Classroom Examples of Robustness Problems in Geometric Computations
Classroom Examples of Robustness Problems in Geometric Computations Lutz Kettner, Kurt Mehlhorn MPI für Informatik, Saarbrücken Sylvain Pion INRIA, Sophia Antipolis Stefan Schirra Otto-von-Guericke-Universität, Magdeburg 10/6/2020 Chee Yap New York University
Overview • Overview • The Orientation Predicate • A 2 D Convex Hull Algorithm Classroom Examples ESA'04 2
Overview • • The algorithms of computational geometry are designed for a machine model with exact real arithmetic. Floating point arithmetic incurs round-off error Substituting floating point arithmetic for the assumed real arithmetic may cause implementations to fail. I will show you some drastic examples of failures due to roundoff error in the hope § That you list more attentively to the alternatives presented later (and which require a fair amount of math) Classroom Examples ESA'04 3
Intersection of Four Simple Solids • Rhino 3 D: § ((( s 1 ∩ s 2) ∩ c 1) → successful § ((( c 1 ∩ c 2) ∩ s 1) ∩ s 2) → ``Boolean operation failed'' Classroom Examples ESA'04 4
Intersection of Four Simple Solids • • output is a combinatorial object plus coordinates (not a point set) Rhino 3 D: § ((( s 1 ∩ s 2) ∩ c 1) → successful § ((( c 1 ∩ c 2) ∩ s 1) ∩ s 2) → ``Boolean operation failed'' Classroom Examples ESA'04 5
Overview • • …, I believe that the program fails due to floating point rounding errors, but the example is too complicated to be followed through in detail We do the following: § First study the effect of floating point arithmetic on one of the basic geometric predicates, namely the orientation precidate for three points § And then study the global effects on a simple 2 d convex hull algorithm. Classroom Examples ESA'04 6
2 D-Orientation of Three Points Orientation( p, q, r) = sign((qx-px)(ry-py) – (qy-py)(rx-px)) Implemented with IEEE 784 double precision àfloat_orient (p, q, r) àFloat_orient is not a correct implementation of orientation. Classroom Examples ESA'04 7
2 D-Orientation of Three Points Orientation( p, q, r) = sign((qx-px)(ry-py) – (qy-py)(rx-px)) 256 x 256 pixel image red=pos. , yellow=0, blue=neg. orientation evaluated with double What do you expect Classroom Examples ESA'04 8
2 D-Orientation of Three Points Orientation( p, q, r) = sign((qx-px)(ry-py) – (qy-py)(rx-px)) 256 x 256 pixel image red=pos. , yellow=0, blue=neg. orientation evaluated with double Classroom Examples ESA'04 9
2 D-Orientation of Three Points Orientation( p, q, r) = sign((qx-px)(ry-py) – (qy-py)(rx-px)) 256 x 256 pixel image red=pos. , yellow=0, blue=neg. orientation evaluated with double Classroom Examples ESA'04 10
2 D-Orientation of Three Points Orientation( p, q, r) = sign((qx-px)(ry-py) – (qy-py)(rx-px)) 256 x 256 pixel image red=pos. , yellow=0, blue=neg. orientation evaluated with double Classroom Examples ESA'04 11
2 D-Orientation of Three Points Orientation( p, q, r) = sign((qx-px)(ry-py) – (qy-py)(rx-px)) 256 x 256 pixel image red=pos. , yellow=0, blue=neg. orientation evaluated with ext double Classroom Examples ESA'04 12
Classification with respect to two Lines • consider § p 1 = ( 0. 5, 0. 5) § p 2 = ( 7. 3000000194, 7. 3000000167) § p 3 = ( 24. 000000068, 24. 000000071) § p 4 = ( 24. 00000005, 24. 000000053) • • (p 2, p 3, p 4) form a counter-clockwise triangle Classification of (x(p 1) + x∙u, y(p 1) + y∙u) with respect to the edges (p 2, p 3) and (p 4, p 2). red = sees no edge, ocher = collinear with one, yellow = collinear with both, blue = sees one but not the other, green = sees both 13 Classroom Examples ESA'04
Convex Hulls in the Plane v 3 v 1 r v 2 • • • maintain current hull as a circular list L=(v 0, v 1, . . . , vk-1) of its extreme points in counter-clockwise order start with three non-collinear points in S. consider the remaining points r one by one. § Determine the set of visible edges § If none, r is inside and we are done § Otherwise, remove all visible edges and add the two tangents from r Classroom Examples ESA'04 14
Convex Hulls in the Plane v 4 v 1 v 3 v 2 • • • maintain current hull as a circular list L=(v 0, v 1, . . . , vk-1) of its extreme points in counter-clockwise order start with three non-collinear points in S. consider the remaining points r one by one. Classroom Examples ESA'04 15
Correctness Properties v 4 r v 1 v 3 v 2 • • [Property A] A point r is outside CH iff there is an i such that the edge (vi, vi+1) is visible for r. (orientation(vi, vi+1, r) > 0) [Property B] If r is outside CH, then the set of edges that are weakly visible (= orientation is non-negative) from r forms a non-empty consecutive subchain; so does the set of edges that are not weakly visible from r. Classroom Examples ESA'04 16
… and next • Instances leading to violations of properties (A) and (B) when executed with double’s • and in all possible ways § § • • a point outside sees no edge a point inside sees an edge a point outside sees all edges a point outside sees a non-contiguous set of edges examples involve nearly collinear points, of course examples are realistic as many real-life instances contain collinear points (which become nearly collinear by conversion to double’s) Classroom Examples ESA'04 17
Global Consequences • A point outside sees no edge of the current hull. p 1=(7. 3000000194, 7. 3000000167) p 2=(24. 000000068, 24. 000000071) p 3=(24. 00000005, 24. 000000053) p 4=(0. 50000001621, 0. 50000001243) p 5=(8, 4) p 6=(4, 9) p 7=(15, 27) p 8=(26, 25) p 9=(19, 11) float_orient(p 1, p 2, p 3) > 0 float_orient(p 1, p 2, p 4) < 0 float_orient(p 2, p 3, p 4) < 0 float_orient(p 3, p 1, p 4) < 0 Classroom Examples ESA'04 18
Global Consequences • A point outside sees all edges of the current hull. p 1=(200, 49. 200000003) p 2=(100, 49. 600000001) p 3=(-233. 33333334, 50. 93333333) p 4=(166. 66666669, 49. 33333336) float_orient(p 1, p 2, p 3) > 0 float_orient(p 1, p 2, p 4) > 0 float_orient(p 2, p 3, p 4) > 0 float_orient(p 3, p 1, p 4) > 0 Classroom Examples ESA'04 19
Global Consequences • A point outside sees all edges of the current hull. p 1=(200, 49. 200000003) p 2=(100, 49. 600000001) p 3=(-233. 33333334, 50. 93333333) p 4=(166. 66666669, 49. 33333336) float_orient(p 1, p 2, p 3) > 0 float_orient(p 1, p 2, p 4) > 0 float_orient(p 2, p 3, p 4) > 0 float_orient(p 3, p 1, p 4) > 0 Depending on the implementation: • Algorithm does not terminate! • Algorithm crashes! Classroom Examples ESA'04 20
Global Consequences • A point inside sees an edge of the current hull. p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) (p 1, p 2, p 3, p 4) form a convex quadrilateral p 5 is truly inside this quadrilateral, but float_orient(p 4, p 1, p 5) > 0 p 4 p 1 p 5 p 2 Classroom Examples ESA'04 p 3 21
Global Consequences • A point inside sees an edge of the current hull. p 4 p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) (p 1, p 2, p 3, p 4) form a convex quadrilateral p 5 is truly inside this quadrilateral, but float_orient(p 4, p 1, p 5) > 0 p 5 p 1 p 4 p 2 p 1 p 5 p 2 Classroom Examples ESA'04 p 3 22
Global Consequences • p 4 A point outside sees a non-contiguous set of edges p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 5 p 1 p 4 p 2 p 1 p 5 p 6 p 2 Classroom Examples ESA'04 p 3 23
Global Consequences • p 4 A point outside sees a non-contiguous set of edges p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 5 p 1 p 4 p 2 p 1 p 5 float_orient(p 4, p 5, p 6) > 0 float_orient(p 5, p 1, p 6) < 0 float_orient(p 1, p 2, p 6) > 0 p 6 p 2 Classroom Examples ESA'04 p 3 24
Global Consequences • p 4 A point outside sees a non-contiguous set of edges p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 10. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 5 p 1 p 4 p 2 p 1 p 5 p 6 p 2 Classroom Examples ESA'04 p 3 25
Global Consequences • p 4 A point outside sees a non-contiguous set of edges p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 10. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 5 p 1 p 6 p 4 p 1 p 5 p 6 p 2 Classroom Examples ESA'04 p 3 26
Global Consequences • p 4 A point outside sees a non-contiguous set of edges p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 5 p 1 p 4 p 2 p 1 p 5 p 6 p 2 Classroom Examples ESA'04 p 3 27
Global Consequences • A point outside sees a non-contiguous set of edges p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 4 p 1 p 5 p 6 p 2 Classroom Examples ESA'04 p 3 28
Global Consequences • p 4 A point outside sees a non-contiguous set of edges p 6 p 1=(24. 00000005, 24. 000000053) p 2=(24. 0, 6. 0) p 3=(54. 85, 6. 0) p 4= (54. 8500000357, 61. 000000121) p 5=(24. 000000068, 24. 000000071) p 6=(6, 6) p 5 p 1 p 4 p 6 p 1 p 5 p 6 p 2 Classroom Examples ESA'04 p 3 29
Conclusion • Classroom examples Data sets and C++ programs available online: http: //www. mpi-sb. mpg. de/~kettner/proj/Non. Robust/ • Long version (available soon): § More analysis § Graham’s scan algorithm § 3 D Delaunay triangulation Classroom Examples ESA'04 30
- Slides: 30