Asymptotic evaluation of window visibility

Asymptotic evaluation of window visibility

Information Processing Letters 31(1989) 119-126 North-Holland AS 8 May 1989 rd Satoshi MATSUO , Tomihisa KA DA, and Satoru Communicated by K. ...

974KB Sizes 0 Downloads 36 Views

Information Processing Letters 31(1989) 119-126 North-Holland

AS

8 May 1989

rd

Satoshi MATSUO

,

Tomihisa KA

DA, and Satoru

Communicated by K. Ikeda Received 1 !%ptember1988 Revised 29 December 1988

Keywords: Analysis of algorithms, graphics, simulation

tend

Although there has been much previous research on window systems, most have focused on the implementation aspects only [6,7,4,1]. Little attention has been paid to theoretical aspects of windows. In particular, abstract behavioral characteristics of windows have been totally neglected. Windows are usually rectangular, and there are a number of previous works in computational geometry regarding rectangular objects [5]. Unfortunately, mcst researchers stress the formulation of efficient aZg&thms for rectangles; collective behavioral characteristics of a set of overlapping rectangular objects have not been investigated in a way applicable to window systems. In this paper, we explore one formal characteristic of windows: visibility. Priority, a total crdering relation, can be defined between windows: given two windows, the one with the higher priority covers and thereby obscures an overlapping region of the other with lower priority. Then the visibility problem of windows is defined as follows: “given n windows, compute the probability of the kth window being totally or partially visible’“. We investigate the l-dimensional version of the problem and show that the visibility of windows is proportional to the reciprocal of the number of windows, and is independent of their average size. 0020-0190/89/$3.50

visib

proble

We first reduce the problem to one dimension, the problenp of overlapping intervals. We consider a set of line segments that are parallel to the x-axis in 2-dimensional space. When the line segments are projected orthogonally to the x-axis, the images of the segments become intervals over the x-axis, with the abscissae of the endpoints becoming the boundaries. We define that the projected intervals inherit the priority relations from their originals. 2.1. Notations and assumptions

(1) L%; 42; y]: a line segment in 2-D space, where 0 < xb < X, < 1, 0 ‘y < 1. (2) [x b; x,]: an interval on the ~-ax& where o
0 1989, Elsevier Science Publishers B.V. (North-Holland)

119

INFORMATION PROCESSING LE’ITERS

Volume 31, Number 3

8 h&y 1989

With this, (I) we have a total ordering among the left and right endpoints of intervals, and (2) we can define an inverse projection function p-‘(I) = I,, since the projection becomes a one-to-one mapping (Fig. 1).

fore, we must make assumptions in order to make A(n) finite and isiNe( n ) computable.

2.2. Definitions (interval visibility)

3.1. Simple model of interval distribution

We say that a line segment I = &,; x,; ~1 is visible over a set L when the following holds:

We consider a simple interval distribution model, which yields a very simple form of isible(n)* Th e result is shown to be consistent with a more complex model of distribution in the latter sections. The model makes the following assuml%isds: (b) All intervals have a constant width IV. (c) The distribution functions of left endpoints (of line segments and intervals) are uniform over the domain [O; 1, - w]. (Actually, any distribution function defineci over [Q; l] is allowed as long as it is identical for all elements of L.) These enable us to treat the coordinates of the line segments as discrete integers; i.e., the rank of the abscissa (or ordinate) of the left endpoint is As a result, A(n) becomes a finite set, islMe(n) computable. In addition, assumption (b) decreases the degree of freedom of each window to 1, which simplifies the analysis, and assumption (c) guarantees that the given interval does-not e&ed the dorrz in [O; I].

