Finding planar regions in a terrain
Abstract
We consider the problem of computing large connected regions in a triangulated terrain of size n for which the normals of the triangles deviate by at most some small fixed angle. In previous work an exact near-quadratic algorithm was presented, but only a heuristic implementation with no guarantee was practicable. We present a new approximation algorithm for the problem which runs in O(n/e2) time and-apart from giving a guarantee on the quality of the produced solution-has been implemented and shows good performance on real data sets representing fracture surfaces with around half a million triangles.
Full text
Finding Planar Regions in a Terrain Stefan Funke 1 , Theo haris Malamatos, Rahul Ray Max-Plank-Institut fur Informatik, Stuhlsatzenhausweg 85, 66123 Saarbr uken, Germany Abstrat We onsider the problem of omputing large onneted regions in a triangulated terrain of size n for whih the normals of the triangles deviate by at most some small xed angle. In previous work an exat near-quadrati algorithm was presented, but only a heuristi implementation with no guarantee was pratiable. We present a new approximation algorithm for the problem whih runs in O ( n= 2 ) time and|apart from giving a guarantee on the quality of the pro dued solution|has b een implemented and shows go o d p erformane on real data sets representing frature surfaes with around half a million triangles. 1. Intro dution A terrain is a surfae in R 3 dened by a fun- tion f : R R ! R . If f is pieewise linear and the surfae onsists of a olletion of triangles, the terrain is alled a triangulated irregular network (TIN) . Given a TIN T , the goal is to nd large, nearly planar regions in T . We dene `near planarity' as follows: for a real parameter Æ > 0, we say that a subset of triangles T in T is Æ -planar if (i) the adjaeny graph of the triangles in T is onneted, and (ii) there is a vetor ! r suh that for eah t 2 T , \ ( n t ; r ) Æ , where n t denotes the normal of triangle t . We all ! r the referene normal . (Throughout the pap er \ ( v ; u ) denotes the angle b etween two vetors ! v and ! u .) Researhers in the material sienes examine surfae top ographies of materials as they provide useful information ab out the generation pro ess and the internal struture of the material. Surfaes generated by frature, wear, orrosion and mahining are of interest. Among many other riteria, they want to examine feature-related parameters like faets in brittle frature surfaes. This appliation motivated our work. Email addresses: funkempi-sb.mpg.de (Stefan Funke), tmalamatmpi-sb.mpg.de (Theo haris Malamatos), rahulmpi-sb.mpg.de (Rahul Ray). 1 Part of this researh was onduted while the author was visiting the University of Illinois at Urbana-Champaign, USA. Related work. Assume that eah triangle in T is assigned a weight and that any set of triangles has weight equal to the sum of the weights of its triangles. Smid, Ray, Wendt and Lange [2℄ onsidered the problem of nding a Æ -planar subset of T of maximum weight. They presented an O ( n 2 log n (log log n ) 3 ) algorithm, where n is the number of triangles in T . Sine this is impratial they prop osed a heuristi whih omputes nearly planar regions quite quikly but with no guarantee. Also they suggested that nding a Æ -planar set with weight at least a onstant fration of the optimum may be equally diÆult as solving the problem exatly, see [2℄. Our results. In this pap er we adopt the following notion of approximation. Given a real parameter > 0, we say that a subset of triangles T of T is - approximate Æ -planar if it is Æ (1 + )-planar and has weight at least as large as an optimal Æ -planar set. Under this notion, we present a new approximation algorithm that runs in O ( n= 2 ) time whih is independent of Æ . For n suÆiently large, the algorithm uses optimal O ( n ) spae. Reently HarPeled and Mazumdar [1℄ have used a similar notion of approximation for the problem of omputing the smallest k -enlosing disk. We have implemented and empirially evaluated the algorithm on real test data from the appliation domain onsisting of frature surfae terrains with more than 500,000 triangles. It provides very go o d quality results in reasonable time. Submitted paper to 20th EWCG Seville, Spain (2004)
20th Europ ean Workshop on Computational Geometry 2. Preliminaries Let T b e a TIN. We asso iate with T an undireted weighted graph G T ( V ; E ) as follows. Eah triangle t in T has an asso iated weight w ( t ) and orresp onds to a vertex v t in V . An edge onnets two verties of V if and only if the orresp onding triangles in T are adjaent. Note that G T is the dual graph of T , is planar and has degree three. Eah vertex v t 2 V is assigned the weight of its asso iated triangle w ( t ) whih an b e, for example, equal to the area of the triangle t or one (when we want to maximize the area of the deteted region or the number of triangles, resp etively). The weight w ( V 0 ) of any subset V 0 of V is dened as the sum of the weights of the verties in V 0 . For a p oint u 2 R 3 we denote by ! u the vetor ! O u , where O is the origin. Let S 2 denote the unit sphere, i.e., the boundary of the three-dimensional ball of radius one entered at the origin. For eah triangle t 2 T , we an asso iate a p oint p t 2 S 2 whih represents the normalized normal of triangle t . Speially, ! p t = ! n t = j ! n t j . Our goal is to approximate the spae S 2 of all p ossible normals by a - nite set of points V S 2 suh that for any p 2 S 2 , there is a point v 2 V nearby. Denition 1 A set of point V S 2 is al led a Æ - disretization of S 2 if 8 p 2 S 2 : 9 v 2 V with \ ( v ; p ) Æ . Lemma 2 There exists a Æ -disretization of S 2 of size O (1 = ( Æ ) 2 ) whih an be omputed in the same time. The following onstrution yields a Æ -disretization of S 2 as needed in Lemma 2. (We omit its pro of in this abstrat.) Consider a ub e L with sidelength two entered at the origin. Note that S 2 L . Plae a 2-dimensional grid of size k k with k = d p 2 = ( Æ ) e over eah of the six faes of L . This generates k 2 equally sized square grid ells on eah fae of L , where eah ell has sidelength at most ( Æ p 2), and 6 k 2 + 2 grid p oints overall. See Figure 1. Let A b e the set onsisting of these grid p oints. Our Æ -disretization V of S 2 is dened as V = n ! z j ! z j : z 2 A o ; that is, for eah gridpoint z we sho ot a ray from the origin through z and we inlude the p oint where the ray leaves S 2 into set V . k k Fig. 1. Cub e with sidelength two ontaining S 2 and with a k k grid on eah of its faes. 3. Finding Large Planar Regions 3.1. The Basi Algorithm We rst desribe a simple algorithm for the problem that omputes an -approximate solution in O ( n= ( Æ ) 2 ) time. The algorithm proeeds as follows: 1. Compute a Æ -disretization V of S 2 . 2. For eah p 2 V , (a) Compute the set V p of verties v t with \ ( p; n t ) (1 + ) Æ . (b) Consider the subgraph of G T indued by set V p and determine its heaviest onneted omp onent C p . 3. Rep ort the set of triangles T orresp onding to the heaviest omp onent C p found in Step 2 and the asso iated referene normal ! p . We now disuss the running time and orretness of the algorithm. Computing the Æ -disretization takes O (1 = ( Æ ) 2 ) by Lemma 2. For eah element p 2 V we determine the subgraph indued by V p and ompute its onneted omp onents, whih an b e done in O ( n ) time. So the total running time of Step 2 is O ( n= ( Æ ) 2 ) whih also dominates the overall running time. For orretness, observe rst that learly the omputed set T is Æ (1 + )-planar. It remains to show that the weight of T is at least that of an optimal Æ -planar set T . For set T there exists a vetor ! r suh that for all triangles t 2 T , \ ( r ; n t ) Æ . Let p b e a point in V for whih \ ( p; r ) = min u 2 V \ ( u; r opt ). By the denition of V , the angle \ ( p; r ) must be at most Æ . Then, for any triangle t 2 T the angle b etween ! n t and ! p is at most Æ + ( Æ ) = Æ (1 + ). Therefore for all t 2 T ,
Marh 25-26, 2004 Seville (Spain) v t 2 V p and hene, the algorithm will nd a onneted omp onent with at least the same weight. Lemma 3 Given a triangulated irregular network T , and two real parameters Æ > 0 and > 0 we an ompute in O ( n= ( Æ ) 2 ) time an -approximate Æ -planar set of triangles in T . The running time of the basi algorithm is optimal in terms of n . But one may ask whether the dep endene on or Æ an b e improved. In the following we will rene the algorithm to ahieve O ( n= 2 ) running time, whih is indep endent of Æ . 3.2. The Rened Algorithm The improvement in the running time of the algorithm omes from two fators. First we determine a set of referene normals V 0 of size at most O ( n= 2 ) that ontains all relevant referene normals, avoiding the insp etion of (1 = ( Æ ) 2 ) p otential referene normals. Seond by a buketing sheme, we redue signiantly the numb er of times eah triangle is onsidered. The rened algorithm pro eeds as follows: 1. For eah triangle t 2 T with normal n t , let p t b e a p oint in V for whih \ ( p t ; n t ) = min u 2 V \ ( u; n t ); store t in the buket asso iated with p t . 2. Determine a set V 0 V of p otential referene normals as V 0 = f p 2 V : 9 p t with non-empty buket and \ ( p; p t ) (1 + 2 ) Æ g . 3. For eah v 2 V 0 , (a) Collet the set of triangles N v whih are ontained in bukets of referene normals r 0 2 V 0 with \ ( r 0 ; v ) (1 + 2 ) Æ . (b) Prune N v keeping only those triangles t with \ ( n t ; v ) (1 + ) Æ . Let N 0 v b e the pruned set. () Consider the subgraph of G T indued by the verties orresponding to triangles in N 0 v and determine its heaviest onneted omp onent C v . 4. Output the heaviest onneted omp onent C v found in Step 3. Before analysing the algorithm, we state a small lemma whih informally says that in the Æ -disretization, for any p oint p there is a small number of other p oints nearby. Lemma 4 Let p be a point in the Æ -disretization V . Then the number of points p 0 2 V with \ ( p; p 0 ) < (1 + 2 ) Æ is at most O (1 = 2 ) . The pro of of this lemma follows easily from our onstrution of V and it is omitted. We note also that given a triangle normal n t we an ompute the point p t with \ ( n t ; p t ) = min u 2 V \ ( n t ; u ) in onstant time by rst determining whih fae of the ub e L is hit by the ray ! n t and then lo ating the p osition of the intersetion p oint within the grid on that fae. We now state the main result of this setion: Theorem 5 Given a triangulated irregular network T , and two real parameters Æ > 0 and > 0 we an ompute in O ( n= 2 ) time an -approximate Æ -planar set of triangles in T . PROOF. We laim that the output of the rened algorithm give us suh a set. To show orretness, it suÆes to prove that the algorithm omputes the same solution as the basi algorithm. We leave this pro of to the reader. We fo us now on the running time. Step 1 of the algorithm takes O ( n ) sine for eah t we an in onstant time determine p t and a- ess the asso iated buket using a hashing sheme. Step 2, where we form the set V 0 , takes O ( n= 2 ) sine there are at most n non-empty bukets. For eah of the non-empty bukets, we explore O (1 = 2 ) p oints in the neighb orho o d by Lemma 4. Finally, for the overall running time of Step 3, observe that again by Lemma 4, eah triangle an be olleted by at most O (1 = 2 ) referene normals and that the running time of one iteration of Step 3 is O ( j N v j ). Therefore Step 3 takes O ( n= 2 ) time in total. 2 4. Exp erimental Results We have implemented the rened algorithm of Setion 3.2 in C++ using the LEDA library [3℄. Exp eriments were arried out on a 1.8 GHz Pentium 4 mahine with 256 MB of RAM. We used several data sets representing frature surfaes from the appliation domain in material sienes. Input data were given as 512 512 raster images with the intensity of eah pixel orresponding to its height value. To obtain the TIN, we triangulated the p oint set by reating triangles ( i; j ) ; ( i + 1 ; j ) ; ( i + 1 ; j + 1) and ( i; j ) ; ( i; j + 1) ; ( i + 1 ; j + 1). See Figure 2. To sp eed-up our program (while preserving the same guarantee), we have ome up with the following three heuristis:
20th Europ ean Workshop on Computational Geometry (i,j+1) (i+1,j+1) (i+1,j)(i,j) Fig. 2. Triangulation sheme for the array of height values. ( i ) With eah potential referene normal we asso- iate the weight of all triangles in bukets at distane at most (1 + 2 ) Æ and examine the referene normals in dereasing order of weight. If the urrent best solution exeeds the asso iated weight of the next referene normal, we an stop examining further. ( ii ) If the normal of a triangle t forms an angle larger than 2(1 + ) Æ with the normal of eah of the three adjaent triangles, we an prune t out (at Step 1). It an only form a singleton solution. ( iii ) In Step 3(b) where we ompute the set of relevant triangles N 0 v we only hek triangles in bukets at angle distane more than Æ , thus saving some exp ensive oating-p oint op erations. In our exp eriments, the three heuristis ombined redue the running time by nearly a fator of two. For our test instanes onsisting of roughly 500 ; 000 triangles and a hoie of Æ = 0 : 2 (ab out 11.5 degrees) and = 0 : 2, the running time varied b etween 70 and 110 se. The best solution was in all ases found within the rst 20 seonds due to the prioritization sheme. Thus most of the running time was sp ent on heking that no b etter solution exists. (A heuristi ould just rep ort the solution omputed, for example, after 30 seonds.) We also ran exp eriments to determine the variations of the running time as a funtion of n and . The dep endene graph on for a xed data set is shown in Figure 3. The upp er urve denotes the total running time and the lower urve denotes the time when the reported solution was deteted. In Figure 4 we examine the dep endene on n (number of triangles). Note that again the rep orted solution was found after only few seonds. For the heuristi implementation in [2℄, running times rep orted are in the range of 30{40 seonds but as it is mentioned the solution omputed may b e far from optimal. 1 10 100 1000 10000 0 0.3 0.6 0.9 1.2 1.5 CPU Seconds Epsilon total time detection time Fig. 3. CPU time versus for n = 522K, Æ = 0 : 2. 0 10 20 30 40 50 60 70 80 90 100 0 100 200 300 400 500 CPU Seconds Data Size (K) total time detection time Fig. 4. CPU time versus n for Æ = 0 : 2, = 0 : 2. Referenes [1℄ S. Har-Peled and S. Mazumdar. Fast algorithms for omputing the smallest k -enlosing dis. In Pro. 11th Annu. European Sympos. Algorithms , Leture Notes Comput. Si. Springer-Verlag, 2003. [2℄ K. Lange, R. Ray, M. Smid, and U. Wendt. Computing large planar regions in terrains. In Proeedings of the 8th International Workshop on Combinatorial Image Analysis (IWCIA) , Eletronis Notes in Computer Siene, Volume 46, 2002. [3℄ K. Mehlhorn and S. Naher. LEDA: A Platform for Combinatorial and Geometri Computing . Cambridge University Press, Cambridge, U.K., 1999. [4℄ U. Wendt, K. Lange, M. Smid, R. Ray, and K. Tonnies. Surfae top ography quantiation by integral and feature-related parameters. Materialwissenshaft und Werkstotehnik , 33(10):621{627, Otob er 2002.
