1.
In this chapter we have looked at the point location problem with pre- processing. We have not looked at the single shot problem, where the subdivision and the query point are given at the same time, and we have no special preprocessing to speed up the searches. In this exercise and some of the following ones, we have a look at such problems.
Given a simple polygon P with n vertices and a query point q, here is an algorithm to determine whether q lies in P. Consider the ray ρ := {(qx +λ,qy) : λ > 0} (this is the horizontal ray starting in q and going rightwards). Determine for every edge e of P whether it intersects ρ. If the number of intersecting edges is odd, then q ∈ P, otherwise q à∈ P.
Prove that this algorithm is correct, and explain how to deal with degen- erate cases. (One degenerate case is when ρ intersects an endpoint of an edge. Are there other special cases?) What is the running time of the algorithm?
2. Suppose you are given an n-vertex simple polygon, P. Describe how to build an efficient data structure for determining in O(log n) time whether a query point, q, is inside of P or not. What is the space and preprocessing time for your data structure?
3. The ray shooting problem occurs in computer graphics (see Chapter 8). A 2-dimensional version can be given as follows: Store a set S of n non-crossing line segments such that one can quickly answer queries of the type: “Given a query ray ρ—a ray is a half-line starting at some point—find the first segment in S intersected by ρ.” (We leave it to you to define the behavior for degenerate cases.) In this exercise, we look at vertical ray shooting, where the query ray must be a vertical ray pointing upwards. Only the starting point need be specified in such a query. Give a data structure for the vertical ray shooting problem for a set S of n non-crossing line segments in general position. Bound the query time and storage requirement of your data structure. What is the preprocessing time?