[go: up one dir, main page]

CN101114379A - A method to determine whether a point is inside a polygon - Google Patents

A method to determine whether a point is inside a polygon Download PDF

Info

Publication number
CN101114379A
CN101114379A CNA2007101215068A CN200710121506A CN101114379A CN 101114379 A CN101114379 A CN 101114379A CN A2007101215068 A CNA2007101215068 A CN A2007101215068A CN 200710121506 A CN200710121506 A CN 200710121506A CN 101114379 A CN101114379 A CN 101114379A
Authority
CN
China
Prior art keywords
polygon
point
convex
polygons
given
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CNA2007101215068A
Other languages
Chinese (zh)
Other versions
CN100524361C (en
Inventor
李静
王文成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Institute of Software of CAS
Original Assignee
Institute of Software of CAS
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Institute of Software of CAS filed Critical Institute of Software of CAS
Priority to CNB2007101215068A priority Critical patent/CN100524361C/en
Publication of CN101114379A publication Critical patent/CN101114379A/en
Application granted granted Critical
Publication of CN100524361C publication Critical patent/CN100524361C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Generation (AREA)

Abstract

本发明属于计算机图形技术和计算几何技术领域,是一种判断点是否位于多边形内的方法。本发明先对多边形进行凸剖分,并建立二叉树来管理这些凸多边形;然后,根据被检测点的坐标位置,对所建立的二叉树进行考察,以找到该二叉数的一叶节点对应的凸多边形,再检测该点是否位于这个凸多边形内,以判断被检测点是否位于给定的多边形内。本发明的优点是计算速度快,比基于多边形剖分的同类方法节省存储空间,易于实现。适用于多个点要对同一个多边形进行这种包含性判断的情况。

The invention belongs to the technical fields of computer graphics technology and computational geometry, and is a method for judging whether a point is located in a polygon. The present invention first carries out convex subdivision to polygons, and establishes binary tree to manage these convex polygons; Then, according to the coordinate position of the detected point, investigates the binary tree established, to find the convex corresponding to the leaf node of the binary number. polygon, and then detect whether the point is located in the convex polygon to determine whether the detected point is located in the given polygon. The invention has the advantages of high calculation speed, less storage space than similar methods based on polygon division, and easy implementation. It is applicable to the situation where multiple points need to perform this inclusive judgment on the same polygon.

Description

一种判断点是否位于多边形内的方法 A method to determine whether a point is inside a polygon

技术领域technical field

本发明属于计算机图形技术和计算几何技术领域,尤其涉及一种判断点是否位于多边形内的方法。The invention belongs to the technical fields of computer graphics technology and computational geometry, and in particular relates to a method for judging whether a point is located in a polygon.

背景技术Background technique

点是否位于多边形内的判定计算,是计算几何中的一个基本问题,这方面的方法在计算机图形学、模式识别、地理信息系统等众多领域有着广泛的应用。这方面的方法可分成两类,一类是不对多边形进行预先处理的,一类是要对多边形预先进行一定的处理的。It is a basic problem in computational geometry to determine whether a point is located in a polygon, and the methods in this area are widely used in many fields such as computer graphics, pattern recognition, and geographic information systems. The methods in this respect can be divided into two categories, one is not to pre-process the polygon, and the other is to pre-process the polygon.

在前一类方法中,最常用的是射线法,即从被检测点发出一条射线,计算与它相交的多边形的边的个数,如果是奇数个,则该点位于多边形内,否则位于多边形外。这类方法需要计算多边形的每条边,时间复杂度高,为O(N)(即其计算量的多少是与N成线性对应关系),N是多边形的边数。In the former method, the most commonly used method is the ray method, that is, a ray is sent from the detected point, and the number of sides of the polygon intersected with it is calculated. If it is an odd number, the point is located in the polygon, otherwise it is located in the polygon. outside. This type of method needs to calculate each side of the polygon, and the time complexity is high, which is O(N) (that is, the calculation amount is linearly corresponding to N), and N is the number of sides of the polygon.

在后一类方法中,主要是对多边形的边、所覆盖的区域等进行一定的组织,使得判断计算的时间复杂度降低,加快计算速度。比如著名的梯形剖分法(参见Zalik B,Jezernik A.,Zalik KR.Polygon trapezoidation by sets of open trapezoids.Computers&Graphics 2003;27(5):791-800.),用经过顶点的平行坐标轴的直线,将多边形剖分成一些梯形,再根据梯形坐标值的单调增加或降低的方法,将梯形顺序排列,判断计算时可利用二分检索技术,以避免处理很多边,将判断计算的时间复杂度降至O(logN),N是多边形的边数。In the latter method, it is mainly to organize the sides of the polygon, the covered area, etc., so that the time complexity of judgment calculation is reduced and the calculation speed is accelerated. For example, the famous trapezoidal subdivision method (see Zalik B, Jezernik A., Zalik KR. Polygon trapezoidation by sets of open trapezoids. Computers & Graphics 2003; 27(5): 791-800.), using a straight line passing through the parallel coordinate axis of the vertex , divide the polygon into some trapezoids, and then arrange the trapezoids in order according to the monotonous increase or decrease of the trapezoidal coordinate values. When judging and calculating, binary search technology can be used to avoid processing many sides and reduce the time complexity of judging and calculating to O(logN), where N is the number of sides of the polygon.

在实际应用中,经常会遇到边数很多的多边形,而目前已有的技术的方法,其空间开销很大,不便于对边数很多的多边形进行处理,受空间表达能力或计算能力的限制,判断效率不高。In practical applications, polygons with a large number of sides are often encountered, but the existing technical methods have a large space overhead, and it is not convenient to process polygons with a large number of sides, which is limited by space expression ability or computing power. , the judgment efficiency is not high.

发明内容Contents of the invention

本发明的目的是提供一种判断点是否位于多边形内的方法,提高计算速度,降低空间开销。The purpose of the present invention is to provide a method for judging whether a point is located within a polygon, which improves calculation speed and reduces space overhead.

本发明的判断点是否位于多边形内的方法,其步骤包括:Whether judging point of the present invention is positioned at the method for polygon, its step comprises:

1)将给定的多边形剖分为单调多边形集合;1) Divide the given polygon into a set of monotone polygons;

