6.838, Computational Geometry; Fall 2001
Point Location
Sergi Elizalde & David Pritchard
An Incremental Randomized Algorithm
How can we construct
this structure, given a set of non-crossing line segments?
Algorithm TrapezoidalMap(S)
- Determine a bounding box R that contains all of the segments
of S
- Initialize T, the trapezoidal map structure and D,
the search structure:
- T is just the single trapezoid corresponding to the whole
box R
- D has only one node, corresponding to that trapezoid
- Compute a random permutation s1, s2,
..., sn of the segments of S
- For each segment si (in this order),
- Find the set of trapezoids in T properly intersected by
si
- Remove them from T and replace them by the new trapezoids
that appear because of the insertion of si
- Remove the leaves of D for the old trapezoids and create
leaves for the new ones. Link them to the existing inner nodes by adding
some new inner nodes as will be explained in a moment.
Key features of the algorithm:
Incremental:
Every time we insert a segment, we have a trapezoidal map and a data structure
for the segments inserted before.
It uses randomness,
so there are no bad inputs.