N Line Segments Problem Given a set of n line segments in the plane, determine whether or not any intersection exists. It is not required to output all.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

Two Segments Intersect?
DO NOW Key Words in Geometry With a neighbor, discuss the difference between the key location words in geometry in relation to Points, Lines and Planes.
Geometry Introduction
Polygon Triangulation
Spatial Information Systems (SIS) COMP Terrain modeling and geometric problems (part 2)
Computational Geometry
Brute-Force Triangulation
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
Computing Convex Hulls CLRS 33.3
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.
What is Computational Geometry? Study of Data Structures and Algorithms for Geometric Problems 1970 ’ s: Need for Computational Geometry Recognized; Progress.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
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.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
Overlay of Two Subdivisions
Convex Sets & Concave Sets A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R.
Algorithms and Data Structures Lecture 13. Agenda: Plane Geometry: algorithms on polygons - Verification if point belongs to a polygon - Convex hull.
What does that mean? To get the taste we will just look only at some sample problems... [Adapted from S.Suri]
ADA: 16. CG Topics1 Objective o an examination of four important CG topics o just a taster of a very large research area Algorithm Design and Analysis.
1 Closest Points A famous algorithmic problem... Given a set of points in the plane (cities in the U.S., transistors on a circuit board, computers on a.
Learn to locate and graph points on the coordinate plane.
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
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
17. Computational Geometry Chapter 7 Voronoi Diagrams.
Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Closest Pair of Points Computational Geometry, WS 2006/07 Lecture 9, Part II Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
What is Geometry? Make 2 lists with your table:
Brute-Force Triangulation
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.
1 Computational Geometry Instructor: yedeshi
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
External Memory Algorithms for Geometric Problems Piotr Indyk (slides partially by Lars Arge and Jeff Vitter)
An arrangement of lines: A(H)
1 Topic Regions Defined by Inequalities Regions Defined by Inequalities.
ƒ(x) Function Notations
PRE-ALGEBRA. Lesson 1-10 Warm-Up PRE-ALGEBRA Lesson 1-10 Warm-Up.
Ordered Pairs Graphing on the Coordinate Plane. Vocabulary coordinate plane axes x-axis y-axis origin Coordinates (ordered pair) x-coordinate y-coordinate.
CMPS 3130/6130 Computational Geometry Spring 2015
15. Computational Geometry Topics
UNC Chapel Hill M. C. Lin Computing Voronoi Diagram For each site p i, compute the common inter- section of the half-planes h(p i, p j ) for i  j, using.
Postulates and Theorems Relating Points, Lines, and Planes
Lecture 15 Computational Geometry Geometry sweeping Geometric preliminaries Some basics geometry algorithms.
Convex Sets & Concave Sets A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R.
The Coordinate Plane. Vocabulary Words Axes - two perpendicular number lines used for locating points Origin – the intersection of the two axes Y-axis.
An algorithm of Lock-free extensible hash table Yi Feng.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Point the Ray. Key Question: How are lines, line segments, and rays different? Learning Goals: The student will: Model and compare parallel and intersecting.
Points, Lines and Rays G4.4M.C1.PO1 I can draw and describe the relationships between points, lines, line segments, rays, and angles including parallelism.
CMPS 3130/6130 Computational Geometry Spring 2017
CMPS 3130/6130 Computational Geometry Spring 2017
Determining the horizontal and vertical trace of the line
Comparison Sorting Elements are rearranged by comparing values of keys
Computational Geometry Capter:1-2.1
I. The Problem of Molding
CHAPTER 33 Computational Geometry
CS 113: Data Structures and Algorithms
The Coordinate Plane #39.
Algorithms and Data Structures Lecture XIV
Computational Geometry
Presentation transcript:

n Line Segments Problem Given a set of n line segments in the plane, determine whether or not any intersection exists. It is not required to output all the intersections.

A Brute-Force Algorithm Simply take each pair of segments, and check if they intersect. If so, output yes to the original problem; otherwise, output no. Running time  (n ). 2 Most segments do not intersect, or if they do, only with a few other segments. Need an faster algorithm for testing in such situations! Nevertheless, sparse distribution in practice:

The Sweeping Algorithm Avoid testing pairs of segments that are far apart. Idea: imagine a vertical sweep line passes through the given set of line segments, from left to right. Sweep line

Assumptions on Non-degeneracy 1. No segment is vertical. // the sweep line always hits a segment at // a point. If ≥ 1 vertical segment, rotate all segments by a small angle and then test for intersection. 2. No three segments are concurrent. Exercise on how to deal with the violating case. Dealing with degeneracies are often the most laborious part of implementing geometric algorithms and proving their correctness.

Ordering Segments A total order over the segments that intersect the current position of the sweep line: a b c d e b > c > d (a and e are out of the ordering) Such a total order T is called the sweep-line status.

Sweep-line Status Describes the relationships among the segments intersected by the sweep line. Supports the following operations on a segment s. Insert(T, s) Delete(T, s) Above(T, s) // segment immediately above s Below(T, s) // segment immediately below s Red-black tree implementation (key comparisons replaced by cross-product comparisons). O(lg n) for each operation.

Sweeping around an Intersection The order of the two intersecting segments gets reversed. a b c d e f before after d < f < c < bd < c < f < b

Event-point Schedule The sweeping algorithm does something only when it reaches an endpoint. Sort the segment endpoints by increasing x-coordinate and proceed from left to right. A sequence of x-coordinates, in increasing order. Where will the sweep line make intermediate stops?

An Example a b c d e f a Intersect! abab acbacb dacbdacb dcbdcb edcbedcb edbedb Sweep-line status:

The Sweeping Algorithm Any-Segments-Intersect(S) // a set S of line segments T = { } // total order of segments intersecting the sweep line sort the endpoints of the segments from left to right for each point p in the sorted list do if p is the left endpoint of a segment s then Insert(T, s) if (Above(T, s) exists and intersects s) or (Below(T, s) exists and intersects s) then return true if p is the right endpoint of a segment s then if both Above(T, s) and Below(T, s) exist and they intersect then return true Delete (T, s) return false Above(T, s) Below(T, s) s p Above(T, s) Below(T, s) p s

Running Time Total time O(n lg n). Sorting of line segments takes O(n lg n) time. There are 2n event points, each costs O(lg n) on updating the sweep-line status.