Orthogonal Line Segment Intersection Given N horizontal and N vertical line segments, find all intersections. All x and y coordinates are distinct.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

Two Segments Intersect?
Polygon Triangulation
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.
Line Segment Intersection. Balanced binary search tree Internal nodes: Rightmost leaf in its left subtree Status Structure T.
Polygon overlay in double precision arithmetic One example of why robust geometric code is hard to write Jack Snoeyink & Andrea Mantler Computer Science,
Brute-Force Triangulation
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
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.
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
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
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.
17. Computational Geometry Chapter 7 Voronoi Diagrams.
Klee’s Measure Problem Computational Geometry, WS 2007/08 Group Work Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen, Institut.
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
Hidden-Line Elimination Computational Geometry, WS 2006/07 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
I/O-Algorithms Lars Arge University of Aarhus March 7, 2005.
Lecture 11 : More Geometric Data Structures Computational Geometry Prof. Dr. Th. Ottmann 1 Geometric Data Structures 1.Rectangle Intersection 2.Segment.
Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Brute-Force Triangulation
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
Discrete and Continuous Functions
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
Triangulating a monotone polygon
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
Lars Arge Presented by Or Ozery. I/O Model Previously defined: N = # of elements in input M = # of elements that fit into memory B = # of elements per.
CMPS 3130/6130 Computational Geometry Spring 2015
Computational Geometry: Intersection Search Joseph S. B. Mitchell Stony Brook University.
1/14/20161 BST Operations Data Structures Ananda Gunawardena.
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.
Lecture 15 Computational Geometry Geometry sweeping Geometric preliminaries Some basics geometry algorithms.
Problem Definition I/O-efficient Rectangular Segment Search Gautam K. Das and Bradford G. Nickerson Faculty of Computer science, University of New Brunswick,
Computational Geometry
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
Line Sweep Algorithms Schalk-Willem Krüger – 2009 Training Camp 1 presentation.start();
3. Polygon Triangulation
Geometric Data Structures
Introduction to Polygons
Computer Graphics CC416 Week 13 Clipping.
CMPS 3130/6130 Computational Geometry Spring 2017
Query Processing in Databases Dr. M. Gavrilova
Algorithm design techniques Dr. M. Gavrilova
Introduction to Functions
Lesson 2.8 The Coordinate Plane
Section 7.2A Domain and Range.
Computational Geometry Capter:1-2.1
Polygon Triangulation
Graphing on the Coordinate Plane
Priority Search Trees Modified Prof. Sahni’s notes.
Insertion Sort Demo Sorting problem:
Plotting Points Guided Notes
Inspired by SWERC 2014 ( City Park), ecs
A B D C E F Rectangle corners Lower left Upper right A (4, 9) (8,11)
Graphing on the Coordinate Plane
The COORDINATE PLANE The COORDINATE PLANE is a plane that is divided into four regions (called quadrants) by a horizontal line called the x-axis and a.
CS 113: Data Structures and Algorithms
Functions and Relations
Algorithms and Data Structures Lecture XIV
Presentation transcript:

Orthogonal Line Segment Intersection Given N horizontal and N vertical line segments, find all intersections. All x and y coordinates are distinct.

Solution Brute Force: O(n^2) Line Sweep: 1.Sort the points according to x coordinates. 2.Sweep a vertical line from left to right. 3.X- coordinates define event Event 1: Left Endpoint of horizontal line encountered: Action: Insert y coordinate into BST Event 2: Right endpoint of horizontal line encountered. Action: Remove y coordinate from BST as we have processed the line.

Event 3: A vertical line is encountered Action: Do a range search of endpoints of y in the bst. Number of y in between current endpoints is number of intersection this vertical line makes. Time Complexity ??

Q. What if the lines were not horizontal or vertical ??

Psuedo Code Maintain a priority queue Q Initially all end points are added to Q While(Q not empty){ event E= Q.delete – min() if(event is left){ set.insert(seg E) seg A = the segment Above segE in set seg B = the segment below segE in set If (I = Intersect( segE,segA) exists) Insert I into Q; If (I = Intersect( segE,segB) exists) Insert I into EQ; } else if(event is right){ seg A = the segment Above segE in set seg B = the segment below segE in set If (I = Intersect( segA,segB) exists) Insert I into Q; set.delete(segE) }

Psuedo-Code else{ output intersection point swap positions of intersecting segment in segA = the segment above segE2 in SL; segB = the segment below segE1 in SL; If (I = Intersect(segE2,segA) exists) If (I is not in Q already) Insert I into Q; If (I = Intersect(segE1,segB) exists) If (I is not in Q already) Insert I into Q; }

Applications Complexity: O ( (N +I)lg(N+I))

Find area of union of all rectangles.

Problems Topcoder SRM 283 PowerSupply

Problems There are N posters hung on a wall one after another. How many posters have at least one visible section in the end? Input: Output: 4