2)将上述单调多边形中非凸的多边形进行凸剖分,得到给定多边形的凸多边形集合;2) Carry out convex subdivision of the non-convex polygons in the above-mentioned monotone polygons to obtain a convex polygon set of given polygons;

3)以凸多边形的边形成的直线作为划分直线,基于每划分直线两侧凸多边形的个数建立平衡二叉树,其中根节点和中间结点存放各自相应的划分直线,每个叶节点存放相应的一凸多边形;3) The straight line formed by the sides of the convex polygon is used as the dividing line, and a balanced binary tree is established based on the number of convex polygons on both sides of each dividing line, in which the root node and the middle node store the respective corresponding dividing lines, and each leaf node stores the corresponding a convex polygon;

4)根据给定点与平衡二叉树非叶子节点存放的划分直线的位置关系对上述平衡二叉树进行搜索,直至到达一叶节点;4) According to the positional relationship between the given point and the dividing line stored in the non-leaf nodes of the balanced binary tree, the above-mentioned balanced binary tree is searched until a leaf node is reached;

5)判断给定点和上述叶节点对应的凸多边形的位置关系,如果该点位于这个凸多边形内,则该点位于给定的多边形内;否则,该点位于给定的多边形外。5) Determine the positional relationship between the given point and the convex polygon corresponding to the leaf node, if the point is inside the convex polygon, then the point is inside the given polygon; otherwise, the point is outside the given polygon.

本发明是一种对多边形进行预先处理的方法,也是基于多边形覆盖区域的剖分。与现有方法相比,所剖分后的单元是凸多边形,其个数要比其它剖分方法生成的单元的个数少,因此,所建立的二叉树和表达凸多边形的空间开销得到节省。二叉树搜索的时间复杂度是O(logN),且判断一个点是否位于一个凸多边形内的时间复杂度也是O(logN),因此本发明的时间复杂度也是O(logN)。但得益于其剖分单元的个数少,其判断速度快于基于梯形剖分的方法。处理边数很多的多边形时,点是否位于多边形内的判断效率得到大幅的提高,适用于各种要对同一个多边形进行多次判断点是否位于多边形内的方法。The invention is a method for preprocessing polygons, which is also based on the subdivision of polygon coverage areas. Compared with the existing method, the subdivided units are convex polygons, and the number of units generated by other subdivision methods is less than that of other subdivision methods. Therefore, the space overhead of establishing a binary tree and expressing convex polygons is saved. The time complexity of binary tree search is O(logN), and the time complexity of judging whether a point is located in a convex polygon is also O(logN), so the time complexity of the present invention is also O(logN). But thanks to the small number of subdivision units, its judgment speed is faster than the method based on trapezoidal subdivision. When dealing with polygons with a large number of sides, the efficiency of judging whether a point is inside a polygon is greatly improved, and it is suitable for various methods that need to judge whether a point is inside a polygon multiple times for the same polygon.

附图说明Description of drawings

图1多边形的凸剖分操作图。Figure 1 Diagram of the convex subdivision operation of polygons.

