CN100524361C - Method for judging point whether or not situated in polygon - Google Patents

Method for judging point whether or not situated in polygon Download PDF

Info

Publication number
CN100524361C
CN100524361C CNB2007101215068A CN200710121506A CN100524361C CN 100524361 C CN100524361 C CN 100524361C CN B2007101215068 A CNB2007101215068 A CN B2007101215068A CN 200710121506 A CN200710121506 A CN 200710121506A CN 100524361 C CN100524361 C CN 100524361C
Authority
CN
China
Prior art keywords
polygon
point
straight line
convex polygon
convex
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.)
Expired - Fee Related
Application number
CNB2007101215068A
Other languages
Chinese (zh)
Other versions
CN101114379A (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 a method of judging whether a point is in a polygon, pertaining to a computer graphic and computer geometry technical field. The invention first convexly decomposes a polygon and builds a binary tree to manage these convex polygons; then the invention investigates the built binary tree according to the coordinate position of the tested point to find the convex polygon to which a leaf node of the binary tree corresponds; finally the invention tests whether the point is in the convex polygon or not, thus judging whether the tested point is in the given polygon or not. The invention has the advantages that the calculating speed is high and the storage space is saved compared with other similar methods based on polygon convex decomposition. The invention is applied to the condition that a plurality of points are judged whether in the same polygon.

Description

Whether a kind of judging point is positioned at the method for polygon
Technical field
The invention belongs to computer graphics techniques and computational geometry technical field, relate in particular to the method whether a kind of judging point is positioned at polygon.
Background technology
Whether point is positioned at the judgement of polygon is calculated, and is a basic problem in the computational geometry, and the method for this respect has a wide range of applications in various fields such as computer graphics, pattern-recognition, Geographic Information System.The method of this respect can be divided into two classes, and a class is polygon not to be carried out pretreatedly, and a class is to carry out certain processing in advance to polygon.
In last class methods, the most frequently used is rays method, promptly sends a ray from tested measuring point, calculates the number on the polygonal limit of intersecting with it, if odd number, then this point is positioned at polygon, otherwise is positioned at outside the polygon.These class methods need be calculated polygonal every limit, and the time complexity height is O (N) (be its calculated amount how much be and the linear corresponding relation of N) that N is a polygonal limit number.
In one class methods of back, mainly be that certain tissue is carried out in polygonal limit, the zone that covered etc., make and judge that the time complexity that calculates reduces, and accelerates computing velocity.Such as famous trapezoidal subdivision method (referring to Zalik B, Jezemik A., Zalik KR.Polygon trapezoidation by sets of open trapezoids.Computers ﹠amp; Graphics 2003; 27 (5): 791-800.), with straight line through the parallel coordinate axes on summit, become some trapezoidal polygon decomposition, again according to the dullness increase of trapezoid coordinate value or the method that reduces, with trapezoidal series arrangement, judge when calculating and to utilize the binary search technology, to avoid handling a lot of limits, the time complexity of judging calculating is reduced to O (logN), and N is a polygonal limit number.
In actual applications, run into a lot of polygon of limit number through regular meeting, and the method for present existing technology, its space expense is very big, is not easy to a lot of polygon of opposite side number handle, and is subjected to the restriction of space expression ability or computing power, and judging efficiency is not high.
Summary of the invention
The purpose of this invention is to provide the method whether a kind of judging point is positioned at polygon, improve computing velocity, reduce space expense.
Whether judging point of the present invention is positioned at the method for polygon, and its step comprises:
1) with given polygon decomposition is the monotone polygon set;
2) non-protruding polygon in the above-mentioned monotone polygon is carried out protruding subdivision, obtain given polygonal convex polygon set;
3) straight line that forms with the limit of convex polygon is as dividing straight line, number equilibrium establishment binary tree based on every division straight line both sides convex polygon, wherein root node and intermediate node are deposited and are divided straight line separately accordingly, and each leaf node is deposited a corresponding convex polygon;
4) the position relation of the division straight line of depositing according to set point and the non-leaf node of balanced binary tree is searched for above-mentioned balanced binary tree, until arriving a leaf node;
5) position of the convex polygon of judgement set point and above-mentioned leaf node correspondence relation, if this point is positioned at this convex polygon, then this point is positioned at given polygon; Otherwise this point is positioned at outside the given polygon.
The present invention a kind ofly carries out pretreated method to polygon, also is based on the subdivision of polygon overlay area.Compare with existing method, the unit behind institute's subdivision is a convex polygon, and its number is lacked than the number of the unit that other subdivision method generates, and therefore, the space expense of binary tree of being set up and expression convex polygon obtains saving.
The time complexity of binary tree search is O (logN), and judges that the time complexity whether a point is positioned at a convex polygon also is O (logN), and therefore time complexity of the present invention also is O (logN).But the number that has benefited from its subdivision unit is few, and its judgement speed is faster than the method based on trapezoidal subdivision.When handling a lot of polygon of limit number, the judging efficiency whether point is positioned at polygon is significantly improved, and is applicable to variously will carry out repeatedly the method whether judging point is positioned at polygon to same polygon.
Description of drawings
The polygonal protruding subdivision application drawing of Fig. 1.
The polygonal protruding subdivision of Fig. 2 is figure as a result.
Fig. 3 is according to the balanced binary tree of protruding subdivision figure foundation as a result.
Fig. 4 judges whether certain point is positioned at the method figure of convex polygon.
Whether Fig. 5 judging point is positioned at the process flow diagram of polygon.
Embodiment
Method of the present invention mainly comprises following two stages: the phase one is that given polygon is carried out protruding subdivision, and the equilibrium establishment binary tree is managed convex polygon; Subordinate phase is the convex polygon according to balanced binary tree of being set up and generation, judges whether tested measuring point is positioned at polygon.
1. the performing step of phase one is as follows:
At first given polygon decomposition is become some monotone polygons (being that each so polygonal limit can be divided into 2 monotone edges sequences) (referring to document de Berg M, van Kreveld M, Overmars M, et al.Computational Geometry:Algorithms and Applications.2nd ed.Berlin:Springer, method in 2000), again each monotone polygon is carried out protruding subdivision.
What the present invention adopted is a kind of protruding subdivision method of not adding some points, and Fig. 1 is polygonal protruding subdivision application drawing, and its concrete steps are as follows:
1) polygon decomposition is become monotone polygon
A) find polygonal concave point and Lower pit on all; Here, if the Y coordinate figure of a concave point claims then that less than the Y coordinate figure on its two adjacent summit this concave point is last concave point; If the Y coordinate figure of a concave point claims then that greater than the Y coordinate figure on its two adjacent summit this concave point is a Lower pit;
B) to concave point on all and Lower pit, according to their Y coordinate figure ordering;
C) to concave point on each, itself and any Y coordinate figure are linked to be a limit less than its Lower pit or concave vertex, choose and wherein be positioned at this polygon and a shortest limit of the length of side, polygon is carried out subdivision one time; In like manner,, itself and any Y coordinate figure are linked to be a limit greater than its last concave point or concave vertex, choose and wherein be positioned at this polygon and a shortest limit of the length of side, polygon is carried out subdivision one time each Lower pit;
D) operation repetition c), last concave point and Lower pit all will be operated once;
2) non-protruding monotone polygon is split into convex polygon
A) find out concave point in the monotone polygon, their Y coordinate figure is sorted from big to small;
B) handle concave point successively according to the descending order of Y coordinate figure, concave point is connected with concave point or other summit of Y coordinate figure less than it, choose the subdivision of the shortest and limit in this monotone polygon of the length of side wherein as this monotone polygon; .
C) carry out b repeatedly) operation, in the polygon of each subdivision, all do not have concave point till, promptly the union of these convex polygons is exactly original polygon.Fig. 2 is polygonal protruding subdivision figure as a result.
3) set up a balanced binary tree of managing convex polygon
The set that convex-edge shape constitutes was carried out two fens iteratively, promptly the convex polygon set of being investigated is divided into 2 set at every turn, in each subclass, have only a convex polygon.In two minutes process, for these polygonal limits in the polygon set of being investigated, two ends, every limit are prolonged, form straight line with these limit conllinear, calculate the difference of the convex polygon number on every straight line both sides, and the number of the convex polygon that intersects with this straight line decides the division straight line of cutting apart this set with respect to the ratio of convex polygon number in this set.
Their concrete computing method are as follows:
A) suppose that the convex polygon set that is positioned at the straight line left side is S L, the convex polygon set that is positioned at its right side is S R, the convex polygon set of intersecting with this straight line is S I, the convex polygon number that they comprised is respectively n L, n R, n IWe calculate 3 parameters, i.e. degrees of purity PD ( PureDegree ) = n L + n R n L + n R + n I , quality of balance BD ( BalanceDegree ) = 1 - | n L - n R | n L + n R , (PD, BD), promptly that less value is the value of SD just to selectance SD (Selection Degree)=Min in these two values of PD and BD.
B) calculate its SD value for every straight line, then, the division straight line so that the maximum straight line of SD value is gathered as this convex polygon is divided into 2 subclass with this set, at this moment the convex polygon that these 2 subclass all will comprise and this division straight line intersects.
Here, the purpose of calculating PD is that will to make and divide the number of the convex polygon that straight line intersects the least possible, to reduce the number of times that convex polygon is repeated to handle, to reduce the height of tree, saves storage space and quickens to judge and calculate; The purpose of calculating BD is the both sides balance as far as possible that makes tree, to improve the speed of judging corresponding binary search when calculating.
The balanced binary tree of being set up, as shown in Figure 3, the relevant division straight line of node record between wherein setting, and a relevant convex polygon of its leafy node record.
2. the performing step of subordinate phase is as follows:
(1) according to the coordinate of tested measuring point, binary tree is carried out by the search of pushing up the end of to, that is: elder generation investigates the root node of tree, see tested measuring point is positioned at which limit that it divides straight line, then just with the child node of beyond correspondence object as next step investigation, so iteration is carried out, and until arriving leaf node, the convex polygon in this leaf node is exactly the convex polygon that will look for.
(2) for the convex polygon in the leaf node, judge whether tested measuring point is positioned at this convex polygon, at first the limit with it is divided into two monotone edges sequences, that is: find a summit of Y coordinate figure maximum in this convex polygon and a summit of Y coordinate figure minimum, should be divided into 2 parts in polygonal limit according to these two summits, each part all is the limit that is linked in sequence, and the summit Y coordinate figure on these limits is that order increases or reduces; Then, form the straight line of a paralleled by X axis according to the Y coordinate figure of tested measuring point, as shown in Figure 4, calculate the X coordinate figure of two intersection points of two monotone edges sequences of this straight line and this convex polygon, whether the X coordinate figure of more tested measuring point is between the X of two intersection points coordinate figure.If then this point is positioned at this convex polygon, just is positioned at given polygon; Otherwise, outside given polygon.
Fig. 5 is the overall flow figure whether judging point of the present invention is positioned at polygon.
Be experimental datas more of the present invention below: generate 4 polygons at random to experimentize, they all have 10000 limits, but the shared ratio of their concave point is respectively 0%, 10%, 30% and 50%.The concave point ratio is that 0% polygon is exactly a convex polygon.During test, we detect 1000 points that evenly distribute in polygonal bounding box, with their average detected time as experimental data.We have carried out the experiment contrast with new method and the fastest known cumulative at random trapezoidal method (the randomized incremental trapezoidation-basedalgorithm) in the world, during experimental data is tabulated as follows.Experiment shows that the convex polygon number that new method is used is less than the employed trapezoidal number of cumulative at random trapezoidal method, and new method all is being better than cumulative at random trapezoidal method aspect memory space requirements and the detection speed.
Figure C200710121506D00082
Experiment shows, compare with the at present the fastest method based on trapezoidal subdivision-increment trapezoidal method, method of the present invention has identical complexity in various aspects such as polygonal pretreated time, space requirement and judgement calculating, but the convex polygon that new method generated will be less than trapezoidal that the increment trapezoidal method is generated, therefore, the space requirement of new method will lack, and it is fast that judgement speed is wanted.

Claims (5)

1, whether a kind of judging point is positioned at the method for polygon, and its step comprises:
1) with given polygon decomposition is the monotone polygon set;
2) find out non-protruding polygonal concave point in the above-mentioned monotone polygon, handle concave point successively according to the order that the Y coordinate figure of concave point is descending: for a concave point, it is connected with concave point or other summit of Y coordinate figure less than it, chooses the subdivision of the shortest and limit in this monotone polygon of the length of side as this monotone polygon; Repeat aforesaid operations, in the polygon of each subdivision, all do not have concave point; Obtain the convex polygon set of monotone polygon;
3) straight line that forms with the limit of convex polygon is as dividing straight line, and based on the number equilibrium establishment binary tree of every division straight line both sides convex polygon, wherein root node and intermediate node are deposited and divided straight line separately accordingly, and leaf node is deposited a corresponding convex polygon;
4) the position relation of the division straight line of depositing according to set point and the non-leaf node of balanced binary tree is searched for above-mentioned balanced binary tree, until arriving a leaf node;
5) position of the convex polygon of judgement set point and above-mentioned leaf node correspondence relation, if this point is positioned at this convex polygon, then this point is positioned at given polygon; Otherwise this point is positioned at outside the given polygon.
2, whether judging point as claimed in claim 1 is positioned at the method for polygon, it is characterized in that described step 1) is:
A) find polygonal concave point and Lower pit on all;
B) to concave point on all and Lower pit, according to their Y coordinate figure ordering;
C) to concave point on each, itself and any Y coordinate figure are linked to be a limit less than its Lower pit or concave vertex, choose and wherein be positioned at this a polygon inside and a shortest limit of the length of side, polygon is carried out subdivision one time; In like manner,, itself and any Y coordinate figure are linked to be a limit greater than its last concave point or concave vertex, choose and wherein be positioned at this a polygon inside and a shortest limit of the length of side, polygon is carried out subdivision one time each Lower pit;
D) operation repetition c), last concave point and Lower pit all will be operated once.
3, whether judging point as claimed in claim 1 is positioned at the method for polygon, it is characterized in that calculating and dividing the ratio of the number of the convex polygon in the crossing current convex polygon set of straight line with respect to convex polygon number in the set, and the ratio of number of convex polygon that is arranged in the current convex polygon set of these division straight line both sides, come the selected division straight line of cutting apart current convex polygon set, its step is as follows:
1) is set in a convex polygon set of dividing the straight line both sides and is respectively S L, S R, the convex polygon set of intersecting with this straight line is S I, the convex polygon number that they comprised is respectively n L, n R, n ICalculate 3 parameters; Degree of purity PD ( PureDegree ) = n L + n R n L + n R + n I , Quality of balance BD ( BalanceDegree ) = 1 - | n L - n R | n L + n R , Selectance SD (Selection Degree)=Min (PD, BD);
2) a maximum division straight line of dividing straight line as current convex polygon set of selected SD value.4, whether judging point as claimed in claim 3 is positioned at the method for polygon, it is characterized in that: as have the maximum division straight line of many SD values, a then optional division straight line as current convex polygon set.
5, whether judging point as claimed in claim 1 is positioned at the method for polygon, it is characterized in that described step 4) is the root node from binary tree, judge tested measuring point is positioned at which limit of its relevant division straight line, and with the tree node of corresponding here child node as next step investigation, operate iteratively along tree node, until reaching a leaf node.
6, whether be positioned at the method for polygon as claim 1 or 5 described judging points, it is characterized in that described step 5) is divided into two monotone edges sequences for the limit with the convex polygon of this leaf node correspondence; Then, form the straight line of a paralleled by X axis, and calculate the X coordinate figure of two intersection points of two monotone edges sequences of this straight line and this convex polygon according to the Y coordinate figure of set point; If the X coordinate figure of set point is between the X of these two intersection points coordinate figure, then this this point is positioned at this convex polygon, also is positioned at given polygon; Otherwise this point is positioned at outside this convex polygon, also is positioned at 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 CN101114379A (en) 2008-01-30
CN100524361C true 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)

