CS 506: Homework #1 |
Problem 1: These are questions about the DCEL data structure discussed in class.
Problem 2:
Generalize our segment intersection algorithm (the decision version
only) so that it will be applicable to circles. (Note that two circles
are not considered to intersect if one is properly nested within the other.)
Hint: a crucial property of segments is that they are monotone with respect
to the direction of sweep, whereas circles are not, so take measures to
handle circles in such a way that the building blocks you use are in fact
monotone with respect to the direction of sweep.
The simplest way is to decompose each circle into four quarter circles;
these quarter circles create four intersections that will be identified
and will have to be discarded, but otherwise they have the monotonic
property that individual segments have: as we move along increasing abscissae,
the ordinates increase (or decrease) monotonically.
Problem 3:
Design a sweepline algorithm for the following problem:
given a set of non-intersecting segments in the plane and a point not
on any of the segments, return (the index of) each segment that is
visible from the given point. (A segment s is visible
from a point P if and only if there exists a point Q
on s such that the segment PQ does not intersect
any segment other than s itself.) Your algorithm should run
in O((nlogn)) time.
We will use a sweep on angle (360 degrees) from the given point;
events in the sweep are exactly the same as in the x sweep used in our
segment intersection algorithm (begin, end, and intersection, although here
we will not get any intersection);
stripes are replaced by wedges and the segment closest to the center
of the wedge is what is visible in that wedge. In order not to print
the same segment over and over, we can store the ID of the top segment
for each wedge in an array, then sort the array by distribution sort
(in linear time) and only print distinct values (or we can mark what
has been printed and look it up). Because we have no intersections,
the running time remains just O(nlogn).
| Back to CS 506 home page |