图2多边形的凸剖分结果图。Fig. 2 Convex subdivision results of polygons.

图3据凸剖分结果图建立的平衡二叉树。Fig. 3 The balanced binary tree established according to the result graph of convex subdivision.

图4判断某点是否位于凸多边形内的方法图。Figure 4 is a diagram of the method for judging whether a point is within a convex polygon.

图5判断点是否位于多边形内的流程图。Figure 5 is a flow chart of judging whether a point is within a polygon.

具体实施方式Detailed ways

本发明的方法主要包括下列两个阶段:第一阶段是对给定的多边形进行凸剖分,建立平衡二叉树来管理凸多边形;第二阶段是根据所建立的平衡二叉树和生成的凸多边形,判断被检测点是否位于多边形内。The method of the present invention mainly comprises following two phases: the first phase is to carry out convex dissection to given polygon, establishes balanced binary tree and manages convex polygon; Whether the detected point is inside the polygon.

1.第一阶段的实现步骤如下:1. The implementation steps of the first stage are as follows:

首先将给定的多边形剖分成一些单调多边形(即每个这样的多边形的边可分成2个单调边序列)(参见文献de Berg M,van Kreveld M,Overmars M,et al.Computational Geometry:Algorithms and Applications.2nd ed.Berlin:Springer,2000中的方法),再将各个单调多边形进行凸剖分。First, the given polygon is divided into some monotone polygons (that is, the sides of each such polygon can be divided into 2 monotone edge sequences) (see the literature de Berg M, van Kreveld M, Overmars M, et al. Computational Geometry: Algorithms and Applications.2nd ed.Berlin: Springer, the method in 2000), and then each monotone polygon is convexly divided.

本发明采用的是一种不加点的凸剖分方法,图1是多边形的凸剖分操作图,其具体步骤如下:What the present invention adopted is a kind of convex subdivision method without adding points, and Fig. 1 is the convex subdivision operation figure of polygon, and its concrete steps are as follows:

1)将多边形剖分成单调多边形1) Divide the polygon into monotone polygons

a)找到多边形的所有上凹点和下凹点;这里,若一个凹点的Y坐标值小于它相邻的两个顶点的Y坐标值,则称该凹点为上凹点;若一个凹点的Y坐标值大于它相邻的两个顶点的Y坐标值,则称该凹点为下凹点;a) Find all the upper concave points and lower concave points of the polygon; here, if the Y coordinate value of a concave point is smaller than the Y coordinate value of its two adjacent vertices, then the concave point is called an upper concave point; if a concave point If the Y coordinate value of a point is greater than the Y coordinate values of its two adjacent vertices, the concave point is called a concave point;

b)对所有上凹点和下凹点,根据它们的Y坐标值排序;b) For all the upper concave points and lower concave points, sort them according to their Y coordinate values;

c)对每一个上凹点,将其与任一个Y坐标值小于它的下凹点或凸顶点连成一条边,选取其中位于该多边形内且边长最短的一条边,将多边形进行一次剖分;同理,对每一个下凹点,将其与任一个Y坐标值大于它的上凹点或凸顶点连成一条边,选取其中位于该多边形内且边长最短的一条边,将多边形进行一次剖分;c) For each upper concave point, connect it with any lower concave point or convex vertex whose Y coordinate value is smaller than it to form a side, select the side that is within the polygon and has the shortest side length, and cut the polygon once In the same way, for each concave point, connect it with any upper concave point or convex vertex whose Y coordinate value is greater than it to form a side, select the side that is located in the polygon and has the shortest side length, and divide the polygon perform a split;

d)重复c)的操作,上凹点和下凹点都要操作一次;d) Repeat the operation of c), the upper concave point and the lower concave point must be operated once;

2)将非凸的单调多边形剖分成凸多边形2) Divide non-convex monotone polygons into convex polygons

a)找出单调多边形中的凹点,将它们的Y坐标值从大到小进行排序;a) Find the concave points in the monotone polygon, and sort their Y coordinate values from large to small;

b)按照Y坐标值由大到小的顺序依次处理凹点,将凹点与Y坐标值小于它的凹点或其它顶点进行连接,选取其中边长最短且在该单调多边形内的一条边作为该单调多边形的一次剖分;b) Process the concave points sequentially according to the order of the Y coordinate value from large to small, connect the concave point with the concave point or other vertices whose Y coordinate value is smaller than it, and select the side with the shortest side length and within the monotone polygon as the a subdivision of the monotonic polygon;

c)反复进行b)的操作,直至各个剖分的多边形中都没有凹点为止,即这些凸多边形的并集就是原来的多边形。图2即为多边形的凸剖分结果图。c) Repeat the operation of b) until there is no concave point in each divided polygon, that is, the union of these convex polygons is the original polygon. Figure 2 is the result of the convex subdivision of the polygon.

