Method, device and equipment for quickly solving intersection points of massive line segments and medium

By performing two-dimensional cross-sectional meshing processing on massive line segments, quickly positioning and obtaining line segment intersection points, the problems of high complexity and low computing efficiency in the existing technology are solved, and efficient line segment intersection points are achieved.

CN119625221AInactive Publication Date: 2025-03-14SOUTHWEST PETROLEUM UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510150131.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-11
Publication Date
2025-03-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When the prior art finds the intersection points of massive line segments, the complexity and low calculation efficiency lead to excessive redundant calculations.

Method used

By constructing a two-dimensional profile and meshing it, find the subgrids passing through each line segment, mark the subgrids passing through each line segment, determine the pair of line segments with intersection points, and solve the intersection points.

Benefits of technology

The calculation efficiency of obtaining massive line segment intersection points is greatly improved, redundant calculations in traditional algorithms are avoided, and the calculation time is significantly reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119625221A_ABST
    Figure CN119625221A_ABST
Patent Text Reader

Abstract

The invention relates to the problem of solving line segment intersection points in the field of image processing, and discloses a method, a device, equipment and a medium for rapidly solving massive line segment intersection points, and the method comprises the steps: constructing a two-dimensional profile according to the distribution range of endpoint coordinates of a plurality of line segments; meshing the two-dimensional section to obtain a plurality of sub-grids; searching for sub-grids passed by each line segment, and marking the sub-grids passed by each line segment to obtain a plurality of effective sub-grids; determining line segment pairs with intersection points based on the effective sub-grids; and solving the intersection points of the line segment pairs with the intersection points to obtain the coordinates of the intersection points. According to the method, the line segment intersection points are rapidly positioned and solved through mesh generation, a large amount of redundant calculation of a traditional algorithm can be avoided, and the solving calculation efficiency of the mass line segment intersection points can be greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the problem of obtaining line segment intersection points in the field of image processing, and in particular to a method, device, equipment and medium for quickly obtaining massive line segment intersection points. Background Art

[0002] The most common method for finding the intersection of line segments is the scanning algorithm, of which the most typical and easiest to implement is the overall scanning method. This method scans and judges each pair of line segments in turn, first testing whether the pair of line segments intersects, and if so, finding and recording the corresponding intersection points. However, in practical applications, since the number of intersection points of line segments is often much smaller than the number of pairs of test line segments, the overall scanning method requires a lot of redundant calculations, which is not suitable for data with high precision. n Line segments and k The time complexity of finding the intersection of line segments with intersection points is Therefore, the complexity of the collation scanning method is relatively high.

[0003] The scanning line algorithm is also a widely used method for finding line segment intersections. Its basic idea is to split the line segment in two-dimensional space into multiple horizontal line segments, and then find the intersection of each scanning line with the line segment by traversing the scanning line. By combining data structure algorithms such as linked lists and binary trees, this method can avoid a large number of invalid intersection tests in the overall scanning method, and can effectively improve the computational efficiency of the line segment intersection problem. n Line segments and k The time complexity of finding the intersection of line segments with intersection points is .

[0004] Although the scan line algorithm is relatively efficient, its computational efficiency is still low in some special application scenarios. Summary of the invention

[0005] The purpose of the present invention is to provide a method, device, equipment and medium for quickly obtaining the intersection points of massive line segments. The existing method for obtaining the intersection points of line segments has the problems of high complexity and low calculation efficiency.

[0006] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: In a first aspect, the present invention provides a method for quickly finding intersections of massive line segments, the method comprising: Construct a two-dimensional profile according to the distribution range of the endpoint coordinates of several line segments; Meshing the two-dimensional section to obtain several sub-grids; Find the subgrids that each line segment passes through, and mark the subgrids that each line segment passes through to obtain several valid subgrids; determining line segment pairs having intersection points based on the valid sub-grids; Solve the intersection of line segments with intersection points to obtain the intersection coordinates.

