A method for Douglas smoothing closed curves by removing redundant collinear points.
By calculating the distance and angle between nodes of a closed curve and removing redundant collinear points, the problem of determining control points in the Douglas algorithm during smooth fitting is solved, achieving more efficient curve smoothing and higher numerical simulation accuracy.
Patent Information
- Application Number
- CN202411371990.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-09-29
AI Technical Summary
When Douglas' algorithm smoothly fits a closed curve, it cannot determine the control points when the connecting line is parallel to the original curve, resulting in redundant collinear points and affecting the smoothing effect.
By calculating the distance between a node and the line connecting it to the farthest node in the list, and by comparing the angle between the vector formed by the node and the nodes before and after it with a certain smaller angle, it is determined whether the nodes are collinear, and redundant collinear control points are deleted to optimize the node list.
This improves the success rate of Douglas method in smoothly fitting closed curves, preserving curve structure and characteristics, and enhancing the efficiency and accuracy of numerical simulation.
Smart Images

Figure CN119180181B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of mesh generation technology, specifically relating to a method for Douglas smoothing closed curves by removing redundant collinear points. Background Technology
[0002] Mesh generation is the first step in numerical simulation. Its purpose is to divide the three-dimensional model into subdivisions to facilitate the solution of the governing equations 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 farthest apart in the curve's point set and connect them with a line. Then, the point farthest from the connecting line is identified as the control point describing the curve's trend. 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, leading to its failure. Therefore, the problem of redundant control points is a key challenge in smoothing and fitting closed curves using the Douglas method. How to eliminate the influence of redundant collinear control points on the Douglas method is a major challenge in engineering. Summary of the Invention
[0004] The purpose of this invention is to provide a method for Douglas smoothing closed curves by removing redundant collinear points. This method aims to remove the influence of collinear points on closed curves with redundant collinear control points, thereby effectively achieving smooth fitting of the curve within a finite number of control points.
[0005] To achieve the above objectives, the present invention employs the following solution:
[0006] A method for Douglas smoothing closed curves by removing redundant collinear points includes the following steps:
[0007] S1: For the selected closed curve l 0. Use the built-in function to obtain information about all nodes on the closed curve and form an ordered list list1, which includes the coordinates of the index of each node.
[0008] S2: Traverse the node list, find the two points on the curve that are farthest apart, take the one closer to the origin as the starting point, and reorder all sorted nodes on the curve in reverse time to form a new ordered list list2. The two points on the curve that are farthest apart are denoted as the starting point P1 and the key point Pk, where k is a positive integer and k∈[3,n]. Pn is the endpoint of the curve after reordering.
[0009] Create an empty list to store the filtered nodes, denoted as List3. Store the starting point P1 and the key point Pk in List3.
[0010] S3: Connect the two farthest nodes P1 and Pk on the curve to form a line segment. L 1, then line segment L 1. Divide the closed curve into two parts, denoted as sub-curves. l 11和 l 12 Each of the nodes in these two parts corresponds to a sub-sequence list, denoted as sorted list list21 and sorted list list22.
[0011] S4: Traverse sublists list21 and list22 respectively, excluding the starting point P1 and the key point Pk, to obtain the nodes in sublist list21 that are far from the line segment. L 1. Find the farthest node Pi1 and its corresponding farthest distance Lmax1, and obtain the sublist list22 containing nodes that are farthest from the line segment. L 1. The farthest node Pi2 and its corresponding farthest distance Lmax2.
[0012] S5: Set the smoothing accuracy threshold according to the smoothing accuracy requirements of the curve in actual engineering. And compare the distances Lmax11 and Lmax12 in step S4 with the smoothing accuracy threshold respectively. Size:
[0013] If the distance Lmax1j is not greater than Then the curve is considered to be l 1j The curve is smooth enough that the start and end points of the sublist list2j are sufficient to fit the trend characteristics of the curve, thus ending the curve smoothing process.
[0014] Conversely, if the distance Lmax1j is greater than Then, connecting nodes Pij and P1 forms a line segment. L 21 Connecting nodes Pij and Pk forms a line segment. L 22 The closed subcurve will be closed through node Pij. l 1j Divide into two parts, denoted as sub-curves l 21和 l 22 The nodes in these two parts each correspond to a sub-sequence list, denoted as ordered list31 and ordered list32. j is 1 or 2. Store the node Pij corresponding to the farthest distance into list List3, where j is 1 or 2.
[0015] S6: Iterate through sublists list31 and list32, excluding the two furthest nodes, to obtain the nodes in sublist list31 that are furthest from the line segment. L 21 Given the farthest node Pi11 and its corresponding farthest distance Lmax21, obtain a sublist list32 containing nodes that are farthest from the line segment. L 22 Find the farthest node Pi21 and its corresponding farthest distance Lmax22, and compare the distances Lmax21 and Lmax22 with the smoothing accuracy threshold. Size.
[0016] S7: ..., iterate recursively until the r-th recursive step, connecting other nodes on the closed subcursion to their corresponding line segments. l r The distance is no greater than Then the smoothing process ends.
[0017] Store the two farthest nodes from the corresponding list in each iteration of the recursion into list3.
[0018] S8: Traverse the list list3 generated in the previous step, each node along with its predecessor and successor nodes, and remove nodes in list3 that are collinear with their predecessor and successor nodes.
[0019] Further optimization, smoothing accuracy threshold 10 -5 m.
[0020] Further optimization is needed; step S8 will have the following specific steps:
[0021] Iterate through the list list3 generated in the previous step. Each node in list3 forms two vectors with its predecessor and successor nodes. Calculate the cosine of the angle between the two vectors corresponding to each node. 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, then the point is considered to be on the straight line containing the two preceding and succeeding points, i.e., the three points are collinear. Then, delete the node from list list3 and reorder list3.
[0022] In a closed curve, if the selected node is the first in list3, then the last node in the list is taken as its previous node and the second node is taken as its next node; if the selected node is the last in the list, then the second to last node in the list is taken as its previous node and the first node is taken as its next node.
[0023] Further optimization was performed, setting the small angle to 5°.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] The method described in this invention determines whether a node is collinear with its neighbors by calculating the distance between the node and the line connecting the node to the farthest node in the list, and by comparing the angle between the node and the vectors formed by the node and its neighbors with a certain smaller angle. This allows for the accurate removal of redundant collinear control points from the closed curve based on the original node list, improving the success rate of the Douglas method in smoothly fitting closed curves while maintaining its overall structure and characteristics. This, in turn, improves the efficiency and accuracy of numerical simulation and provides a valuable reference for future numerical modeling. Attached Figure Description
[0026] Figure 1 This is a flowchart of the method for performing Douglas smoothing on closed curves by removing redundant collinear points, as described in this invention.
[0027] Figure 2 This is a schematic diagram of the closed curve before Douglas smoothing in the embodiment.
[0028] Figure 3 This is a schematic diagram showing the connection between the starting point and key points after reordering in the embodiment;
[0029] Figure 4 This is a schematic diagram of the point furthest from the starting point and the key point in the embodiment;
[0030] Figure 5 This is a schematic diagram of the closed curve after Douglas smoothing in the embodiment. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0032] like Figure 1 As shown, a method for Douglas smoothing a closed curve by removing redundant collinear points includes the following steps:
[0033] S1: For the selected closed curve l 0. Use the built-in function to obtain information about all nodes on the closed curve and form an ordered list list1, which includes the coordinates of the index of each node.
[0034] In this embodiment, as Figure 2 The curve shown is the closed curve before optimization. The curve has 5 nodes, namely P'1(0,2), P'2(0,0), P'3(4,0), P'4(3,2) and P'5(1.5,2).
[0035] S2: Traverse the node list, find the two points on the curve that are farthest apart, take the one closer to the origin as the starting point, and reorder all sorted nodes on the curve in reverse time to form a new ordered list list2. The two points on the curve that are farthest apart are denoted as the starting point P1 and the key point Pk, where k is a positive integer and Pn is the endpoint of the curve after reordering.
[0036] Create an empty list, denoted as List3, to store the selected nodes. Store the starting point P1 and the key point Pk in List3.
[0037] Specifically, in this example, the five elements in the reordered list list2 are P1(0,0), P2(4,0), P3(3,2), P4(1.5,2), and P5(0,2). The starting point is P1, and the key point is P5, which is also the ending point. P1(0,0) and P5(0,2) are then stored in list list3.
[0038] S3: Connect the two farthest nodes P1 and Pk on the curve to form a line segment. L 1, then line segment L 1. Divide the closed curve into two parts, denoted as sub-curves. l 11和 l 12 Each of the nodes in these two parts corresponds to a sub-sequence list, denoted as sorted list list21 and sorted list list22.
[0039] Figure 3 The red 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 the starting point P1 and the key point Pk are adjacent points in this example, the closed curve is divided into two parts, including the black line part and the line segment connecting the starting point P1 and the key point Pk itself.
[0040] S4: Traverse sublists list21 and list22 respectively, excluding the starting point P1 and the key point Pk, to obtain the nodes in sublist list21 that are far from the line segment. L 1. Find the farthest node Pi1 and its corresponding farthest distance Lmax1, and obtain the sublist list22 containing nodes that are farthest from the line segment. L 1. The farthest node Pi2 and its corresponding farthest distance Lmax2.
[0041] Figure 4 The figure shown is a distance line segment in this embodiment. L 1. A diagram illustrating the farthest point. Specifically, sublist list21 contains no nodes except for the starting point P1 and the key point Pk, therefore Lmax11 does not exist. Sublist list22 contains three farthest points: P3(3,2), P4(1.5,2), and P5(0,2), with a maximum distance Lmax12 of 2. Store P3(3,2), P4(1.5,2), and P5(0,2) in list list3.
[0042] S5: Set the smoothing accuracy threshold according to the smoothing accuracy requirements of the curve in actual engineering. And compare the distances Lmax11 and Lmax12 in step S4 with the smoothing accuracy threshold respectively. Size:
[0043] If the distance Lmax1j is not greater than Then the curve is considered to be l 1j The curve is smooth enough that the start and end points of the sublist list2j are sufficient to fit the trend characteristics of the curve, and the curve smoothing process ends.
[0044] Conversely, if the distance Lmax1j is greater than Then, connecting nodes Pij and P1 forms a line segment. L 21 Connecting nodes Pij and Pk forms a line segment. L 22 The closed subcurve will be closed through node Pij. l 1j Divide into two parts, denoted as sub-curves l 21和 l 22 The nodes in these two parts each correspond to a sub-sequence list, denoted as ordered list31 and ordered list32. j is 1 or 2. Store the node Pij corresponding to the farthest distance into list List3, where j is 1 or 2.
[0045] S6: Iterate through sublists list31 and list32, excluding the two furthest nodes, to obtain the nodes in sublist list31 that are furthest from the line segment. L 21 Given the farthest node Pi11 and its corresponding farthest distance Lmax21, obtain a sublist list32 containing nodes that are farthest from the line segment. L 22Find the farthest node Pi21 and its corresponding farthest distance Lmax22, and compare the distances Lmax21 and Lmax22 with the smoothing accuracy threshold. Size.
[0046] S7: ..., iterate recursively until the r-th recursive step, connecting other nodes on the closed subcursion to their corresponding line segments. l r The distance is no greater than Then the smoothing process ends.
[0047] Store the two farthest nodes from the corresponding list in each iteration of the recursion into list3.
[0048] Specifically, in this embodiment, a smoothing accuracy threshold is set to maximize smoothing accuracy. for m.
[0049] S8: Traverse the list `list3` generated in the previous step. Each node in `list3`, along with its predecessor and successor nodes, forms two corresponding vectors. Calculate the cosine of the angle between these two vectors for each node. Note that in a closed curve, if the selected node is the first node in `list3`, then the last node in the list is taken as its predecessor, and the second node as its successor; if the selected node is the last node in the list, then the second-to-last node is taken as its predecessor, and the first node as its successor.
[0050] Specifically, in this embodiment, for node P4 (1.5,2), the vectors formed by it with the preceding node P3 and the following node P5 are (-1.5,0) and (1.5,0), respectively.
[0051] 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, then the point is considered to be on the straight line containing the two points, that is, the three points are collinear. Then the node is deleted from list3 and list3 is reordered.
[0052] In the actual engineering of earth-rock dam mesh generation, three points corresponding to a small angle of 5° are considered collinear. The final ordered list of non-collinear nodes is returned. Specifically, in this embodiment, if P4 is collinear with the vectors formed by the nodes before and after it, P4 is deleted. Finally, the remaining nodes are renumbered, and the final node list is returned. Specifically, in this embodiment... Figure 5 To improve the closed curve diagram after smoothing using the Douglas method, the final node list is P''1 (0,0), P''2 (4,0), P''3 (3,2) and P4'' (0,2).
[0053] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A method for Douglas smoothing closed curves by removing redundant collinear points, characterized in that, Includes the following steps: S1: For the selected closed curve l 0. Obtain information about all nodes on the closed curve using built-in functions, and form an ordered list list1, including the coordinates of the index of each node; S2: Traverse the node list, find the two points on the curve that are farthest apart, take the one closer to the origin as the starting point, and reorder all sorted nodes on the curve in reverse time to form a new ordered list list2. The two points on the curve that are farthest apart are denoted as the starting point P1 and the key point Pk, where k is a positive integer and k∈[3,n], and Pn is the endpoint of the curve after reordering. Create an empty list to store the filtered nodes, denoted as the sequence 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, denoted as sub-curves. l 11和 l 12 Each of the nodes in these two parts corresponds to a sub-sequence list, denoted as ordered list21 and ordered list22; S4: Traverse sublists list21 and list22 respectively, excluding the starting point P1 and the key point Pk, to obtain the nodes in sublist list21 that are far from the line segment. L 1. Find the farthest node Pi1 and its corresponding farthest distance Lmax1, and obtain the sublist list22 containing nodes that are farthest from the line segment. L 1. The farthest node Pi2 and its corresponding farthest distance Lmax2; S5: Set the smoothing accuracy threshold according to the smoothing accuracy requirements of the curve in actual engineering. And compare the distances Lmax11 and Lmax12 in step S4 with the smoothing accuracy threshold respectively. Size: If the distance Lmax1j is not greater than Then the curve is considered to be l 1j The curve is smooth enough that the start and end points of the sublist list2j are sufficient to fit the trend characteristics of the curve, and the curve smoothing process ends. Conversely, if the distance Lmax1j is greater than Then, connecting nodes Pij and P1 forms a line segment. L 21 Connecting nodes Pij and Pk forms a line segment. L 22 The closed subcurve will be closed through node Pij. l 1j Divide into two parts, denoted as sub-curves l 21和 l 22 Each of the nodes in these two parts corresponds to a sub-sequence list, denoted as ordered list31 and ordered list32, where j is 1 or 2; Store the node Pij corresponding to the farthest distance in list List3, where j is 1 or 2; S6: Iterate through sublists list31 and list32, excluding the two furthest nodes, to obtain the nodes in sublist list31 that are furthest from the line segment. L 21 Given the farthest node Pi11 and its corresponding farthest distance Lmax21, obtain the sublist list32 containing nodes that are farthest from the line segment. L 22 Find the farthest node Pi21 and its corresponding farthest distance Lmax22, and compare the distances Lmax21 and Lmax22 with the smoothing accuracy threshold. Size; S7: ..., iterate recursively until the r-th recursive step, connecting other nodes on the closed subcursion to their corresponding line segments. 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 of the recursion into list3; S8: Traverse the list list3 generated in the previous step, each node along with its predecessor and successor nodes, and remove nodes in list3 that are collinear with their predecessor and successor nodes.
2. The method for Douglas smoothing a closed curve by removing redundant collinear points according to claim 1, characterized in that, Smoothing accuracy threshold 10 -5 m.
3. The method for Douglas smoothing a closed curve by removing redundant collinear points according to claim 1, characterized in that, Step S8 is described in the following steps: Iterate through the list list3 generated in the previous step. Each node in list3 forms two vectors with its predecessor and successor nodes. Calculate the cosine of the angle between the two vectors corresponding to each node. 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, then the point is considered to be on the straight line containing the two preceding and succeeding points, i.e., the three points are collinear. Then, delete the node from list list3 and reorder list3. In a closed curve, if the selected node is the first in list3, then the last node in the list is taken as its previous node and the second node is taken as its next node; if the selected node is the last in the list, then 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 Douglas smoothing a closed curve by removing redundant collinear points according to claim 3, characterized in that, Set the small 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