3)建立一个管理凸多边形的平衡二叉树3) Build a balanced binary tree that manages convex polygons

对凸边形构成的集合迭代地进行二分,即每次将所考察的凸多边形集合分成2个集合,直至每个子集合中只有一个凸多边形。在二分的过程中,对于所考察的多边形集合中这些多边形的边,将每条边两端延长,形成与这些边共线的直线,计算每条直线两边的凸多边形个数的差异,以及与该直线相交的凸多边形的个数相对于该集合中凸多边形个数的比例,来决定分割该集合的划分直线。The set composed of convex polygons is iteratively divided into two sets, that is, the set of convex polygons under investigation is divided into two sets each time until there is only one convex polygon in each subset. In the process of bisection, for the sides of these polygons in the polygon set under consideration, extend the two ends of each side to form a straight line collinear with these sides, calculate the difference in the number of convex polygons on both sides of each straight line, and The ratio of the number of convex polygons intersected by the straight line to the number of convex polygons in the set determines the dividing line that divides the set.

它们的具体计算方法如下:Their specific calculation methods are as follows:

a)假设位于一条直线左侧的凸多边形集合为SL、位于其右侧的凸多边形集合为SR、与该直线相交的凸多边形集合为SI,它们所包含的凸多边形个数分别为nL、nR、nI。我们计算3个参量,即纯净度 PD ( PureDegree ) = n L + n R n L + n R + n I , 平衡度 BD ( BalanceDegree ) = 1 - | n L - n R | n L + n R , 选择度SD(Selection Degree)=Min(PD,BD),即PD和BD这两个值中较小的那一个值就为SD的值。a) Assuming that the set of convex polygons located on the left side of a straight line is S L , the set of convex polygons located on the right side is S R , and the set of convex polygons intersecting the line is S I , the numbers of convex polygons they contain are respectively n L , n R , n I . We calculate 3 parameters, the purity PD ( Pure Degree ) = no L + no R no L + no R + no I , Balance BD ( Balance Degree ) = 1 - | no L - no R | no L + no R , Selectivity SD (Selection Degree)=Min(PD, BD), that is, the smaller value of the two values of PD and BD is the value of SD.

b)为每条直线计算其SD值,然后,以SD值最大的一条直线作为这个凸多边形集合的划分直线,将此集合分割成2个子集合,此时这2个子集合均要包含与该划分直线相交的凸多边形。b) Calculate the SD value for each straight line, and then use the straight line with the largest SD value as the dividing line of this convex polygon set, and divide this set into two sub-sets. At this time, these two sub-sets must contain the same division Convex polygons intersected by lines.

这里,计算PD的目的是要使与划分直线相交的凸多边形的个数尽可能少,以减少凸多边形被重复处理的次数,以降低树的高度,节省存储空间和加速判断计算;计算BD的目的是使树的两边尽可能平衡,以提高判断计算时相应的二分搜索的速度。Here, the purpose of calculating PD is to make the number of convex polygons intersected with the dividing line as small as possible, so as to reduce the number of repeated processing of convex polygons, reduce the height of the tree, save storage space and speed up judgment calculation; calculate BD The purpose is to make the two sides of the tree as balanced as possible, so as to improve the speed of the corresponding binary search when judging the calculation.

所建立的平衡二叉树,如图3所示,其中树的间结点记录相关的划分直线,而其叶子结点记录相关的一个凸多边形。The established balanced binary tree is shown in Fig. 3, in which the intermediate nodes of the tree record the related division straight lines, and its leaf nodes record the related convex polygon.

2.第二阶段的实现步骤如下:2. The implementation steps of the second stage are as follows:

(1)根据被检测点的坐标,对二叉树进行由顶至底的搜索,即:先考察树的根结点,看被检测点位于其划分直线的哪一边,然后就以那一边对应的子结点作为下一步考察的对象,如此迭代进行,直至到达叶结点,该叶节点中的凸多边形就是所要找的凸多边形。(1) According to the coordinates of the detected points, search the binary tree from top to bottom, that is: first examine the root node of the tree, see which side of the line the detected point is located on, and then use the child corresponding to that side The node is taken as the object of the next investigation, and iteratively proceeds until the leaf node is reached, and the convex polygon in the leaf node is the convex polygon to be found.

