computational geometry
play

Computational Geometry Lecture 15: Windowing queries Computational - PowerPoint PPT Presentation

Motivation Segment trees Windowing again Windowing queries Computational Geometry Lecture 15: Windowing queries Computational Geometry Lecture 15: Windowing queries Motivation Segment trees Windowing queries Windowing again Windowing


  1. Motivation Segment trees Windowing again Windowing queries Computational Geometry Lecture 15: Windowing queries Computational Geometry Lecture 15: Windowing queries

  2. Motivation Segment trees Windowing queries Windowing again Windowing Zoom in; re-center and zoom in; select by outlining Computational Geometry Lecture 15: Windowing queries

  3. Motivation Segment trees Windowing queries Windowing again Windowing Computational Geometry Lecture 15: Windowing queries

  4. Motivation Segment trees Windowing queries Windowing again Windowing Given a set of n axis-parallel line segments, preprocess them into a data structure so that the ones that intersect a query rectangle can be reported efficiently Computational Geometry Lecture 15: Windowing queries

  5. Motivation Segment trees Windowing queries Windowing again Windowing Given a set of n arbitrary, non-crossing line segments, preprocess them into a data structure so that the ones that intersect a query rectangle can be reported efficiently Computational Geometry Lecture 15: Windowing queries

  6. Motivation Segment trees Windowing queries Windowing again Windowing Two cases of intersection: An endpoint lies inside the query window; solve with range trees The segment intersects a side of the query window; solve how? Computational Geometry Lecture 15: Windowing queries

  7. Motivation Segment trees Windowing queries Windowing again Using a bounding box? If the query window intersects the line segment, then it also intersects the bounding box of the line segment (whose sides are axis-parallel segments) So we could search in the 4 n bounding box sides Computational Geometry Lecture 15: Windowing queries

  8. Motivation Segment trees Windowing queries Windowing again Using a bounding box? But: if the query window intersects bounding box sides does not imply that it intersects the corresponding segments Computational Geometry Lecture 15: Windowing queries

  9. Motivation Segment trees Windowing queries Windowing again Windowing Current problem of our interest: Given a set of arbitrarily oriented, non-crossing line segments, preprocess them into a data structure so that the ones intersecting a vertical (horizontal) query segment can be reported efficiently Computational Geometry Lecture 15: Windowing queries

  10. Motivation Segment trees Windowing queries Windowing again Using an interval tree? q q Computational Geometry Lecture 15: Windowing queries

  11. Motivation Definition Segment trees Querying Windowing again Storage Interval querying Given a set I of n intervals on the real line, preprocess them into a data structure so that the ones containing a query point (value) can be reported efficiently We have the interval tree, but we will develop an alternative solution Computational Geometry Lecture 15: Windowing queries

  12. Motivation Definition Segment trees Querying Windowing again Storage Interval querying Given a set S = { s 1 , s 2 ,..., s n } of n segments on the real line, preprocess them into a data structure so that the ones containing a query point (value) can be reported efficiently s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 The new structure is called the segment tree Computational Geometry Lecture 15: Windowing queries

  13. Motivation Definition Segment trees Querying Windowing again Storage Locus approach The locus approach is the idea to partition the solution space into parts with equal answer sets s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 For the set S of segments, we get different answer sets before and after every endpoint Computational Geometry Lecture 15: Windowing queries

  14. Motivation Definition Segment trees Querying Windowing again Storage Locus approach Let p 1 , p 2 ,..., p m be the sorted set of unique endpoints of the intervals; m ≤ 2 n s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 The real line is partitioned into ( − ∞ , p 1 ) , [ p 1 , p 1 ] , ( p 1 , p 2 ) , [ p 2 , p 2 ] , ( p 2 , p 3 ) ,..., ( p m , + ∞ ) , these are called the elementary intervals Computational Geometry Lecture 15: Windowing queries

  15. Motivation Definition Segment trees Querying Windowing again Storage Locus approach We could make a binary search tree that has a leaf for every elementary interval ( − ∞ , p 1 ) , [ p 1 , p 1 ] , ( p 1 , p 2 ) , [ p 2 , p 2 ] , ( p 2 , p 3 ) ,..., ( p m , + ∞ ) Each segment from the set S can be stored with all leaves whose elementary interval it contains: [ p i , p j ] is stored with [ p i , p i ] , ( p i , p i + 1 ) ,..., [ p j , p j ] A stabbing query with point q is then solved by finding the unique leaf that contains q , and reporting all segments that it stores Computational Geometry Lecture 15: Windowing queries

  16. Motivation Definition Segment trees Querying Windowing again Storage Locus approach s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 ( −∞ , p 1 ) ( p 1 , p 2 ) ( p 2 , p 3 ) ( p 3 , p 4 ) ( p 4 , p 5 ) ( p 5 , p 6 ) ( p 6 , p 7 ) ( p 7 , p 8 ) ( p 8 , + ∞ ) [ p 1 , p 1 ] [ p 2 , p 2 ] [ p 3 , p 3 ] [ p 4 , p 4 ] [ p 5 , p 5 ] [ p 6 , p 6 ] [ p 7 , p 7 ] [ p 8 , p 8 ] Computational Geometry Lecture 15: Windowing queries

  17. Motivation Definition Segment trees Querying Windowing again Storage Locus approach p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 Computational Geometry Lecture 15: Windowing queries

  18. Motivation Definition Segment trees Querying Windowing again Storage Locus approach Question: What are the storage requirements and what is the query time of this solution? Computational Geometry Lecture 15: Windowing queries

  19. Motivation Definition Segment trees Querying Windowing again Storage Towards segment trees ( p i , p i +2 ] In the tree, the leaves store elementary intervals But each internal node ( p i , p i +1 ) ( p i +1 , p i +2 ) corresponds to an interval too: [ p i +1 , p i +1 ] [ p i +2 , p i +2 ] the interval that is the union of the elementary intervals of all leaves below it p i p i +1 p i +2 Computational Geometry Lecture 15: Windowing queries

  20. Motivation Definition Segment trees Querying Windowing again Storage Towards segment trees ( p 2 , p 4 ] ( p 6 , + ∞ ) ( p 1 , p 2 ] p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 Computational Geometry Lecture 15: Windowing queries

  21. Motivation Definition Segment trees Querying Windowing again Storage Towards segment trees Let Int ( ν ) denote the interval of node ν To avoid quadratic storage, we store any segment s j as high as possible in the tree whose leaves correspond to elementary intervals More precisely: s j is stored with ν if and only if Int ( ν ) ⊆ s j but Int ( parent ( ν )) �⊆ s j Computational Geometry Lecture 15: Windowing queries

  22. Motivation Definition Segment trees Querying Windowing again Storage Towards segment trees ( p i − 2 , p i +2 ] ( p i , p i +2 ] ν ( p i , p i +1 ) ( p i +1 , p i +2 ) [ p i +1 , p i +1 ] [ p i +2 , p i +2 ] s j ( p i − 2 , p i +2 ] Int ( parent ( ν )) ( p i , p i +2 ] Int ( ν ) p i − 2 p i − 1 p i p i +1 p i +2 Computational Geometry Lecture 15: Windowing queries

  23. Motivation Definition Segment trees Querying Windowing again Storage Segment trees A segment tree on a set S of segments is a balanced binary search tree on the elementary intervals defined by S , and each node stores its interval, and its canonical subset of S in a list (unsorted) The canonical subset (of S ) of a node ν is the subset of segments s j for which Int ( ν ) ⊆ s j but Int ( parent ( ν ) �⊆ s j Computational Geometry Lecture 15: Windowing queries

  24. Motivation Definition Segment trees Querying Windowing again Storage Segment trees s 1 s 1 , s 3 , s 4 s 6 , s 7 s 5 s 3 , s 5 s 1 , s 2 s 6 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 s 1 , s 2 s 3 , s 4 s 5 s 6 s 7 s 8 s 7 , s 8 s 7 , s 8 s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 Computational Geometry Lecture 15: Windowing queries

  25. Motivation Definition Segment trees Querying Windowing again Storage Segment trees s 1 s 1 , s 3 , s 4 s 6 , s 7 s 5 s 3 , s 5 s 1 , s 2 s 6 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 s 1 , s 2 s 3 , s 4 s 5 s 6 s 7 s 8 s 7 , s 8 s 7 , s 8 s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 Computational Geometry Lecture 15: Windowing queries

  26. Motivation Definition Segment trees Querying Windowing again Storage Segment trees Question: Why are no segments stored with nodes on the leftmost and rightmost paths of the segment tree? Computational Geometry Lecture 15: Windowing queries

  27. Motivation Definition Segment trees Querying Windowing again Storage Query algorithm The query algorithm is trivial: For a query point q , follow the path down the tree to the elementary interval that contains q , and report all segments stored in the lists with the nodes on that path Computational Geometry Lecture 15: Windowing queries

  28. Motivation Definition Segment trees Querying Windowing again Storage Example query s 1 s 1 , s 3 , s 4 s 5 s 3 , s 5 s 6 , s 7 s 1 , s 2 s 6 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 s 1 , s 2 s 3 , s 4 s 5 s 6 s 7 s 8 s 7 , s 8 s 7 , s 8 s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 Computational Geometry Lecture 15: Windowing queries

  29. Motivation Definition Segment trees Querying Windowing again Storage Example query s 1 s 1 , s 3 , s 4 s 6 , s 7 s 5 s 3 , s 5 s 1 , s 2 s 6 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 s 3 , s 4 s 1 , s 2 s 5 s 6 s 7 s 8 s 7 , s 8 s 7 , s 8 s 3 s 6 s 2 s 7 s 1 s 8 s 4 s 5 Computational Geometry Lecture 15: Windowing queries

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend