A method for quickly selecting a polygon when clicking on the polygon intersection area

CN117289848BActive Publication Date: 2026-10-27LONG MA HU LIAN (FU JIAN) KE JI YOU XIAN GONG SI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311305660.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-10
Publication Date
2026-10-27
Estimated Expiration
2043-10-10

AI Technical Summary

Technical Problem

求2个多边形相交的多边形虽然有很多算法,但是当多边形为任意凸凹多边形时,计算量也是比较大的

Benefits of technology

[0019]本发明采用以上技术方案,相比使用矩形替代多边形,本发明更准确、不存在幻点现象。 相比接求出2个多边形相交的部分,本发明计算量更小,更快速,并且支持任意凸、凹多边形,甚至是交叉多边形。多边形顶点顺序无要求,顺时针、逆时针或2种顺序混合均可。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117289848B_ABST
    Figure CN117289848B_ABST
Patent Text Reader

Abstract

The application discloses a method for quickly selecting a polygon when a click polygon intersection area is clicked, wherein each polygon is represented by a vertex array, each vertex has two coordinate values of x and y; the areas of all polygons are calculated and stored in a polygon area array; the coordinates of the clicked point are obtained, and a mature point inside-outside judgment algorithm is selected to find all polygons containing the clicked point; if no polygon is found, no polygon is selected; if only one polygon is found, only the polygon is selected; if more than two polygons are found, the areas of all found polygons are found from the polygon area array, and the polygon with the smallest area is selected as the selected polygon. The application has smaller calculation amount, is faster, and supports any convex, concave polygon, and even intersecting polygon.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method for quickly selecting polygons when clicking on the intersecting region of polygons. Background Technology

[0002] In the operation of electronic devices, it is often necessary to click and select images. For example, in games, in order to enable player interaction, players usually need to click and select images on the game interface with a mouse or finger. From there, players can drag, delete, and perform other operations on the selected images.

[0003] Current image selection methods use the smallest bounding rectangle of the image as the criterion. When the clicked location falls within the smallest bounding rectangle, the image is considered selected. However, because rectangles are used to replace polygons, this method is inherently inaccurate and prone to phantom point phenomena: a point that is not actually inside a polygon may be within the replaced rectangle, leading to false positives. The main drawback of existing image selection methods is that the judgment range is too broad.

[0004] Another solution is to directly calculate the intersection of the two polygons, thus determining the ratio of their areas. This ratio indicates whether they are contained within each other or intersecting. While this method can resolve phantom point phenomena, polygon intersection algorithms are inherently complex and computationally intensive. Furthermore, some algorithms only support convex polygons, while others only support convex and concave polygons, not intersecting polygons. Intersecting polygons need to be decomposed into multiple non-intersecting polygons before processing.

[0005] It can be seen that when the selected area is located in the overlapping or intersecting area of ​​multiple polygonal patterns, the existing judgment criteria are generally as follows: (1) In the case of inclusion relationship, the innermost polygon is selected as the selected polygon. 2. In the case of intersection relationship, the polygon with the largest ratio of the area of ​​the intersection part to the area of ​​the polygon is selected as the selected polygon.

[0006] However, directly applying the two rules above would be extremely complex. First, it requires determining whether the relationship is one of inclusion or intersection; second, it requires calculating the intersecting parts of the polygons. While there are many algorithms for finding the intersecting polygons of two polygons, the computational load is still quite large when the polygons are arbitrarily convex or concave. Summary of the Invention

[0007] The purpose of this invention is to provide a method for quickly selecting polygons when clicking on the intersection area of ​​polygons.

[0008] The technical solution adopted in this invention is:

[0009] A method for quickly selecting polygons when clicking on the intersection area of ​​polygons, comprising the following steps:

[0010] Step 1: Represent each polygon using a vertex array, where each vertex has two coordinate values, x and y. This is the standard method for representing polygons.

[0011] Step 2: Calculate the area of ​​all polygons and store it in a polygon area array.

[0012] Step 3: Obtain the coordinates of the current click point, and select an existing mature point to use an algorithm to find all polygons that contain the click point inside the polygon.

[0013] Step 4: Determine if a polygon containing the clicked point is found; if so, proceed to Step 5; otherwise, determine that no polygon is selected and end the selection process.

[0014] Step 5: Determine if the polygon containing the clicked point is unique; if so, select the unique polygon; otherwise, proceed to step 6.

[0015] Step 6: Read the polygon area array and find the area of ​​all polygons containing the clicked point. Select the polygon with the smallest area as the selected polygon.

[0016] Furthermore, the polygon vertex array represents a sorted order in clockwise or counterclockwise order, or a mixed sort of clockwise and counterclockwise order.

[0017] Furthermore, polygons can be convex, concave, or even intersecting polygons.

[0018] Furthermore, the algorithms for determining whether a point is inside or outside the polygon in step 3 include the ray method and the wrap-around number algorithm.

[0019] This invention employs the above technical solution. Compared to using rectangles to replace polygons, this invention is more accurate and eliminates phantom point phenomena. Compared to directly calculating the intersection of two polygons, this invention requires less computation, is faster, and supports arbitrary convex and concave polygons, even intersecting polygons. The order of polygon vertices is not required; clockwise, counterclockwise, or a mixture of both orders are acceptable. Attached Figure Description

[0020] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments;

