1 / 14

Line Segment Intersection

Line Segment Intersection. Computational Geometry, WS 2006/07 Lecture 3 – Part I Prof. Dr. Thomas Ottmann. Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg. Line Segment Intersection.

ayala
Download Presentation

Line Segment Intersection

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. Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg

  2. Line Segment Intersection • Motivation: Computing the overlay of several maps • The Sweep-Line-Paradigm: A visibilityproblem • Line Segment Intersection • Overlay of planar subdivisions Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  3. Maps Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  4. river road overlaid maps Motivation Thematic map overlay in Geographical Information Systems 1. Thematic overlays provide important information. 2. Roads and rivers can both be regarded as networks of line segments. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  5. Problem definition Input: SetS={s1...,sn } of n closed line segmentssi={(xi, yi), (x´i, y´i)} Output: All intersection points among the segments in S The intersection of two lines can be computed in time O(1). Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  6. Naive algorithm Goal: Output sensitive algorithm! Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  7. D C F G B A H E The Sweep-Line-Paradigm: A visibilityproblem Input: Set of n vertcal line segments Output: All pairs of mutually visible segments Naive method: Observation: Two line segments s and s´ are mutually visible iff there is a y such that s and s´are immediate neighbors at y. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  8. Q T • .H H • .D D!H • .A A!DH • .F AD!F!H • .C A!C!DFH • .E ACD!E!FH • AC!EFH • .G ACEF!G!H • .B A!B!CEFGH • ABCE!GH • AB!EGH • :: : : : Sweep line algorithm Qissetof the start and end points of the segments in decreasing y-order T is set of the active line segments D C F B A H E G Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  9. Algorithm Initialise Q as set of start and endpoints of segments in decreasing y-order; Initialise the set of active segments T = ; while Q do p = Q.Min; remove p from Q; if (p start point of segment s) T = T  {s}; determine neighbors s´ and s´´ of s; report (s, s´) and (s, s´´) as visible pairs else /* p is end point of segment s */ determine neighbors s´ and s´´ of s; report (s´, s´´) as visible pair;T = T - {s} Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  10. Sweep Line principle Imaginary linemoves in y direction. Each point is anevent. Input: A set of (iso-oriented objects) Output: Problem-dependent Q:object and problem-dependant queue of event points T: ordered set of the active objects /* status structure */ whileQdo select next event point from Q and remove it from Q; update(T); report problem-dependent result Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  11. Data structures: event queue Operations to be supported: Initialisation, min, deletion of points, Possible implementation: Balanced search tree of points with order p < q  py < qy or (py = qy and px < qx) Initialisation takes time O(m log m) for m items. Deletion takes time O(log m)with m items in queue. In most cases a priority queue supporting insertion and min-removal (eg. heap, O(m),O(log m), for initialisation and min-removal) is enough . Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  12. k l k i m j i l l i m j j k Data structures: status structure Operations to be supported: Insertion, deletion, searching for neighbors Possible implementation: Balanced search tree, O(log n) time Node values (keys) are used for routing Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  13. Runtime analysis Initialise Q as set of start and endpoints of segments in decreasing y-order; Initialise the set of active segments T = ; while Q do p = Q.Min; remove p from Q; if (p start point of segment s) T = T  {s}; determine neighbors s´ and s´´ of s; report (s, s´) and (s, s´´) as visible pairs else /* p is end point of segment s */ determine neighbors s´ and s´´ of s; report (s´, s´´) as visible pair;T = T - {s} Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  14. Summary Theorem: For a given set of n vertical line segments all k pairs of mutually visible segments can be reported in time O(n log n). Note: k is O(n) Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

More Related