A Fast, Practical Algorithm for the Trapezoidation of Simple Polygons submitted to CISST 05 by:

Save this PDF as:

Size: px
Start display at page:

Download "A Fast, Practical Algorithm for the Trapezoidation of Simple Polygons submitted to CISST 05 by:"


1 A Fast, Practcal Algorthm for the Trapezodaton of Smple Polygons submtted to CISST by: Dr. Thomas F. Han (presenter) School of Computer & Informaton Scences Unversty of South Alabama Moble, Al 6688 Phone: -6-6 FAX: -6- E-mal: Dr. Davd D. Langan,III School of Computer & Informaton Scences Unversty of South Alabama Moble, Al 6688 Phone: -6-6 FAX: -6- E-mal:

2 A Fast, Practcal Algorthm for the Trapezodaton of Smple Polygons Thomas F. Han, Davd D. Langan, III Abstract A fast, practcal, determnstc algorthm for the horzontal trapezodaton of smple polygons s presented. The polygon s decomposed nto a mnmal collecton of trapezod sequences, such that two trapezods adjacent wthn a sequence always share a common horzontal border. Such trapezod sequences are a convenent data structure n a dsplay lst for a collecton of polygonal objects to be flled/rendered. A lnear traversal of the polygon outlne dentfes a subset of crtcal vertces, whch are then processed n sweep order. Horzontal as well as vertcal edges very common n practcal polygons are handled explctly. Complexty s lnear for most practcal polygons, wth non-lnear runnng tmes beng requred only for much less frequently occurrng geometres. A straghtforward extenson allows trapezodaton of smple polygons wth holes. Index Terms Computatonal geometry, renderng (computer graphcs), trapezodaton, polygon decomposton. I. INTRODUCTION Decomposng a smple polygon has been one of the most challengng problems n two-dmensonal computatonal geometry. It s a basc prmtve n computer graphcs and, generally seems the natural preprocessng step for most nontrval operatons on smple polygons [[],[]]. The goal of polygonal decomposton s to break a gven smple planar polygon nto a set of standard two-dmensonal shapes (most often nonoverlappng trangles or trapezods) wthout addng any new vertces. Decompostons nto trapezods and trangles are equvalent n terms of computatonal complexty, snce one problem can be reduced to the other n lnear tme [[]]. Decompostons are often used to reduce problems nvolvng complcated regons to problems, nvolvng prmtve shapes, that are generally easer to solve. Defnton: A smple polygon s the regon of a plane bounded by a fnte collecton of lne segments formng a smple closed curve. Let v, v,,v be n n ponts n the plane wth a cyclc orderng. Let e = ( v, v),, e = ( v, v+ ), en be n edges connectng the ponts (vertces). Then these edges bound a polygon ff [[]] Manuscrpt receved March,. T. F. Han, and D. D. Langan, are wth the School of Computer & Informaton Scences, Unversty of South Alabama, Moble, AL 6688 USA (phone: -6-6; e-mal: The ntersecton of each par of edges adjacent n the cyclc orderng s the sngle vertex shared between them: e e+ = v+, for all =,, n.. Nonadjacent edges do not ntersect: e ej = φ, for all j +. In partcular, the storng and renderng of flled polygons n computer graphcs often requres such a decomposton. In the case of trapezodaton, t s further convenent to organze the trapezods nto a mnmal collecton of trapezod sequences so that common edges of adjacent trapezods can be represented more compactly. In fact, each trapezod sequence covers a monotone polygon component of the general smple polygon. Snce monotone polygons are easy to resolve nto trapezods [[]], the general trapezodaton problem could be approached as one of decomposng a general polygon nto monotone polygons, whch are then further decomposed nto the consttuent trapezods. Ths s the approach taken here, wth the output beng a collecton of horzontal trapezods (parttoned nto a set of trapezod sequences.) Defnton: A trapezod sequence s an ordered lst of horzontal trapezods ( t, t,, tk ) such that bottom top bottom top {( y = y+ ) ( x x+ φ) =,, k }, bottom where y s the y-coordnate of the bottom of the bottom th trapezod, and x s the range of x-coordnates covered by the bottom edge of the th trapezod. That s, the bottom edge of a trapezod overlaps the top edge of the next trapezod. Defnton: A horzontal decomposton of a polygon nto trapezod sequences s a set of trapezod sequences such the unon of all trapezods n all trapezod sequences s the trapezodaton of the polygon. That s, the horzontal decomposton s a (generally non-unque) parttonng of trapezods nto a collecton of trapezod sequences. As an example of the need for a fast algorthm for the trapezodaton of polygons, consder the feld of prnter graphcs. A prnted page contans ether geometrc flled shapes or btmaps. All geometrcally defned shapes are typcally specfed by areas bounded by conc, Bézer, or straght-lne segments. Curves are then approxmated to a seres of straght-lne segments by a process called flattenng the curve. Thus, geometrc shapes to be flled are almost always descrbed by polygons. The polygons that ultmately wll consttute a prnted page are then converted nto trapezod sequences that are stored n a dsplay lst. Ths dsplay lst s a data structure, whch s a spatally compressed representaton of the page that

3 can be effcently stored, reused, and rendered. It s clear that the speed of the trapezodaton algorthm wll have an mpact on prnter page output rates. Currently, fllng polygons s typcally done scan-lne by scan-lne usng an actve edge table to keep track of scan-lne spans nteror to the polygon. Ths s an mage precson algorthm, and depends on the specfc resoluton of the devce, and requres a great deal of processng, specally n the case of hgh-resoluton dsplay devces where a polygon can span a large number of scan lnes. Object precson algorthms, such as the algorthm descrbed here, have the advantage of beng devce resoluton ndependent. Secton II of ths paper gves a bref revew of exstng approaches to ths problem whle secton III descrbes the algorthm. Secton IV gves a proof outlne, and secton V gves a complexty analyss. Secton VI llustrates the used mplementaton approach, whle Secton VII gves comparatve performance results. II. PREVIOUS WORK Quadratc trangulaton algorthms have been mplct n proofs snce Lennes paper [[]]. In 8, Garey, Johnson, Preparata, and Tarjan [[8]] trangulated a smple polygon by decomposng t nto monotone polygons and then decomposng each of these separately nto trangles usng an algorthm also descrbed n that paper. The decomposton nto monotone polygons uses the regularzaton procedure ntroduced by Lee and Preparata [[]]. Ths procedure has n complexty, where n s the number of vertces, and adds to the polygon non-ntersectng dagonals, whch do not cross the polygon boundary. A 8 algorthm by Chazelle [[]] s partcularly easy to mplement. It fnds a dagonal of the polygon P that dvdes t nto two polygons P and P, such that the number of vertces n P and P are each less than P +. The algorthm fnds such a dagonal n Ο ( P ) tme. A smple dvde-and-conquer algorthm based on ths technque yelds a total complexty of n. A 8 paper by Hertel and Mehlhorn [[]] combned the steps of the algorthm of Garey et al. [[8]] nto one sweep to yeld an Ο algorthm. They then mproved t to Ο( nlog r) ( nlog n), where r s the number of concave angles (nternal angles >8 ) wthn the nput polygon, by restrctng the sweep event ponts to only O(r) ponts of the polygon. The sweep lne also s no longer a smple straght lne. A crooked lne s vared, snce some ponts do not get processed untl the actual sweep lne s well past them. Ths algorthm works even f the smple nput polygon has polygonal holes. Lke that of Hertel and Melhorn [[]], Chazelle and Incerp s 8 algorthm [[]] depends on the geometrc complexty of the polygon. Any smple polygon can be decomposed nto alternatng sequences of clockwse and counterclockwse spralng chans: they defne snuosty, s, as the number of such chans. The complexty of ther algorthm s s. All attempts to start wth the monotonzaton or dagonal splttng path faled untl 8, when Fourner and Montuno [[]] showed the equvalence of trapezodal decomposton wth trangulaton for smple polygons, and as a result, many recent efforts have been concentrated on polygon trapezodaton. Ther determnstc sweep algorthm constructs vertcal trapezods defned by two non-adjacent vertces of the nput n. Once trapezodalzed, P s polygon, P, n tme broken nto monotone polygons and trangulated by jonng the trapezod defnng vertces. Clarkson, along wth Tarjan [[6]] n 8 devsed a randomzed algorthm based on the dvde-and-conquer strategy that fnds the vsblty partton of the polygons wth respect to a random subset of edges. The polygon s then recursvely subdvded about that partton nto smaller polygons usng * Jordan sortng. The algorthm runs n expected Ο ( nlog n) can also be used to check whether or not a gven polygon s smple. In, Krkpatrck, Klawe, and Tarjan [[]] presented an log n algorthm employng much smpler data structures. In addton, ther algorthm can be modfed to run n Ο * ( nlog n) ( log n) In, Sedel [[]] ntroduced a randomzed ncremental algorthm to compute the horzontal vsblty map (trapezo- * daton) of a smple polygon. It has a complexty On ( log n),. It f the coordnates of the ponts of the polygon are ntegers bounded by a fxed polynomal n n. The basc dea s the same as n Tarjan s 88 paper, but the trangle splttng s acheved wthout any Jordan sortng or other complcated data structures. For bounded nteger coordnates, ths algorthm bulds a data structure n lnear tme that can answer queres about horzontal neghbors n Ο. but s much smpler to mplement than that of Clarkson and Tarjan. In fact, he asserts that ts mplementaton smplcty s a property that very few, f any, of the algorthms mentoned can clam. Also n, Bernard Chazelle [[]] dscovered a lnear tme, determnstc algorthm that settled the queston about the ntrnsc computatonal complexty of trangulaton once and for all. However, the algorthm s accordng to Toussant [[]] unmplementable, and accordng to O Rourke [[]] contans detals [that] are formdable. Ths algorthm has, to the authors knowledge, never been mplemented. III. CURRENT TRAPEZOIDATION ALGORITHM The presented algorthm has a precondton that the polygon s smple, and (n the current descrpton) that the vertces are gven n clockwse order around the polygon startng at some arbtrary vertex. It wll also be assumed that unnecessary nlne vertces have been prevously removed by a smple, lnear, preprocessng stage.

4 Vertex coordnates are snapped to an arbtrarly fne (wthn the representaton) grd to allow drect coordnate comparson wthout havng to worry about round-offs. A. Prelmnares To help n the dscusson of the algorthm, some termnology s now defned: Defnton: A chan C = ( v, v,, vp ) s a planar straght-lne graph wth vertex set { v, v,, v p } and edge set {( v, v+ ) =,, p }. [[8]] Defnton: A chan C = ( v, v,, vp ) s sad to be monotone relatve to a gven lne l f a lne orthogonal to l ntersects C at exactly one pont. That s, the orthogonal projectons {( lv), lv ( ), l( v p )} of the vertces of C on l are ordered as lv ( ),( lv),,( lvp ). [[8]] We extend the orderng to be nonstrct usng ether the or relatons. Defnton: A fallng chan s a maxmal (n the sense that t ncludes any horzontal edges at ether end) chan that s monotone relatve to a vertcal lne, and havng non-ncreasng y-coordnates. A fallng chan has the property DOWNTORIGHT f the lower end s to the rght of the upper end. A rsng chan s nonmaxmal, but s otherwse smlarly defned. Defnton: A polygon s monotone f ts boundary s composed of exactly two non-ntersectng monotone chans relatve to the same lne. For example, a polygon s vertcally monotone f ts boundary s composed of two vertcally monotone chans: the polygon s left chan and rght chan. In ths case, each chan termnates at the polygon s uppermost vertex (assumng no horzontal edges at the top and bottom) and lowermost vertex and contans zero or more vertces n between. [[]] Defnton: A fallng chan s splt nto two downchans at the rghtmost vertex (wth tes beng broken by takng the lower vertex of a vertcal edge). If the rght extremum s at ether end of the fallng chan, one of the down-chans s null. Defnton: Smlarly, a rsng chan s splt nto two up-chans at the leftmost vertex (wth tes beng broken by takng the upper vertex of a vertcal edge). Agan, f the left extremum s at ether end of the rsng chan, one of the up-chans s null. Defnton: A jon vertex, or smply a jon, s a vertex that connects (.e., s an element of adjacent) up-chans and/or down-chans. That s, a jon vertex v C n +,, + m k k = C + k k +, where C and C are two successve up[down] chans of length n and m successvely. There are dstnct jon types, and are llustrated n Fgure, where the heavy drected arcs represent upchans, the lghter drected arcs represent downchans, and the jon s the connectng vertex. The shadng represents the sde of the chans nteror to the polygon (whch you wll recall s clockwse orented). LPEAK RPEAKR LVALLEY RVALLEYR UCUSP LPEAKR RPEAK LVALLEYR RVALLEY DCUSP Fgure Jon Types. (Arcs represent chans) The jon types are defned n Table. It should be noted that, because of the precondton for no nlne vertces, the condton e + = cannot occur. The algorthm proceeds by dentfyng all j jon vertces n a pass through the vertex lst. It can be readly seen that, for practcal polygons, j << n, where n s the number of vertces n the polygon, and j s the number of jon vertces. The jon vertces are then sorted lexcographcally by ther x-coordnate, and negatve y-coordnate. Whle ths sortng could be done by a Jordon sort n lnear tme, t s more effcent to use a qucksort for practcal polygons of bounded sze. The algorthm then processes (.e., sweeps) jons sequentally from left to rght. Trapezod (sequences) are generated durng the processng of certan jon types (.e., at certan sweep events.) Vertces that are not jons that are nternal to chans wll generally only be vsted twce, once durng jon dentfcaton, and once durng trapezod generaton. At any pont n the jon processng (.e., at a sweep event), there wll exst one or more wndows, whch are composed of concatenated fragments of up-chans. These chans are what can be seen lookng toward the left from any pont havng the current sweep event s x-coordnate, and therefore represent a potental sequence of left sdes for adjacent trapezods. Defnton: A wndow relatve to jon p, s a transent (exstng at sweep event p) up-chan, and s composed of fragments of wndows, connected by horzontal segments. Four operatons exst on wndows:. Creaton from an up-chan.. Splttng at a y-nterpolaton (see below).. Extenson, by concatenatng an up-chan.. Reducton (possbly completely), durng trapezod generaton. Practcal polygons are those defnng typcal graphcal objects outlned by flattened curves and straght lne segments. In these cases, the length of chans tends not to be as small as, for example, random generated and non-smoothed polygons.

5 Table Defnton of Jon Types. Jon type LPEAK LPEAKR RPEAK RPEAKR LVALLEY LVALLEYR RVALLEY RVALLEYR UCUSP DCUSP Defnton Vertex, v, jonng top of up-chan and a non- DOWNTORIGHT down-chan, such that the vector product of the ncdent edges, e >. + Vertex, v, jonng top of up-chan and a DOWNTORIGHT down-chan, such that the vector product of the ncdent edges, e >. + Vertex, v, jonng top of up-chan and a non- DOWNTORIGHT down-chan, such that the vector product of the ncdent edges, e <. + Vertex, v, jonng top of up-chan and a DOWNTORIGHT down-chan, such that the vector product of the ncdent edges, e <. + Vertex, v, jonng bottom of up-chan and a non-downtoright down-chan, such that the vector product of the ncdent edges, e + <. Vertex, v, jonng bottom of up-chan and a DOWNTORIGHT down-chan, such that the vector product of the ncdent edges, e + <. Vertex, v, jonng bottom of up-chan and a non-downtoright down-chan, such that the vector product of the ncdent edges, e + >. Vertex, v, jonng bottom of up-chan and a DOWNTORIGHT down-chan, such that the vector product of the ncdent edges, e + >. Vertex, v, jonng two up-chans. Vertex, v, jonng two down-chans. upper part of the splt wndow, (X,). The ear bounded by the down-chan (,), the bottom part of the splt wndow, and the horzontal edge from X to jon, s a vertcally monotone polygon, and wll be converted to trapezods, and taken out of consderaton for the remander of the process. Defnton: A y-nterpolaton at a heght y of a wndow W exsts f the wndow vertcally spans y, and, n ths case, s one of three types. It s the pont havng y-coordnate y, and x-coordnate determned for each of three types as follows: Type I: If there exst two vertces n W at heght y (.e., a horzontal edge at heght y): the x-coordnate of the vertex ncdent on the head end of the horzontal edge. We wll call the vertex at the tal end of the horzontal edge the secondary y-nterpolaton. Type II: If there exsts a sngle vertex n W at heght y: the x-coordnate of that vertex. Type III: If there exst no vertces n W at heght y: the x-coordnate of the ntersecton of the horzontal lne at heght y and the edge n W that vertcally spans y. The wndow y-nterpolaton types are llustrated n Fgure. The drected arcs are clockwse-specfed edges n the wndow. All ponts labeled p are y-nterpolatons at the heght ndcated by the dashed horzontal lne. For type I nterpolatons, ponts labeled p ' are secondary y-nterpolatons. Defnton: In any polygon (or polygon fragment) there s one wndow W relatve to the current jon p (sweep event), that s dstngushed by havng the largest (rghtmost) y-nterpolaton at heght y p to the left of p. Wndow, W, s termed left-facng jon p. B. Jon Processng Wndows are sequentally created, evolve, and are used up durng jon processng. The concept and role of wndows are llustrated n Fgure. The edges of ths graph represent the up-chans and down-chans, and the nodes represent the jons, whch are labeled n sweep order. The bold edges n Fgure (a), (b), and (c) represent the exstng wndows just pror to processng jons, 6, and respectvely. p p p p p p Type I Type I Type II Type III (a) Fgure Example of wndows. x 6 (b) After processng jon, the wndow from jon to denoted (, ) wll be splt at ts y-nterpolaton at the heght of jon (pont X). Now the lower wndow wll consst of the up-chan (,), a horzontal segment from jon to X, and the 6 (c) Fgure Wndow y-nterpolaton types The processng of each type of jon wll now be descrbed. For each of the peak and valley jons, there wll be exactly one ncdent up-chan. If ths up-chan s seen for the frst tme (.e., the sweep event jon s at the left end of the chan), t s marked as a wndow by labelng the top jon of the chan. If the sweep event jon s at the rght end of the up-chan, t does no harm to label the chan as a wndow, snce t wll already be labeled as such. Thus, n any case, the top of the ncdent up-chan s marked as the top of a wndow.

6 The specfc (addtonal) processng requred by each jon type wll now be descrbed. The ntal pass over the vertces of the polygon has already provded explct clock-wse lnkages between jons/nodes. The terms pror and next when appled to jons wll refer to those lnkages. ) ucusp A UCUSP vertex s the leftmost vertex of a rsng chan, and s thus the earlest pont n a sweep when the rsng chan wll be seen. The two up-chans on ether sde of the jon are lnked nto a sngle wndow. Ths ensures that all wndows to the left of a jon wll exst (or wll have been used up durng trapezodaton) before that jon s processed. Gven explct lnkages between successve jons, the processng of ths type of jon s done n constant tme. ) dcusp By the tme ths jon s processed, t wll be the rghtmost vertex of a (remanng) monotone polygonal component. The left sde of ths polygon s the wndow ncdent on the top jon, whch s the jon pror to the dcusp jon tself. The rght sde of the polygon s the fallng chan contanng the dcusp jon,.e., the concatenaton of the two down-chans connected by the dcusp jon. Ths monotone polygon s smply reduced to a trapezod sequence. Gven the explct lnkage between adjacent jons, as well as the explct lnkage between vertces (exstng or that are created durng nterpolaton), the processng of ths type of jon s done n a tme that s lnear n the number of vertces n the monotone polygonal component beng reduced. ) rpeakr (and smlarly lvalley) No processng, (other than markng the ncdent up-chan as a wndow), s requred. The processng of ths type of jon requres constant tme. ) rpeak (AND SIMILARLY lvalleyr) As n the dcusp case, ths s the rghtmost vertex of a remanng monotone polygonal component. The left sde of ths polygon s the wndow ncdent on ths jon, and the rght sde s the down-chan ncdent on the same jon. Ths monotone polygon s smply reduced to a trapezod sequence. Agan, gven the explct lnkage between vertces, the processng of ths type of jon s done n a tme that s lnear n the number of vertces n the monotone polygonal component beng reduced. ) rvalleyr (and smlarly lpeak) W q D p U W W Fgure rvalleyr jon handlng. The handlng of rvalleyr jons s llustrated n Fgure,where vertex p s the current (rvalleyr) jon, and U and D are respectvely the up-chan and down-chan ncdent on p. The H D p U wndow, W, ncdent on q, the jon pror to p (.e., the top of D), s splt at the y-nterpolaton of W at the heght of p. A horzontal edge H s defned from ths nterpolaton (or the secondary y-nterpolaton, f t s of Type I) to p (equvalent to p or to the next vertex f there exsts a horzontal edge ncdent on p). The lower part of the splt wndow, W (up to the y-nterpolaton of W at yp, or, f t s of Type I, the secondary nterpolaton), s connected va H to the up-chan, U (equvalent to U wth the ntal horzontal edge removed, f t exsts), formng an updated wndow. The removed shaded ear s a vertcally monotone polygon whose left chan s the top part of the splt wndow, W, whose rght chan s the down-chan D, ncdent on p, and whose bottom s closed by a horzontal edge from p to the y-nterpolaton of W at heght yp. Ths monotone polygon s smply reduced to a trapezod sequence. Agan, assumng explct lnkages exst between adjacent edges, t can easly be seen that the processng of ths type of jon can be done n tme that s lnear n the number of vertces n the trapezod sequence beng reduced. 6) rvalley (AND SIMILARLY lpeakr) C C D W U W q H p q p q H p W H D U C C Fgure rvalley jon handlng. We wll call jon vertces of type RVALLEY and LPEAKR left spke jons. The handlng of RVALLEY jons s llustrated n Fgure, where vertex p s the current (RVALLEY) jon. Chans U and D are respectvely the up-chan and down-chan ncdent on p. Frst we must search (by a method dscussed below) for the wndow, W, that s left-facng p. The y-nterpolaton of W at heght y p s the pont q. The dashed arcs C and C represent the seres of chans/wndows connectng the top and bottom of W respectvely to the ends of D and U opposte to p. Pont q ' s equvalent to ether q or, n the case of type I nterpolatons, the secondary y-nterpolaton of W at heght y p. Pont p ' s equvalent to ether p or, f there exsts a horzontal edge ncdent on p, to the next vertex. Chan U ' s equvalent to U wth any ntal horzontal edge removed. Horzontal edge H s defned from q ' to p ', and H s defned from p to q. Thus the polygon s splt nto two dsconnected polygons defned by [ H, W, C, D] and [ H ', U', C, W]. C. Searchng for nterpolaton wndow In the left spke jon cases (RVALLEY and LPEAKR), a search s requred for the specfc wndow that s left-facng the spke jon. In one approach, the search begns at the jon pror to the spke jon, and traverses jon vertces n a counter-clockwse order, lookng for wndows, whch vertcally span the jon