Families Citing this family (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
CN101751665B (en) * 2008-12-15 2013-02-27 富士通株式会社 Method and system for detecting whether current pixel is located in 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
CN105869188B (en) * 2016-04-22 2019-06-21 日立楼宇技术(广州)有限公司 The detection method and system of point-to-points side shape position relation
CN110569445B (en) * 2019-08-29 2023-06-02 湖北工业大学 Neighbor detection method in social network based on position
CN111915665B (en) * 2020-07-21 2022-05-31 中国科学院软件研究所 Method for judging points in polygon by using simplified intersection calculation on computer
CN112257556A (en) * 2020-10-20 2021-01-22 国网吉林省电力有限公司电力科学研究院 Electric power operation safety region defining method based on polygon inside and outside point judgment

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
approximate convex decomposition of polygons. Jyh-Ming Lien etc.computational geometry: theory and applications,Vol.35 No.1. 2006
approximate convex decomposition of polygons. Jyh-Ming Lien etc.computational geometry: theory and applications,Vol.35 No.1. 2006 *
基于凸剖分的点在多边形内的高效判定. 李静,王文成,吴恩华.自然科学进展,第17卷第7期. 2007
基于凸剖分的点在多边形内的高效判定. 李静,王文成,吴恩华.自然科学进展,第17卷第7期. 2007 *
简单多边形剖分为凸多边形的一个算法. 张英慧.燕山大学学报,第23卷第4期. 1999
简单多边形剖分为凸多边形的一个算法. 张英慧.燕山大学学报,第23卷第4期. 1999 *

Also Published As

Publication number Publication date
CN101114379A (en) 2008-01-30

Similar Documents

Publication Publication Date Title
CN100524361C (en) Method for judging point whether or not situated in polygon
Kizilateş et al. On the nearest neighbor algorithms for the traveling salesman problem
EP2783314B1 (en) Massive model visualization in pdm systems with spatial indexing
Park et al. Unstructured grid adaptation: status, potential impacts, and recommended investments towards CFD 2030
Veloso et al. Reachability Queries in Very Large Graphs: A Fast Refined Online Search Approach.
CN102915347B (en) A kind of distributed traffic clustering method and system
CN106295250A (en) Method and device is analyzed in the quick comparison of the short sequence of secondary order-checking
Clift Calculating optimal addition chains
JP2008186440A (en) Topology evolution optimization computing method for structural design
Hryniów et al. Parallel digraphs-building algorithm for polynomial realisations
Martinez et al. A simple algorithm for Boolean operations on polygons
Baram et al. Exact Minkowski sums of polygons with holes
Yanagisawa A multi-source label-correcting algorithm for the all-pairs shortest paths problem
Wang et al. 2D point-in-polygon test by classifying edges into layers
Diao et al. Generating equilateral random polygons in confinement II
US10706049B2 (en) Method and apparatus for querying nondeterministic graph
Schaerf et al. On contour crossings in contour-advective simulations–part 1–algorithm for detection and quantification
Muir Pseudoflow, new life for Lerchs-Grossmann pit optimisation
Bender et al. Continuous collision detection between points and signed distance fields
Maravilha et al. A new algorithm based on differential evolution for combinatorial optimization
JP5429164B2 (en) Finite automaton generation system
Piotrowski et al. Enhanced interactive parallel coordinates using machine learning and uncertainty propagation for engineering design
Ohrhallinger et al. Interpolating an unorganized 2d point cloud with a single closed shape
US11302075B1 (en) Medial surface construction for solid models using tetrahedral meshes
Lee Multi-resolution modelling for feature-based solid models using the effective volumes of features

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