• Nenhum resultado encontrado

l ea

eb

l1

Figure 72: Proof of the Zone Theorem.

the set. For each point, it is possible to compute the angles between this point and the remainingn−1points and then sort these angles. This would takeO(nlogn)time per point, andO(n2logn)time overall.

With arrangements we can speed this up toO(n2)total time, getting rid of the extraO(logn)factor. Here is how. Recall the point-line dual transformation. A pointp= (px, py)and line` : (y =ax−b)in the primal plane are mapped through to a dual point`and dual linepas follows:

` = (a, b)

p : (b=pxa−py).

Recall that thea-coordinate in the dual plane corresponds to the slope of a line in the primal plane. Suppose that pis the point that we want to sort around, and letp1, p2, . . . , pnbe the points in final angular order aboutp.

p*8

p*3

p*2

p*7

p*6

p*5

p*1

p*4

p*

p p5 4

p

p3

p2

p1

p8

p7

p6

Figure 73: Arrangements and angular sequences.

Consider the arrangement defined by the dual linespi. How is this order revealed in the arrangement? Consider the dual linep, and its intersection points with each of the dual linespi. These form a sequence of vertices in the arrangement alongp. Consider this sequence ordered from left to right. It would be nice if this order were the desired circular order, but this is not quite correct. Thea-coordinate of each of these vertices in the dual arrangement is the slope of some line of the formppi. Thus, the sequence in which the vertices appear on the line is aslope orderingof the points aboutpi, not anangular ordering.

However, given this slope ordering, we can simply test which primal points lie to the left ofp(that is, have a smallerx-coordinate in the primal plane), and separate them from the points that lie to the right ofp(having a largerx-coordinate). We partition the vertices into two sorted sequences, and then concatenate these two sequences, with the points on the right side first, and the points on the left side later. The resulting is an angular sequence starting with the angle−90degrees and proceeding up to+270degrees.

Thus, once the arrangement has been constructed, we can reconstruct each of the angular orderings in O(n) time, for a total ofO(n2)time.

Maximum Discrepancy: Next we consider a problem derived from computer graphics and sampling. Suppose that we are given a collection ofnpointsS lying in a unit squareU = [0,1]2. We want to use these points for random sampling purposes. In particular, the property that we would like these points to have is that for any halfplaneh, we would like the size of the fraction of points ofPthat lie withinhshould be roughly equal to the area of intersection ofhwithU. That is, if we defineµ(h)to be the area ofh∩U, andµS(h) =|S∩h|/|S|, then we would likeµ(h)≈µS(h)for allh. This property is important when point sets are used for things like sampling and Monte-Carlo integration.

To this end, we define thediscrepancyofSwith respect to a halfplanehto be

S(h) =|µ(h)−µS(h)|.

For example, in the figure below (a), the area ofh∩U isµ(h) = 0.625, and there are 7 out of 13 points in h, thusµS(h) = 7/13 = 0.538. Thus the discrepancy ofhis|0.625−0.538|= 0.087. Define thehalfplane

discrepancyofSto be the maximum (or more properly the supremum, or least upper bound) of this quantity over all halfplanes:

∆(S) = sup

hS(h).

p

l θ h

r1 r2

(a) (b)

Figure 74: Discrepancy of a point set.

Since there are an uncountably infinite number of halfplanes, it is important to derive some sort offiniteness criterionon the set of halfplanes that might produce the greatest discrepancy.

Lemma: Lethdenote the halfplane that generates the maximum discrepancy with respect toS, and let`denote the line that boundsh. Then either (i)`passes through at least two points ofS, or (ii)`passes through one point ofS, and this point is the midpoint of the line segment`∩U.

Remark: If a line passes through one or more points ofS, then should this point be included inµS(h)? For the purposes of computing the maximum discrepancy, the answer is to either include or omit the point, whichever will generate the larger discrepancy. The justification is that it is possible to perturbh infinites-imally so that it includes none or all of these points without alteringµ(h).

Proof: If`does not pass through any point ofS, then (depending on which is largerµ(h)orµS(h)) we can move the line up or down without changingµS(h)and increasing or decreasingµ(h)to increase their difference. If`passes through a pointp∈S, but is not the midpoint of the line segment`∩U, then we claim that we can rotate this line aboutpand hence increase or decreaseµ(h)without alteringµS(h), to increase their difference.

To establish the claim, consider the figure above (b). Suppose that the line`passes through pointpand letr1 < r2 denote the two lengths along`frompto the sides of the square. Observe that if we rotate` through a small angleθ, then to a first order approximation, the loss due to area of the triangle on the left is r21θ/2, since this triangle can be approximated by an angular sector of a circle of radiusr1and angleθ. The gain due to the area of the triangle on the right isr22θ/2. Thus, sincer1< r2this rotation will increase the area of region lying belowhinfinitessimally. A rotation in the opposite decreases the area infinitessimally.

Since the number of points bounded byhdoes not change as a function ofθ, the discrepancy cannot be achieved as long as such a rotation is possible.

(Note that this proof reveals something slightly stronger. If`contacts two points, the line segment between these points must contain the midpoint of the`∩U. Do you see why?)

Since for each pointp∈Sthere are only a constant number of lines`(at most two, I think) through this point such thatpis the midpoint of`∩U, it follows that there are at mostO(n)lines of type (i) above, and hence the discrepancy of all of these lines can be tested inO(n2)time.

To compute the discrepancies of the other lines, we can dualize the problem. In the primal plane, a line ` that passes through two pointspi, pj ∈S, is mapped in the dual plane to a point`at which the linespi and pj intersect. This is just a vertex in the arrangement of the dual lines for S. So, if we have computed the arrangement, then all we need to do is to visit each vertex and compute the discrepancy for the corresponding primal line.

It is easy to see that the area`∩Uof each corresponding line in the primal plane can be computed inO(1)time.

So, all that is needed is to compute the number of points ofS lying below each such line. In the dual plane, the corresponds to determining the number of dual lines that lie below or above each vertex in the arrangement.

If we know the number of dual lines that lie strictly above each vertex in the arrangement, then it is trivial to compute the number of lines that lie below by subtraction.

We define a point to be atlevelk, denotedLk, in an arrangement if there are at mostk−1lines above this point and at mostn−klines below this point. Thek-th level of an arrangement is anx-monotone polygonal curve, as shown below. For example, the upper envelope of the lines is level 1 of the arrangement, and the lower envelope is levelnof the arrangement. Note that a vertex of the arrangement can be on multiple levels. (Also note that our definition of level is exactly one greater than our text’s definition.)

L3

L5

L1

Figure 75: Levels in an arrangement.

We claim that it is an easy matter to compute the level of each vertex of the arrangement (e.g. by plane sweep).

The initial levels at x = −∞are determined by the slope order of the lines. As the plane sweep proceeds, the index of a line in the sweep line status is its level. Thus, by using topological plane sweep, inO(n2)time we can compute the minimum and maximum level number of each vertex in the arrangement. From the order reversing property, for each vertex of the dual arrangement, the minimum level number minus 1 indicates the number of primal points that lie strictly below the corresponding primal line and the maximum level number is the number of dual points that lie on or below this line. Thus, given the level numbers and the fact that areas can be computed inO(1)time, we can compute the discrepancy inO(n2)time andO(n)space, through topological plane sweep.