7 (whch wll be termed canddate wndows). Each such canddate wndow s nterpolated and ether elmnated (ts y-nterpolaton s to the left of the y-nterpolaton of a prevous potental left-facng wndow, or s to the rght of the jon), or otherwse accepted as the new potental left-facng wndow. Fgure 6(a) llustrates ths process for spke jon. As jons are traversed counter-clockwse from ths jon, the frst canddate wndow (.e., one that meets vertcal spannng crteron) s A. After traversng further, canddate wndow B s dscovered wth an nterpolaton closer and to the left of vertex, and becomes the new potental left-facng wndow. Canddate wndow C s found thereafter, wth a closer nterpolaton on the left of the left spke jon. The search s termnated when the jon traversal returns to the spke jon. An optmzaton to potentally reduce the number of requred nterpolatons can be farly easly mplemented. A (a) B C 6 8 Fgure 6 Search for wndow n spke case. IV. PROOF OUTLINE A B (b) C 6 8 All left sdes of horzontal trapezods wll be part of a wndow (as defned n secton III),.e., composed of (fragments of) up-chan edges. Smlarly, the rght sdes of trapezods wll be composed of (fragments of ) down-chan edges. Ths can be seen by walkng the contour of the polygon (n the prescrbed clockwse drecton); the nsde of the (smple) polygon, and consequently the component trapezods, wll always be on the rght-hand sde. The rghtmost end, jon r, of a down-chan, D, wll trgger the trapezodaton of the (monotone polygonal) area between D, and the horzontally projected porton, W, of a unque wndow, W, that exsts at the sweep event r. W s the wndow left-facng r, and must exst at the sweep event r snce up-chans are converted to, or ncorporated nto, wndows as soon as they are seen (.e., as soon as the leftmost end of an up-chan s the current sweep event). Every pont on D must have the same unque left-facng wndow, W, that s W ' W, snce both W and D are vertcally monotone. Both D and W wll be consumed n the trapezodaton process for ths component of the polygon. Any remnant wndow W W ' wll be extended to form the bass for a new wndow at a later sweep event. V. COMPLEXITY ANALYSIS In ths analyss we assume that all vertces (ncludng vertces created by wndow nterpolatons) are doubly lnked n order around the polygon (or polygon component). We also assume that jon vertces are doubly lnked n order around the polygon. The ntal set-up of such lnkages can be done n lnear tme by a sngle pass through the vertex lst of the orgnal polygon. Jons of type UCUSP, RPEAKR, and LVALLEY can be processed n constant tme. The complete set of trapezods for a gven nput polygon s generated dsjontly durng the processng of jons of type RPEAK, LVALLEYR, DCUSP, RVALLEYR, or LPEAK. These fve jon types ndvdually ncur constant processng tme, and together they ncur tme for the generaton of n trapezods n the worst case (each tme a par of vertces are n horzontal vew of each, or there exsts a horzontal edge, the trapezod count decreases by one). Thus the total tme to process these eght jon types s lnear n n, the number of vertces n the nput polygon. The processng of spke jons requres the traversal of all jon vertces n the polygon fragment that contans the spke. At least one wndow wll meet the requrements gven n secton III.B.6), and ths (left-facng) wndow wll requre, on average, the traversal of half ts vertces. The total number of vertces vsted has an upper bound of the number of vertces n the component, wth the ntal fragment sze beng n. Each wndow splttng event dvdes the polygon nto two polygonal components. If we assume that the components are dstrbuted randomly, the complexty of treatng spke jons wll n. In practcal cases, the number of be bounded by jons, j, wll be relatvely small, that s j << n. We know that j < s, where s s the snuousty of the polygon, snce changes n drecton havng a vertcal component create peaks and valleys (.e., jons), and only some of the remanng changes n drecton (whch have a horzontal component) create UCUSPS Ο s log n. If we and DCUSP jons. Thus, a tghter bound s further assert, as dscussed n III.C, for practcal nputs, that the number of wndows that need to be nterpolated s on average very small (close to ), then a tghter estmate of the average-case complexty of jon processng tme s Ο j log j, where j < j s the number of spke jons. For s s random polygons, j j/6 snce there are two spke jon s types, wth the down-chan drecton constraned to one quadrant, and the up-chan drecton constraned to one subdvson (on average half) of that quadrant. It s beleved that j s wll be less than that n more practcal polygons, snce spke jons are somewhat unnatural. Thus, wth the excepton of spke jons, whch are expected to be farly rare n practcal polygons, the algorthm s lnear. It s beleved that spke jons themselves are not very expensve n practcal polygons. VI. IMPLEMENTATION In the followng, an mplementaton nvolvng a relatvely smple lnked data structure s descrbed. The nodes n ths

