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

Similar documents
An Optimal Algorithm for Prufer Codes *

Parallelism for Nested Loops with Non-uniform and Flow Dependences

Scan Conversion & Shading

Scan Conversion & Shading

For instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1)

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Sorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions

A Binarization Algorithm specialized on Document Images and Photos

Lecture 5: Multilayer Perceptrons

UNIT 2 : INEQUALITIES AND CONVEX SETS

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour

Problem Set 3 Solutions

Today s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss.

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

Reading. 14. Subdivision curves. Recommended:

CHAPTER 2 DECOMPOSITION OF GRAPHS

CMPS 10 Introduction to Computer Science Lecture Notes

Concurrent Apriori Data Mining Algorithms

CSCI 104 Sorting Algorithms. Mark Redekopp David Kempe

Mathematics 256 a course in differential equations for engineering students

Insertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array


S1 Note. Basis functions.

1 Dynamic Connectivity

F Geometric Mean Graphs

Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.

Related-Mode Attacks on CTR Encryption Mode

Content Based Image Retrieval Using 2-D Discrete Wavelet with Texture Feature with Different Classifiers

Sequential search. Building Java Programs Chapter 13. Sequential search. Sequential search

Multiblock method for database generation in finite element programs

An Approach in Coloring Semi-Regular Tilings on the Hyperbolic Plane

The Shortest Path of Touring Lines given in the Plane

Parallel matrix-vector multiplication

CSE 326: Data Structures Quicksort Comparison Sorting Bound

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements

Module Management Tool in Software Development Organizations

CSE 326: Data Structures Quicksort Comparison Sorting Bound

Support Vector Machines

The Codesign Challenge

Sorting: The Big Picture. The steps of QuickSort. QuickSort Example. QuickSort Example. QuickSort Example. Recursive Quicksort

Improvement of Spatial Resolution Using BlockMatching Based Motion Estimation and Frame. Integration

Problem Definitions and Evaluation Criteria for Computational Expensive Optimization

Programming in Fortran 90 : 2017/2018

A Fast Content-Based Multimedia Retrieval Technique Using Compressed Data

Type-2 Fuzzy Non-uniform Rational B-spline Model with Type-2 Fuzzy Data

The Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique

User Authentication Based On Behavioral Mouse Dynamics Biometrics

Load Balancing for Hex-Cell Interconnection Network

A MOVING MESH APPROACH FOR SIMULATION BUDGET ALLOCATION ON CONTINUOUS DOMAINS

High-Boost Mesh Filtering for 3-D Shape Enhancement

Fast Computation of Shortest Path for Visiting Segments in the Plane

3D vector computer graphics

Term Weighting Classification System Using the Chi-square Statistic for the Classification Subtask at NTCIR-6 Patent Retrieval Task

Vectorization of Image Outlines Using Rational Spline and Genetic Algorithm

the nber of vertces n the graph. spannng tree T beng part of a par of maxmally dstant trees s called extremal. Extremal trees are useful n the mxed an

Interpolation of the Irregular Curve Network of Ship Hull Form Using Subdivision Surfaces

Wavefront Reconstructor

Multi-Resolution Geometric Fusion

The Erdős Pósa property for vertex- and edge-disjoint odd cycles in graphs on orientable surfaces

Collision Detection. Overview. Efficient Collision Detection. Collision Detection with Rays: Example. C = nm + (n choose 2)

Constructing Minimum Connected Dominating Set: Algorithmic approach

Simplification of 3D Meshes

Virtual Memory. Background. No. 10. Virtual Memory: concept. Logical Memory Space (review) Demand Paging(1) Virtual Memory

All-Pairs Shortest Paths. Approximate All-Pairs shortest paths Approximate distance oracles Spanners and Emulators. Uri Zwick Tel Aviv University

A mathematical programming approach to the analysis, design and scheduling of offshore oilfields

2D Raster Graphics. Integer grid Sequential (left-right, top-down) scan. Computer Graphics

Private Information Retrieval (PIR)

Hierarchical clustering for gene expression data analysis

Querying by sketch geographical databases. Yu Han 1, a *

Brave New World Pseudocode Reference

Cluster Analysis of Electrical Behavior

Report on On-line Graph Coloring

Open Access A New Algorithm for the Shortest Path of Touring Disjoint Convex Polygons

VISUAL SELECTION OF SURFACE FEATURES DURING THEIR GEOMETRIC SIMULATION WITH THE HELP OF COMPUTER TECHNOLOGIES

TN348: Openlab Module - Colocalization

Course Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms

Skew Angle Estimation and Correction of Hand Written, Textual and Large areas of Non-Textual Document Images: A Novel Approach

Active Contours/Snakes

COMPLETE CALCULATION OF DISCONNECTION PROBABILITY IN PLANAR GRAPHS. G. Tsitsiashvili. IAM, FEB RAS, Vladivostok, Russia s:

FEATURE EXTRACTION. Dr. K.Vijayarekha. Associate Dean School of Electrical and Electronics Engineering SASTRA University, Thanjavur

Accounting for the Use of Different Length Scale Factors in x, y and z Directions

Non-Split Restrained Dominating Set of an Interval Graph Using an Algorithm

Feature Reduction and Selection

Sorting. Sorting. Why Sort? Consistent Ordering

Array transposition in CUDA shared memory

Explicit Formulas and Efficient Algorithm for Moment Computation of Coupled RC Trees with Lumped and Distributed Elements

Lobachevsky State University of Nizhni Novgorod. Polyhedron. Quick Start Guide

On Some Entertaining Applications of the Concept of Set in Computer Science Course

CE 221 Data Structures and Algorithms

More on the Linear k-arboricity of Regular Graphs R. E. L. Aldred Department of Mathematics and Statistics University of Otago P.O. Box 56, Dunedin Ne

Fitting: Deformable contours April 26 th, 2018

UB at GeoCLEF Department of Geography Abstract

Tsinghua University at TAC 2009: Summarizing Multi-documents by Information Distance

MULTISPECTRAL IMAGES CLASSIFICATION BASED ON KLT AND ATR AUTOMATIC TARGET RECOGNITION

Analysis of Continuous Beams in General

Machine Learning: Algorithms and Applications

Some Tutorial about the Project. Computer Graphics

NAG Fortran Library Chapter Introduction. G10 Smoothing in Statistics

Line Clipping by Convex and Nonconvex Polyhedra in E 3

Transcription:

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: than@usouthal.edu Dr. Davd D. Langan,III School of Computer & Informaton Scences Unversty of South Alabama Moble, Al 6688 Phone: -6-6 FAX: -6- E-mal: dlangan@usouthal.edu

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: than@usouthal.edu, dlangan@usouthal.edu).. 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

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.

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.

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 8 8 8 6 (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.

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

(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

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

[] 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,.