A closed spline curve CNC machining tool path algorithm
By using a closed spline curve CNC machining toolpath algorithm, the machining path of the workpiece is automatically generated, which solves the problems of toolpath planning complexity and tool radius compensation in the existing technology, and realizes fast and convenient machining path generation and adjustment, which is applicable to any planar graphic.
Patent Information
- Application Number
- CN202510350107.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-03-24
AI Technical Summary
In the existing technology, the planning and editing of toolpaths for workpiece turning requires specialized software tools and skills, making it difficult to quickly and effectively compensate for tool radius, and it cannot automatically generate machining paths, making it unsuitable for CNC machining of closed spline curves of arbitrary planar graphics.
This paper presents a toolpath algorithm for CNC machining of closed spline curves. By inputting the workpiece contour curve, cutting depth and tool radius, it automatically generates the machining path. It adopts data structure definition, adjacent point vector calculation, unit vector normalization and new target point calculation. It is applicable to any planar graphic and inserts arc transitions to handle high curvature areas.
It enables quick and convenient adjustment of toolpaths for machining closed spline curves in industrial settings, reducing operational complexity. Only basic parameters need to be input to generate the machining path, making it suitable for any planar shape and avoiding abrupt changes in the toolpath.
Smart Images

Figure CN120276366B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of turning machining, and particularly relates to a closed spline curve CNC machining tool path algorithm. BACKGROUND
[0002] In the field of numerical control turning machining, the planning and editing of the turning tool path of a workpiece is a key step to ensure accurate machining of a part. In the past, the machining of a workpiece was usually edited by a skilled technician on a machine tool. In recent years, thanks to the rapid development of computers, some CAM software has appeared to assist in editing and generating the turning path of a workpiece. However, these software still need technicians with corresponding knowledge to edit and operate, and still cannot be widely promoted and applied. At present, the planning and editing of the turning tool path of a workpiece mainly need to use professional tool software such as AutoCAD and CAM software to edit and make a tool path trajectory file, and the professional skills of the operator are required to be high. This way is difficult to quickly and effectively compensate for the tool radius, and the tool radius needs to be recalculated and edited by using professional tool software every time the tool radius changes. If a closed spline curve CNC machining tool path algorithm capable of being applied to any planar graph tool path calculation, inputting the profile curve of a workpiece and the cutting depth and tool radius to automatically generate a corresponding machining path, and quickly and conveniently adjusting the closed spline curve graph machining tool path of the closed spline curve in the industrial field can be designed, the above problems can be solved. SUMMARY
[0003] The application solves the technical problems of the prior art, and provides a closed spline curve CNC machining tool path algorithm capable of being applied to any planar graph tool path calculation, inputting the profile curve of a workpiece and the cutting depth and tool radius to automatically generate a corresponding machining path, and quickly and conveniently adjusting the closed spline curve graph machining tool path of the closed spline curve in the industrial field.
[0004] The technical scheme adopted by the application is as follows:
[0005] Step S1, data structure definition;
[0006] Step S2, adjacent point vector calculation;
[0007] Step S3, unit vector normalization;
[0008] Step S4, calculation of a new target point;
[0009] Step S5, iteration of the profile to generate a new curve;
[0010] In step S4, the distance of two adjacent edges is the same distance dis, the cutting depth is h, and the tool radius is r, so the distance of adjacent edges dis = h + r;
[0011] At this time, the angle θ between the vector D and PP1 is calculated, and the distance v of the vector D on the PP1 vector is calculated according to θ, that is, cosθ = Dunit * D1 / |Dunit| * |D1|;
[0012] The distance v of the vector D on the PP1 vector is dis * cosθ;
[0013] Then, the scaling ratio k is calculated, which satisfies k * v = dis, that is, k = dis / v;
[0014] The final offset direction vector is d = k * Dunit, and the new point outward expansion compensation coordinate set L1 and the inward expansion compensation coordinate set L2 are L1 = Pi + d and L2 = Pi - d.
[0015] Further, step S1 inputs an ordered point set C = {P0, P1,..., Pn-1} according to the workpiece contour to form a contour curve, and when the contour curve is a closed polygon, Pn = P0.
[0016] Further, step S2 selects a current point P in the ordered point set C of step S1, and the left and right adjacent points P1 and P2 of the point P form two vectors with the point P, and the unit vectors D1 and D2 of the P1 vector and the P2 vector are taken.
[0017] Further, in step S3, the vector lengths of the unit vectors D1 and D2 are both 1, the D1 and D2 vectors are added, and the unit vector D of the vector on the inward expansion or outward expansion is obtained, that is, D = D1 + D2.
[0018] Further, if the contour is clockwise, D points to the inside; if it is counterclockwise, it needs to be taken in reverse; if |D|≠0, the final direction unit vector is Dunit = D / |D|.
[0019] Further, when the adjacent edges are collinear, |D| = 0, and the offset is directly along the normal direction.
[0020] Further, step S5 calculates two actual target points L1 and L2 according to the two vectors and the cutting depth and tool radius, and connects them as a new contour.
[0021] Further, a circular arc transition is inserted in the high-curvature area to avoid sudden changes in the tool path.
[0022] The beneficial effects of the present application are: the application is a real-time input interface, only three parameters of the contour point set, the cutting depth h and the tool radius r are needed to generate the machining tool path online, without complicated operation, the offset distance is dynamically adjusted through the formula dis=h+r, without regenerating the bottom layer geometric data, only updating the parameters and re-traversing the point set, which can be applied to tool path calculation of any plane figure, the contour curve of the workpiece and the cutting depth and tool radius can be input to automatically generate the corresponding machining path, and the closed spline curve figure machining tool path can be quickly and conveniently adjusted in the industrial field. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 is a workpiece machining contour generation schematic diagram;
[0024] Figure 2 is a unit vector schematic diagram in the present application;
[0025] Figure 3 is a unit vector schematic diagram in the present application;
[0026] Figure 4 is a point schematic diagram of internal shrinkage and external expansion in the present application. DETAILED DESCRIPTION
[0027] As shown in the embodiment, the present application comprises the following specific steps: Figures 1 to 4
[0028] Step S1, data structure definition;
[0029] Step S2, adjacent point vector calculation;
[0030] Step S3, unit vector normalization;
[0031] Step S4, calculation of new target point;
[0032] Step S5, traversal contour generation new curve;
[0033] In step S4, for the internal shrinkage or external expansion of the plane figure, the distance of the two adjacent edges is the same distance dis, wherein the cutting depth is h and the tool radius is r, so the distance of the adjacent edges dis=h+r;
[0034] At this time, the angle θ between the vector D and PP1 is calculated, and the distance v of the vector D on the PP1 vector is calculated, that is: cosθ=Dunit*D1 / |Dunit|*|D1|;
[0035] The distance v of the vector D on the PP1 vector is dis*cosθ;
[0036] Then, the scaling ratio k is calculated, and the scaling ratio satisfies k*v=dis, that is: k=dis / v;
[0037] 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.
[0038] As shown in Figure 1 and Figure 2 , in the embodiment, step S1 inputs an ordered point set C={P0, P1,..., Pn-1} according to a workpiece contour to form a contour curve, and when the contour curve is a closed polygon, Pn=P0.
[0039] As shown in Figure 2 , in the embodiment, step S2 selects a current point P in the ordered point set C of step S1, and the left and right adjacent points P1 and P2 of the point P form two vectors with the point P, and the unit vectors D1 and D2 of the P1 vector and the P2 vector are taken.
[0040] As shown in Figure 2 , in the embodiment, in step S3, the vector lengths of the unit vectors D1 and D2 are both 1, the D1 and D2 vectors are added, and the unit vector D of the vector on the inward contraction or outward expansion is obtained, that is: D=D1+D2.
[0041] As shown in Figure 3 , in the embodiment, if the contour is clockwise, D points to the inside; if it is counterclockwise, it needs to be taken inversely; if |D|≠0, the final direction unit vector is: Dunit=D / |D|. As can be seen, the inverse or cross product symbol is taken.
[0042] As shown in Figure 3 , in the embodiment, when the adjacent edges are collinear, |D|=0, and the offset is directly along the normal direction.
[0043] As shown in Figure 1 and Figure 4 , in the embodiment, step S5 calculates two actual target points L1 and L2 according to the two vectors and the cutting depth and tool radius, and connects them to form a new contour.
[0044] As shown in Figure 1 and Figure 4 , in the embodiment, a circular arc transition is inserted in the high-curvature area to avoid sudden changes in the tool path. As can be seen, a circular arc transition is inserted in the high-curvature area (such as an angle <90°) to avoid sudden changes in the tool path.
[0045] The working principle of the application is: step S1, data structure definition; step S2, adjacent point vector calculation; step S3, unit vector normalization; step S4, calculation of new target point; step S5, traversal of contour to generate new curve.
[0046] Although the embodiments of the present application are described in the practical schemes, they do not constitute the limitation to the meaning of the present application, and the modification to the embodiments thereof and the combination with other schemes according to the present specification are obvious to the person skilled in the art.
Claims
1. A closed spline curve CNC machining tool path algorithm, characterized in that: It comprises the following specific steps: Step S1, data structure definition; Step S2, adjacent point vector calculation; Step S3, unit vector normalization; Step S4, new target point calculation; Step S5, new curve generation by traversing the contour; In step S4, the distance of the two adjacent edges is the same distance dis for the inward or outward expansion of the planar figure, wherein the cutting depth is h, and the tool radius is r, so the distance of the adjacent edges dis=h+r; At this time, the angle θ between the vector D and PP1 is calculated, and the distance v of the vector D on the PP1 vector is calculated according to θ, that is: cosθ=Dunit*D1 / |Dunit|*|D1|; The distance v of the vector D on the PP1 vector is dis*cosθ; Then, the scaling ratio k is calculated, 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 expansion compensation coordinate set L2 are: L1=Pi+d; L2=Pi-d; 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 P1 vector and P2 vector are taken. In step S3, the vector length of the unit vectors D1 and D2 is 1, and the unit vector D of the vector on the inward or outward expansion is calculated by adding D1 and D2 vectors, that is: D=D1+D2.
2. The closed spline curve CNC machining tool path algorithm of claim 1, wherein: In step S1, the ordered point set C={P0, P1,..., Pn−1} is input according to the workpiece contour to form a contour curve, and when the contour curve is a closed polygon, Pn=P0.
3. The closed spline curve CNC machining tool path algorithm of claim 1, wherein: If the contour is clockwise, D points to the inside; if it is counterclockwise, it needs to be taken inversely; if |D|≠0, the final direction unit vector is: Dunit=D / |D|.
4. The closed spline curve CNC machining tool path algorithm of claim 3, wherein: When the adjacent edges are collinear, |D|=0, and the offset is directly along the normal direction.
5. The closed spline curve CNC machining tool path algorithm of claim 3, wherein: Step S5 calculates two actual target points L1 and L2 from the two vectors and the cutting depth and tool radius and connects them as a new contour 。 6. The closed spline curve CNC machining tool path algorithm of claim 5, wherein: For high-curvature areas, a circular arc transition is inserted to avoid tool path mutation.
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