8 structure ntally come from the vertces of the nput polygon, and temporary nodes correspondng to edge nterpolatons may be added durng the jon processng. The suggested approach has been coded and tested, and the performance s shown n the followng secton. An ntal pass s made though the vertex lst of the nput polygon to create a doubly lnked crcular lst of vertces. Durng ths pass, jon vertces that connect up-chans and downchans are dentfed, labeled, and lnked (by a separate thread) to form a doubly lnked crcular lst. The peak and valley jons are labeled usng a -bt code where separate bts represent characterstcs of postve edge cross product, downtorght, and peak. A rsng chan that has an x-extremum strctly to the left of the top and bottom jons s splt nto two up-chans at ths vertex. Ths vertex becomes a ucusp jon (connectng the two resultng up-chans) and s lnked nto the jon lst. Smlarly, a fallng chan that has an x-extremum strctly to the rght of the top and bottom jons, s splt nto two down-chans at ths vertex. Ths dcusp vertex s also lnked nto the jon lst. Thus the vertces are doubly lnked to adjacent vertces, and, f they are jons, to pror and next jons. Cusps use two addtonal bts n the jon type code. Addtonal nodes, correspondng to edge nterpolatons, are nserted as wndows are y-nterpolated. The crcular lsts are splt nto two dsjont crcular lsts, correspondng to polygonal components, durng the processng of lpeakr, or rvalley (spke) jons. Sectons of a lst are removed (and transformed nto trapezod sequences) durng the processng of rvalleyr, or lpeak jons. Crcularly closed lsts are completely transformed nto trapezod sequences durng the processng of dcusp, rpeak, or lvalleyr jons. Ths dynamc mult-threaded lst s the only data structure used, other than a statc queue of jons to be processed. VII. PERFORMANCE MEASUREMENT Approxmately 6, polygons were extracted from a large sute of vector graphcs test pages provded by QMS, Inc. Ths provded a practcal dataset, on whch relatve tmngs were performed on the current mplementaton, n relaton to Narkhede s mplementaton of Sedel s algorthm [[6]]. The results gven n Fgure shows our algorthm to average about tmes faster, for polygon szes up to 8 vertces. Relatve tmngs were also performed on random polygons (up to vertces) generated by RPG [[]]. Here our algorthm s n the order of an average of tmes faster. It should be noted that these polygons do not have the characterstcs found n a practcal dataset. VIII. CONCLUSION A fast, practcal, determnstc algorthm to decompose an arbtrary smple polygon nto trapezods has been presented. The polygon vertex coordnates can be specfed as real numbers, and horzontal as well as vertcal edges very common n practcal polygons are explctly handled. An ntermedate output of the algorthm s a decomposton of the nput polygon nto a mnmal set of monotone polygons. The fact that the trapezods are output n useful groupngs (trapezod sequences), allows a further compresson of polygon trapezodal storage. A very fast lnear scan of vertces s used to determne a collecton of key vertces (jons), and these are processed n sweep order. No complcated data structures are needed. The practcal complexty appear to be very close to lnear. Nested holes were mplemented as a smple extenson. Speedup (Sedel/Han) 8 6 Polygon sze (num of vertces) Fgure Relatve executon tmes, Han vs Sedel. IX. ACKNOWLEDGEMENTS We would lke to thank QMS, Inc. for supportng ths research. We would also lke to thank Somnath Gulve for hs help n buldng a dynamc testng tool to experment wth, and exhaustvely test [[]], the mplementaton of the algorthm. REFERENCES [] Auer, T., and Held, M. RPG: Heurstc for the generaton of random polygons. Proc. 8th Canada Conf. Comput. Geom. Ottawa, Canada, Aug. 6, 8. [] Chazelle B. A theorem on polygon cuttng wth applcatons. Proceedngs of rd IEEE Symposum on Foundaton of Computatonal Scence,, 8. [] Chazelle B. Trangulatng a smple polygon n lnear tme. st IEEE Symposum on Foundaton of Computatonal Scence (),. [] Chazelle B., and Gubas L.J. Vsblty and ntersecton problems n plane geometry. Dscrete and Computatonal Geometry (8), 8. [] Chazelle B., and Incerp J. Trangulaton and shape-complexty. ACM TOG, ():, 8. [6] Clarkson K., Tarjan R.E., and Van Wyk C.J. A fast Las Vegas algorthm for trangulatng a smple polygon. Dscrete Computatonal Geometry, :, 8. [] Fourner A., and Montuno D.Y. Trangulatng smple polygons and equvalent problems. ACM Transactons on Graphcs, ():, 8. [8] Garey M.R., Johnson D.S., Preparata, F.P., and Tarjan R.E. Trangulatng a smple polygon. Informaton Processng Letter, :, 8. [] Han T.F., Gulve S. Interactve, Vsual Testng Strategy for Computatonal Geometry Problems. Proceedngs of 6th Annual ACM Southeast Conference, Atlanta, Georga, Aprl, 8