[0021] Figure 1 This is a schematic diagram showing the relative positions of multiple polygons. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0023] When the mouse click point falls within multiple polygons, how can you quickly select the most suitable polygon as the selected polygon? For example... Figure 1 As shown, parts 1, 2, 3, and 4 are the intersecting parts of the polygons, while parts 5, 6, and 7 are the non-intersecting parts. When the user clicks on parts 5, 6, and 7, the polygons that should be selected are undoubtedly polygon 3, polygon 4, and polygon 5, respectively.

[0024] Polygon 1 is completely inside polygon 4. Therefore, when the user clicks 1, polygon 1 must be selected; otherwise, there are no other points to select it. Similarly, when the user clicks 3, polygon 2 must be selected. While clicking 2 or 4 doesn't guarantee the selected polygon, it allows us to deduce which polygon is most likely to be chosen. Since polygon 2 has the largest ratio of its area (intersecting part 2) to its total area, it's the most likely polygon to be selected. Likewise, polygon 3 has the largest ratio of its area (intersecting part 4) to its total area, making it the most likely polygon to be selected.

[0025] In fact, when carefully observing the selection criteria for polygons, it is not necessary to determine whether the polygons are contained or intersecting, nor is it necessary to calculate the intersecting parts of the polygons. You only need to select them according to the following rules: calculate the area of ​​the polygons and select the polygon with the smaller area as the selected polygon.

[0026] When the relationship is one of inclusion, the innermost polygon obviously has the smallest area. When the relationship is one of intersection, the area of ​​the intersection is fixed, that is, the numerator remains the same, and what changes is the area of ​​the denominator polygon. The smaller the area of ​​the denominator polygon, the larger the ratio will be.

[0027] like Figure 1 As shown, this invention discloses a method for quickly selecting polygons when clicking on the intersection area of ​​polygons, which includes the following steps:

[0028] Step 1: Represent each polygon using a vertex array, where each vertex has two coordinate values, x and y. This is the standard method for representing polygons.

[0029] Furthermore, the polygon vertex array represents a sorted order in clockwise or counterclockwise order, or a mixed sort of clockwise and counterclockwise order.

[0030] Specifically, there are no requirements for the order of the polygon vertices; clockwise, counterclockwise, or a combination of both are acceptable.

[0031] Step 2: Calculate the area of ​​all polygons and store it in a polygon area array.

[0032] Step 3: Obtain the coordinates of the current click point, and select an existing mature point to use an algorithm to find all polygons that contain the click point inside the polygon.

[0033] Step 4: Determine if a polygon containing the clicked point is found; if so, proceed to Step 5; otherwise, determine that no polygon is selected and end the selection process.

[0034] Step 5: Determine if the polygon containing the clicked point is unique; if so, select the unique polygon; otherwise, proceed to step 6.

[0035] Step 6: Read the polygon area array and find the area of ​​all polygons containing the clicked point. Select the polygon with the smallest area as the selected polygon.

[0036] Furthermore, it supports arbitrary convex and concave polygons, and even intersecting polygons.

[0037] Furthermore, the algorithms for determining whether a point is inside or outside the polygon in step 3 include the ray method and the wrap-around number algorithm.

[0038] This invention employs the above technical solution. Compared to using rectangles to replace polygons, this invention is more accurate and eliminates phantom point phenomena. Compared to directly calculating the intersection of two polygons, this invention requires less computation, is faster, and supports arbitrary convex and concave polygons, even intersecting polygons. The order of polygon vertices is not required; clockwise, counterclockwise, or a mixture of both orders are acceptable.

[0039] Obviously, the described embodiments are only a part of the embodiments of this application, not all of them. Without conflict, the embodiments and features in the embodiments of this application can be combined with each other. The components of the embodiments of this application described and illustrated herein can generally be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of this application is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

Claims

1. A method for quickly selecting polygons when clicking on the intersection area of ​​polygons, characterized in that: It includes the following steps: Step 1: Represent each polygon using a vertex array, with each vertex having two coordinate values, x and y. Step 2: Calculate the area of ​​all polygons and store them in a polygon area array; Step 3: Obtain the coordinates of the current click point, and select an existing mature point to use an algorithm to find all polygons that contain the click point inside the polygon. Step 4: Determine if a polygon containing the clicked point has been found. If yes, proceed to step 5; otherwise, determine that no polygon is selected and end the selection process. Step 5: Determine if the polygon containing the clicked point is unique. If so, then the corresponding unique polygon is selected; Otherwise, proceed to step 6; Step 6: Read the polygon area array and find the area of ​​all polygons containing the clicked point. Select the polygon with the smallest area as the selected polygon.

2. The method for quickly selecting polygons when clicking on the intersection area of ​​polygons according to claim 1, characterized in that: The polygon vertex array represents a sorted array that is clockwise or counterclockwise, or a mixed sort of clockwise and counterclockwise.

3. The method for quickly selecting polygons when clicking on the intersection area of ​​polygons according to claim 1, characterized in that: Polygons can be convex, concave, or intersecting.

4. The method for quickly selecting polygons when clicking on the intersection area of ​​polygons according to claim 1, characterized in that: The algorithms for determining whether a point is inside or outside the polygon in step 3 include the ray method and the wrap-around number algorithm.

Citation Information

Patent Citations

  • Method for quickly superposing polygon vector layers

    CN101923552A

  • Clicked object amplifying method and device based on floating touch

    CN103677568A