Geodesic Frechet Distance Inside a Simple Polygon

We unveil an alluring alternative to parametric search that applies to both the non-geodesic and geodesic Fr\'echet optimization problems. This randomized approach is based on a variant of red-blue intersections and is appealing due to its elegance a…

Authors: Atlas F. Cook IV, Carola Wenk

Geodesic Frechet Distance Inside a Simple Polygon
Symposium on Theoretical Aspects of Computer Science 2008 (Bordeaux), pp. 193-204 www .stacs-conf .org GEODESIC FRÉCHET DIST ANCE INSIDE A SIMPLE POL YGON A TLAS F. COOK IV AND CAR OLA WENK Departmen t of Computer Siene, Univ ersit y of T exas at San An tonio One UTSA Cirle, San An tonio, TX 78249-0667 E-mail addr ess : {aook, arola}s.utsa.edu Abstra t. W e un v eil an alluring alternativ e to parametri sear h that applies to b oth the non-geo desi and geo desi F ré het optimization problems. This randomized approa h is based on a v arian t of red-blue in tersetions and is app ealing due to its elegane and pratial eieny when ompared to parametri sear h. W e presen t the rst algorithm for the geo desi F ré het distane b et w een t w o p olygonal urv es A and B inside a simple b ounding p olygon P . The geo desi F ré het deision problem is solv ed almost as fast as its non-geo desi sibling and requires O ( N 2 log k ) time and O ( k + N ) spae after O ( k ) prepro essing, where N is the larger of the omplexities of A and B and k is the omplexit y of P . The geo desi F ré het optimization problem is solv ed b y a randomized approa h in O ( k + N 2 log kN log N ) exp eted time and O ( k + N 2 ) spae. This run time is only a logarithmi fator larger than the standard non-geo desi F ré het algorithm [4 ℄. Results are also presen ted for the geo desi F ré het distane in a p olygonal domain with obstales and the geo desi Hausdor distane for sets of p oin ts or sets of line segmen ts inside a simple p olygon P . 1. In tro dution The omparison of geometri shap es is essen tial in v arious appliations inluding om- puter vision, omputer aided design, rob otis, medial imaging, and drug design. The F ré het distane is a similarit y metri for on tin uous shap es su h as urv es or surfaes whi h is dened using reparametrizations of the shap es. Sine it tak es the on tin uit y of the shap es in to aoun t, it is generally a more appropriate distane measure than the often used Hausdor distane. The F ré het distane for urv es is ommonly illustrated b y a p erson w alking a dog on a leash [ 4℄. The p erson w alks forw ard on one urv e, and the dog w alks forw ard on the other urv e. As the p erson and dog mo v e along their resp etiv e urv es, a leash is main tained to k eep tra k of the separation b et w een them. The F ré het distane is the length of the shortest leash that mak es it p ossible for the p erson and dog to w alk from b eginning to end on their resp etiv e urv es without breaking the leash. See setion 2 for a formal denition of the F ré het distane. 1998 A CM Subje t Classi ation: Computational Geometry . Key wor ds and phr ases: F ré het Distane, Geo desi, P arametri Sear h, Simple P olygon. The full v ersion of this pap er is a v ailable as a te hnial rep ort [10 ℄. This w ork has b een supp orted b y the National Siene F oundation gran t NSF CAREER CCF-0643597. c  A.F . Cook and C. Wenk CC  Creative Commons Attribution- NoDerivs License 194 A.F. COOK AND C. WENK Most previous w ork assumes an obstale-free en vironmen t where the leash onneting the p erson to the dog has its length dened b y an L p metri. In [4℄ the F ré het distane b et w een p olygonal urv es A and B is omputed in arbitrary dimensions for obstale-free en vironmen ts in O ( N 2 log N ) time, where N is the larger of the omplexities of A and B . Rote [23 ℄ omputes the F ré het distane b et w een pieewise smo oth urv es. Bu hin et al. [7℄ sho w ho w to ompute the F ré het distane b et w een t w o simple p olygons. F ré het distane has also b een used suessfully in the pratial realm of map mat hing [ 26 ℄. All these w orks assume a leash length that is dened b y an L p metri. This pap er's on tribution is to measure the leash length b y its geo desi distane inside a simple p olygon P (instead of b y its L p distane). T o our kno wledge, there are only t w o other w orks that emplo y su h a leash. One is a w orkshop artile [18℄ that omputes the F ré het distane for p olygonal urv es A and B on the surfae of a on v ex p olyhedron in O ( N 3 k 4 log( k N )) time. The other pap er [ 12 ℄ applies the F ré het distane to morphing b y onsidering the p olygonal urv es A and B to b e obstales that the leash m ust go around. Their metho d w orks in O ( N 2 log 2 N ) time but only applies when A and B b oth lie on the b oundary of a simple p olygon. Our w ork an handle b oth this ase and more general ases. W e onsider a simple p olygon P to b e the only obstale and the urv es, whi h ma y in terset ea h other or self-in terset, b oth lie inside P . A ore insigh t of this pap er is that the free spae in a geo desi ell (see setion 2) is x -monotone, y -monotone, and onneted. W e sho w ho w to qui kly ompute a ell b oundary and ho w to propagate rea habilit y through a ell in onstan t time. This is suien t to solv e the geo desi F ré het deision problem. T o solv e the geo desi F ré het optimization problem, w e replae the standard parametri sear h approa h b y a no v el and asymptotially faster (in the exp eted ase) randomized algorithm that is based on red-blue in tersetion oun ting. W e sho w that the geo desi F ré het distane b et w een t w o p olygonal urv es inside a simple b ounding p olygon an b e omputed in O ( k + N 2 log k N log N ) exp eted time and O ( k + N 3 log k N ) w orst-ase time, where N is the larger of the omplexities of A and B and k is the omplexit y of the simple p olygon. The exp eted run time is almost a quadrati fator in k faster than the straigh tforw ard approa h, similar to [12 ℄, of partitioning ea h ell in to O ( k 2 ) sub ells. Briey , these sub ells are simple om binatorial regions based on p airs of hourglass in terv als. It is notable that the randomized algorithm also applies to the non-geo desi F ré het distane in arbitrary dimensions. W e also presen t algorithms to ompute the geo desi F ré het distane in a p olygonal domain with obstales and the geo desi Hausdor distane for sets of p oin ts or sets of line segmen ts inside a simple p olygon. 2. Preliminaries Let k b e the omplexit y of a simple p olygon P that on tains p olygonal urv es A and B in its in terior. In general, a ge o desi is a path that a v oids all obstales and annot b e shortened b y sligh t p erturbations [20℄. Ho w ev er, a geo desi inside a simple p olygon is simply a unique shortest path b et w een t w o p oin ts. Let π ( a, b ) denote the geo desi inside P b et w een p oin ts a and b . The ge o desi distan e d ( a, b ) is the length of a shortest path b et w een a and b that a v oids all obstales, where length is measured b y L 2 distane. Let ↓ , ↑ , and ↓↑ denote dereasing, inreasing, and dereasing then inreasing funtions, resp etiv ely . F or example,  H is ↓↑ -bitoni means that H is a funtion that dereases monotonially then inreases monotonially . A bitoni funtion has at most one  hange in monotoniit y . GEODESIC FRÉCHET DIST ANCE INSIDE A SIMPLE POL YGON 195 M a a M M b p a M b p b b d c a c a a c p d d Figure 1: Shortest paths in the hourglass H ab,cd dene H ab, c d . The F ré het distane for t w o urv es A, B : [0 , 1] → R l is dened as δ F ( A, B ) = inf f ,g : [0 , 1] → [0 , 1] sup t ∈ [0 , 1] d ′ ( A ( f ( t )) , B ( g ( t )) ) where f and g range o v er on tin uous non-dereasing reparametrizations and d ′ is a distane metri for p oin ts, usually the L 2 distane, and in our setting the geo desi distane. F or a giv en ε > 0 the fr e e sp a e is dened as F S ε ( A, B ) = { ( s, t ) | d ′ ( A ( s ) , B ( t )) ≤ ε } ⊆ [0 , 1] 2 . A free spae ell C ⊆ [0 , 1] 2 is the parameter spae dened b y t w o line segmen ts ab ∈ A and cd ∈ B , and the free spae inside the ell is F S ε ( ab, cd ) = F S ε ( A, B ) ∩ C . The deision problem to  he k whether the F ré het distane is at most a giv en ε > 0 is solv ed b y Alt and Go dau [4℄ using a fr e e sp a e diagr am whi h onsists of all free spae ells for all pairs of line segmen ts of A and B . Their dynami programming algorithm  he ks for the existene of a monotone path in the free spae from (0 , 0) to (1 , 1) b y propagating r e ahability information ell b y ell through the free spae. 2.1. F unnels and Hourglasses Geo desis in a free spae ell C an b e desrib ed b y either the funnel or hourglass struture of [14℄. A funnel desrib es all shortest paths b et w een a p oin t and a line segmen t, so it represen ts a horizon tal (or v ertial) line segmen t in C . An hourglass desrib es all shortest paths b et w een t w o line segmen ts and represen ts all distanes in C . The funnel F p,cd desrib es all shortest paths b et w een an ap ex p oin t p and a line segmen t cd . The b oundary of F p,cd is the union of the line segmen t cd and the shortest path  hains π ( p, c ) and π ( p, d ) . The hour glass H ab,cd desrib es all shortest paths b et w een t w o line segmen ts ab and cd . The b oundary of H ab,cd is omp osed of the t w o line segmen ts ab , cd and at most four shortest path  hains in v olving a , b , c , and d . See Figure 1. F unnel and hourglass b oundaries ha v e O ( k ) omplexit y b eause shortest paths inside a simple p olygon P are ayli, p olygonal, and only ha v e orners at v erties of P [15℄. An y horizon tal or v ertial line segmen t in a geo desi free spae ell is asso iated with a funnel's distane funtion F p, c d : [ c, d ] → R with F p, cd ( q ) = d ( p, q ) . The b elo w three results are generalizations of Eulidean prop erties and are omitted. See [10℄ for details. Lemma 2.1. F p, cd is ↓↑ -bitoni. Corollary 2.2. A ny horizontal (or verti al) line se gment in a fr e e sp a e  el l has at most one  onne te d set of fr e e sp a e values. Consider the hourglass H ab, c d in Figure 1. Let the shortest distane from a to an y p oin t on cd o ur at M a ∈ cd . Dene M b similarly . As p v aries from a to b , the minimum distane from p to cd traes out a funtion H ab, c d : [ a, b ] → R with H ab, c d ( p ) = min q ∈ [ c,d ] d ( p, q ) . 196 A.F. COOK AND C. WENK Lemma 2.3. H ab, cd is ↓↑ -bitoni. 3. Geo desi Cell Prop erties Consider a geo desi free spae ell C for p olygonal urv es A and B inside a simple p olygon. Let ab ∈ A and cd ∈ B b e the t w o line segmen ts dening C . Lemma 3.1. F or any ε ,  el l C  ontains at most one fr e e sp a e r e gion R , and R is x - monotone, y -monotone, and  onne te d. Pr o of. The monotoniit y of R follo ws from Corollary 2.2. F or onnetedness,  ho ose an y t w o free spae p oin ts ( p 1 , q 1 ) , ( p 2 , q 2 ) , and onstrut a path onneting them in the free spae as follo ws: mo v e v ertially from ( p 1 , q 1 ) to the minim um p oin t on its v ertial. Do the same for ( p 2 , q 2 ) . By Lemma 2.1, this mo v emen t auses the distane to derease monotonially . By Lemma 2.3, an y t w o minim um p oin ts are onneted b y a ↓↑ -bitoni distane funtion H ab, c d (f. setion 2.1), but as the starting p oin ts are in the free spae  and therefore ha v e distane at most ε  all p oin ts on this onstruted path lie in the free spae. Giv en C 's b oundaries, it is p ossible to propagate rea habilit y information (see setion 2) through C in onstan t time. This follo ws from the monotoniit y and onnetedness of the free spae in C and is useful for solving the geo desi deision problem. 4. Red-Blue In tersetions This setion sho ws ho w to eien tly oun t and rep ort a ertain t yp e of red-blue in ter- setions in the plane. This problem is in teresting b oth from theoretial and applied stanes and will pro v e useful in setion 5.3 for the F ré het optimization problem. Let R b e a set of m red urv es in the plane su h that ev ery red urv e is on tin uous, x -monotone, and monotone de r e asing . Let B b e a set of n blue urv es in the plane where ea h blue urv e is on tin uous, x -monotone, and monotone inr e asing . Assume that the urv es are dened in the slab [ α, β ] × R , and let I ( k ) b e the time to nd the at most one in tersetion of an y red and blue urv e. 1 Theorem 4.1. The numb er of r e d-blue interse tions b etwe en R and B in the slab [ α, β ] × R  an b e oun ted in O ( N log N ) total time, wher e N = max( m, n ) . These interse tions  an b e rep orted in O ( N log N + K · I ( k )) total time, wher e K is the total numb er of interse tions r ep orte d. After O ( N log N ) pr epr o  essing time, a random r e d-blue interse tion in [ α, β ] × R  an b e r eturne d in O (lo g N + I ( k )) time, and the r e d urve involve d in the most r e d-blue interse tions  an b e r eturne d in O (1) time. A l l op er ations r e quir e O ( N ) sp a e. 2 Pr o of Sketh. Figure 2 illustrates the k ey idea. Supp ose a red urv e r 3 ( x ) lies ab ove a blue urv e b 2 ( x ) at x = α . If it is also true that r 3 ( x ) lies b elow b 2 ( x ) at x = β , then these monotone urv es m ust in terset in [ α, β ] × R . T w o sorted lists L α , L β of urv e v alues store ho w man y blue urv es lie b elo w ea h red urv e at x = α and x = β . Subtrating the v alues in L α and L β yields the n um b er of atual in tersetions for ea h red urv e in [ α, β ] × R (and 1 There is at most one in tersetion due to the monotoniities of the red and blue urv es. 2 P alazzi and Sno eyink [21 ℄ also oun t and rep ort red-blue in tersetions using a slab-based approa h. Ho w ev er, their w ork is for line segmen ts instead of urv es, and they require that all red segmen ts are disjoin t and all blue segmen ts are disjoin t. W e ha v e no su h disjoin tness requiremen t. GEODESIC FRÉCHET DIST ANCE INSIDE A SIMPLE POL YGON 197 max y min b 1 r 2 b 2 r 3 r 1 r 3 b 2 r 1 r 3 r 1 r 2 b 1 b 1 r 2 b 2 L α L β β x α (x) (x) (x) (x) (x) y 5 4 2 1 3 Index (α) 2 1 (α) 1 (β) (β) 1 1 1 (α) (α) (α) (β) (β) y (β) Figure 2: r 3 ( x ) lies ab o v e two blue urv es at x = α but only lies ab o v e one blue urv e at x = β . Subtration rev eals that r 3 ( x ) has one in tersetion in the slab [ α, β ] × R . also rev eals the red urv e that is in v olv ed in the most in tersetions). In tersetion  ounting simply sums up these v alues. In tersetion r ep orting builds a balaned tree from L α and L β . T o nd a r andom red-blue in tersetion in [ α, β ] × R , preompute the n um b er κ of red- blue in tersetions in [ α, β ] × R . Pi k a random in teger b et w een 1 and κ and use the n um b er of in tersetions stored for ea h red urv e to lo ate the partiular red urv e r i ( x ) that is in v olv ed in the randomly seleted in tersetion. By sear hing a p ersisten t v ersion of the rep orting struture [24 ℄, r i ( x ) 's j th red-blue in tersetion an b e returned in O (lo g N + I ( k )) query time after O ( N log N ) prepro essing time. 5. Geo desi F ré het Algorithm 5.1. Computing One Cell's Boundaries in O (lo g k ) Time A b oundary of a free spae ell is a horizon tal (or v ertial) line segmen t. This b oundary an b e asso iated with a funnel F p,cd that has a ↓↑ -bitoni distane funtion F p, cd (f. Lemma 2.1 ). Giv en ε ≥ 0 , omputing the free spae on a ell b oundary requires nding the (at most t w o) v alues t 1 , t 2 su h that F p, cd ( t 1 ) = F p, cd ( t 2 ) = ε (see Figure 3). ε c) cd α 1 α v α 4 α 5 α 2 } I 5 I 4 I v I 2 I 1 t 2 I 2 I 1 I 4 I v I 5 a) p c 1 2 v 4 5 d t 1 F p, cd Free Space y= b) Figure 3: a & b) A funnel F p, cd is asso iated with a ell b oundary and has a bitoni dis- tane funtion F p, cd . ) The (at most t w o) v alues t 1 , t 2 su h that F p, cd ( t 1 ) = F p, cd ( t 2 ) = ε dene the free spae on a ell b oundary . Lemma 5.1. Both the minimum value of F p, cd and the (at most two) values t 1 , t 2 suh that F p, cd ( t 1 ) = F p, cd ( t 2 ) = ε  an b e found for any ε ≥ 0 in O (lo g k ) time (after pr epr o  essing). Pr o of Sketh. After O ( k ) shortest path prepro essing [13 , 16 ℄, a binary sear h is p erformed on the O ( k ) ars of F p, cd in O (lo g k ) time. See our full pap er [10℄ for details. 198 A.F. COOK AND C. WENK b kj ε a ij (ε) b ij (ε) ε a ij (ε) b kj (ε) C kj c) Distance function with a type (c) critical value type (b) critical value b) Distance function with a a) Free Space Diagram Critical value Critical value C ij 1.0 0.0 0.0 1.0 Position on cell boundary b Position on cell boundary ij a ij a kj Figure 4: Critial v alues of the F ré het distane Corollary 5.2. The fr e e sp a e on al l four b oundaries of a fr e e sp a e  el l  an b e found in O (lo g k ) time by  omputing t 1 and t 2 for e ah b oundary. 5.2. Geo desi F ré het Deision Problem Theorem 5.3. After pr epr o  essing a simple p olygon P for shortest p ath queries in O ( k ) time [13 ℄ , the ge o desi F r é het de ision pr oblem for p olygonal urves A and B inside P  an b e solve d for any ε ≥ 0 in O ( N 2 log k ) time and O ( k + N ) sp a e. Pr o of. F ollo wing the standard dynami programming approa h of [4℄, ompute all ell b ound- aries in O ( N 2 log k ) time (f. Corollary 5.2), and propagate rea habilit y information through all ells in O ( N 2 ) time. O ( k ) spae is needed for the prepro essing strutures of [13 ℄, and only O ( N ) spae is needed for dynami programming if t w o ro ws of the free spae diagram are stored at a time. 5.3. Geo desi F ré het Optimization Problem Let ε ∗ b e the minim um v alue of ε su h that the F ré het deision problem returns true. That is, ε ∗ equals the F ré het distane δ F ( A, B ) . P arametri sear h is a te hnique ommonly used to nd ε ∗ (see [3, 4, 9, 25 ℄). 3 The t ypial approa h to nd ε ∗ is to sort all the ell b oundary funtions based on the unkno wn parameter ε ∗ . The omparisons p erformed during the sort guaran tee that the result of the deision problem is kno wn for all ritial v alues [4℄ that ould p oten tially dene ε ∗ . T raditionally , su h a sort op erates on ell b oundaries of onstan t omplexit y . The geo desi ase is dieren t b eause ea h ell b oundary has O ( k ) omplexit y . As a result, a straigh tforw ard parametri sear h based on sorting these v alues w ould require O ( kN 2 log k N ) time ev en when using Cole's [9℄ optimization. 4 W e presen t a randomized algorithm with exp eted run time O ( k + N 2 log k N log N ) and w orst-ase run time O ( k + N 3 log k N ) . This algorithm is an order of magnitude faster than parametri sear h in the exp eted ase. Ea h ell b oundary has at most one free spae in terv al (f. Lemma 2.1 ). The upp er b oundary of this in terv al is a funtion b ij ( ε ) , and the lo w er b oundary of this in terv al is a funtion a ij ( ε ) . See Figure 4a. The seminal w ork of Alt and Go dau [ 4℄ denes three t yp es 3 An easier to implemen t alternativ e to parametri sear h is to run the deision problem one for ev ery bit of auray that is desired. This approa h runs in O ( B N 2 log k ) time and O ( k + N ) spae, where B is the desired n um b er of bits of auray [25 ℄. 4 A v ariation of the general sorting problem alled the n uts and b olts problem (see [ 17 ℄) is tan talizingly lose to an aeptable O ( N 2 log N ) sort but do es not apply to our setting. GEODESIC FRÉCHET DIST ANCE INSIDE A SIMPLE POL YGON 199 of ritial v alues that are useful for omputing the exat geo desi F ré het distane. There are exatly t w o t yp e (a) ritial v alues asso iated with distanes b et w een the starting p oin ts of A and B and the ending p oin ts of A and B . T yp e (b) ritial v alues o ur O ( N 2 ) times when a ij ( ε ) = b ij ( ε ) . See Figure 4 b. T yp e (a) and (b) ritial v alues o ur O ( N 2 ) times and are easily handled in O ( N 2 log k log N ) time. This pro ess in v olv es omputing v alues in O ( N 2 log k ) time, sorting in O ( N 2 log N ) time, and running the deision problem in binary sear h fashion O (lo g N ) times. Resolving the t yp e (a) and (b) ritial v alues as a rst step will simplify the randomized algorithm for the t yp e () ritial v alues. Alt and Go dau [4℄ sho w that t yp e () ritial v alues o ur when the p osition of a ij ( ε ) in ell C ij equals the p osition of b k j ( ε ) in ell C k j in the free spae diagram. See Figure 4a. As ε inreases, b y Lemma 2.1 , a ij ( ε ) is ↓ -monotone on the ell b oundary and b ij ( ε ) is ↑ -monotone (see Figure 4b). As illustrated in Figure 4 , a ij ( ε ) and b k j ( ε ) in terset at most one. This follo ws from the monotoniities of a ij ( ε ) and b k j ( ε ) . Hene, there are O ( N 2 ) in tersetions of a ij ( ε ) and b k j ( ε ) in ro w j and a total of O ( N 3 ) t yp e () ritial v alues o v er all ro ws. There are also O ( N 2 ) in tersetions of a ij ( ε ) and b ik ( ε ) in  olumn i and a total of O ( N 3 ) additional t yp e () ritial v alues o v er all olumns. Lemma 5.4. The interse tion of a ij ( ε ) and b k l ( ε )  an b e found for any ε ≥ 0 in O (lo g k ) time after pr epr o  essing. Pr o of Sketh. Build binary sear h trees for a ij ( ε ) and b k l ( ε ) and p erform a binary sear h. See our full pap er [10 ℄ for details. Theorem 4.1 requires that all a ij ( ε ) and b k l ( ε ) are dened in the slab [ α, β ] × R that on tains ε ∗ . Preomputing the t yp e (a) and t yp e (b) ritial v alues of [4 ℄ shrinks the slab su h that no left endp oin t of an y relev an t a ij ( ε ) , b k l ( ε ) app ears in [ α, β ] × R when pro essing the t yp e () ritial v alues. In addition, a ij ( ε ) , b k l ( ε ) an b e extended horizon tally so that no right endp oin t app ears in [ α, β ] × R . These  hanges do not aet the asymptoti n um b er of in tersetions and allo w Theorem 4.1 to oun t and rep ort t yp e () ritial v alues in [ α, β ] × R . The b elo w randomized algorithm solv es the geo desi F ré het optimization problem in O ( k + N 2 log k N log N ) exp eted time. This is faster than the standard parametri sear h approa h whi h requires O ( kN 2 log k N ) time. Randomized Optimization Algorithm (1) Preompute and sort all t yp e (a) and t yp e (b) ritial v alues in O ( N 2 log k N ) time (f. Lemma 5.1 ). Run the deision problem O (lo g N ) times to resolv e these v alues and shrink the p oten tial slab for ε ∗ do wn to [ α, β ] × R in O ( N 2 log k log N ) time. (2) Coun t the n um b er κ j of t yp e () ritial v alues for ea h ro w j in the slab [ α, β ] × R using Theorem 4.1 . Let C j b e the resulting oun ting data struture for ro w j . (3) T o a hiev e a fast exp e te d run time, pi k a random in tersetion ϑ j for ea h ro w using C j . 5 See Theorem 4.1 . (4) T o a hiev e a fast worst- ase run time, use C j to nd the a M j ( ε ) urv e in ea h ro w that has the most in tersetions (see Theorem 4.1 ). A dd all in tersetions in [ α, β ] × R that in v olv e a M j ( ε ) to a global p o ol P of unresolv ed ritial v alues 6 and delete a M j ( ε ) from an y future onsideration. 5 Pi king a ritial v alue at random is related to the distane seletion problem [6 ℄ and is men tioned in [2℄, but to our kno wledge, this alternativ e to parametri sear h has nev er b een applied to the F ré het distane. 6 The idea of a global p o ol is similar to Cole's optimization for parametri sear h [9℄. 200 A.F. COOK AND C. WENK (5) Find the median Ξ of the v alues in P in O ( N 2 ) time using the standard median algorithm men tioned in [17 ℄. Also nd the median Ψ of the O ( N ) randomly seleted ϑ j in O ( N ) time using a weighte d median algorithm based on the n um b er of ritial v alues κ j for ea h ro w j . (6) Run the deision problem t wie: one on Ξ and one on Ψ . This shrinks the sear h slab [ α, β ] × R and at le ast halv es the size of P . Rep eat steps 2 through 6 un til all r ow -based t yp e () ritial v alues ha v e b een resolv ed. (7) Resolv e all  olumn -based t yp e () ritial v alues in the same spirit as steps 2 through 6 and return the smallest ritial v alue that satised the deision problem as the v alue of the geo desi F ré het distane. Theorem 5.5. The exat geo desi F r é het distan e b etwe en two p olygonal urves A and B inside a simple b ounding p olygon P  an b e  ompute d in O ( k + N 2 log k N log N ) exp e te d time and O ( k + N 3 log k N ) worst- ase time, wher e N is the lar ger of the  omplexities of A and B and k is the  omplexity of P . O ( k + N 2 ) sp a e is r e quir e d. Pr o of. Prepro ess P one for shortest path queries in O ( k ) time [ 13℄. In the exp eted ase, ea h exeution of the deision problem will eliminate a onstan t fration of the remaining t yp e () ritial v alues due to the pro of of Qui ksort's exp eted run time and the median of medians approa h for Ψ . Consequen tly , the exp eted n um b er of iterations of the algorithm is O (lo g N 3 ) = O (log N ) . In the w orst-ase, ea h of the O ( N ) a ij ( ε ) in a ro w will b e pi k ed as a M j ( ε ) . Therefore, ea h ro w an require at most O ( N ) iterations. Sine al l ro ws are pro essed ea h iteration, the en tire algorithm requires at most O ( N ) iterations for r ow -based ritial v alues. By a similar argumen t,  olumn -based ritial v alues also require at most O ( N ) iterations. The size of the p o ol P is expressed b y the inequalit y S ( x ) ≤ S ( x − 1)+ O ( N 2 ) 2 , where x is the urren t step n um b er, and S (0) = 0 . In tuitiv ely , ea h step adds O ( N 2 ) v alues to P and then at least half of the v alues in P are alw a ys resolv ed using the median Ξ . It is not diult to sho w that S ( x ) ∈ O ( N 2 ) for an y step n um b er x . Ea h iteration of the algorithm requires in tersetion oun ting and in tersetion alula- tions for O ( N ) ro ws (or olumns) at a ost of O ( N 2 log k N ) time. In addition, the global p o ol P has its median alulated in O ( N 2 ) time, and the deision problem is exeuted in O ( N 2 log k ) time. Consequen tly , the exp eted run time is O ( k + N 2 log k N log N ) and the w orst-ase run time is O ( k + N 3 log k N ) inluding O ( k ) prepro essing time [13 ℄ for geo desis. The prepro essing strutures use O ( k ) spae that m ust remain allo ated throughout the al- gorithm, and the p o ol P uses O ( N 2 ) additional spae. Although the exat non-geo desi F ré het distane is normally found in O ( N 2 log N ) time using parametri sear h (see [4℄), parametri sear h is often regarded as impratial b eause it is diult to implemen t 7 and in v olv es enormous onstan t fators [9 ℄. T o the b est of our kno wledge, the randomized algorithm in setion 5.3 pro vides the rst pratial alternativ e to parametri sear h for solving the exat non-geo desi F ré het optimization problem in R l . Theorem 5.6. The exat non-geo desi F r é het distan e b etwe en two p olygonal urves A and B in R l  an b e  ompute d in O ( N 2 log 2 N ) exp e te d time, wher e N is the lar ger of the  omplexities of A and B . O ( N 2 ) sp a e is r e quir e d. 7 Qui ksort-based parametri sear h has b een implemen ted b y v an Oostrum and V eltk amp [25 ℄ using a omplex framew ork. GEODESIC FRÉCHET DIST ANCE INSIDE A SIMPLE POL YGON 201 b) B I 2 I 1 I 4 I v I 5 B p c 1 2 4 5 d v a) o c) Funnel Figure 5: a) A funnel for a δ C -ell an b e found b y extending a ell's initial leash along one segmen t to reate a path sk et h and then b) snapping this sk et h in to a homotopi shortest path. ) A funnel F o, cd has O ( kN ) omplexit y , but the distane funtion F o, cd has only O ( k ) omplexit y b eause d ( o, p ) is a onstan t. Pr o of. The argumen t is v ery similar to the pro of of Theorem 5.5. The main dierene is that non-geo desi distanes an b e omputed in O (1) time (instead of O (lo g k ) time). 6. Geo desi F ré het Distane in a P olygonal Domain with Obstales Consider the real-life situation of a p erson w alking a dog in a park. If the p erson and dog w alk on opp osite sides of a group of trees, then the leash m ust go around the trees. More formally , supp ose the t w o p olygonal urv es A and B lie in a planar p olygonal domain D [19 ℄ of omplexit y k . The leash is required to  hange on tin uously , i.e., it m ust sta y inside D and ma y not pass through or jump o v er an obstale. It ma y , ho w ev er, ross itself. Let δ C b e the geo desi F ré het distane for this senario when the leash length is measured geo desially . 8 Due to the on tin uit y of the leash's motion, the free spae inside a geo desi ell is represen ted b y an hourglass  just as it w as for the geo desi F ré het distane inside a simple p olygon. Hene, free spae in a ell is x -monotone, y -monotone, and onneted (f. Lemma 3.1 ), and rea habilit y information an b e propagated through a ell in onstan t time. The main task in omputing δ C is to onstrut all ell b oundaries. One the ell b ound- aries are kno wn, the deision and optimization problems an b e solv ed b y the algorithms for the geo desi F ré het distane inside a simple p olygon (f. Theorems 5.3 and 5.5 ). W e use Hersh b erger and Sno eyink's homotopi shortest paths algorithm [16 ℄ to inremen tally onstrut all ell b oundary funnels needed to ompute δ C . T o use the homotopi algorithm, the p olygonal domain D should b e triangulated in O ( k log k ) time [19℄, and all obstales should b e replaed b y their v erties. A shortest path map [19 ℄ an nd an initial geo desi leash L I b et w een the start p oin ts of the p olygonal urv es A and B in O ( k log k ) time. Lemma 6.1. Given the initial le ash for the b ottom-left  orner of a δ C - el l C , al l four funnel b oundaries of C and the initial le ashes for  el ls adja ent to C  an b e  ompute d in O ( k ) time. Pr o of. The funnels represen ting ell b oundaries are onstruted inr emental ly . The idea is to extend the initial leash in to a homotopi sk et h that desrib es ho w the shortest path should wind through the obstales and then to snap this sk et h in to a shortest path (see Figures 5a and 5b). 8 W e reen tly learned that this topi has b een indep enden tly explored in [8℄. 202 A.F. COOK AND C. WENK Homotopi shortest paths ha v e inreased omplexit y o v er normal shortest paths b eause they an lo op around obstales. F or example, if the p erson w alks in a triangular path around all the obstales, then the leash follo ws a homotopi shortest path that an ha v e O ( k ) omplexit y in a single yle around the obstales. By rep eatedly winding around the obstales O ( N ) times, a path a hiev es O ( kN ) omplexit y . T o a v oid sp ending O ( kN ) time p er ell, w e extend a previous homotopi shortest path in to a sk et h b y app ending a single line segmen t to the previous path (see Figure 5a). A dding this single segmen t an un wind at most one lo op o v er a subset of obstales, so only the most reen t O ( k ) v erties of the sk et h will need to b e up dated when the sk et h is snapp ed in to the true homotopi shortest path. A turning angle is used to iden tify these O ( k ) v erties b y ba ktra king on the sk et h un til the angle is at least 2 π dieren t from the nal angle. Putting all this together, a b oundary for a free spae ell an b e omputed in O ( k ) time b y starting with an initial leash L I of O ( kN ) omplexit y , onstruting a homotopi sk et h b y app ending a single segmen t to L I , ba ktra king with a turning angle to nd O ( k ) v erties that are eligible to b e  hanged, and nally snapping these O ( k ) v erties to the true homotopi shortest path using Hersh b erger and Sno eyink's algorithm [ 16 ℄. The result is a funnel that desrib es one ell b oundary . By extending L I in four om binatorially distint w a ys, all four ell b oundaries an b e dened. Sp eially , w e an extend L I along the urren t ab ∈ A segmen t to form the rst funnel or along the cd ∈ B segmen t to form the seond funnel. The third funnel is reated b y extending L I along ab ∈ A and then cd ∈ B . The fourth funnel is reated b y extending L I along cd ∈ B and then ab ∈ A . These ell b oundaries on v enien tly dene the initial leash for ells that are adjaen t to C . Theorem 6.2. The δ C de ision pr oblem  an b e solve d in O ( kN 2 ) time and O ( k + N ) sp a e. Pr o of. Ea h ell b oundary is a funnel F o, cd with O ( kN ) omplexit y [11 ℄. Ho w ev er, this high omplexit y is a result of lo oping o v er obstales, and most of these p oin ts do not aet the funnel's distane funtion F o, cd . As illustrated in Figure 5 , F o, cd has only O ( k ) omplexit y b eause only v erties π ( p, c ) ∪ π ( p, d ) on tribute ars to F o, cd . Construt all ell b oundary funnels in O ( kN 2 ) time (f. Lemma 6.1), in terset ea h funnel's distane funtion with y = ε in O ( N 2 log k ) time, and propagate rea habilit y in- formation in O ( N 2 ) time. Only O ( k + N ) spae is needed for dynami programming when storing only t w o ro ws at a time. Theorem 6.3. The δ C optimization pr oblem  an b e solve d in O ( kN 2 + N 2 log k N log N ) exp e te d time and O ( kN 2 ) sp a e. 9 Pr o of. The δ C optimization problem an b e solv ed using red-blue in tersetions. O (lo g N ) steps are p erformed in the exp eted ase b y Theorem 5.5 . Ea h step has to p erform in- tersetion oun ting in O ( N 2 log k N ) time and solv e the deision problem. If the funnels are preomputed in O ( kN 2 ) time and spae, then the deision problem an b e solv ed in O ( N 2 log k ) time. Hene, after O ( kN 2 ) time and spae prepro essing, δ C an b e found in O (lo g N ) exp eted steps where ea h step tak es O ( N 2 log k N ) time. 9 If spae is at a premium, the algorithm an also run with O ( k + N 2 ) spae and O ( k N 2 log N + N 2 log kN log N ) exp eted time b y reomputing the funnels ea h time the deision problem is omputed. Note that O ( N 2 ) storage is required for the red-blue in tersetions algorithm (f. Theorem 5.5 ). GEODESIC FRÉCHET DIST ANCE INSIDE A SIMPLE POL YGON 203 7. Geo desi Hausdor Distane Hausdor distane is a similarit y metri ommonly used to ompare sets of p oin ts or sets of line segmen ts. The dir e te d geo desi Hausdor distane an b e formally dened as ˜ δ H ( A, B ) = sup a ∈ A inf b ∈ B d ( a, b ) , where A and B are sets and d ( a, b ) is the geo desi distane b et w een a and b (see [4, 5℄). The undir e te d geo desi Hausdor distane is the larger of the t w o direted distanes: δ H ( A, B ) = max( ˜ δ H ( A, B ) , ˜ δ H ( B , A )) . Theorem 7.1. δ H ( A, B ) for p oint sets A, B inside a simple p olygon P  an b e  ompute d in O (( k + N ) log( k + N )) time and O ( k + N ) sp a e, wher e N is the lar ger of the  omplexities of A and B and k is the  omplexity of P . If A and B ar e sets of line se gments, δ H ( A, B )  an b e  ompute d in O ( kN 2 α ( k N ) log k N ) time and O ( kN α ( k N ) log k N ) sp a e. Pr o of Sketh. A geo desi V oronoi diagram [22℄ nds nearest neigh b ors when A and B are p oin t sets. When A and B are sets of line segmen ts, all nearest neigh b ors for a line segmen t an b e found b y omputing a lo w er en v elop e [1 ℄ of O ( N ) hourglass distane funtions. The largest nearest neigh b or distane o v er all line segmen ts is δ H ( A, B ) . 8. Conlusion T o ompute the geo desi F ré het distane b et w een t w o p olygonal urv es inside a simple p olygon, w e ha v e pro v en that the free spae inside a geo desi ell is x -monotone, y -monotone, and onneted. By extending the shortest path algorithms of [13, 16 ℄, the b oundaries of a single free spae ell an b e omputed in logarithmi time, and this leads to an eien t algorithm for the geo desi F ré het deision problem. A randomized algorithm based on red-blue in tersetions solv es the geo desi F ré het optimization problem in lieu of the standard parametri sear h approa h. The randomized algorithm is also a pratial alternativ e to parametri sear h for the non-geo desi F ré het distane in arbitrary dimensions. W e an ompute the geo desi F ré het distane b et w een t w o p olygonal urv es A and B inside a simple b ounding p olygon P in O ( k + N 2 log k N log N ) exp eted time, where N is the larger of the omplexities of A and B and k is the omplexit y of P . In the exp eted ase, the randomized optimization algorithm is an order of magnitude faster than a straigh tforw ard parametri sear h that uses Cole's [9℄ optimization to sort O ( kN 2 ) v alues. The geo desi F ré het distane in a p olygonal domain with obstales enfores a homotop y on the leash. It an b e omputed in the same manner as the geo desi F ré het distane inside a simple p olygon after omputing ell b oundary funnels using Hersh b erger and Sno eyink's homotopi shortest paths algorithm [16℄. F uture w ork ould attempt to ompute these funnels in O (lo g k ) time instead of O ( k ) time. The geo desi Hausdor distane for p oin t sets inside a simple p olygon an b e omputed using geo desi V oronoi diagrams. The geo desi Hausdor distane for line segmen ts an b e omputed using lo w er en v elop es; future w ork ould sp eed up this algorithm b y dev eloping a geo desi V oronoi diagram for line segmen ts. Referenes [1℄ P . K. Agarw al and M. Sharir. Da v enp ortS hinzel sequenes and their geometri appliations. T e hnial Rep ort T e hnial rep ort DUKETR199521, 1995. 204 A.F. COOK AND C. WENK [2℄ P . K. Agarw al and M. Sharir. Eien t algorithms for geometri optimization. A CM Comput. Surv. , 30(4):412458, 1998. [3℄ P . K. Agarw al, M. Sharir, and S. T oledo. Appliations of parametri sear hing in geometri optimization. v olume 17, pages 292318, Duluth, MN, USA, 1994. A ademi Press, In. [4℄ H. Alt and M. Go dau. Computing the Fré het distane b et w een t w o p olygonal urv es. International Journal of Computational Ge ometry and Appli ations , 5:7591, 1995. [5℄ H. Alt, C. Knauer, and C. W enk. Comparison of distane measures for planar urv es. A lgorithmi a , 38(1):4558, 2003. [6℄ S. Bespam y atnikh and M. Segal. Seleting distanes in arrangemen ts of h yp erplanes spanned b y p oin ts. v olume 2, pages 333345, Septem b er 2004. [7℄ K. Bu hin, M. Bu hin, and C. W enk. Computing the Fré het distane b et w een simple p olygons in p olynomial time. SoCG: 22nd Symp osium on Computational Ge ometry , pages 8087, 2006. [8℄ E. W. Cham b ers, É. C. de V erdière, J. Eri kson, S. Lazard, F. Lazarus, and S. Thite. W alking y our dog in the w o o ds in p olynomial time. 17th F al l W orkshop on Computational Ge ometry , 2007. [9℄ R. Cole. Slo wing do wn sorting net w orks to obtain faster sorting algorithms. J. A CM , 34(1):200208, 1987. [10℄ A. F. Co ok IV and C. W enk. Geo desi Fré het and Hausdor distane inside a simple p olygon. T e hnial Rep ort CS-TR-2007-004, Univ ersit y of T exas at San An tonio, August 2007. [11℄ C. A. Dunan, A. Efrat, S. G. K ob ouro v, and C. W enk. Dra wing with fat edges. Int. J. F ound. Comput. Si. , 17(5):11431164, 2006. [12℄ A. Efrat, L. J. Guibas, S. Har-P eled, J. S. B. Mit hell, and T. M. Murali. New similarit y measures b et w een p olylines with appliations to morphing and p olygon sw eeping. Disr ete & Computational Ge ometry , 28(4):535569, 2002. [13℄ L. J. Guibas and J. Hersh b erger. Optimal shortest path queries in a simple p olygon. J. Comput. Syst. Si. , 39(2):126152, 1989. [14℄ L. J. Guibas, J. Hersh b erger, D. Lev en, M. Sharir, and R. E. T arjan. Linear time algorithms for visibilit y and shortest path problems inside simple p olygons. pages 113, 1986. [15℄ L. J. Guibas, J. Hersh b erger, D. Lev en, M. Sharir, and R. E. T arjan. Linear-time algorithms for visibilit y and shortest path problems inside triangulated simple p olygons. A lgorithmi a , 2:209233, 1987. [16℄ J. Hersh b erger. A new data struture for shortest path queries in a simple p olygon. Inf. Pr o  ess. L ett. , 38(5):231235, 1991. [17℄ J. K omlós, Y. Ma, and E. Szemerédi. Mat hing n uts and b olts in O(n log n) time. SOD A: 7th A CM- SIAM Symp osium on Disr ete A lgorithms , pages 232241, 1996. [18℄ A. Mahesh w ari and J. Yi. On omputing Fré het distane of t w o paths on a on v ex p olyhedron. EW CG 2005 , pages 414, 2005. [19℄ J. S. B. Mit hell. Geometri shortest paths and net w ork optimization. Handb o ok of Computational Ge ometry , 1998. [20℄ J. S. B. Mit hell, D. M. Moun t, and C. H. P apadimitriou. The disrete geo desi problem. SIAM J. Comput. , 16(4):647668, 1987. [21℄ L. P alazzi and J. Sno eyink. Coun ting and rep orting red/blue segmen t in tersetions. CV GIP: Gr aph. Mo dels Image Pr o  ess. , 56(4):304310, 1994. [22℄ E. P apadop oulou and D. T. Lee. A new approa h for the geo desi Voronoi diagram of p oin ts in a simple p olygon and other restrited p olygonal domains. A lgorithmi a , 20(4):319352, 1998. [23℄ G. Rote. Computing the Fré het distane b et w een pieewise smo oth urv es. T e hnial Rep ort ECG- TR-241108-01, Ma y 2005. [24℄ N. Sarnak and R. E. T arjan. Planar p oin t lo ation using p ersisten t sear h trees. Commun. A CM , 29(7):669679, 1986. [25℄ R. v an Oostrum and R. C. V eltk amp. P arametri sear h made pratial. SoCG: 18th Symp osium on Computational Ge ometry , pages 19, 2002. [26℄ C. W enk, R. Salas, and D. Pfoser. A ddressing the need for map-mat hing sp eed: Lo alizing global urv e-mat hing algorithms. 18th Int'l Conf. on Si. and Statisti al Datab ase Mgmt (SSDBM) , pages 379388, 2006. This work is licensed und er the Crea tiv e Commons Attr ib ution -NoDerivs License. T o view a copy of this license, v isit http://reative o mm ons .o rg /l i ens es /b y- nd /3 .0 / .

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment