Method for performing Douglas smoothing processing on closed curve by removing redundant collinear points
By calculating the distance between the node and the vector angle between the furthest node and the node, the redundant collinear points in the closed curve are removed, and the fit failure problem caused by redundant collinear points in Douglas smoothing method is solved, and the success rate of smooth fitting is improved and the efficiency of numerical simulation.
Patent Information
- Application Number
- CN202411371990.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-09-29
AI Technical Summary
In Douglas smoothing method, redundant collinear control points lead to failure of closed curve smooth fitting, how to effectively remove redundant collinear points to improve the success rate of smooth fit and the efficiency of numerical simulation.
By calculating the distance between the node and the furthest node, and determining whether the angle between the vector formed by the node and the front and rear nodes exceeds a small angle, accurately delete the redundant collinear control points in the closed curve, iterate and recurse until the smoothing accuracy threshold is reached.
The success rate of Douglas method for smooth fitting of the closed curve is improved, the efficiency and accuracy of numerical simulation are improved, and the influence of unnecessary control points is reduced.
Smart Images

Figure CN119180181A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of grid generation, and in particular relates to a method for performing Douglas smoothing processing on a closed curve by removing redundant collinear points. Background Art
[0002] Meshing is the first step in numerical simulation calculations. Its purpose is to divide the three-dimensional model into sections so that the control equations can be solved using the finite difference method or the finite element method.
[0003] In the original Douglas smoothing method, it is necessary to find the two points with the longest distance in the curve point series and connect them, and then find the point with the longest distance from other points in the point series to the connecting line as the control point to describe the trend characteristics of the curve. However, when the connecting line is parallel to a part of the original curve, there will be multiple points with the same distance. The Douglas algorithm cannot decide which point to use as the control point, which will cause the Douglas algorithm to fail. Therefore, in the process of using the Douglas method to smoothly fit closed curves, the problem of redundant control points is a key difficulty. How to eliminate the influence of redundant collinear control points on the Douglas method is a major difficulty in the engineering field. Summary of the invention
[0004] The object of the present invention is to provide a method for Douglas smoothing a closed curve by removing redundant collinear points, so as to remove the influence of collinear points on a closed curve with redundant collinear control points, thereby effectively completing the smooth fitting of the curve within a limited number of control points.
[0005] In order to achieve the above object, the present invention adopts the following scheme: A method for performing Douglas smoothing on a closed curve by removing redundant collinear points comprises the following steps: S1: For the selected closed curve l 0, obtain the information of all nodes on the closed curve through the built-in function, and form an ordered list list1, including the coordinates of the serial number of each node.
[0006] S2: Traverse the node list and find the two points on the curve that are farthest apart. Take the one closest to the origin as the starting point, and reorder all the sorted nodes of the curve in reverse time to form a new ordered list list2. The two points on the curve that are farthest apart are recorded as the starting point P1 and the key point Pk, where k is a positive integer and k∈[3,n], and Pn is the end point of the curve after reordering.
[0007] Create an empty list to store the filtered nodes, record it as the serial number list List3, and store the starting point P1 and the key point Pk in the list List3.
[0008] S3: Connect the two farthest nodes P1 and Pk on the curve to form a line segment L 1, then the line segment L 1. Divide the closed curve into two parts, recorded as subcurves l 11和 l 12 The nodes on these two parts each correspond to a subsequence list, recorded as ordered list list21 and ordered list list22.
[0009] S4: traverse the other nodes in sublist list21 and sublist list22 except the starting point P1 and the key point Pk, and obtain the nodes in sublist list21 that are away from the line segment L 1 The farthest node Pi1 and the corresponding farthest distance Lmax1, get the distance from the line segment in the sublist list22 L 1The farthest node Pi2 and the corresponding farthest distance Lmax2.
[0010] S5: Set the smoothing accuracy threshold according to the actual project requirements for the smoothing accuracy of the curve , and respectively compare the distance Lmax11 and distance Lmax12 in step S4 with the smoothing accuracy threshold Size: If the distance Lmax1j is not greater than , then the curve is considered l 1j Smooth enough, the starting point and end point of the sublist list2j are sufficient to fit the trend characteristics of the curve, and the curve smoothing process is ended.
[0011] On the contrary, if the distance Lmax1j is greater than , then the line segment connecting nodes Pij and P1 is formed L 21 , connecting nodes Pij and Pk to form a line segment L 22 , through the node Pij, the subcurve will be closed l 1j Divided into two parts, denoted as sub-curves l 21和 l 22 , the nodes on these two parts each correspond to a subsequence list, recorded as ordered list list31 and ordered list list32. j is 1 or 2. The node Pij corresponding to the farthest distance is stored in the list List3, j is 1 or 2.
[0012] S6: traverse the sublist list31 and sublist list32 respectively, except for the two farthest nodes, and obtain the nodes in sublist list31 that are farthest from the line segment. L 21 The farthest node Pi11 and the corresponding farthest distance Lmax21 are obtained from the sublist list32. L 22 The farthest node Pi21 and the corresponding farthest distance Lmax22, and compare the distance Lmax21 and distance Lmax22 with the smoothing accuracy threshold respectively size.
[0013] S7: ..., iterate and recurse in sequence until the other nodes on the closed subcurve are connected to the corresponding line segments in the rth recursion l r The distance is no greater than , the smoothing process ends.
[0014] Store the two farthest nodes in the corresponding list in each iteration recursion into list list3.
[0015] S8: Traverse the list list3 generated in the previous step, each node and its previous node and next node, and remove the nodes in list list3 that are co-linear with the previous and next adjacent nodes.
[0016] Further optimization, smoothing accuracy threshold For 10 -5 m.
[0017] Further optimization, the step S8, the specific steps are as follows: Traverse the list list3 generated in the previous step. Each node in list list3 and its previous node and next node form two corresponding vectors. Calculate the cosine value of the angle between the two vectors corresponding to each node. If the absolute value of the cosine value of the angle between the two vectors is greater than the cosine value of a certain set small angle, it is considered that the point is on the straight line where the previous and next points are located, that is, the three points are collinear. Then delete the node from list list3 and reorder list list3. In a closed curve, if the node is the first one in list3, the last node in the list is taken as its previous node, and the second node is taken as its next node; if the node is the last one in the list, the second-to-last node in the list is taken as its previous node, and the first node is taken as its next node.
[0018] For further optimization, the minimum angle is set to 5°.
[0019] Compared with the prior art, the present invention has the following beneficial effects: The method of the present invention determines whether the node is collinear with the front and rear nodes by calculating the distance between the node and the line connecting the farthest node in the list, and by comparing the angle between the vector formed by the node and the front and rear nodes with a smaller angle, thereby accurately deleting redundant collinear control points in the closed curve on the basis of the original node list, improving the success rate of the Douglas method for smooth fitting of the closed curve, while maintaining its overall structure and characteristics, thereby improving the efficiency and accuracy of numerical simulation, and providing a valuable reference for future numerical modeling. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of the method for performing Douglas smoothing on a closed curve by removing redundant collinear points according to the present invention; Figure 2 is a schematic diagram of a closed curve before Douglas smoothing in an embodiment; Figure 3 is a schematic diagram of connecting the starting point and the key point after reordering in the embodiment; Figure 4 Schematic diagram of the farthest point from the line connecting the starting point and the key point in the embodiment; Figure 5 It is a schematic diagram of a closed curve after Douglas smoothing is performed in the embodiment. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] like Figure 1 As shown, a method for performing Douglas smoothing on a closed curve by removing redundant collinear points comprises the following steps: S1: For the selected closed curve l 0, obtain the information of all nodes on the closed curve through the built-in function, and form an ordered list list1, including the coordinates of the serial number of each node.
[0023] In this embodiment, if Figure 2 The figure shows the closed curve before optimization. There are five nodes on the curve, namely P'1 (0, 2), P'2 (0, 0), P'3 (4, 0), P'4 (3, 2) and P'5 (1.5, 2).
[0024] S2: Traverse the node list and find the two points on the curve that are farthest apart. Take the one closest to the origin as the starting point, and reorder all the sorted nodes of the curve in reverse time to form a new ordered list list2. The two points on the curve that are farthest apart are recorded as the starting point P1 and the key point Pk, where k is a positive integer and Pn is the end point of the curve after reordering.
[0025] Create an empty list to store the selected nodes, record it as the serial number list List3. Store the starting point P1 and the key point Pk in the list List3.
[0026] Specifically, in this example, the order of the 5 elements in the reordered ordered list list2 is P1 (0,0), P2 (4,0), P3 (3,2), P4 (1.5,2) and P5 (0,2). Among them, the starting point is P1; the key point is P5, which is also the end point. P1 (0,0) and P5 (0,2) are stored in the list List3.
[0027] S3: Connect the two farthest nodes P1 and Pk on the curve to form a line segment L 1, then the line segment L 1. Divide the closed curve into two parts, recorded as subcurves l 11和 l 12 The nodes on these two parts each correspond to a subsequence list, recorded as ordered list list21 and ordered list list22.
[0028] Figure 3 The red straight line in the middle is the line segment formed by connecting the starting point and the key point after reordering in this embodiment. L ,Since in this example, the starting point P1 and the key point Pk themselves are adjacent points, the closed curve is divided into two parts, including the black line part and the line segment between the starting point P1 and the key point Pk itself.
[0029] S4: traverse the other nodes in sublist list21 and sublist list22 except the starting point P1 and the key point Pk, and obtain the nodes in sublist list21 that are away from the line segment L 1 The farthest node Pi1 and the corresponding farthest distance Lmax1, get the distance from the line segment in the sublist list22 L 1The farthest node Pi2 and the corresponding farthest distance Lmax2.
[0030] Figure 4 Shown is the distance line segment in this embodiment L1 Schematic diagram of the farthest point. Specifically, except for the starting point P1 and the key point Pk, there is no node in the sublist list21, so Lmax11 does not exist; there are three farthest points in the sublist list22, namely P3 (3, 2), P4 (1.5, 2) and P5 (0, 2), and the farthest distance Lmax12 is 2. P3 (3, 2), P4 (1.5, 2) and P5 (0, 2) are stored in the list List3.
[0031] S5: Set the smoothing accuracy threshold according to the actual project requirements for the smoothing accuracy of the curve , and respectively compare the distance Lmax11 and distance Lmax12 in step S4 with the smoothing accuracy threshold Size: If the distance Lmax1j is not greater than , then the curve is considered l 1j Smooth enough, the starting point and the end point of the sublist list2j are sufficient to fit the trend characteristics of the curve, and the curve smoothing process ends; On the contrary, if the distance Lmax1j is greater than , then the line segment connecting nodes Pij and P1 is formed L 21 , connecting nodes Pij and Pk to form a line segment L 22 , through the node Pij, the subcurve will be closed l 1j Divided into two parts, denoted as sub-curves l 21和 l 22 , the nodes on these two parts each correspond to a subsequence list, recorded as ordered list list31 and ordered list list32. j is 1 or 2. The node Pij corresponding to the farthest distance is stored in the list List3, j is 1 or 2.
[0032] S6: traverse the sublist list31 and sublist list32 respectively, except for the two farthest nodes, and obtain the nodes in sublist list31 that are farthest from the line segment. L 21 The farthest node Pi11 and the corresponding farthest distance Lmax21 are obtained from the sublist list32. L 22 The farthest node Pi21 and the corresponding farthest distance Lmax22, and compare the distance Lmax21 and distance Lmax22 with the smoothing accuracy threshold respectively size.
[0033] S7: ..., iterate and recurse in sequence until the other nodes on the closed subcurve are connected to the corresponding line segments in the rth recursion l r The distance is no greater than , the smoothing process ends.
[0034] Store the two farthest nodes in the corresponding list in each iteration recursion into list list3.
[0035] Specifically, in this embodiment, in order to improve the smoothing accuracy as much as possible, a smoothing accuracy threshold is set. for m.
[0036] S8: Traverse the list list3 generated in the previous step. Each node in list list3 and its previous node and next node form two corresponding vectors. Calculate the cosine value of the angle between the two vectors corresponding to each node. It should be noted that in a closed curve, if the node is the first in list list3, the last node in the list is used as its previous node and the second node is used as its next node; if the node is the last in the list, the second-to-last node in the list is used as its previous node and the first node is used as its next node.
[0037] Specifically, in this embodiment, for the node P4 (1.5, 2), the vectors formed by it, the preceding node P3, and the following node P5 are (-1.5, 0) and (1.5, 0), respectively.
[0038] If the absolute value of the cosine of the angle between the two vectors is greater than the cosine of a certain set small angle, the point is considered to be on the straight line where the two points before and after are located, that is, the three points are collinear, and then the node is deleted from list3 and list3 is reordered.
[0039] In the actual engineering of earth-rock dam mesh generation, the three corresponding points are collinear when the small angle is set to 5°. Return the final ordered and non-collinear node list. Specifically, in this embodiment, if P4 is collinear with the vector formed by the previous and next nodes, then delete P4, and finally renumber the remaining nodes and return the final node list. Specifically, in this embodiment, Figure 5 To improve the closed curve diagram after Douglas method smoothing, the final node list is P''1 (0,0), P''2 (4,0), P''3 (3,2) and P4'' (0,2).
[0040] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A method for Douglas smoothing a closed curve by removing redundant collinear points, characterized in that: The following steps are involved: S1: For the selected closed curve l 0, obtain the information of all nodes on the closed curve through the built-in function, and form an ordered list list1, including the coordinates of the serial number of each node; S2: Traverse the node list, find the two points on the curve that are farthest apart, take the one closest to the origin as the starting point, reorder all the ordered nodes of the curve in reverse time, and form a new ordered list list2. The two points on the curve that are farthest apart are recorded as the starting point P1 and the key point Pk, where k is a positive integer and k∈[3,n], and Pn is the end point of the reordered curve; Create an empty list to store the selected nodes, record it as the serial number list List3, and store the starting point P1 and the key point Pk in the list List3; S3: Connect the two farthest nodes P1 and Pk on the curve to form a line segment L 1, then the line segment L 1. Divide the closed curve into two parts, recorded as subcurves l 11和 l 12 , the nodes on these two parts each correspond to a subsequence list, recorded as ordered list list21 and ordered list list22; S4: traverse the other nodes in sublist list21 and sublist list22 except the starting point P1 and the key point Pk, and obtain the nodes in sublist list21 that are away from the line segment L 1 The farthest node Pi1 and the corresponding farthest distance Lmax1, get the distance from the line segment in the sublist list22 L 1The farthest node Pi2 and the corresponding farthest distance Lmax2; S5: Set the smoothing accuracy threshold according to the actual project requirements for the smoothing accuracy of the curve , and respectively compare the distance Lmax11 and distance Lmax12 in step S4 with the smoothing accuracy threshold Size: If the distance Lmax1j is not greater than , then the curve is considered l 1j Smooth enough, the starting point and the end point of the sublist list2j are sufficient to fit the trend characteristics of the curve, and the curve smoothing process ends; On the contrary, if the distance Lmax1j is greater than , then the line segment connecting nodes Pij and P1 is formed L 21 , connecting nodes Pij and Pk to form a line segment L 22 , through the node Pij, the subcurve will be closed l 1j Divided into two parts, denoted as sub-curves l 21和 l 22 , the nodes on these two parts each correspond to a subsequence list, recorded as ordered list list31 and ordered list list32, j is 1 or 2; Store the node Pij corresponding to the farthest distance into the list List3, where j is 1 or 2; S6: traverse the sublist list31 and sublist list32 respectively, except for the two farthest nodes, and obtain the nodes in sublist list31 that are farthest from the line segment. L 21 The farthest node Pi11 and the corresponding farthest distance Lmax21 are obtained from the sublist list32. L 22 The farthest node Pi21 and the corresponding farthest distance Lmax22, and compare the distance Lmax21 and distance Lmax22 with the smoothing accuracy threshold respectively size; S7: ..., iterate and recurse in sequence until the other nodes on the closed subcurve are connected to the corresponding line segments in the rth recursion l r The distance is no greater than , then the smoothing process ends; Store the two farthest nodes in the corresponding list in each iteration recursion into list3; S8: Traverse the list list3 generated in the previous step, each node and its previous node and next node, and remove the nodes in list list3 that are co-linear with the previous and next adjacent nodes.
2. The method for performing Douglas smoothing on a closed curve by removing redundant collinear points according to claim 1, characterized in that: Smoothing accuracy threshold For 10 -5 m.
3. The method for performing Douglas smoothing on a closed curve by removing redundant collinear points according to claim 1, characterized in that: The specific steps of step S8 are as follows: Traverse the list list3 generated in the previous step. Each node in list list3 and its previous node and next node form two corresponding vectors. Calculate the cosine value of the angle between the two vectors corresponding to each node. If the absolute value of the cosine value of the angle between the two vectors is greater than the cosine value of a certain set small angle, it is considered that the point is on the straight line where the previous and next points are located, that is, the three points are collinear. Then delete the node from list list3 and reorder list list3. In a closed curve, if the node is the first one in list3, the last node in the list is taken as its previous node, and the second node is taken as its next node; if the node is the last one in the list, the second-to-last node in the list is taken as its previous node, and the first node is taken as its next node.
4. The method for performing Douglas smoothing on a closed curve by removing redundant collinear points according to claim 3, characterized in that: Set the Minor Angle to 5°.
Citation Information
Patent Citations
Navigation path planning method and system based on parameter curve optimization
CN113847924A
Robot path planning method fusing bidirectional search mechanism and improved A* algorithm
CN114199270A
Construction of three-dimensional road network map
US20230222734A1