[0007] Preferably, determining the line segment pairs having intersection points based on the valid sub-grids includes: Construct the attribute list of each valid sub-grid; Inserting the line segment information of each line segment into the corresponding attribute linked list of the valid sub-grid, wherein the attribute linked list has at least one node, and at least one node in a valid sub-grid is used to represent that there is at least one line segment passing through the valid sub-grid; Count the number of nodes in each valid sub-grid, and mark the valid sub-grids with more than or equal to two nodes as the grids to be determined for intersection; Determine whether each line segment in the grid to be determined has an intersection. If so, mark the corresponding line segment as a line segment pair with an intersection.

[0008] Preferably, the relationship between any valid sub-mesh and a line segment in the valid sub-mesh includes: the line segment intersects at least two edges of the valid sub-mesh, the line segment coincides with any edge of the valid sub-mesh, or the line segment intersects with any corner vertex of the valid sub-mesh.

[0009] Preferably, the types of the line segments include: straight line segments, broken line segments, curved line segments and / or a combination of straight line segments, broken line segments and curved line segments.

[0010] Preferably, constructing a two-dimensional profile according to the distribution range of the endpoint coordinates of a plurality of line segments includes: Extract the maximum value of the horizontal coordinate, the minimum value of the horizontal coordinate, the maximum value of the vertical coordinate and the minimum value of the vertical coordinate from the coordinates of the endpoints of several line segments; Determine the boundaries of the distribution range of the endpoint coordinates of the plurality of line segments based on the maximum value of the abscissa, the minimum value of the abscissa, the maximum value of the ordinate, and the minimum value of the ordinate; A two-dimensional profile is constructed according to the boundaries of the distribution range of the endpoint coordinates of several line segments.

[0011] Preferably, the two-dimensional cross section is meshed to obtain a plurality of sub-grids, including: Construct horizontal sampling interval and vertical sampling interval; Based on the horizontal sampling interval and the vertical sampling interval, the two-dimensional profile is gridded to obtain a number of sub-grids.

[0012] Preferably, the sub-grid is a rectangular sub-grid or a square sub-grid.

[0013] In a second aspect, the present invention provides a device for quickly obtaining a large number of line segments, which is used to implement the above-mentioned method for quickly obtaining intersection points of a large number of line segments, and the device comprises: A profile construction module, used to construct a two-dimensional profile according to the distribution range of the endpoint coordinates of a number of line segments; A meshing module is used to mesh the two-dimensional section to obtain several sub-grids; A grid search module is used to search for the subgrids that each line segment passes through, and mark the subgrids that each line segment passes through to obtain several valid subgrids; An intersection determination module, used for determining line segment pairs with intersection points based on valid sub-grids; The intersection solving module is used to solve the intersection of line segment pairs with intersection points to obtain the intersection coordinates.

[0014] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for quickly obtaining intersection points of massive line segments when executing the computer program.

[0015] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned method for quickly obtaining intersection points of a large number of line segments.

[0016] The beneficial effects of the present invention are mainly embodied in: The present invention quickly locates and obtains line segment intersections through grid generation, which can avoid a large number of redundant calculations in traditional algorithms and can greatly improve the calculation efficiency of obtaining massive line segment intersections. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings: Figure 1 It is a flow chart of a method for quickly obtaining intersection points of massive line segments provided by an embodiment of the present invention; Figure 2 is a two-dimensional rectangular cross-sectional schematic diagram of the present invention; Figure 3 It is a schematic diagram of mesh division of a two-dimensional rectangular section of the present invention; Figure 4 is a schematic diagram of effective subgrids in a two-dimensional rectangular section of the present invention; Figure 5 is a schematic diagram of line segment pairs with intersection points within a valid sub-grid in a two-dimensional rectangular cross section of the present invention; Figure 6 is a schematic diagram of the intersection coordinates of all line segments in the two-dimensional rectangular section of the present invention; Figure 7It is a block diagram of a device for quickly obtaining intersection points of massive line segments provided by one embodiment of the present invention; Figure 8 It is a schematic diagram of a complex line segment model of the present invention; Fig. 9 It is a schematic diagram of line segment intersection points in a local area obtained by using the method for quickly obtaining massive line segment intersection points of the present invention; Fig.10 It is a schematic diagram of the intersection points of line segments in the same local area obtained by the traditional scanning line algorithm. DETAILED DESCRIPTION

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in combination with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the structure of the drawings is only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention.