visibk( 1) = a( [ XL; xL])(o < xb < x; < xi 6 XC< 1 A(VmEL)(p(m)n[xL; AJW A Ihe

xi] +fl (2 .9


segment is iwisible iff it is not visible: (2 .2)

Interval i = [xb; x,1 is said to be visible when its original image of the projection is visible: (i) 3 visiMe(p-‘( i)). Finally, we define A(n) be the set of endpoint coordinates line segments. Then,

(2 .3)

the visibility of intervals. Let all possible combinations of and priority relations for n we have

i&n( 1

3. Asymptotic evaluation of interval visibility

3.2. Evaluation of intervai visibility

At

point, it is Isiwe(n) because A(n) i 120

this

to fd se

te e-

The evaluation is based on the following fact: the window with the lowest priority is visible only n it has nonempty overlappings with at least

Volume 31,

Number 3

INFORMATION PROCESSING LET? EI?s

8 May 1989

w

Fig.2.Case

one uf the gaps which are defined as the maximal intervals net covered by other intervals. Given a gap, for example, the interval in question is visible if it totally covers the gap or one of its endpoints is included in the gap. Case I: w >, f

In this simpkt case, it is obvious that there are only two gaps at both ends of the interval that is the union of ths image of all windows (Fig. 2). Consider addng an interval with lowest priority to a set of n - 1 intervals. By assumption (c), we observe that n --.I left endpoints exist in the range [O; l- w], creating n “slots” into which the left endpoint of the new interval can be placed. Then, the new interval is visible if its left endpoint is placed at the leftmost slot (left-end visible) or at the rightmost slot (right-end visible). Since the distribution is uniform, we have

For 4 \( w < 3, there are at most three gaps. In order for the interval to be visible through the third (inner) gap, there must be a pair of neighboring left endpoints separated by more than w, and the left endpoint of the interval must fall inbe,

Jit),

the probabky

of the

w>g.

existence of a gap satisfying the above condition. First, take the minimum n = 3. Let 1i and I2 be the two intervals that already exist, with A+,(&) < ~~(1~). Define x1 = ~~(1~) and x2 = ~~(1~). For a gap to exist, x2 must reside within x1 + w < x2 6 1 - w. Since the left endpoints exist between the range 0 6 x1, x2 < (1 - w), the probability that there is a gap between 3; and & is ((1 - 2~) x1)/(1. - w) (Fig. 3). As the gap exists only if xl exists within 0 < x1 ( (1 - 2w), , ,<3) is given by 2 p-2w l-2w-x)dx /0 ( \* (1 -9 = [2(1-

2w)x - XZj;-2W 2 -9 ( _-d - w )

=

(EJ.

(3.1) Similarly, for hc’>, 3, we label the intervals I i,. . . , Ik in the orilet of their priority. Define for 1 < k < n - 1. Suppose that I1 is xk = xb(Ik) the leftmost interval, and there is a gap between it and other intervals. Then, all intervals othrr thm 1i must reside within range x*+w
x3 ,...,.

X,,__1~1-‘~

(Fig. 4). Since any interval can be situated at the

w

1-W Fig. 3. Case f < w < 5.

321

Volume 31, Number 3

8 May 1989

INFORMATION PROCESSING LETTERS

Fig. 4.

leftmost position, the probability that a gap exists ketween II and Ip..., I,,_ I is given by (n - l)/1-2w(l

I l-

Examining the above factors, we obtain following probakility for each case:

- 2w - x)~-~ dx m( ni

0

1)Jb-2wxmW1(l

(1- W)n-l [-(1-2w-X)n-1]~-2w

= m

(1- W)n-l

1 (3 .2)

(m-l)!(n-m-l)! (n - l)! n-1

l1

0

2W

]L

-

W)n-l)

-I

)I(

(3 .3)

Notice that the probability is irrespective of m, and is therefore equivalent for all neighboring pairs. As there are n - 2 pairs, we easily obtain > w(n): ,w(n)=(n-2)(E)nB1

(Fig. 5). We must also consider two additional factors here: any combination of m intervals may reside to left of the gap, of those intervals, any one can take the place of

(n>3).

(3.4)

Finally, we obtain the upper and the lower bounds of bible(n). The widths of the outer gaps and the inner gap are really interdependent as well as dependent on w. Specifically, the possibility

I

-w

Fig. 5. 122

(n-l)! ( n-m - l)!m!

XIX

n more general cases, the gap can exist between any two neighboring intervals. Assume that I1 is the mth interval from the left, and there is a gap between it and the next interval to the right. Then, m - 1 intervals to the left of II must reside with.inO
- 2w - x)n-2 dx

W)n-l

(1=

the

1

Volume 31, Number 3

INFORMATION PROCESSING LETTERS

that the added interval is visible through the outer gaps is smaller if the inner gap exists, because the sizes of the outer gaps are smaller than the averfore, the upper bound of &n). In retrospect, intro would increase visibility of intervals; thus the lower bound of rSrr,re (n ) is 2/n. Thus, we have

2 n

-<

\

n-l

2 isiblc( n 1 K;+(n-2)

(

E

-

1

(3.5)

(03).

Asymptotically, in this case for w.

isi&

converges

t0

+2/n

Case4:w
For smaller values of w, there can be more gaps (e.g., for $ G w < i, at most two gaps could exist), adding more terms to (3.5)-but by performing the same type of analysis, we would see that they are all higher-order terms compared to (2/n), and are thus irrelevant to the asymptotic convergence. Therefore, we could conclude that, for practical values of w,

tori

8 May 1989

inte

Next, we examine if the above result will hold for a more complex model of interval distribution. We achieve this by calcula combinatorial method. The de ments, intervals, priority relations, and visibility are identical to those of the asymptotic evaluation; however, the following assumption differs: (b’) The distribution functions of endpoints are uniform over the domain 10; 11. (This still enables us to treat the coor ates of the line segments as ranks.) Assumption (b’) as the effect of increasing the degree of freedom allowed for each window to two, so that the model resembles real-world situations better. It should also be noted that, under uniform distribution, the eicpected average size of intervals is not 4 but 3. Unfortunately, the number of cases of interval distribution in the above model is (2n)!/2” for IP= ] L ] intervals if no equivalence relations are considered. The number of cases is huge even for a smaller n (e.g., for n = 5, it is 113,400), and grows exponentially; thus, the enumeration of all cases is virtually impossible for a larger n. To resolve this, we construct an algorithm that calculates the probability in O(efi) time complexity and

3172846642560 533971651248000 8.1382886178e+O40 53121496358e+O71

Fig. 6. Results from combinatorial calculation of visibility. 123

Volume 31, Number 3

INFORMATION PROCESSINO LETTERS

o(n) storage complexity. The algorithm is based on defining two ecluivalence relations among the interval distribution cases, and reduces the problem to enumerating the integer partitions of n. Although the time complexity was still exponential, we were able to obtain results for practical values of up to n 5: 80 with a program written in C on a SUN-3 workstation. Figure 6 is the table of extracted results. The calculation confirmed our intuitive preisi,,,&z) is a monotonically desumption that for n 2 1; furthermore, for a L4hle(~)s 2/n. The deviation is less > 20, and it monotonically des indicates that, asympisiMe(n)+ +(2./n). This e result obtained in the previous section.

ications of the result 5.1.

Design

of window system hardware

Many window system hardwares put limits on the number of windows that can be displayed horizontally. This is due to the speed restriction imposed by the access mechanism of the frame buffer; multiple frame buffers must be accessed during a horizontal raster scan of the display. The limit depends on hardware speed/cost trade-off; for example, it is sixteen for Intel’s 82786 [3], while removing this limitation would in turn compromise the arbitrary horizontal placement of windows [2]. In general, the evaluation of worLt=case situations is necessary when designing hardware, so that the specifications are sufficient to cover them. However, if they are not frequent, the design can be simplified SO that it resorts to software for recovery should they occur. this problem by computin (n), i.e., the probability of the horizontal limit being exceeded. We performed simulation for various numbers of

Exceeded 0

1

3 11 398 1225

2266

0 4e-05

39-05 0.00011 0.00398 0.01225 0.02265

Fig. 7. Results from computing Pexreedea with 100,000 trials of Monte-Carlo simulation.

it shows that even for 100 w is less than 0.3%. The actual much smaller, because it is rarely the case that 100 windows would share common raster lines. Hence, it is relatively safe to assume that the worst-case situations are least likely to occur, and only when such an exceptional condition is purposely created should one need to seek software solutions. 5.2. Window layout The result obtained can be applied to making assumptions in “optimal” lnvout of windows 1. QJ Our result isi&(n)G indicates that, for sets 2/n of practically sized windows, the “bottom” ones are very likely to become invisible. Such windows, in turn, become inaccessible by a pointing device; thus, either (1) a mechanism to allow selection of invisible windows should be available, or (2) the windows must be resized/rearranged to make them visible. The former approach is taken for example by some Macintosh applications, in which names of windows are available as menu choices. The latter approach is taken for example by tiled window systems such as Andrew [4]. When resizing/‘rearranging windows, the expectancy of the number of visible windows could be a guide in determining the placement of windows, or making decisions whether to iconify them, etc. The expectancy is given by a very 1

124

8 May 1989

ere, we will not indulge in defining the meaning of the term “optimal”.

Volume 31, Number 3

simple formula, inductive proof:

INFORMATION PROCESSING LETTERS

which is easily verified by an

R

c

(5.1)

i=l

The value would be a relatively safe overestimation for the window layout algorithm, as the acu tual number of visible windows would probably be smaller due to the reason stated previously.

xtending the result to higher dimensions It is difficult to extend the res?ults obtained in one dimension directly to determining the visibility of rectangles in higher dimensions. We cannot determine the rectangle’s visibility by simply combining the visibility relations along each axis. (We can easily give a counterexample.) In the worst case, if the widths of all rectangles along each axis (x, y) are of constant value, say (wX, w,), then we can easily place the rectangles so that the added rectangle is visible irrespective of n or its placement (Fig. 8). In order to overcome this anomaly, we have conceived an alternative method of determining rectangle visibility in higher dimensions. However, as the analysis of gaps is still premature, we will cover it only briefly here. The main idea is that if the width of the inter-

8 May 1989

vals is constant w >, i, then an interval covers exactly one endpoint (left or right) of each lower priority interval. If it covers the left endpoinr of another interval, then its own left endpoint will be to the left of the covered will be to the right. Then ing: upon adding a new ble iff there exist two intervals, one whose left endpoint is to the left of the left en added interval, and another whose 1 to the right. From this, we obtain

siMe(n+ 1) = 1 -

= l-

n-l n-2 n+l ! n

( 1

=A

(n&2)

)

(6.1) which matches our result in Section 3. This argument can be easily extende d-dimensional space: let interval In = (x:, . . . , x$) iy1a d-dimensional space, where ~7 is an interval in l-dimensional space. We define that I”+’ is covered by intervals 1’, . . . , I” iff

holds. Then,

The visible

the probability

that the (n + 1)st

becomes it is placed

Fig. 8. Worst-case ratangle layout. 125

INFDRMATION

vohnne 31, Number 3

PROCESSING LETTERS

8 May 1989

interval is visible is given by

= l-

= ‘-

(n>,r)

=

l

to thank Nakamura members of th aekawa La members of the Kawai Lab. for providing inspirations and cooperative support to our work.

!n-l ) [n:E’lj

rences

(n-l)(n-2)...(n-r-I-1) (n+ r-l)(n+r-2+(n+l)

ill F.R.A. Hopgood et al., eds., Methodology of Window

(6.2)

where r = 2d. The above evaluates to 0(1/n), which is seemingly identical to the l-dimensional case; note, however, that the actual probabilities are drastically different for higher dimensions due to the exponential growth of the coefficients with respect to d.

126

&Management(Springer, Berlin, 1986).

PI S. Ilgen and I.D. Scherson, Real-time virtual window management for bit mapped raster graphics, In: Proc. CG Jnternationaf ‘87 (Springer, Tokyo, 1987). t31 Intel Corporation, 82786 User’s ManruB. 231933-001, 1986. VI J. Morris et al., Andrew: a distributed personal computing environment, Comm. A CM 29 (1986) 184-201. PI F.P. Preparata and MI. Shamos, Computat:onal Geometry: An Introduction (Springer, New York, 1985). WI R. Scheifer and 9. Gettys, The X window system, ACM Trans. Graphics 5 (1986) 79-109. 171Programmers Reference Manual for Sun Windows (Sun Microsystems, 1985).