(2)对于叶结点中的凸多边形,判断被检测点是否位于该凸多边形内,首先将它的边分成两个单调边序列,即:找到这个凸多边形中Y坐标值最大的一个顶点和Y坐标值最小的一个顶点,根据这两个顶点将该多边形的边分成2个部分,每个部分都是顺序连接的边,且这些边的顶点Y坐标值是顺序增大的或减小的;然后,根据被检测点的Y坐标值形成一条平行X轴的直线,如图4所示,计算该直线与这个凸多边形的两个单调边序列的两个交点的X坐标值,比较被检测点的X坐标值是否位于两个交点的X坐标值之间。如果是,则该点位于这个凸多边形内,也就是位于给定的多边形内;否则,在给定的多边形外。(2) For the convex polygon in the leaf node, to judge whether the detected point is located in the convex polygon, first divide its edge into two monotone edge sequences, that is: find the vertex with the largest Y coordinate value in the convex polygon and A vertex with the smallest Y coordinate value divides the edge of the polygon into two parts according to these two vertices, each part is a sequentially connected edge, and the Y coordinate value of the vertices of these edges increases or decreases in sequence Then, form a straight line parallel to the X axis according to the Y coordinate value of the detected point, as shown in Figure 4, calculate the X coordinate values of the two intersection points of the straight line and the two monotone edge sequences of this convex polygon, compare the detected Whether the X coordinate value of the point is between the X coordinate values of the two intersection points. If so, the point lies within this convex polygon, that is, within the given polygon; otherwise, it is outside the given polygon.

图5是本发明判断点是否位于多边形内的整体流程图。Fig. 5 is an overall flow chart of the present invention for judging whether a point is located within a polygon.

下面是本发明的一些实验数据:随机生成4个多边形以进行实验,它们都有10000条边,但它们的凹点所占的比例分别为0%、10%、30%和50%。凹点比例为0%的多边形就是凸多边形。测试时,我们在多边形的包围盒内均匀分布1000个点进行检测,将它们的平均检测时间作为实验数据。我们将新方法与国际上已知最快的随机渐增梯形法(the randomized incremental trapezoidation-basedalgorithm)进行了实验对比,实验数据见下列表中。实验表明,新方法使用的凸多边形个数少于随机渐增梯形法所使用的梯形个数,新方法在存储空间需求和检测速度方面均好于随机渐增梯形法。The following are some experimental data of the present invention: 4 polygons are randomly generated for experimentation, and they all have 10,000 sides, but the proportions of their concave points are 0%, 10%, 30% and 50% respectively. A polygon with a concave ratio of 0% is a convex polygon. During the test, we evenly distribute 1000 points in the polygonal bounding box for detection, and take their average detection time as the experimental data. We compared the new method with the randomized incremental trapezoidation-based algorithm (the randomized incremental trapezoidation-based algorithm), which is the fastest known in the world. The experimental data are shown in the table below. Experiments show that the number of convex polygons used by the new method is less than the number of trapezoids used by the random increasing trapezoidal method, and the new method is better than the random increasing trapezoidal method in terms of storage space requirements and detection speed.

凹点比例(%)Dimple ratio (%) 剖分的凸多边形或梯形个数Number of convex polygons or trapezoids to divide 树结点个数Number of tree nodes 最大树深度(层次树)Maximum tree depth (hierarchical tree) 梯形(梯形法)trapezoidal (trapezoidal method) 凸多边形(本发明)Convex polygon (this invention) 梯形法trapezoidal method 本发明this invention 梯形法trapezoidal method 本发明this invention  0%0% 2000120001  1 1  4631746317  1 1  4646  1 1  10%10% 2000120001  14231423  5179251792  23162316  5656  1212  30%30% 2000120001  36283628  5076950769  59105910  5151  1515  50%50% 2000120001  42294229  5090350903  74647464  4747  1515

凹点比例(%)Dimple ratio (%) 预处理时间(毫秒)Preprocessing time (ms) 存储空间(KB)storage space(KB) 检测一个点的平均时间(微妙)Average time to detect a point (microseconds) 梯形法trapezoidal method 本发明this invention 梯形法trapezoidal method 本发明this invention 梯形法trapezoidal method 本发明this invention  0%0% 54.7954.79  13.6313.63  24462446  12001200  0.870.87  0.380.38  10%10% 61.3061.30  52.7852.78  25562556  15361536  0.850.85  0.500.50  30%30% 60.2060.20  77.8277.82  25352535  20572057  0.950.95  0.510.51  50%50% 61.2061.20  100.00100.00  25382538  22542254  0.860.86  0.750.75

实验表明,与目前最快的基于梯形剖分的方法—增量梯形法相比,本发明的方法在多边形的预处理的时间、空间需求和判断计算等各个方面具有相同的复杂度,但是新方法所生成的凸多边形要少于增量梯形法所生成的梯形,因此,新方法的空间需求要少,判断速度要快。Experiments show that compared with the current fastest method based on trapezoidal division—incremental trapezoidal method, the method of the present invention has the same complexity in various aspects such as the time of polygon preprocessing, space requirements and judgment calculations, but the new method The generated convex polygons are less than the trapezoids generated by the incremental trapezoidal method, so the new method requires less space and faster judgment speed.