[0019] Embodiment 1 Figure 1 FIG. 1 is a flow chart of a method for quickly finding intersections of massive line segments provided by an embodiment of the present invention. Figure 1 As shown, this embodiment provides a method for quickly finding intersections of massive line segments, the method comprising: Step S10: construct a two-dimensional profile according to the distribution range of the endpoint coordinates of a plurality of line segments.

[0020] In this embodiment, a two-dimensional profile is constructed according to the distribution range of the endpoint coordinates of a plurality of line segments, including: Step S101: extracting the maximum value of the abscissa, the minimum value of the abscissa, the maximum value of the ordinate and the minimum value of the ordinate from the coordinates of the endpoints of a number of line segments; Step S102: determining the boundaries of the distribution range of the endpoint coordinates of a plurality of line segments based on the maximum value of the abscissa, the minimum value of the abscissa, the maximum value of the ordinate, and the minimum value of the ordinate; Step S103: constructing a two-dimensional profile according to the boundaries of the distribution range of the endpoint coordinates of the plurality of line segments.

[0021] In this embodiment, each line segment has two endpoints, and the two endpoints of each line segment have a coordinate in the coordinate system. By extracting the coordinates of the two endpoints of all the line segments, the maximum value of the horizontal coordinate, the minimum value of the horizontal coordinate, the maximum value of the vertical coordinate, and the minimum value of the vertical coordinate can be extracted; according to the maximum value of the horizontal coordinate, the minimum value of the horizontal coordinate, the maximum value of the vertical coordinate, and the minimum value of the vertical coordinate, the boundaries of the distribution range of the endpoint coordinates of several line segments can be determined, and the boundaries of the distribution range of the endpoint coordinates of several line segments can be directly used as the boundaries of the two-dimensional section, or the boundaries of the two-dimensional section can be slightly larger than the boundaries of the distribution range of the endpoint coordinates of several line segments, so as to ensure that all line segments are located in the two-dimensional section, such as Figure 2 shown.

[0022] Step S20: gridding the two-dimensional section to obtain a plurality of sub-grids.

[0023] In this embodiment, the two-dimensional cross section is meshed to obtain several sub-grids, including: Step S201: constructing a horizontal sampling interval and a vertical sampling interval; Step S202: Based on the horizontal sampling interval and the vertical sampling interval, the two-dimensional profile is gridded to obtain a plurality of sub-grids.

[0024] The horizontal sampling interval and the vertical sampling interval can be flexibly selected according to the user's design requirements; the shapes of the multiple sub-grids obtained in step S202 can be rectangular or square. In the same two-dimensional section, the shapes of the multiple sub-grids are the same, all rectangular or square. The two-dimensional section after gridding, such as Figure 3 shown.

[0025] Step S30: Find the subgrids that each line segment passes through, and mark the subgrids that each line segment passes through to obtain several valid subgrids, such as Figure 4 shown.

[0026] In this embodiment, the types of line segments include: straight line segments, broken line segments, curved line segments and / or a combination of straight line segments, broken line segments and curved line segments, that is, there are multiple types of line segments in the two-dimensional section, and there are different intersection relationships between these line segments and sub-grids. That is, the relationship between any valid sub-grid and the line segments in the valid sub-grid includes: the line segment intersects with at least two sides of the valid sub-grid, the line segment coincides with any side of the valid sub-grid, or the line segment intersects with any corner vertex of the valid sub-grid.

[0027] Step S40: determining line segment pairs having intersection points based on the valid sub-grids.

