Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!orion.oac.uci.edu!ucivax!milne From: milne@ics.uci.edu (Alastair Milne) Newsgroups: comp.lang.pascal Subject: Re: Text windows Message-ID: <27439508.7758@ics.uci.edu> Date: 16 Nov 90 07:28:08 GMT References: <7187@hub.ucsb.edu> Distribution: comp Organization: UC Irvine Department of ICS Lines: 24 In <7187@hub.ucsb.edu> 6600bori@ucsbuxa.ucsb.edu (Boris Burtin) writes: >I have been working on a text windowing program in Turbo Pascal, and just have >one question. I have a function that determines whether two windows overlap. >It currently does this by checking if one of the corners of one of the windows >is inside the other window. The problem is that I have not truly optimized the >coding. I have a long string and and/or statements that works, but gives me >a complex whenever I look at it. Does anyone have an algorithm for this kind >of problem? This sounds as if it would be easily handled by the Cohen-Sutherland clipping algorithm. You'd probably have to apply it to up to all four sides of one window, though, using the other as a basis; but it's reasonably fast. The reference I used to have for this was Newman and Sproull, but I can't remember their title; it may also be in Foley and Van Dam's book -- something like "Fundamentals of Interactive Computer Graphics". The fact that it's described for graphics doesn't matter, since you still need to compare coordinate pairs. You're just applying them to rather large points, i.e. text fonts. Alastair Milne