Claims (7)

1.一种判断点是否位于多边形内的方法,其步骤包括:1. A method for judging whether a point is located in a polygon, the steps comprising: 1)将给定的多边形剖分为单调多边形集合;1) Divide the given polygon into a set of monotone polygons; 2)将上述单调多边形中非凸的多边形进行凸剖分,得到给定多边形的凸多边形集合;2) Carry out convex subdivision of the non-convex polygons in the above-mentioned monotone polygons to obtain a convex polygon set of given polygons; 3)以凸多边形的边形成的直线作为划分直线,基于每划分直线两侧凸多边形的个数建立平衡二叉树,其中根节点和中间结点存放各自相应的划分直线,叶节点存放相应的一凸多边形;3) The straight line formed by the sides of the convex polygon is used as the dividing line, and a balanced binary tree is established based on the number of convex polygons on both sides of each dividing line, in which the root node and the middle node store the respective corresponding dividing lines, and the leaf nodes store the corresponding convex polygons. polygon; 4)根据给定点与平衡二叉树非叶子节点存放的划分直线的位置关系对上述平衡二叉树进行搜索,直至到达一叶节点;4) According to the positional relationship between the given point and the dividing line stored in the non-leaf nodes of the balanced binary tree, the above-mentioned balanced binary tree is searched until a leaf node is reached; 5)判断给定点和上述叶节点对应的凸多边形的位置关系,如果该点位于这个凸多边形内,则该点位于给定的多边形内;否则,该点位于给定的多边形外。5) Determine the positional relationship between the given point and the convex polygon corresponding to the leaf node, if the point is inside the convex polygon, then the point is inside the given polygon; otherwise, the point is outside the given polygon. 2.如权利要求1所述的判断点是否位于多边形内的方法,其特征在于所述步骤1)为:2. the method for judging whether point is located in polygon as claimed in claim 1, is characterized in that described step 1) is: a)找到多边形的所有上凹点和下凹点;a) find all the concave points and concave points of the polygon; b)对所有上凹点和下凹点,根据它们的Y坐标值排序;b) For all the upper concave points and lower concave points, sort them according to their Y coordinate values; c)对每一个上凹点,将其与任一个Y坐标值小于它的下凹点或凸顶点连成一条边,选取其中位于该多边形内部且边长最短的一条边,将多边形进行一次剖分;同理,对每一个下凹点,将其与任一个Y坐标值大于它的上凹点或凸顶点连成一条边,选取其中位于该多边形内部且边长最短的一条边,将多边形进行一次剖分;c) For each upper concave point, connect it with any lower concave point or convex vertex whose Y coordinate value is smaller than it to form a side, select the side that is inside the polygon and has the shortest side length, and cut the polygon once In the same way, for each concave point, connect it with any upper concave point or convex vertex whose Y coordinate value is greater than it to form a side, select the side that is located in the polygon and has the shortest side length, and divide the polygon perform a split; d)重复c)的操作,上凹点和下凹点都要操作一次。d) Repeat the operation of c), the upper concave point and the lower concave point must be operated once. 3.如权利要求1或2所述的判断点是否位于多边形内的方法,其特征在于所述步骤2)为:3. the method for judging whether the point is located in the polygon as claimed in claim 1 or 2, is characterized in that described step 2) is: a)找出单调多边形中的凹点,将它们的Y坐标值由大到小进行排序;a) Find the concave points in the monotone polygon, and sort their Y coordinate values from large to small; b)按照Y坐标值由大到小的顺序依次处理凹点,将凹点与Y坐标值小于它的凹点或其它顶点进行连接,选取其中边长最短且在该单调多边形内的一条边作为该单调多边形的一次剖分;b) Process the concave points sequentially according to the order of the Y coordinate value from large to small, connect the concave point with the concave point or other vertices whose Y coordinate value is smaller than it, and select the side with the shortest side length and within the monotone polygon as the a subdivision of the monotonic polygon; c)反复进行b)的操作,直至各个剖分的多边形中都没有凹点为止。c) Repeat the operation of b) until there is no concave point in each divided polygon. 4.如权利要求1所述的判断点是否位于多边形内的方法,其特征在于计算与划分直线相交的当前凸多边形集合中的凸多边形的个数相对于集合中凸多边形个数的比例,以及位于该划分直线两侧的当前凸多边形集合中的凸多边形的个数的比例,来选定分割当前凸多边形集合的划分直线,其步骤如下:4. the method for judging whether point is located in polygon as claimed in claim 1, it is characterized in that calculating and dividing the ratio of the number of convex polygons in the current convex polygon collection intersected by straight line relative to the convex polygon number in the collection, and Positioned on the ratio of the number of convex polygons in the current convex polygon set on both sides of the dividing line to select the dividing line that divides the current convex polygon set, the steps are as follows: 1)设位于一条划分直线两侧的凸多边形集合分别为SL、SR、与该直线相交的凸多边形集合为S1,它们所包含的凸多边形个数分别为nL、nR、n;计算3个参量;纯净度 PD ( PureDegree ) = n L + n R n L + n R + n I , 平衡度 BD ( BalanceDegree ) = 1 - | n L - n R | n L + n R , 选择度SD(Selection Degree)=Min(PD,BD);1) Let the sets of convex polygons located on both sides of a dividing line be S L , S R , and the set of convex polygons intersecting the line be S 1 , and the numbers of convex polygons they contain are n L , n R , n ;Calculation of 3 parameters; purity PD ( Pure Degree ) = no L + no R no L + no R + no I , balance BD ( Balance Degree ) = 1 - | no L - no R | no L + no R , Selectivity SD (Selection Degree) = Min (PD, BD); 2)选定SD值最大的一条划分直线作为当前凸多边形集合的划分直线。2) Select a dividing line with the largest SD value as the dividing line of the current convex polygon set. 5.如权利要求4所述的判断点是否位于多边形内的方法,其特征在于:如存在多条SD值最大的划分直线,则任选一条作为当前凸多边形集合的划分直线。5. The method for judging whether a point is located in a polygon as claimed in claim 4, characterized in that: if there are multiple dividing straight lines with the maximum SD value, then choose one as the dividing straight line of the current convex polygon set. 6.如权利要求1所述的判断点是否位于多边形内的方法,其特征在于所述步骤4)为从二叉树的根结点开始,判断被检测点位于它相关的划分直线的哪一边,并以这边对应的子结点作为下一步考察的树结点,沿着树结点迭代地操作,直至达到一个叶结点。6. the method for judging whether point is located in polygon as claimed in claim 1, it is characterized in that described step 4) is for starting from the root node of binary tree, judges which side that detected point is positioned at its relevant dividing straight line, and Take the corresponding child node here as the tree node to be investigated in the next step, and iteratively operate along the tree node until a leaf node is reached. 7.如权利要求1或6所述的判断点是否位于多边形内的方法,其特征在于所述步骤5)为将该叶节点对应的凸多边形的边分成两个单调边序列;然后,根据给定点的Y坐标值形成一条平行X轴的直线,并计算该直线与这个凸多边形的两个单调边序列的两个交点的X坐标值;如果给定点的X坐标值位于这两个交点的X坐标值之间,则这该点位于该凸多边形内,也位于给定的多边形内;否则该点位于该凸多边形外,也位于给定的多边形外。7. the method for judging whether point is located in polygon as claimed in claim 1 or 6, it is characterized in that described step 5) divides the edge of the convex polygon corresponding to this leaf node into two monotone edge sequences; then, according to given The Y coordinate value of the fixed point forms a straight line parallel to the X axis, and calculates the X coordinate value of the two intersection points of the line and the two monotone edge sequences of the convex polygon; if the X coordinate value of the given point is located at the X of the two intersection points coordinate values, then the point is inside the convex polygon and inside the given polygon; otherwise, the point is outside the convex polygon and outside the given polygon.
CNB2007101215068A 2007-09-07 2007-09-07 Method for judging point whether or not situated in polygon Expired - Fee Related CN100524361C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007101215068A CN100524361C (en) 2007-09-07 2007-09-07 Method for judging point whether or not situated in polygon

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007101215068A CN100524361C (en) 2007-09-07 2007-09-07 Method for judging point whether or not situated in polygon