[0028] In this embodiment, determining line segment pairs having intersection points based on valid sub-grids includes: Step S401: construct an attribute list of each valid sub-grid; Step S402: inserting the line segment information of each line segment into the corresponding attribute linked list of the valid sub-grid, wherein the attribute linked list has at least one node, and at least one node in a valid sub-grid is used to represent that there is at least one line segment passing through the valid sub-grid; Step S403: Count the number of nodes in each valid sub-grid, and mark the valid sub-grid with the number of nodes greater than or equal to two nodes as the grid to be determined for intersection; Step S404: determine whether each line segment in the grid of intersection points to be determined has an intersection, and if so, mark the corresponding line segment as a line segment pair with an intersection point.

[0029] In this embodiment, as long as there are two or more nodes in a valid sub-grid, it means that there may be intersecting line segments in the valid grid, or there may not be intersecting line segments; for example, when two straight line segments are parallel, although they pass through a grid at the same time, there is no intersection between the two lines in the grid; or when there are two curved line segments, although they pass through a grid at the same time, there is no intersection. For another example: two curved line segments or curved line segments may have at least two intersections in a grid.

[0030] Therefore, as long as two line segments have an intersection in a valid sub-grid, the two line segments are marked as a line segment pair with an intersection, such as Figure 5 shown.

[0031] Step S50: solving the intersection of the line segment pairs with intersection points to obtain the intersection coordinates.

[0032] In this embodiment, by solving the intersection of line segment pairs with intersection points, the line segment pairs have at least one intersection coordinate in a valid sub-grid, and the intersection coordinates are saved to obtain all the intersection coordinates, such as Figure 6 shown.

[0033] The present invention quickly locates and obtains line segment intersections through grid generation, which can avoid a large number of redundant calculations in traditional algorithms and can greatly improve the calculation efficiency of obtaining massive line segment intersections.

[0034] Embodiment 2 Figure 7 A device for quickly finding the intersection of a large number of line segments is provided in one embodiment of the present invention. Figure 7 As shown, this embodiment provides a device for quickly finding the intersection points of a large number of line segments, and the device is used to implement the method for quickly finding the intersection points of a large number of line segments in the first embodiment. The device includes: A profile construction module, used to construct a two-dimensional profile according to the distribution range of the endpoint coordinates of a number of line segments; A meshing module is used to mesh the two-dimensional section to obtain several sub-grids; A grid search module is used to search for the subgrids that each line segment passes through, and mark the subgrids that each line segment passes through to obtain several valid subgrids; An intersection determination module, used for determining line segment pairs with intersection points based on valid sub-grids; The intersection solving module is used to solve the intersection of line segment pairs with intersection points to obtain the intersection coordinates.

[0035] This embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for quickly obtaining intersections of a large number of line segments when executing the computer program.

[0036] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for quickly obtaining intersection points of a large number of line segments is implemented.

[0037] The present invention quickly locates and obtains line segment intersections through grid generation, which can avoid a large number of redundant calculations in traditional algorithms and can greatly improve the calculation efficiency of obtaining massive line segment intersections.

[0038] Embodiment 3 A complex line segment model is used to verify the application effect of the method for quickly obtaining the intersection points of a large number of line segments in the first embodiment. Figure 8 As shown, there are 4000 line segments in total. Fig. 9 The line segment intersection points (red points) of the local area obtained by using the first embodiment are shown. Fig.10 The same local area line segment intersection points (green points) obtained by the traditional scanning line algorithm are shown. It can be seen that both algorithms accurately obtain the intersection points of the complex line segment model, but there is a significant difference in the calculation time of the two algorithms. The calculation time of the traditional scanning line algorithm is 3.3s, and the calculation time of the present invention is 0.6s, which is within 20% of the traditional algorithm. Therefore, the present invention can effectively improve the calculation efficiency of the line segment intersection obtaining process.