9 [] Hertel S., and Melhorn K. Fast trangulaton of smple polygons. Proc. of th Internatonal Conf. on Foundatonal Computatonal Theory, v.8 of Lecture Notes n Computer Scence, 8. Sprnger-Verlag, 8. [] Krkpatrck D.G., Klawe M.M., and Tarjan R.E. Polygon Trangulaton n log n tme wth smple data structures. Proceedngs of 6th Annual ACM Symposum on Computaton Geometry,,. [] Laszlo M.J. Computatonal Geometry and Computer Graphcs n C++, Prentce Hall, Englewood Clffs, NJ, 6. [] Lee D.T. and Preparata F.P. Locaton of a pont n a planar subdvson and ts applcaton. SIAM Journal of Computaton, 6:-66,. [] Lennes N.J. Theorems on smple polygon and polyhedron. Amercan J. of Mathematcs. : 6,. [] Mulmuley K. Computatonal Geometry: An Introducton Through Randomzed Algorthms. Prentce Hall, Englewood Clffs, NJ,. [6] Narkhede A., and Manochoa, D., Fast Polygon Trangulaton Based on Sedel s Algorthm. A Techncal Report, Dept. of Computer Scence, UNC, Chapel Hll. [] O Rourke J. Computatonal Geometry n C. Cambrdge Unversty Press,. [8] Preparata F.P., and Shamos M.L. Computatonal Geometry, An Introducton. Sprnger-Verlag, NY, 8. [] Sedel R. A Smple and fast ncremental randomzed algorthm for computng trapezodal decompostons and for trangulatng polygons. Computatonal Geometry Theory and Applcatons, : 6, [] Toussant G. An output-complexty-senstve polygon trangulaton algorthm. Report SICS-86.; McGll Unversty, Montreal, 88. [] Toussant G. Trangulaton and Arrangements. All Insttute Lecture at McGll Unversty, Montreal,.