Polygon overlay in double precision arithmetic One example of why robust geometric code is hard to write Jack Snoeyink & Andrea Mantler Computer Science,

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Spatial Information Systems (SIS) COMP Terrain modeling and geometric problems (part 2)
Computational Geometry
Computational Geometry
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Supplementary Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut.
Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
Lars Arge 1/43 Big Terrain Data Analysis Algorithms in the Field Workshop SoCG June 19, 2012 Lars Arge.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
Course Website: Computer Graphics 4: Viewing In 2D.
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Computational Geometry for the Tablet PC
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
CS138A Line Segment Intersection Peter Schröder.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Jack Snoeyink FWCG08 Oct 31, 2008 David L. Millman University of North Carolina - Chapel Hill.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Lecture 2 Chapter 2: Polygon Partitioning.
Lecture 33 CSE 331 Nov 20, Homeworks Submit HW 9 by 1:10PM HW 8 solutions at the end of the lecture.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 2 Chapter 2: Polygon Partitioning.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Orthogonal Line Segment Intersection Given N horizontal and N vertical line segments, find all intersections. All x and y coordinates are distinct.
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
Applied Cartography and Introduction to GIS GEOG 2017 EL
Analysis in 9.2: Overlay. Analysis Usually starts with selection but selection can be used throughout an analysis The main tools for analysis are, however,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
Computational Geometry Course Summary (First Half) Spring 2008 Pay special attention to: algorithm details (able to explain correctness and carry out a.
Robustness in Numerical Computation I Root Finding Kwanghee Ko School of Mechatronics Gwnagju Institute of Science and Technology.
Windows, Viewports, and Clipping
Geometric Figures: Polygons.
UNC Chapel Hill M. C. Lin Introduction to Motion Planning Applications Overview of the Problem Basics – Planning for Point Robot –Visibility Graphs –Roadmap.
CMPS 3130/6130 Computational Geometry Spring 2015
Arrangements Efi Fogel Tel Aviv University. Outline Arrangements Algorithms based on Arrangements Boolean Set Operations Minkowski Sums and Polygon Offset.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
CS552: Computer Graphics Lecture 12: 3D Clipping.
Introduction to Computer Graphics with WebGL
Computer Graphics Shading in OpenGL
Largest Red-Blue Separating Rectangles
2.2.4 Use slope criteria for parallel and perpendicular lines to solve problems on the coordinate plane.
CMPS 3130/6130 Computational Geometry Spring 2017
Query Processing in Databases Dr. M. Gavrilova
Classroom Examples of Robustness Problems in Geometric Computations
Algorithm design techniques Dr. M. Gavrilova
Implementation I Ed Angel
Lecture 31 CSE 331 Nov 13, 2017.
Objective of This Course
Computational Geometry for the Tablet PC
I. The Problem of Molding
Lecture 30 CSE 331 Nov 11, 2016.
Lecture 33 CSE 331 Nov 19, 2012.
Appendix B: Coordinate System and Lines
Classroom Examples of Robustness Problems in Geometric Computations
Lecture 30 CSE 331 Nov 10, 2017.
Classroom Examples of Robustness Problems in Geometric Computations
Implementation I Ed Angel Professor Emeritus of Computer Science
Algorithms and Data Structures Lecture XIV
Presentation transcript:

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 n Motivating problems –Clipping, polygon ops, overlay, arrangement –Study precision required by algorithm n Quick summary of algorithms –Test pairs, sweep, topological sweep n A double-precision sweep algorithm –“Spaghetti” segments n Conclusions

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

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

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

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

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

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

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

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

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

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

Brute force n Test all pairs for intersection

n Sort along lines n Break&rejoin segs Brute force

Plane sweep [BO79,C92] n Maintain order along sweep line

Plane sweep [BO79,C92] n Maintain order along sweep line

Plane sweep [BO79,C92] n Maintain order along sweep line n Know all intersections behind n Next event queue

Plane sweep [BO79,C92] n Maintain order along sweep line n Know all intersections behind n Next event queue

n Maintain order along sweep line n Know all intersections behind n Next event queue Plane sweep [BO79,C92]

n Maintain order along sweep line n Know all intersections behind n Next event queue

Plane sweep [BO79,C92] n Maintain order along sweep line n Know all intersections behind n Next event queue

Plane sweep [BO79,C92] n Maintain order along sweep line n Know all intersections behind n Next event queue

Plane sweep [BO79,C92] n Maintain order along sweep line n Know all intersections behind n Next event queue

Topological sweep [CE92] n Maintain order along sweep curve n Know all intersections behind

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

Divide and Conquer [B95] n Find intersections in slab with staircase

Divide and Conquer [B95] n Find intersections in slab with staircase n Remove staircase

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

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

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

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

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)

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

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

Spaghetti lines n Restricted to double precision: –Can’t test where an intersection is –Can’t sort on lines –Can’t sort by x

Spaghetti lines n Restricted to double precision: –Push segments as far right as possible

Spaghetti lines n Restricted to double precision: –Push segments as far right as possible –Endpoints witness intersections

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

Data Structures n Sweep line:

Data Structures n Sweep line: –Alternate bundles of red and blue segs

Data Structures n Sweep line: –Alternate bundles of red and blue segs –Bundles are in doubly-linked list

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

Data Structures n 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

Events n Sweep events –Now only at vertices n Processing

Event processing n Sweep events –Now only at vertices n Processing red –Use trees to locate point in blue bundle

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

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

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

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

Handling degeneracies n Shared endpoints n Endpoint on a line n Collinear segments

Handling degeneracies n Shared endpoints n Endpoint on a line n Collinear segments Introduce vertices, since they are exact

Algorithm Summary n We have an optimal algorithm to build an arrangement of red/blue segments, (and only for red/blue segments). n We used only the orientation predicate. n Data structuring is moderate. n Can handle point/line degeneracies: breaking lines at input points is OK.

Demo applet ~snoeyink/ demos/ rbseg/

A lower bound for spaghetti With only intersection and above/below tests, counting intersections requires Ω(nk ½ ) ops. With convex hulls O(n log 2 n + k) ops suffice for intersections [BS99], but not arrangement. n k½k½

Open question n How do we perform geometric rounding to take output back to single precision? –probably dependant on application domain –snap rounding is one idea

Fin