1 / 56

Jack Snoeyink & Andrea Mantler Computer Science, UNC Chapel Hill

Polygon overlay in double precision arithmetic One example of why robust geometric code is hard to write. Jack Snoeyink & Andrea Mantler Computer Science, UNC Chapel Hill. Outline. Motivating problems Clipping, polygon ops, overlay, arrangement Study precision required by algorithm

eagan
Download Presentation

Jack Snoeyink & Andrea Mantler Computer Science, UNC Chapel Hill

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Polygon overlay in double precision arithmeticOne example of why robust geometric code is hard to write Jack Snoeyink & Andrea Mantler Computer Science, UNC Chapel Hill

  2. Outline • Motivating problems • Clipping, polygon ops, overlay, arrangement • Study precision required by algorithm • Quick summary of algorithms • Test pairs, sweep, topological sweep • A double-precision sweep algorithm • “Spaghetti” segments • Conclusions

  3. Three problems in the plane • Polygon clipping (graphics) • Boolean operations (CAD) • Map overlay (GIS)

  4. Build red/blue arrangement • Build the arrangement of: nred and nblue line segments in plane, specified by their endpoint coordinates & having no red/red or blue/blue crossings.

  5. Why precision is an issue • Algorithms find geometric relationships from coordinate computations. • Efficient algorithms compute only a few relationships and derive the rest.

  6. Assumptions & Goal • Assumptions for correctness • Solve the exact problem given by the input • Work for any distribution of the input • Goal: Input+output sensitive algorithm • Demand least precision possible • O(n log n + k) for n segs, k intersections

  7. Algorithms to build line segment arrangements • Brute force: test all pairs • Sweep the plane with a line [BO79,C92] • Topological sweep [CE92] • Divide & Conquer [B95] • Trapezoid sweep [C94]

  8. Four geometric tests • Orientation/Intersection test • Intersection-in-Slab • Order along line • Order by x coordinate

  9. Four geometric tests • Orientation/Intersection test • Intersection-in-Slab • Order along line • Order by x coordinate

  10. Four geometric tests • Orientation/Intersection test • Intersection-in-Slab • Order along line • Order by x coordinate

  11. Four geometric tests • Orientation/Intersection test • Intersection-in-Slab • Order along line • Order by x coordinate

  12. Algorithms to build line segment arrangements • Brute force: test all pairs • Sweep the plane with a line [BO79,C92] • Topological sweep [CE92] • Divide & Conquer [B95]

  13. Brute force • Test all pairs for intersection

  14. Brute force • Test all pairs for intersection • Sort along lines • Break&rejoin segs

  15. Plane sweep [BO79,C92] • Maintain order along sweep line

  16. Plane sweep [BO79,C92] • Maintain order along sweep line

  17. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  18. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  19. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  20. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  21. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  22. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  23. Plane sweep [BO79,C92] • Maintain order along sweep line • Know all intersections behind • Nextevent queue

  24. Topological sweep [CE92] • Maintain order along sweep curve • Know all intersections behind

  25. Topological sweep [CE92] • Maintain order along sweep curve • Know all intersections behind • “20 easy pieces”

  26. Divide and Conquer [B95] • Find intersections in slab with staircase

  27. Divide and Conquer [B95] • Find intersections in slab with staircase • Remove staircase

  28. Divide and Conquer [B95] • Find intersections in slab with staircase • Remove staircase • Partition & repeat

  29. Degrees of predicates • Orientation/Intersection test (deg. 2) • Intersection-in-Slab (deg. 3) • Order along line (deg. 4) • Order by x coordinate (deg. 5)

  30. Degree computations • Point p = (1,px,py) = ((0),(1),(1)) • Line equation through points p, q:

  31. Degree computations • Point p = (1,px,py) = ((0),(1),(1)) • Line equation: (2)W+(1)X+(1)Y • Point at intersection of two lines:

  32. Degree computations • Point p = (1,px,py) = ((0),(1),(1)) • Line equation: (2)W+(1)X+(1)Y • Point at intersection ((2),(3),(3)) • Orientation Test:(2)(0)+(1)(1)+(1)(1) = (2) • In Slab: (1) < (3)/(2) or (2)(1) < (3) = (3) • Same Line: (2)(2) + (1)(3) + (1)(3) = (4) • x Order: (3)/(2) < (3)/(2) or (5)<(5) = (5)

  33. Restrict to double precision Degree of algorithms to build line segment arrangements • Brute force (2/4) • Sweep with a line (5) • Topological sweep (4) • Divide & Conquer (3/4) • Trapezoid sweep (3)

  34. Restricted predicates imply... • Restricted to double precision: • Can’t test where an intersection is • Can’t sort on lines • Can’t sort by x

  35. Spaghetti lines • Restricted to double precision: • Can’t test where an intersection is • Can’t sort on lines • Can’t sort by x

  36. Spaghetti lines • Restricted to double precision: • Push segments as far right as possible

  37. Spaghetti lines • Restricted to double precision: • Push segments as far right as possible • Endpoints witness intersections

  38. A sweep for red/blue spaghetti • Maintain order along sweep consistent with pushing intersections to right • Detect an intersection when the sweep passes its witness

  39. Data Structures • Sweep line:

  40. Data Structures • Sweep line: • Alternate bundles of red and blue segs

  41. Data Structures • Sweep line: • Alternate bundles of red and blue segs • Bundles are in doubly-linked list

  42. Data Structures • Sweep line: • Alternate bundles of red and blue segs • Bundles are in doubly-linked list • Blue bundles are in a balanced tree

  43. Data Structures • Sweep line: • Alternate bundles of red and blue segs • Bundles are in doubly-linked list • Blue bundles are in a balanced tree • Each bundle is a small tree

  44. Events • Sweep events • Now only at vertices • Processing

  45. Event processing • Sweep events • Now only at vertices • Processing red • Use trees to locate point in blue bundle

  46. Event processing • Sweep events • Now only at vertices • Processing red • Use trees to locate point in blue bundle • Use linked list to locate in red

  47. Event processing • Sweep events • Now only at vertices • Processing red • Use trees to locate point in blue bundle • Use linked list to locate in red • Split/merge bundles to restore invariant

  48. Event processing • Sweep events • Now only at vertices • Processing red • Use trees to locate point in blue bundle • Use linked list to locate in red • Split/merge bundles to restore invariant

  49. Event processing • Process blue the same • Time: O(n log n + k) • Tree operations prop to # of vertices • Bundle operations prop to # of intersections • Degeneracies can easily be handled

  50. Handling degeneracies • Shared endpoints • Endpoint on a line • Collinear segments

More Related