Computational Geometry

« nazaj

Computational geometry - Tutorial 17.3.2021


Sweeping algorithms


Exercise 1

The figure below shows the segments from the set $S$. We would like to find the intersections of the segments using the algorithm we have seen on the lectures. Write down the list of pairs of segments $\lbrace s,s’ \rbrace$ ($s, s’ \in S$) for which the algorithms checks whether $s \cap s’$ is empty or not. The pairs should appear in the list in the same order as they are checked by the algorithm. If the algorithm checks a pair multiple times, then the pair should appear accordingly many times in the list.


The algorithm for finding intersection of segments as described on the lectures:


Exercise 2

We are given a set $S$ of $n$ pairwise disjoint segments. Each segment from $S$ has one endvertex on the line $y = 0$ and the other endvertex on the line $y = 1$. The segments of $S$ partition the strip between the lines $y = 0$ in $y = 1$. Give pseudocode for a data structure which can be constructed in $O(n \log n)$ time and can answer queries to identify the part of the strip containing the query point $p = ({p_x}, {p_y})$ ($0 < {p_y} < 1$) in $O(\log n)$ time.



Exercise 3

We are given a set $L$ of $n$ lines in a plane. Let $I$ be the set of intersections of the lines in $L$. Describe an algorithm that returns the smallest rectangle containing $I$ with edges parallel to the coordinate axes in $O(n \log n)$ time.


Idea: find the leftmost, rightmost, topmost and bottommost intersections


Exercise 4

Let $S$ be a set of $n$ circles in a plane. (A circle is a curve, i.e., the edge of a disk.) Describe an output-sensitive sweeping algorithm which reports all intersections between the circles in $S$ in $O((n+k) \log n)$ time, where $k$ is the number of reported intersections.