Advanced Materials Research Vols. 181-182 (2011) pp 661-666 Online available since 2011/Jan/20 at www.scientific.net © (2011) Trans Tech Publications, Switzerland doi:10.4028/www.scientific.net/AMR.181-182.661
A Real-time Algorithm for Convex Hull Construction and Delaunay Triangulation of Scattered Points Data He Xueming1,2,a, Lu Yi1,b, Li chenggang2,c, Ni Minmin1, Hua Chenliang1 1
School of Mechanical Engineering, Jiangnan University, Wuxi,214122,China
2
School of Mechanical Science and Engineering, Huazhong University of Science and Technology, Wuhan 430074,China a
[email protected],
[email protected],
[email protected]
Keywords: computation geometry, scattered points, convex hull, Delaunay triangulation
Abstract. Convex hull is a very important data structure of computational geometry design. This paper presents an algorithm to construct the convex hull of a set of scattered points by coordinates and relative angle method. The algorithm determines the convex vertexes and eliminates some non-convex vertexes, which greatly reduces the searching scope and the complexity. Delaunay triangulation is widely used in 3D surface reconstruction. Due to its duality, Delaunay triangulation is usually constructed through Voronoi diagram. Delaunay triangulation is directly constructed in this paper. The algorithm is simple, stable and easy to implement, especially for less data points. Introduction Convex hull is the closed min-area convex polygon which includes all the points of the data point and the line of any two points is in it. Usually, there are two problems to resolve: to determine which the convex hull vertexes are and to determine the links of these convex hull vertexes. The total time used to resolve the two problems is O (n logn), where n is the number of points. Graham algorithm can achieve the lower limit time complexity. Obviously, it is necessary to reduce the points that construct convex hull[1]. Triangulation is a basic problem in computation geometry. A geometrical object is divided into several simple objects. The simplest geometry is triangle in R 2 and tetrahedral in R3 . Due to the particular mathematical property, Delaunay is a tool of mathematic analysis, an important representation and an analysis method of DTM model in GIS[2]. Convex Hull Construction Algorithm Normally, only some points are the convex hull vertexes, and the other points are inside the convex hull. Thus, the computation speed is raised, which avoids the complication of inserting point by point, especially when there are lots of points. This is quick convex hull[3]. The Judgment of Points and Polygons. According to the sum of angle vector of a single point and every polygon vertex, the locations of the point and the polygon can be obtained[4]. When the point P is inside the polygon P1 P2 P3 P4 Pn , the point and every vertex of the polygon P1 P2 P3 P4 Pn are connected (the clockwise angle is negative, and the counterclockwise angle is positive), and the sum of angle vector of the point P and every polygon vertex is 360°. When the point P is outside the polygon P1 P2 P3 P4 Pn , the sum of angle vector of the point P and every polygon vertex is 0°. As shown in Fig.1 (a), the sum of the point P and the heptagon P1P2 P3 P4 P5 P6 P7 is: ∠P1 PP2 +∠P2 PP3 +2 + ∠P6 PP7 +∠P7 PP1 = 33°+36°+47°+61°+63°+54°+66° = 360°
(1)
So, the point P is an interior point of the heptagon P1P2 P3 P4 P5 P6 P7 ; in other words, the point P is inside of the heptagon P1P2 P3 P4 P5 P6 P7 . As shown in Fig.1 (b), the sum of the point P and the heptagon P1P2 P3 P4 P5 P6 P7 is:
All rights reserved. No part of contents of this paper may be reproduced or transmitted in any form or by any means without the written permission of TTP, www.ttp.net. (ID: 122.193.143.37-22/11/12,02:11:53)
662
Advanced Materials Science and Technology
(2) So, the point P is an exterior point of the heptagon P1P2 P3 P4 P5 P6 P7 ; in other words, the point P is outside of the heptagon P1P2 P3 P4 P5 P6 P7 . ∠P1 PP2 +∠P2 PP3 +2+∠P6 PP7 +∠P7 PP1 = 11.4°+14.5°+12.4° − 6° − 36° − 9.5°+13.2° = 0°
(a) Heptagon P1 P2 P3 P4 P5 P6 P7 and interior point P.
(b) Heptagon P1 P2 P3 P4 P5 P6 P7 and exterior point P. Fig. 1 The position of heptagon and point P.
Convex Hull Construction. By using simple mapping, convex hull can be constructed, when the abscissa is defined as the X-axis and the ordinate is defined as the Y-axis. The algorithm is as followed (see Fig. 2):
Fig. 2 Four maximum and minimum points. (1) The point PL has the minimum X-coordinate
Fig. 3 Process of convex hull construction. value, while the point PR has the maximum.
The point PD has the minimum Y-coordinate value in the axis, while the point PU is the maximum. The four points are connected (if the point satisfies the condition that it is not only one, then the point with the minimum coordinate value in the Y-axis is needed when the reference axis is X-axis, and the point with the minimum coordinate value in the X-axis is needed when the reference axis is Y-axis). As a result, tetragon PL PD PR PU divides the points into four areas: LLL, RLL, LUL, RUL denoted as S LD , S RD , S LU , S RU . (2) Check the points of every area after dividing. According to the judgment criterion of the position for a point and a polygon, the inner points which are not the convex hull vertexes can be determined. So, only the exterior points need to be considered. Fig. 3 shows the process of convex hull construction. First, the LLL area S LD is taken into account. Because there is only one point, P1 must be convex hull vertex. Second, connect the point P1 to PL and PD , delete the primary contour PL PD (dashed line), and conserve the point P1 into a link list TuBao[i]. In the same way, only one point P2 is in the area S RD and one point P4 is in the area S RU . The point P2 is directly connected with PR , PD and the point P4 is connected with PR , PU , the primary contour PR PD and PR PU (dashed line) are deleted, and the points P2 , P4 are saved into link list. More than one point in the area S LU needs to find the farthest point P3 . The point P3 is connected with the point PL and PD , the contour PL PD (dashed line) is deleted, and the point P3 is conserved into the link list. (3) Now, the contour P3 PL and P3 PU divide the area S LU into two areas S LUL and S LUR where there are other points, while the point P1 , P2 , P4 divide the area S LD , S RD , S RU into area
Advanced Materials Research Vols. 181-182
663
where there is no any point. The result is shown in Fig.4. When only one point P5 is in the area S LUL , the point P5 is connected with two endpoints P3 , PL and the contour P3 PL (dashed line) is deleted. In the same way, when only one point P6 is in the area S LUR , the point P6 is connected with two endpoints P3 , PU , and two contours P3 PU , P3 PU (dashed line) are deleted, and the point P3 , P6 are conserved into the link list. (4) Hereto, all the areas are empty. Convex hull is constructed. The points in the link list are convex hull vertexes which need resorting in line with anticlockwise or clockwise direction. The point P1 with minimum Y-coordinate value is saved in another link list PaiXu[i]. Next, the algorithm separately lines P1 with the other convex hull vertexes and the angle between the X-axis positive direction and these lines are obtained. The points are marked P2 , P3 , …… P10 and are saved in the link list PaiXu[i]. For the point P1 which has minimum Y-coordinate value, the angles are 0° ≤ θ ≤ 180° . In proper order, the points in PaiXu[i] are connected. The final result is shown in Fig. 5.
Fig. 4 Flow 2 of convex hull construction.
Fig. 5 Reordering of a set point S.
Convex hull construction by simple mapping method can choose the convex hull vertexes quickly, which greatly reduces the time. The point with minimum Y-coordinate value is a base point, and it resorts other points. If there are three points collinear, the algorithm is still good. Delaunay Triangulation Definition. Typical applications of triangulation include finite element analysis and computer graphics. The Delaunay triangulation is a special triangulation which maximizes the minimum angle over all triangulation of the set of points. Because of its nice properties, it has been widely used in a number of applications such as communication networks, surface interpolation and nearest neighbors in graph. Green and Sibson[5] first realized an algorithm for generating a Dirichlet frequency polygon. Brassel and Reif[6] later presented similar algorithm. McCullagh and Ross[7] reduced searching time by improving searching method. Maus[8] also put forward a very similar algorithm. This paper presents another algorithm on the basis of previous study. Definition 1: The S is defined as a set of points, its Delaunay triangulation is a triangulation of S such that every triangle’s circum-circle contains no other point of S inside it. The edges of a Delaunay triangulation are denoted as the Delaunay edges. From the definition 1, the triangulation of Fig. 6 (a) is not a Delaunay triangulation. Fig. 6 (b) is a Delaunay triangulation of the 4 points. The Judgment Criterion of the Points and Circles. To judge the position of a point and a circle, take the coordinates of points into the circle equation and then the expression value is the judgment criterion. Also, the distance from a point to the center of a circle radius can be accorded to r. But, the two methods make the triangulation algorithm verbose and time-consuming. This paper proposed a new method, namely four points of a circle: the opposite angle is 180° if a quadrangle consists of four points in a circle. The points that need to be checked form a quadrangle with three points (a circle). If the opposite angle is greater than 180°, then the point is inside of the circle. If the opposite angles are less than 180°, then the point is outside of the circle. If the opposite angles are equal to 180°, then the point is on the circle.
664
Advanced Materials Science and Technology
(a)
(b)
Fig. 6 Two possible triangulations of four points.
Fig. 7 Judgment of a point and a circle. P2 , P3 . The point Pa with P1 , P2 ,
Fig.7 illustrates the triangle circum-circle of the point P1 , P3 constitutes a quadrangle. The vertex angle with the vertex Pa is ∠P1 Pa P2 , so its opposite angle is ∠P1P3 P2 , the accumulated angle is θ = ∠P1Pa P2 + ∠P1 P3 P2 = 86° + 35° = 121° < 180° , then the point Pa is outside of the circle. When the point Pb is checked, the accumulated angle is θ = ∠P1 Pb P3 + ∠P1 P2 P3 = 77° + 103° = 180° . So the point Pb is on the circle. When the point Pc is checked, the accumulated angle is θ = ∠P1Pc P3 + ∠P1 P2 P3 = 101° + 103° = 204° > 180° , so the point Pc is inside of the circle. Definition 2:In R 2 , the dot product of vectors u = (u1 ,u 2 ) and v = (v1 ,v 2 ) is u ⋅ v = u1v1 + u2 v2
(3)
Then the angle between two vectors can be computed from the dot product and the norms of them: u ⋅ v = u v cos θ (4) u ⋅v u v
Thus, θ = arccos = arccos
u1v1 + u2 v2 u12 + v12 i u22 + v22
(5)
When the angle is known, the position of a point and a circle on the basis of judgment criterion can be determined. Delaunay Triangulation. Delaunay triangulation, as a main DTM notation, has a widely application. After 20 years’ study, its algorithms become mature, including a merge method, a point by point insertional method and a triangular network. The algorithm proposed in this paper is a method to construct Delaunay triangulation by the basis of point-by point insertion, which makes any n points satisfy Delaunay triangulation. Fig. 8 is taken as an example, and the process of Delaunay triangulation is as follows.
Fig. 8 Sorting on the basis of angles.
Fig. 9 P4 Delaunay triangulation of the point P1 P2 P3 .
(1) A point with maximum Y-coordinate is the point P1 and the algorithm separately lines the point P1 with the other points, then the angle between the X-axis positive direction and these lines is obtained, and these points P2 , P3 , P4 …… P13 are marked in an increasing order. If there are
Advanced Materials Research Vols. 181-182
665
three points collinear, the coordinate is taken into account. Since the reference point has the min Y-coordinate, all the angles between the lines and the coordinate in the Y-axis is 0°~180°. The smaller coordinate in the Y-axis in front is arranged before the larger coordinates in the Y-axis rearwards. Thus, it is guaranteed the point Pn is outside of polygon constituted by n-1 points. (2) The first three points P1 , P2 , P3 make up a triangle. The point P4 is taken outside of the triangle P1 P2 P3 and is lined to three vertexes. If the circum-circle of the new triangle excludes any point, then it is kept. The result looks like the bold lines shown in fig. 9. If it includes some points of P1 , P2 , P3 , P4 , then the edge(if one edge is communal then it is reserved) is deleted. If it includes some points except P1 , P2 , P3 , P4 , these points can be signed with the continuous thin line which will be deleted later. As shown in Fig. 9, the circum-circle of the triangle P2 P3 P4 includes no one point, and then the triangle is saved. But the circum-circle of the triangle P1 P2 P4 includes the point P10 , the communal edge P2 P4 and the convex hull boundary P1 P2 are recovered. The edge P1 P4 will be deleted when the point P10 is brought in. The circum-circles of the triangle P2 P3 P4 , P1 P3 P4 include the point P4 , P2 , so they will be deleted. Meanwhile, the edge P1 P2 , P2 P3 , P3 P4 , P1 P4 which are the communal edges are saved. In fact, only the edge P1 P3 needs to be deleted (dotted line). (3) Normally, the points P5 …… P13 are taken point by point to construct Delaunay triangle. Fig.10 illustrates the final Delaunay triangle.
Fig. 10 Delaunay triangulation of the point set S.
Fig. 11 Delaunay triangulation of the complex points.
Implement. For complex data points, the algorithm is also suitable. It can be proven that the triangulation network not only produces no holes and bridges, but also misses no points and prevents a lot of errors. The algorithm presented in this paper is feasible. Fig. 11 shows the Delaunay triangulation network of complex planar scatter point data. Conclusion An algorithm of constructing convex hull is introduced by the simple mapping and relative angle calculation in this paper. The convex hull vertexes are kept, at the same time, the points which are not the convex hull vertexes are left. Thus, the algorithm is yet simplified by the link list storage. Without making use of Voronoi diagram, the process of constructing Delaunay triangulation is simpler, especially for the point set with less point data. After sorting the points in the set, Delaunay triangulation of any previous n points can be produced. References [1] Zhang Xiangjing. Research on the Algorithm for Constructing Convex Hull of Scattered Point data. Journal of Geomatics, 2000, 4: 9-11. [2] Wu Xiaobo, Wang Shixin, Xiao Chunsheng. Research on the Algorithm for Delaunay Triangulation. Acta Geodaetica et Cartographic Sinica, 1999, 28(1): 28-34.
666
Advanced Materials Science and Technology
[3] Yang Xunnian. A Quick Algorithm for Convex Hull in 3D. Journal of Zhejiang University (Natural Sciences), 1999, 33(2): 111-113. [4] Zhou Jie, Ding Xianrong, Wang Dguan. An Efficient Delaunay Triangulation Algorithm for Planar Sattered Point Data. Journal of Geomatics, 2003, 28(6): 21-23. [5] Green P J. and Sibson R. Computing Dirichlet Tessellations in the Plane. The Computer Journal, 1978, 21 (2): 168-173. [6] Brassel K E. and Reif D. Procedure to Generate Thiessen Polygons. Geophysical Analysis, 1979(11): 289-303. [7] McCaullaghM T. and Ross CG. Delaunay Triangulation of a Random Data Set For Iirarithmic Mapping. The Cartographic Journal, 1980 (17): 93-99. [8] Maus A. Delaunay Triangulation and the Convex Hull of n Points in Expected Linear Time. BIT, 1984 (24): 151-163. [9] Ying Sun. Surface reconstruction using Gamma Shapes. 2007.
Advanced Materials Science and Technology 10.4028/www.scientific.net/AMR.181-182
A Real-Time Algorithm for Convex Hull Construction and Delaunay Triangulation of Scattered Points Data 10.4028/www.scientific.net/AMR.181-182.661 DOI References [5] Green P J. and Sibson R. Computing Dirichlet Tessellations in the Plane. The Computer Journal, 1978, 21 (2): 168-173. doi:10.1093/comjnl/21.3.243 [8] Maus A. Delaunay Triangulation and the Convex Hull of n Points in Expected Linear Time. BIT, 1984 (24): 151-163. doi:10.1007/BF01937482 [9] Ying Sun. Surface reconstruction using Gamma Shapes. 2007. doi:10.1063/1.2539745