Lecture Range Searching II: Windowing Queries

Lecture Range Searching II: Windowing Queries

Computational Geometry · Lecture Range Searching II: Windowing Queries INSTITUT FUR¨ THEORETISCHE INFORMATIK · FAKULTAT¨ FUR¨ INFORMATIK Tamara Mchedlidze · Darren Strash 23.11.2015 1 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Object types in range queries y0 y x x0 Setting so far: Input: set of points P (here P ⊂ R2) Output: all points in P \ [x; x0] × [y; y0] Data structures: kd-trees or range trees 2 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Object types in range queries y0 y0 y x x0 y x x0 Setting so far: Further variant Input: set of points P Input: set of line segments S (here P ⊂ R2) (here in R2) Output: all points in Output: all segments in P \ [x; x0] × [y; y0] S \ [x; x0] × [y; y0] Data structures: kd-trees Data structures: ? or range trees 2 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Axis-parallel line segments special case (e.g., in VLSI design): all line segments are axis-parallel 3 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Axis-parallel line segments special case (e.g., in VLSI design): all line segments are axis-parallel Problem: Given n vertical and horizontal line segments and an axis-parallel rectangle R = [x; x0] × [y; y0], find all line segments that intersect R. 3 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Axis-parallel line segments special case (e.g., in VLSI design): all line segments are axis-parallel Problem: Given n vertical and horizontal line segments and an axis-parallel rectangle R = [x; x0] × [y; y0], find all line segments that intersect R. How to approach this case? 3 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Axis-parallel line segments special case (e.g., in VLSI design): all line segments are axis-parallel Problem: Given n vertical and horizontal line segments and an axis-parallel rectangle R = [x; x0] × [y; y0], find all line segments that intersect R. Case 1: ≥ 1 endpoint in R ! use range tree Case 2: both endpoints 62 R ! intersect left or top edge of R 3 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Case 2 in detail Problem: Given a set H of n horizontal line segments and a vertical query segment s, find all line segments in H that intersect s. (Vertical segments and a horizontal query are analogous.) 4 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Case 2 in detail Problem: Given a set H of n horizontal line segments and a vertical line query segment s, find all line segments in H that intersect s. (Vertical segments and a horizontal query are analogous.) One level simpler: vertical line s := (x = qx) 0 0 0 Given n intervals I = f[x1; x1]; [x2; x2];:::; [xn; xn]g and a point qx, find all intervals that contain qx. s 4 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Case 2 in detail Problem: Given a set H of n horizontal line segments and a vertical line query segment s, find all line segments in H that intersect s. (Vertical segments and a horizontal query are analogous.) One level simpler: vertical line s := (x = qx) 0 0 0 Given n intervals I = f[x1; x1]; [x2; x2];:::; [xn; xn]g and a point qx, find all intervals that contain qx. s What do we need for an appropriate data structure? 4 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Interval Trees Construction of an interval tree T if I = ; then T is a leaf else let xmid be the median of the endpoints of I and define 0 0 Ileft = f[xj; xj] j xj < xmidg 0 0 Imid = f[xj; xj] j xj ≤ xmid ≤ xjg 0 Iright = f[xj; xj] j xmid < xjg T consists of a node v for xmid and lists L(v) and R(v) for Imid sorted by left and right interval endpoints, respectively left child of v is an interval tree for Ileft right child of v is an interval tree for Iright L = s3; s4; s5 v R = s5; s3; s4 L = s1; s2 R = s1; s2 L = s6; s7 R = s7; s6 s5 s2 s3 Imid s7 Ileft Iright s1 s4 s6 5 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Properties of interval trees Lemma 1: An interval tree for n intervals needs O(n) space and has depth O(log n). It can be constructed in time O(n log n). 6 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Properties of interval trees Lemma 1: An interval tree for n intervals needs O(n) space and has depth O(log n). It can be constructed in time O(n log n). How does the query work? 6 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Properties of interval trees Lemma 1: An interval tree for n intervals needs O(n) space and has depth O(log n). It can be constructed in time O(n log n). QueryIntervalTree(v; qx) if v no leaf then if qx < xmid(v) then search in L from left to right for intervals containing qx QueryIntervalTree(lc(v); qx) else search in R from right to left for intervals containing qx QueryIntervalTree(rc(v); qx) 6 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Properties of interval trees Lemma 1: An interval tree for n intervals needs O(n) space and has depth O(log n). It can be constructed in time O(n log n). QueryIntervalTree(v; qx) if v no leaf then if qx < xmid(v) then search in L from left to right for intervals containing qx QueryIntervalTree(lc(v); qx) else search in R from right to left for intervals containing qx QueryIntervalTree(rc(v); qx) Lemma 2: Using an interval tree we can find all k intervals containing a query point qx in O(log n + k) time. 6 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II From lines to line segments How can we adapt the idea of an interval tree for query segments 0 qx × [qy; qy] instead of a query line x = qx? qx xmid 7 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II From lines to line segments How can we adapt the idea of an interval tree for query segments 0 qx × [qy; qy] instead of a query line x = qx? qx 0 [−∞; qx] × [qy; qy] xmid 7 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II From lines to line segments How can we adapt the idea of an interval tree for query segments 0 qx × [qy; qy] instead of a query line x = qx? qx 0 [−∞; qx] × [qy; qy] xmid The correct line segments in Imid can easily be found using a range tree instead of simple lists. 7 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II From lines to line segments How can we adapt the idea of an interval tree for query segments 0 qx × [qy; qy] instead of a query line x = qx? qx 0 [−∞; qx] × [qy; qy] xmid The correct line segments in Imid can easily be found using a range tree instead of simple lists. Theorem 1: Let S be a set of horizontal (axis-parallel) line segments in the plane. All k line segments that intersect a vertical query segment (an axis-parallel rectangle R) can be found in O(log2(n) + k) time. The data structure requires O(n log n) space and construction time. 7 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Arbitrary line segments Map data often contain arbitrarily oriented line segments. Problem: Given n disjoint line segments and an axis-parallel rectangle R = [x; x0] × [y; y0], find all line segments that intersect R. How to proceed? 8 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Arbitrary line segments Map data often contain arbitrarily oriented line segments. Problem: Given n disjoint line segments and an axis-parallel rectangle R = [x; x0] × [y; y0], find all line segments that intersect R. How to proceed? Case 1: ≥ 1 endpoint in R ! use range tree Case 2: both endpoints 62 R ! intersect at least one edge of R 8 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Decomposition into elementary intervals Interval trees don't really help here 0 [−∞; qx] × [qy; qy] xmid 9 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Decomposition into elementary intervals Interval trees don't really help here 0 [−∞; qx] × [qy; qy] xmid Identical 1d base problem: 0 0 0 Given n intervals I = f[x1; x1]; [x2; x2];:::; [xn; xn]g and a point qx, find all intervals that contain qx. 0 sort all xi and xi in list p1; : : : ; p2n create sorted elementary intervals (−∞; p1); [p1; p1]; (p1; p2); [p2; p2];:::; [p2n; p2n]; (p2n; 1) 9 Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Range Searching II Segment trees Idea for data structure: create binary search tree with elementary intervals in leaves for all points qx in the same elementary interval the answer is the same leaf µ for elementary interval e(µ) stores interval set I(µ) query requires O(log n + k) time s2 s3 s1 s4 s5 10 Dr.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    43 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us