Closed spline curve CNC machining tool path algorithm
Through the CNC machining tool path algorithm for closed spline curves, the machining path of the workpiece is automatically generated, which solves the problems of tool path planning complexity and tool radius adjustment in the existing technology, and achieves fast and convenient machining path generation.
Patent Information
- Application Number
- CN202510350107.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-03-24
AI Technical Summary
In the prior art, workpiece turning tool path planning and editing requires professional tool software, which is difficult to quickly and conveniently compensate and adjust the tool radius, and cannot be suitable for the automatic machining path generation of any planar graphics.
A closed spline curve CNC machining tool path algorithm is provided. By inputting workpiece profile curve, cutting depth and tool radius, the machining path is automatically generated, and data structure definition, adjacent point vector calculation, unit vector normalization and new target point calculation are used to apply tool path calculation of any plane figure.
It realizes the rapid and convenient adjustment of closed spline curve graphic machining tool paths in the industrial site, without regenerating underlying geometric data, and only requires updating parameters to generate machining paths, which are suitable for any planar graphics.
Smart Images

Figure CN120276366A_ABST
Abstract
Description
Technical Field
[0001] The present invention is applied to the technical field of turning machining, and particularly relates to a closed spline curve CNC machining tool path algorithm. Background Art
[0002] In the field of numerical control turning machining, the planning and editing of the turning tool path of a workpiece are key steps to ensure the precise machining of the part. In the past, it was usually technical personnel with professional knowledge who edited the G-code tool path on the machine tool to achieve the machining of the workpiece. In recent years, thanks to the rapid development of computers, some CAM software has emerged to assist in editing and generating the turning path of the workpiece. However, these software still require technical personnel with corresponding knowledge to edit and operate, and still cannot be widely promoted and applied on a large scale. Currently, the main planning and editing of the turning tool path of the workpiece need to use professional tool software to edit and produce the tool path file, such as AutoCAD, CAM software, etc., and have high requirements for the professional skills of the operator. This method is difficult to quickly and effectively compensate for the tool radius. Every time the tool radius changes, it is necessary to use professional tool software to recalculate and edit the tool path file again. If a tool path calculation that can be applied to any planar graph can be designed, and the contour curve of the workpiece, the cutting depth, and the tool radius are input, the corresponding machining path can be automatically generated, and the closed spline curve CNC machining tool path algorithm for quickly and conveniently adjusting the closed spline curve graph machining tool path at the industrial site can solve the above problems. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to overcome the deficiencies of the prior art, and provide a closed spline curve CNC machining tool path algorithm that can be applied to the tool path calculation of any planar graph. By inputting the contour curve of the workpiece, the cutting depth, and the tool radius, the corresponding machining path can be automatically generated, and the closed spline curve graph machining tool path can be quickly and conveniently adjusted at the industrial site.
[0004] The technical solution adopted by the present invention is as follows: The present invention includes the following specific steps: Step S1, data structure definition; Step S2, adjacent point vector calculation; Step S3, unit vector normalization; Step S4, calculate the new target point; Step S5, traverse the contour to generate a new curve; For the inshrinkage or outexpansion of the planar graph in Step S4, the distance between two adjacent sides is the same distance dis, where the cutting depth is h and the tool radius is r. Therefore, the distance dis between adjacent sides = h + r; At this time, take the included angle θ between vector D and PP1, and calculate the distance v of vector D on the PP1 vector according to θ, that is: cosθ = Dunit * D1 / |Dunit| * |D1|; The distance v of vector D on the PP1 vector = dis * cosθ; Then calculate the scaling ratio k, and the scaling ratio satisfies k * v = dis, that is: k = dis / v; The final offset direction vector is d = k * Dunit, and the new point outward expansion compensation coordinate set L1 and the inward contraction compensation coordinate set L2 are: L1 = Pi + d; L2 = Pi - d.
[0005] Furthermore, in step S1, an ordered point set C = {P0, P1,..., Pn−1} is input according to the workpiece contour to form a contour curve. When the contour curve is a closed polygon, Pn = P0.
[0006] Furthermore, in step S2, the current point P is selected from the ordered point set C in step S1. The left and right adjacent points P1 and P2 of P form two vectors with point P, and the unit vectors D1 and D2 of the P1 vector and the P2 vector are taken.
[0007] Furthermore, in step S3, the vector magnitudes of the unit vector D1 and the unit vector D2 are both 1. Add the D1 and D2 vectors to find the unit vector D of the vector for inward contraction or outward expansion, that is: D = D1 + D2.
[0008] Furthermore, if the contour is clockwise, D points to the inside; if it is counterclockwise, it needs to be negated; if |D| ≠ 0, the final direction unit vector is: Dunit = D / |D|.
[0009] Furthermore, when the adjacent sides are collinear, |D| = 0, and directly offset along the normal direction.
[0010] Furthermore, in step S5, two actual target points L1 and L2 are obtained according to the two vectors, the cutting depth, and the tool radius, and they are connected to form a new contour.
[0011] Furthermore, insert an arc transition in the high curvature area to avoid sudden changes in the tool path.
[0012] The beneficial effects of the present invention are: This application is a real-time input interface. Only three parameters, namely the contour point set, the cutting depth h, and the tool radius r, are required to generate the machining tool path online. There is no need for cumbersome operations. The offset distance is dynamically adjusted through the formula dis = h + r. There is no need to regenerate the underlying geometric data. Only the parameters need to be updated and the point set needs to be traversed again. It can be applied to the tool path calculation of any planar graph. By inputting the contour curve of the workpiece, the cutting depth, and the tool radius, the corresponding machining path can be automatically generated, and the machining tool path of the closed spline curve graph can be quickly and conveniently adjusted in the industrial field. Description of the Drawings
[0013] Figure 1 is a schematic diagram for generating the machining profile of the workpiece; Figure 2 is a schematic diagram of the unit vector in the present invention; Figure 3 is a schematic diagram of the contracted unit vector in the present invention; Figure 4 is a schematic diagram of the contracted and expanded points in the present invention. Detailed Description of the Invention
[0014] As Figures 1 to 4 shown, in this embodiment, the present invention includes the following specific steps: Step S1, data structure definition; Step S2, calculation of adjacent point vectors; Step S3, normalization of the unit vector; Step S4, calculation of the new target point; Step S5, traversing the profile to generate a new curve; In step S4, for the contraction or expansion of the planar figure, the distances between two adjacent sides are the same distance dis, where the cutting depth is h and the tool radius is r. Therefore, the distance dis between adjacent sides = h + r; At this time, take the angle θ between the vector D and PP1, and calculate the distance v of the vector D on the PP1 vector according to θ, that is: cosθ = Dunit * D1 / |Dunit| * |D1|; The distance v of the vector D on the PP1 vector = dis * cosθ; Then calculate the scaling ratio k, and the scaling ratio satisfies k * v = dis, that is: k = dis / v; Finally, the offset direction vector is d = k * Dunit, and the new point outward expansion compensation coordinate set L1 and the inward contraction compensation coordinate set L2 are: L1 = Pi + d; L2 = Pi - d.
[0015] As Figure 1 and Figure 2 shown, in this embodiment, in step S1, an ordered point set C = {P0, P1,..., Pn−1} is input according to the workpiece profile to form a profile curve. When the profile curve is a closed polygon, Pn = P0.
[0016] As Figure 2 shown, in this embodiment, in step S2, the current point P is selected from the ordered point set C in step S1. The left and right adjacent points P1 and P2 of P form two vectors with point P, and the unit vectors D1 and D2 of the P1 vector and the P2 vector are taken.
[0017] As Figure 2, as shown, in this embodiment, the vector magnitudes (norms) of the unit vectors D1 and D2 in step S3 are both 1. Add the vectors D1 and D2 to find the unit vector D of the vector for inward or outward contraction, that is: D = D1 + D2.
[0018] As Figure 3 shown, in this embodiment, if the contour is clockwise, D points inward; if it is counterclockwise, it needs to be inverted; if |D| ≠ 0, the final direction unit vector is: Dunit = D / |D|. Thus, it can be seen that it is inverted or judged by the cross product symbol.
[0019] As Figure 3 shown, in this embodiment, when adjacent sides are collinear, |D| = 0, and it is directly offset along the normal direction.
[0020] As Figure 1 and Figure 4 shown, in this embodiment, in step S5, two actual target points L1 and L2 are calculated according to two vectors, the cutting depth, and the tool radius, and they are connected to form a new contour.
[0021] As Figure 1 and Figure 4 shown, in this embodiment, an arc transition is inserted into the high-curvature region to avoid sudden changes in the tool path. Thus, it can be seen that an arc transition is inserted into the high-curvature region (such as an angle < 90°) to avoid sudden changes in the tool path.
[0022] The working principle of the present invention: Step S1, data structure definition; Step S2, adjacent point vector calculation; Step S3, unit vector normalization; Step S4, calculation of new target points; Step S5, traversing the contour to generate a new curve.
[0023] Although the embodiments of the present invention are described with actual solutions, they do not constitute a limitation to the meaning of the present invention. For those skilled in the art, modifications to its implementation solutions according to this specification and combinations with other solutions are obvious.
Claims
1. A CNC machining tool path algorithm for closed spline curves, characterized in that: It includes the following specific steps: Step S1, data structure definition; Step S2, adjacent point vector calculation; Step S3, unit vector normalization; Step S4, calculate the new target point; Step S5, traverse the contour to generate a new curve; In step S4, for the inward or outward expansion of the planar figure, the distances between two adjacent sides are the same distance dis, where the cutting depth is h and the tool radius is r. Therefore, the distance between adjacent sides dis = h + r; At this time, take the angle θ between vector D and PP1, and calculate the distance v of vector D on the PP1 vector according to θ, that is: cosθ = Dunit * D1 / |Dunit| * |D1|; The distance v of vector D on the PP1 vector is v = dis * cosθ; Then calculate the scaling ratio k, and the scaling ratio satisfies k * v = dis, that is: k = dis / v; Finally, the offset direction vector is d = k * Dunit, and the new point outward expansion compensation coordinate set L1 and inward contraction compensation coordinate set L2 are: L1 = Pi + d; L2 = Pi - d.
2. The CNC machining tool path algorithm for a closed spline curve according to claim 1, wherein: In step S1, an ordered point set C = {P0, P1,..., Pn−1} is input according to the workpiece contour to form a contour curve. When the contour curve is a closed polygon, Pn = P0.
3. The CNC machining tool path algorithm for a closed spline curve according to claim 2, characterized in that: In step S2, select the current point P in the ordered point set C in step S1. The left and right adjacent points P1 and P2 of P form two vectors with point P, and the unit vectors D1 and D2 of the P1 vector and the P2 vector are taken.
4. The CNC machining tool path algorithm for a closed spline curve according to claim 3, wherein: In step S3, the vector magnitudes of the unit vector D1 and the unit vector D2 are both 1. Add the D1 and D2 vectors to find the unit vector D of the vector in the inward or outward expansion direction, that is: D = D1 + D2.
5. The CNC machining tool path algorithm for a closed spline curve according to claim 4, characterized in that: If the contour is clockwise, D points to the inside; if it is counterclockwise, it needs to be negated; if |D| ≠ 0, the final direction unit vector is: Dunit = D / |D|.
6. The CNC machining tool path algorithm for a closed spline curve according to claim 5, characterized in that: When the adjacent sides are collinear, |D| = 0, and directly offset along the normal direction.
7. The CNC machining tool path algorithm for a closed spline curve according to claim 5, characterized in that: Step S5 calculates two actual target points L1 and L2 based on two vectors, the cutting depth, and the tool radius, and connects them into a new contour 。 8. A CNC machining tool path algorithm for a closed spline curve according to claim 7, characterized in that: Insert an arc transition in the high curvature area to avoid sudden changes in the tool path.
Citation Information
Patent Citations
Non-circular component precision grinding numerical control machining method and system
CN115958473A
Numerical control machining contour parallel tool path generation method based on point cloud data
CN116360337A
Quasi-Fermat spiral curve form cavity machining tool path planning method based on distance gradient
CN117111546A
Numerical control tool path generation method for reverse engineering
CN117891207A
Five-axis numerical control machining track interpolation method
CN119179302A