[0039] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0040] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0041] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for quickly finding the intersection of massive line segments, characterized in that: The method comprises: Construct a two-dimensional profile according to the distribution range of the endpoint coordinates of several line segments; Meshing the two-dimensional section to obtain several sub-grids; Find the subgrids that each line segment passes through, and mark the subgrids that each line segment passes through to obtain several valid subgrids; determining line segment pairs having intersection points based on the valid sub-grids; Solve the intersection of line segments with intersection points to obtain the intersection coordinates.

2. The method for quickly obtaining intersection points of massive line segments according to claim 1, characterized in that: Determine line segment pairs with intersection points based on valid sub-meshes, including: Construct the attribute list of each valid sub-grid; Inserting the line segment information of each line segment into the corresponding attribute linked list of the valid sub-grid, wherein the attribute linked list has at least one node, and at least one node in a valid sub-grid is used to represent that there is at least one line segment passing through the valid sub-grid; Count the number of nodes in each valid sub-grid, and mark the valid sub-grids with more than or equal to two nodes as the grids to be determined for intersection; Determine whether each line segment in the grid to be determined has an intersection. If so, mark the corresponding line segment as a line segment pair with an intersection.

3. The method for quickly obtaining intersection points of massive line segments according to claim 1 or 2, characterized in that: The relationship between any valid sub-mesh and the line segment in the valid sub-mesh includes: the line segment intersects with at least two edges of the valid sub-mesh, the line segment coincides with any edge of the valid sub-mesh, or the line segment intersects with any corner vertex of the valid sub-mesh.

4. The method for quickly obtaining intersection points of massive line segments according to claim 3, characterized in that: The types of the line segments include: straight line segments, broken line segments, curved line segments and / or a combination of straight line segments, broken line segments and curved line segments.

5. The method for quickly obtaining intersection points of massive line segments according to claim 1, characterized in that: Construct a two-dimensional profile based on the coordinate distribution range of the endpoints of several line segments, including: Extract the maximum value of the horizontal coordinate, the minimum value of the horizontal coordinate, the maximum value of the vertical coordinate and the minimum value of the vertical coordinate from the coordinates of the endpoints of several line segments; Determine the boundaries of the distribution range of the endpoint coordinates of the plurality of line segments based on the maximum value of the abscissa, the minimum value of the abscissa, the maximum value of the ordinate, and the minimum value of the ordinate; A two-dimensional profile is constructed according to the boundaries of the distribution range of the endpoint coordinates of several line segments.

6. The method for quickly obtaining intersection points of massive line segments according to claim 1 or 5, characterized in that: The two-dimensional section is meshed to obtain several sub-grids, including: Construct horizontal sampling interval and vertical sampling interval; Based on the horizontal sampling interval and the vertical sampling interval, the two-dimensional profile is gridded to obtain a number of sub-grids.

7. The method for quickly obtaining intersection points of massive line segments according to claim 1, characterized in that: The sub-grid is a rectangular sub-grid or a square sub-grid.

8. A device for quickly obtaining a large number of line segments, used to implement the method for quickly obtaining a large number of line segment intersections according to any one of claims 1 to 7, characterized in that: The device comprises: A profile construction module, used to construct a two-dimensional profile according to the distribution range of the endpoint coordinates of a number of line segments; A meshing module is used to mesh the two-dimensional section to obtain several sub-grids; A grid search module is used to search for the subgrids that each line segment passes through, and mark the subgrids that each line segment passes through to obtain several valid subgrids; An intersection determination module, used for determining line segment pairs with intersection points based on valid sub-grids; The intersection solving module is used to solve the intersection of line segment pairs with intersection points to obtain the intersection coordinates.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for quickly obtaining intersection points of a large number of line segments according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for quickly obtaining intersection points of a large number of line segments described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method for converting slope three-dimensional geologic model into two-dimensional calculation slope surface

    CN111553008A

  • Method for extracting spatial information of intersection equipment of railway yard

    CN116502318A

  • Calculation method of two-dimensional measuring line intersection point and related product

    CN119065004A

  • Mesh division method, finite element analysis device and computer program

    JP2007065802A