Publications (2)

Publication Number Publication Date
CN101114379A true CN101114379A (en) 2008-01-30
CN100524361C CN100524361C (en) 2009-08-05

Family

ID=39022708

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007101215068A Expired - Fee Related CN100524361C (en) 2007-09-07 2007-09-07 Method for judging point whether or not situated in polygon

Country Status (1)

Country Link
CN (1) CN100524361C (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100570641C (en) * 2008-03-18 2009-12-16 中国科学院软件研究所 Plant leaf analogy method based on physics
CN102495933A (en) * 2011-12-14 2012-06-13 黄桂青 Systematic auto balancing equivalent transformation method for constructive geometry binary tree structure of Boolean operation
CN102707301A (en) * 2011-03-28 2012-10-03 上海英迪信息技术有限公司 Positioning device and positioning method thereof
CN101751665B (en) * 2008-12-15 2013-02-27 富士通株式会社 Method and system for detecting whether the current pixel lies within a polygon
CN101848229B (en) * 2009-03-24 2014-06-25 北京理工大学 Method for solving minimum generated network problem in distributed network computing
CN105869188A (en) * 2016-04-22 2016-08-17 广州日滨科技发展有限公司 Detection method and system for point to polygon position relation
CN110569445A (en) * 2019-08-29 2019-12-13 湖北工业大学 A Location-Based Neighbor Detection Method in Social Networks
CN111915665A (en) * 2020-07-21 2020-11-10 中国科学院软件研究所 A method for determining points in polygons using simplified intersection calculation on computer
CN112257556A (en) * 2020-10-20 2021-01-22 国网吉林省电力有限公司电力科学研究院 A Defining Method of Electric Power Work Safety Area Based on the Judgment of Inner and Outer Points of Polygons

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100570641C (en) * 2008-03-18 2009-12-16 中国科学院软件研究所 Plant leaf analogy method based on physics
CN101751665B (en) * 2008-12-15 2013-02-27 富士通株式会社 Method and system for detecting whether the current pixel lies within a polygon
CN101848229B (en) * 2009-03-24 2014-06-25 北京理工大学 Method for solving minimum generated network problem in distributed network computing
CN102707301A (en) * 2011-03-28 2012-10-03 上海英迪信息技术有限公司 Positioning device and positioning method thereof
CN102495933A (en) * 2011-12-14 2012-06-13 黄桂青 Systematic auto balancing equivalent transformation method for constructive geometry binary tree structure of Boolean operation
CN105869188A (en) * 2016-04-22 2016-08-17 广州日滨科技发展有限公司 Detection method and system for point to polygon position relation
CN110569445A (en) * 2019-08-29 2019-12-13 湖北工业大学 A Location-Based Neighbor Detection Method in Social Networks
CN111915665A (en) * 2020-07-21 2020-11-10 中国科学院软件研究所 A method for determining points in polygons using simplified intersection calculation on computer
CN111915665B (en) * 2020-07-21 2022-05-31 中国科学院软件研究所 A method for determining points in polygons using simplified intersection calculation on computer
CN112257556A (en) * 2020-10-20 2021-01-22 国网吉林省电力有限公司电力科学研究院 A Defining Method of Electric Power Work Safety Area Based on the Judgment of Inner and Outer Points of Polygons

Also Published As

Publication number Publication date
CN100524361C (en) 2009-08-05

Similar Documents

Publication Publication Date Title
CN100524361C (en) Method for judging point whether or not situated in polygon
CN110887502B (en) Must-pass node shortest path searching method
Shi et al. Adaptive simplification of point cloud using k-means clustering
Cao et al. Parallel banding algorithm to compute exact distance transform with the GPU
US9721320B2 (en) Fully parallel in-place construction of 3D acceleration structures and bounding volume hierarchies in a graphics processing unit
Zhao et al. Mathematical morphology-based generalization of complex 3D building models incorporating semantic relationships
CN104462204B (en) A kind of method for visualizing of two classes relevance presenting levelses data
Dong et al. A fast method for fracture intersection detection in discrete fracture networks
CN103065319A (en) Closed surface automatic search method of space multiply connected domain
CN104915991B (en) A kind of space partitioning method for intersecting wire geographic element
CN101488227B (en) Circular arc fast cutting method for rectangular window
CN102799750B (en) Method for quickly generating common side and non-common sides of geometry surface triangle
CN104331883B (en) A kind of image boundary extraction method based on asymmetric inversed placement model
Joshi et al. Modification of Weiler-Atherton algorithm to address loose polygons
CN101533525A (en) Method for analyzing the overlay of point and face
Wang et al. 2D point-in-polygon test by classifying edges into layers
Wu et al. Novel parallel algorithm for constructing Delaunay triangulation based on a twofold-divide-and-conquer scheme
Arora et al. An efficient graph cut algorithm for computer vision problems
Van Der Donckt et al. Minmaxlttb: Leveraging minmax-preselection to scale lttb
CN104240232B (en) A kind of road damage inspection optimization method based on image procossing
Alis et al. Parallel processing of big point clouds using Z-Order-based partitioning
EP1468368A1 (en) Multi-variate data related presentation and analysis
Schaerf et al. On contour crossings in contour-advective simulations–part 1–algorithm for detection and quantification
CN103208000B (en) Based on the Feature Points Extraction of local extremum fast search
Wang et al. An effective algorithm for lines and polygons overlay analysis using uniform spatial grid indexing

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090805

Termination date: 20110907