1 Introduction

With the application of high-end equipment, the demand for complex curved surfaces with high quality is increasing. Due to the limitation of degree of freedom, it is difficult to use 3-axis machine tool to meet the requirements of high-quality and efficient machining for complex curved surface parts. The 5-axis machine tools are widely used because of two additional rotary freedoms. However, the relative position of the tool and the workpiece in 5-axis machining needs to be planned to avoid interference. According to the geometry characteristic of the complex curved surfaces, the commercial software uses the fixed tilt angles and yaw angles to machining. However, the machining quality is often affected by the unreasonable tool axis vectors. Especially the curved surface with larger curvature change, the angle of adjacent tool axis vectors is often too large. If feed speed is set larger, the rotary axes’ angular velocity increases sharply, which easily exceeds the constraints of the machine tool, affecting the smoothness of the machining and causing vibration marks on the processed surface.

To avoid the above problems, it can be solved in two aspects. The most common measure is giving a lower feed speed to reduce the rotary axes’ kinematical parameters (angular velocity and angular acceleration), but this will affect the machining efficiency. Another measure is further controlling the tool axis vectors based on the toolpath planning without reducing the feed speed, which will not affect the processing efficiency. In our previous research, a local optimization method for the blade surface with a sharp curvature is given. Tool axis vectors are optimized by selecting the tool axis vector optimizing interval. However, when the tool axis vector optimizing interval is overmuch, the local optimization algorithm is difficult to guarantee the optimization effectiveness for the tool axis vector. Aiming at the above problem, this study proposes a global tool axis vector optimization method based on the minimum angular acceleration for the rotary axes, which can effectively solve the phenomenon of overmuch tool axis vector optimizing intervals and provide guarantee for the high-quality machining of complex surface.

In order to avoid the interference between tools and parts by the shortest cutter, Ahmed et al. [1] proposed an efficient method using the Kd-tree data structure to detect interference points based on the cloud data which represented the part and the fixture model. For similar purpose when processing impeller blades, Li et al. [2] generated toolpaths based on the direction vectors to avoid the interference and collision by an on-machine probe. To improve the earlier algorithm [3], Tang et al. [4] presented a modified collision avoidance strategy on the basis of the biggest collision boxes which can reduce the time complexity for 5-axis NC machining. Beyond this method, Morishige et al. [5] devised an interference-free algorithm by producing the collision avoidance direction with two-dimensional configuration space. Aiming to complex curved surface with high distortion, Jung et al. [6] proposed a 5-axis machining toolpath generation method with comprehensive consideration for tilt angle, tool feeding direction, and normal vector, by which the toolpaths were shortest and the processing efficiency can be shorter. Constructing a unified mathematical model under the constraint of tools, Wang et al. [7] invented a new method for not only high-efficiency collision detection but also tool orientation modification with different tool adjustment strategies. Besides, in order to get a rapid numerical control processing, Wang et al. [8] proposed a tool interference checking method according to a devised criterion of Cartesian coordinate system transformation. In order to generate a toolpath meeting the demands of high-speed machining, Sun et al. [9] presented a direct toolpath generation method with spiral topology design under the constraint of iso-scallop requirement. Chiou et al. [10] designed a toolpath generation method based on the machining potential field to find the optimal tool feeding directions for the multi-axis NC machining for complex curved surface. For the purpose of modifying the kinematic errors, Srijuntongsiri et al. [11] analyzed an algorithm based on the optimal rotation-angle variation.

When it comes to the optimization for the tool axis vector, Tang et al. [12] proposed a tool vector method based on toolpaths in spiral milling processing in order to enhance the contour accuracy which was appropriate to the additive manufacturing with laser. To optimize the method for process in aspects including cutting forces and motion stability of NC machine, Tunc et al. [13] proposed an approach for selecting proper tool axis vector by integrated simulation in processing based on an already generated 5-axis milling path for the improved process stability. Zhu et al. [14] found the tool axis vector which can obtain the maximum average strip width to modify the existing tool orientation control methods for sculptured surface processing with a strategy called 3 + 2-axis machining. Looking into the irregular surface cutting textures when processing for avoiding singularities, Lin et al. [15] researched a tool orientation translation method utilizing particle swarm optimization. Xu et al. [16] presented a tool positioning algorithm in five-axis processing which can promote the smoothness and continuity when generating toolpaths. Aiming to the milling processing with ball-end cutter for five-axis machine tool, Liu et al. [17] presented a new optimization method based on graph to control the tool axis vector. In order to overcome the large incoherent movement of the rotary feed axis, Ma et al. [18] proposed a meaningful method with simulation and verification experiment to design optimal tool axis vectors with a focused consideration for kinematical characteristics of axes in rotary feeding when processing complex curved surface. Using a modified method of C-space, Zhou et al. [19] generated smooth tool axis vectors with the proposed safe space method which could optimize the toolpaths around the area where interference caused. Jun [20] and Tang [21], based on machining surface error analysis and consideration of the geometry of adjacent parts and the tool direction with well feasibility in C-space, minimized the change of tool direction during machining. To deal with the problem of processing deterioration due to abrupt changes of tool orientation, Ho et al. [22] proposed a method for tool orientation smoothing combined with a cutting error–modified method to reduce cutting errors and improve machining efficiency.

Based on the above, the researches focus on reducing the angle of tool axis vectors at continuous CC points as the optimization target. And the kinematical parameters of machine tools are rarely considered, such as the constraints of rotary axes’ angular velocity and angular acceleration. In the global optimization of tool axis vectors, the computational efficiency is not considered. Therefore, a global optimization method of tool axis vectors with high efficiency is proposed based on the minimum rotary angular acceleration. Since any direction of the ball-end cutter maintain the same contact state of cutter and workpiece, it is widely used in complex curved surface machining. With the minimum angular acceleration as the optimization objective, the tool axis vectors are optimized without changing the number of CC points to decrease the rotary axes’ angular acceleration, and the machining quality of the complex surface is improved. Firstly, the interference judgment principle is used to acquire the feasible spaces of tool axis vectors at CC points. Then, the property of concavity or convexity for the toolpath curve is judged, so as to divide the interval of toolpath curve and the key tool axis vectors on the toolpath curve are determined. Finally, the tool axis vectors on the toolpath are optimized based on the minimum angular acceleration in each interval. On this basis, the tool axis vectors at the joint position of the adjacent intervals are adjusted to ensure smoothing of the tool axis vectors on the entire toolpath. In the last, through the simulation analysis and experiment machining in the parts, the effectiveness and validity of the proposed tool axis vector optimization method for improving the quality complex curved surface parts are proved.

A method of global optimization for tool axis vector is proposed by means of partition in this paper. Firstly, the rotary axes’ kinematical parameters of machine tool are calculated. Then, a global tool axis vector optimization method based on the minimum angular acceleration is proposed. Finally, simulation and experiment machining results show the validity of proposed method. And the conclusion is given at last.

2 Prediction of kinematical parameters of rotary axes

In this section, the toolpath generation method is first given and then the coordinate system transformation is introduced. On this basis, the finite difference method is used to calculate the rotary axes’ kinematical parameters. And these are the basis of tool axis vector optimization in curved surface machining.

2.1 Toolpath calculation in five-axis machining

During complex curved surface machining, the machining curved surface can be represented by vectors as:

$$ \mathbf{S}\left(u,v\right)={\left[x\left(u,v\right),\kern0.3em y\left(u,v\right),\kern0.3em z\left(u,v\right)\right]}^{\mathrm{T}} $$
(1)

where u and v are variables of the parametric surface S(u, v). In general, u and v have a value range of [0,1].

In surface geometry, the unit normal vector N of surface S(u, v) can be calculated by the equation as:

$$ \mathbf{N}\left(u,v\right)=\frac{{\mathbf{S}}_u\left(u,v\right)\times {\mathbf{S}}_v\left(u,v\right)}{\left\Vert {\mathbf{S}}_u\left(u,v\right)\times {\mathbf{S}}_v\Big(u,v\Big)\right\Vert } $$
(2)

In which, Su(u, v) and Sv(u, v) represent the first-order derivatives of the surface S.

On the curved surface, the toolpath r(ξ) can be expressed by a parameter curve as:

$$ \mathbf{r}\left(\xi \right)={\left[x\left(\xi \right),\kern0.3em y\left(\xi \right),\kern0.3em z\left(\xi \right)\right]}^{\mathrm{T}} $$
(3)

In which ξ represents the curve parameter; the value range is [0,1]. And the unit tangent vector of the toolpath r(ξ) are calculated by the equation as:

$$ \mathbf{T}=\frac{{\mathbf{r}}^{\prime}\left(\xi \right)}{\left|{\mathbf{r}}^{\prime}\left(\xi \right)\right|} $$
(4)

Figure 1 is the schematic diagram of the curved surface S(u, v) machining. The toolpath r(ξ) on the surface is shown in the blue curve, and PC represents the CC point, which is the point where the cutter comes into contact with the processing surface. The unit normal vector N, unit tangent vector T, and unit vector K = N × T at CC point PC are taken as the basis vectors, so the LCS (local coordinate system) PCXLYLZL is established. With the change of the tool axis vector, the contact state of ball-end cutter and workpiece is always consistent, so the coordinates of the CC point PC and the cutter tip point P can be converted to each other by Eq. 5.

$$ {\mathbf{P}}_{\mathbf{C}}=\mathbf{P}+R\cdot \mathbf{V}-R\cdot \mathbf{N} $$
(5)
Fig. 1
figure 1

Schematic diagram of surface machining model

In which V and R represent the unit tool axis vector and the radius of the ball-end cutter, respectively.

In this study, the toolpaths of CC points in the machining process are generated by the equal residual scallop height method. The important parameters in the toolpath generation algorithm are the side-step length represented by L and the step-size represented by LS. And the side-step length is the distance of the corresponding CC points on the adjacent toolpaths, which is determined by the residual height h. The step-size LS refers to the distance of adjacent CC points on the same toolpath, which is related to the chord height error ε [23]. The curved surface machining schematic shown in Fig. 2 provides a good understanding of the concept of side-step length and step-size.

Fig. 2
figure 2

Surface machining schematic diagram

In order to calculate the side-step length in toolpath planning, the corresponding calculation should be made according to the characteristics of the surface and the residual height h. Figure 3 shows the plane machining, when the maximum residual height h is given; the corresponding side-step length L can be obtained as:

$$ L=2\sqrt{R^2-{\left(R-h\right)}^2}=2\sqrt{2 Rh-{h}^2} $$
(6)
Fig. 3
figure 3

Calculation schematic of side-step length for plane

A convex surface is shown in Fig. 4; assuming the curvature radius is ρ, the calculation equation for side-step length is as follows:

$$ h=\frac{\left(\rho +R\right)}{\rho}\sqrt{\rho^2-{\left(\frac{L}{2}\right)}^2}-\sqrt{R^2-{\left[\frac{\rho +R}{\rho}\frac{L}{2}\right]}^2}-\rho $$
(7)
Fig. 4
figure 4

Calculation schematic of side-step length for convex surface

In general, the residual scallop height h ≪ ρ, so Eq. (7) is simplified to:

$$ L=\sqrt{8 hR{\left(\frac{\rho }{R+\rho}\right)}^2}=2\sqrt{2 hR}\frac{\rho }{\left(\rho +R\right)} $$
(8)

For a concave surface as shown in Fig. 5, the side-step length can be obtained as:

$$ L\approx 2\sqrt{2 hR}\frac{\rho }{\left(\rho -R\right)} $$
(9)
Fig. 5
figure 5

Calculation schematic of side-step length for convex surface

As shown in Fig. 6, the straight segments are used to approximate the ideal trajectory in the actual machining. To control the quality of machined surface, a reasonable chord height error is set in the actual machining. After giving the chord height error, the step-size can be calculated as:

$$ {L}_s=2\sqrt{\rho^2-{\left(\rho -\varepsilon \right)}^2}=2\sqrt{2\rho \varepsilon -{\varepsilon}^2} $$
(10)
Fig. 6
figure 6

Model of step-size

The toolpath in the five-axis machining not only includes the cutter tip point trajectory but also the pose of the cutter during the movement [13]. The tool attitude is shown in Fig. 7; α represent tilt angle and β is yaw angle, which are obtained by rotating the tool axis vector around the YL-axis and ZL-axis in LCS, respectively. In local coordinate system PCXLYLZL, according to the vector [0, 0, 1, 0]T, the tool axis vectors expressed by tilt angles α and yaw angles β can be obtained as:

$$ {\mathbf{V}}_{axis}^{LCS}=\mathbf{Rot}\left({Z}_L,\beta \right)\cdot \mathbf{Rot}\left({Y}_L,\alpha \right)\cdot {\left[0,0,1,0\right]}^T $$
(11)
Fig. 7
figure 7

Tool axis vector and control angle in PCXLYLZL

In which, \( {\mathbf{V}}_{axis}^{LCS} \) refers to the tool axis vector in PCXLYLZL. Rot(ZL, β) and Rot(YL, α) represent the rotation matrices that rotate around the ZL-axis and YL-axis.

From the above, the toolpath calculation method including cutter tip points and tool axis vectors on the surface is obtained.

2.2 Calculation of inverse kinematics of machine tool

In 5-axis NC machining, tool axis vectors have different representation in different coordinate system. For example, tool axis vectors can be expressed by the angle values (θA and θC) of rotary axes in MCS (machine coordinate system). And the toolpath can be obtained through the method in the Section 2.1. In general, the cutter location files [P, V] = [x, y, z, ex, ey, ez] can be obtained in the CAM software, which contains cutter tip point coordinates and tool axis vectors expressed in WCS (workpiece coordinate system). So it is necessary to establish one-to-one correspondence between different coordinate systems through coordinate transformation. And the tool axis vector V = [ex, ey, ez]T in WCS should be transformed into V = [θA, θC] in MCS which can be read by 5-axis machine tools of A/C rotary axes.

The tool axis vectors V = [ex, ey, ez 0]T in WCS can be obtained by rotating the vector VM = [0 0 1 0]T in MCS around A-axis and C-axis. The equation can be obtained as:

$$ \mathbf{V}=\mathbf{Rot}\left(\mathbf{Z},{\theta}^C\right)\cdot \mathbf{Rot}\left(\mathbf{X},{\theta}^A\right)\cdot {\mathbf{V}}_M $$
(12)

In which θΓ(Γ = A or C) represents the rotary angles of machine tool, and the relationship of WCS and MCS is obtained as:

$$ {\displaystyle \begin{array}{l}\mathbf{M}=\mathbf{Rot}\left(\mathbf{Z},\kern0.3em {\theta}^C\right)\cdot \mathbf{Rot}\left(\mathbf{X},\kern0.3em {\theta}^A\right)\\ {}\kern1.3em =\left[\begin{array}{cccc}\cos {\theta}^C& -\cos {\theta}^A\cdot \sin {\theta}^C& \sin {\theta}^A\cdot \sin {\theta}^C& 0\\ {}\sin {\theta}^C& \cos {\theta}^A\cdot \cos {\theta}^C& -\sin {\theta}^A\cdot \cos {\theta}^C& 0\\ {}0& \sin {\theta}^A& \cos {\theta}^A& 0\\ {}0& 0& 0& 1\end{array}\right]\end{array}} $$
(13)

Therefore, from the Eqs. (12) and (13), the tool axis vectors can be expressed in WCS as:

$$ \left\{\begin{array}{l}{e}_x=\sin {\theta}^A\cdot \sin {\theta}^C\\ {}{e}_y=-\sin {\theta}^A\cdot \cos {\theta}^C\\ {}{e}_z=\cos {\theta}^A\end{array}\right. $$
(14)

Thus, the inverse kinematics conversion relation of the tool axis vectors between MCS and WCS are established as:

$$ \left\{\begin{array}{l}{\theta}^A=\arctan 2\left(\sqrt{e_x^2+{e}_y^2},{e}_z\right)\\ {}{\theta}^C=\arctan 2\left({e}_x,{e}_y\right)\end{array}\right. $$
(15)

So inverse kinematics calculated method from WCS to MCS is established. And tool axis vectors and rotary angles of machine tool can convert into each other.

2.3 Estimation of kinematic parameters for rotary axes

Given a machining surface S(u, v), the machining toolpath can be obtained by Section 2.1. During machining, the ball-end cutter contacts the curved surface at CC points and cuts along the toolpath. And the tool axis vectors are guaranteed to move along the specified pose. The large variation of tool axis vectors at adjacent CC points can easily cause a surge in the movement parameters of rotary axes, which affects the machining quality.

In the actual calculation, the improved finite difference method is adopted to calculate rotary axes’ velocity and acceleration. The toolpath obtained in Section 2.1 is composed of CC points’ coordinates and tool axis vectors. The ith CC point on the toolpath is denoted as PCi. At the point PCi, the angles of A/C rotary axes are calculated by the cutter location files of [P, V] = [x, y, z, ex, ey, ez], so the rotary axes’ angular velocity and angular acceleration are calculated by the discrete method. It is assumed that the feed speed is v when the cutter moves along the toolpath and remains unchanged, the arc length PCiPCi + 1 is approximately Li = |PCiPCi+ 1|, and the tool axis vector alters from Vi to Vi + 1. By inverse kinematics of machine tools, the rotary angle values of machine tools can be obtained at the corresponding CC posits through Eq. (15). As shown in the Fig. 8, each CC point corresponds to a set of A/C-axis angle values, so the discrete method is used to calculate rotary axes’ angular velocity and angular acceleration as:

$$ \left\{\begin{array}{l}{\boldsymbol{\upomega}}_i^{\varGamma }=v\cdot \frac{\theta_{i+1}^{\varGamma }-{\theta}_i^{\varGamma }}{L_i}\\ {}{\mathbf{a}}_i^{\varGamma }=2v\cdot \frac{{\boldsymbol{\upomega}}_{i+1}^{\varGamma }-{\boldsymbol{\upomega}}_i^{\varGamma }}{L_{i+1}+{L}_i}\end{array}\right.\kern1.2em \varGamma =A\kern0.5em \mathrm{or}\kern0.4em C $$
(16)
Fig. 8
figure 8

Calculation diagram of rotary angular velocity and acceleration

In which \( {\theta}_i^{\varGamma } \)(Γ =A or C) represents rotary angles at the ith CC point in machine tool. \( {\boldsymbol{\upomega}}_i^{\varGamma } \) and \( {\mathbf{a}}_i^{\varGamma } \) are the rotary axes’ angular velocity and angle acceleration at the ith CC point.

In order to better represent the rotary axes’ kinematical performance, the synthetic rotary axes’ angular velocity and angular acceleration are defined as:

$$ {\boldsymbol{\upomega}}_i=\left\{\begin{array}{l}\frac{\theta_{i+1}-{\theta}_i}{L_i}\cdot v=\sqrt{{\left({\boldsymbol{\upomega}}_i^A\right)}^2+{\left({\boldsymbol{\upomega}}_i^C\right)}^2}\kern1em i=1,\dots, n-1\kern0.1em \\ {}0\kern12.10001em i=n\kern1.5em \end{array}\right. $$
(17)
$$ {\mathbf{a}}_i=\left\{\begin{array}{l}2v\cdot \frac{{\boldsymbol{\upomega}}_{i+1}-{\boldsymbol{\upomega}}_i}{T_{i+1}+{T}_i}=\sqrt{{\left({\mathbf{a}}_i^A\right)}^2+{\left({\mathbf{a}}_i^C\right)}^2}\kern1.1em i=2,\dots, n-1\\ {}0\kern12.80001em i=1,n\end{array}\right. $$
(18)

Thus, the performance of the rotary axes can be predicted by Eqs. (17) and (18), which provides a basis of optimizing tool axis vector.

3 Global tool axis vector optimization based on minimum angular acceleration

In Section 2, the methods of toolpath generation and kinematics calculation are presented, and the inverse kinematics transformation is derived according to the machine structure. Then, the rotary axes’ kinematical parameters are estimated. In this section, a global optimization method for tool axis vectors is given.

In the process of local tool axis vector optimization, when the tool axis vector optimizing interval is overmuch, the local optimization method is time-consuming and ineffective. For the purpose of solving this problem effectively, a global tool axis vector optimization method based on the minimum angular acceleration is proposed. In the global tool axis vector optimization, there is a large amount of calculation when optimizing the tool axis vector of the entire toolpath directly, which is easy to produce a solution-free phenomenon. In order to reduce the calculation amount effectively and avoid the problem that the tool axis vector has no solution, the idea of global optimization is proposed based on segmented toolpath. Firstly, according to the interference judgment criterion, the feasible spaces of the tool axis vectors in the LCS are calculated. Then, the toolpath curve is segmented and the key tool axis vectors are set by the property of concavity or convexity for the toolpath curve. Finally, based on the principle of the minimum rotary axes’ angular acceleration, an improved tool axis vector interpolation algorithm is used to optimize the tool axis vectors in each interval. On this basis, the tool axis vectors at the joint position of the adjacent intervals are adjusted to ensure the smoothing of tool axis vectors on the entire toolpath.

3.1 Solving of feasible spaces for tool axis vectors

In the tool axis vector optimization process, a common method is optimizing tool axis vectors firstly and then judge whether the interference occurs when the cutter is milling the machined surface. When the curved surface is mostly convex, this method is more practical. However, the interference occurs easily when the ball-end cutter is machining concave surface, so the tool axis vector needs to be adjusted again. In order to effectively avoid the interference occurring to cutters and workpieces, the feasible space solution method of tool axis vectors for each CC point is given. And then, the feasible spaces of tool axis vectors at CC points are solved, which lays a foundation for the global tool axis vector optimization method.

According to the shape of surface, the machining toolpath is first generated by the equal residual scallop height method in the process of surface machining. Toolpaths are generated by direction-parallel cutting, and each of which has nk CC points (k = 1,..., N). Taking a toolpath as an example as shown in Fig. 9, the global tool axis vector optimization process is explained. To avoid interference after the tool axis vector optimization, the feasible space of tool axis vectors at each CC point on the toolpath is obtained by the C-space method in local coordinate system. To prevent local interference of cutters and workpieces, the effective cutting radius of the cutter should not be more than the minimum radius of curvature at the CC point [24], so the local interference-free region can be obtained as:

$$ {\rho}_t\le {\rho}_{S\min } $$
(19)
Fig. 9
figure 9

Curved surface and toolpath

In which ρt represents effective cutting radius of cutter. The ρt of ball-end cutter is equal to cutter radius R. ρSmin is the minimum value of curvature radius of the machined surface.

In terms of global interference, the cutter is simplified into a cylinder with an infinite length, the surface of cutter is denoted as St, and the surface to be machined is denoted as Sr. The global interference-free region can be obtained as:

$$ {d}_{r,t}=\left[{\mathbf{S}}^t-{\mathbf{S}}^r\right]\cdot \mathbf{N}>0 $$
(20)

where dr,t represents the directed distance between cutter surface St and machined surface Sr, and N is the normal vector of surface at CC point.

For quickly solving the feasible space of tool axis vectors in LCS, the C-space method is used in this study to traverse tilt angle and yaw angle. The coordinate system of two-dimensional C-space is established in Fig. 10 by taking the tilt angle α as the vertical axis and the yaw angle β as the horizontal axis. In this coordinate system, a rectangular region composed of αϵ[− π/2, π/2] and βϵ[− π, π] is called a C-space. Any point (α, β) of the C-space can represent the tool axis vector pose in LCS. To calculate the feasible tool axis vector in C-space, the two-dimensional C-space is discrete to obtain the matrix grid of M × N columns. By judging whether each matrix grid satisfies Eqs. (19) and (20), the feasible spaces of tool axis vectors in LCS are obtained. In the traversal process, the coordinates of the four vertices of each rectangular grid can be expressed as [(αi,  βj),  (αi,  βj + 1),  (αi + 1,  βj),  (αi + 1,  βj + 1)]. In order to make the calculation simplified, the intermediate point is used to represent the pose of cutter, as shown in Eq. (21):

$$ {C}_{i,j}=\left[\left({\alpha}_i+{\alpha}_{i+1}\right)/2,\left({\beta}_j+{\beta}_{j+1}\right)/2\right] $$
(21)
Fig. 10
figure 10

Discrete solution of feasible space for tool axis. a C-space gridding. b Feasible space of tool axis vector

The feasible space of tool axis vectors at each CC point in LCS can be calculated by the C-space method. According to the transformation relationship of LCS and WCS in Section 2.2, the feasible spaces of tool axis vectors in WCS are obtained, and then the feasible spaces of the tool axis vectors indicated by the rotary angles A and C in MCS can be obtained by inverse kinematics transform.

Through the above method, the feasible space of tool axis vectors can be obtained at each CC point in different coordinate systems, and the constraint conditions for tool axis vector optimization are determined, which lays a foundation for the global tool axis vector optimization.

3.2 Key CC points selection and tool axis vector determination

In Section 3.1, the feasible space of tool axis vectors is obtained at each CC point in different coordinate systems, which provides constraints for tool axis vector optimization. There exists the defect of large computation when directly optimizing tool axis vectors on the entire toolpath curve. To solve the problem of long calculation time due to large calculation amount, the toolpath needs to be segmented. For a toolpath curve, there are convex curve and concave curve. Therefore, according to the principle of concavity and convexity, the toolpath curve is divided into multiple curve segments, and the key tool axis vectors are set at the end position of each curve segment, and then the tool axis vectors of each interval segment are optimized to achieve the overall optimization. However, for a given toolpath, it is generally difficult to express the toolpath information using equations. Therefore, it is necessary to obtain the concavity and convexity of the toolpath curve by discrete method and divide the toolpath curve according to the property of concavity or convexity for the toolpath. The end point and the junction of concavity and convexity of the toolpath, that is the inflection point, are considered as the key CC points of tool axis vectors. Constrained by the feasible spaces of CC points, tool axis vectors are optimized as the critical tool axis vectors. Then, in each interval, tool axis vectors are homogenized to obtain the smoothing tool axis vector without interference on the entire toolpath.

For a given curve, the curve equation is f(x) and the curve is assumed to be monotonic in the interval [x1, x2]. The concavity and convexity of the curve can be judged by the end point value and the midpoint value, as shown in Fig. 11.

Fig. 11
figure 11

Judgment of concavity and convexity. a Convex curve. b Concave curve

As shown in the Fig. 11a, according to the relationship between the curve and the line, the curve in the figure satisfies the following equation as:

$$ f\left(\frac{x_1+{x}_2}{2}\right)>\frac{f\left({x}_1\right)+f\left({x}_2\right)}{2} $$
(22)
$$ {f}^{{\prime\prime} }(x)<0 $$
(23)

When the curve equation satisfies the Eqs. (22) and (23), the curve is a convex curve. Similarly, the curve in Fig. 11b satisfies the equation as:

$$ f\left(\frac{x_1+{x}_2}{2}\right)<\frac{f\left({x}_1\right)+f\left({x}_2\right)}{2} $$
(24)
$$ {f}^{{\prime\prime} }(x)>0 $$
(25)

When the curve equation satisfies Eqs. (24) and (25), the curve is a concave curve.

However, for a curved surface, the machining toolpath curve cannot be clearly expressed by the equation most of the time. In this case, the cutter location files of the toolpath curve obtained by UG are used to judge the concavity and convexity of the curve by means of discrete methods. The cutter location files contain the cutter position information {[P,V]1, [P,V]2, …, [P,V]n} of the n CC points on the toolpath. From the calculation method of the CC points described by Eq. (5) in Section 2.1, the coordinates of the CC points PCi = (xci, yci, zci) on the toolpath curve can be obtained. Using the finite difference method to solve the derivative, the first derivative of toolpath curve can be expressed as:

$$ {f}^{\prime}\left({x}_{i,i+1}\right)=\frac{z{c}_{i+1}-z{c}_i}{\sqrt{{\left(x{c}_{i+1}-x{c}_i\right)}^2+{\left(y{c}_{i+1}-y{c}_i\right)}^2}}\kern1em 1\le i\le n-1 $$
(26)

The second derivative of the toolpath curve is expressed as:

$$ {f}^{{\prime\prime}}\left({x}_i\right)=\frac{z{c}_{i+1}-2z{c}_i+z{c}_{i-1}}{\sqrt{{\left(x{c}_i-x{c}_{i-1}\right)}^2+{\left(y{c}_i-y{c}_{i-1}\right)}^2}\sqrt{{\left(x{c}_{i+1}-x{c}_i\right)}^2+{\left(y{c}_{i+1}-y{c}_i\right)}^2}}\kern1em 2\le i\le n-1 $$
(27)

The first and second derivatives on the toolpath curve can be obtained by Eqs. (26) and (27). The point where the first derivative of the toolpath curve is zero is called the extreme point. According to the value of the second derivative of the toolpath curve, concavity and convexity of the toolpath curve can be judged. When the second derivative satisfies the formula f(xi) > 0, the curve is a concave curve, and when the formula f(xi) < 0, the curve is a convex curve. After solving the concavity and convexity, the point that satisfies the formula f(xi) = 0 is called the inflection point, which is the boundary point on the toolpath. After calculating extreme points and inflection points, the sequence numbers of key CC points on the toolpath can be obtained. Thus, the position of key CC points on the toolpath curve are shown in Fig. 12.

Fig. 12
figure 12

Position of extreme points and inflection points on toolpath

Suppose there are m inflection points on a toolpath, and the key tool axis vectors are set at the inflection points of the toolpath. The toolpath curve can be divided into m + 1 interval segments [ei, fi]. Constrained by the feasible spaces of the critical tool axis vectors, the key tool axis vectors are set, and the other tool axis vectors are optimized in each interval segment to achieve the global optimization.

The tool axis vectors at key CC points on the toolpath are obtained by the mentioned method, as shown in Fig. 13. According to the feasible space solution method in Section 3.1, the feasible spaces for the tool axis vectors at each CC points are obtained. With this constraint, the tool axis vectors are adjusted at this position; the smooth transition of the tool axis vector during the machining process is ensured, reducing the vibration caused by the unsteady feed of rotary axes, and improving the surface quality.

Fig. 13
figure 13

Key tool axis vector selection

3.3 Tool axis vector optimization and adjustment

In Section 3.1, the feasible spaces solution method of tool axis vectors at the CC points are given. The tool axis vectors V[Vfir, V1,…,Vm, Vend] at the key CC points are obtained in Section 3.2 through the judgment of concavity and convexity of the toolpath curve, and the toolpath curve is divided into m + 1 interval segments. In this section, the tool axis vector optimization method in each interval is mainly introduced.

In order to better express the optimization effect of tool axis vector, the objective function is constructed as:

$$ \left\{\begin{array}{l}\min f=\sum \limits_{i=1}^{n-1}{\left({\omega}_{i+1}-{\omega}_i\right)}^2\\ {}s.t.\kern0.7em {\mathbf{V}}_i\in {\boldsymbol{\Omega}}_i\end{array}\right. $$
(28)

In which ωi is the angular velocity value at the ith CC point, and Vi and Ωi, respectively represent tool axis vector and feasible space of tool axis vectors at the ith CC point.

To minimize the function, Eq. (28) is derived to obtain Eq. (29) as:

$$ {f}^{\prime }=2\sum \limits_{i=1}^{n-1}\left({\omega}_{i+1}-{\omega}_i\right) $$
(29)

When ωi + 1 = ωi, the above formula takes the minimum value.

In actual machining process, the feed speed will not remain constant. In this study, the influence of the feed speed is ignored and the feed speed between adjacent cutter contact points are considered constant. The following relationship exists between adjacent cutter contact points in surface machining.

$$ {\omega}_i{t}_i={\theta}_i $$
(30)
$$ {L}_i=v\cdot {t}_i $$
(31)

In which θi is the angle of adjacent tool axis vectors at adjacent CC points, Li is the arc length of adjacent CC points, and v and ti represent the feed speed and the time of adjacent CC points, respectively.

The combination of Eqs. (30) and (31) can be obtained as:

$$ {\theta}_i={\omega}_i\cdot \frac{L_i}{v} $$
(32)

When the feed speed v is considered to be constant, the minimum value of the objective function occurs at ωi + 1 = ωi, so there is:

$$ \frac{\theta_i}{\theta_{i+1}}=\frac{L_i}{L_{i+1}} $$
(33)

According to the relationship of Eq. (33), it can be obtained as

$$ \frac{\theta_i}{\theta_i+{\theta}_{i+1}}=\frac{L_i}{L_i+{L}_{i+1}} $$
(34)
$$ \frac{\sum \limits_{i=e}^i{\theta}_i}{\sum \limits_{i=e}^f{\theta}_i}=\frac{\sum \limits_{i=e}^i{L}_i}{\sum \limits_{i=e}^f{L}_i} $$
(35)

From the above derivation, to minimize rotary axes’ angular acceleration, the angle of the adjacent tool axis vectors at adjacent CC points should be proportional to the arc length of adjacent CC points. Furthermore, it can be further known that the proportion of the angle of adjacent tool axis vectors in total angle should be equal to the proportion of the arc length of the adjacent CC points in total arc length in the optimizing interval [e, f].

In Section 3.2, m + 1 toolpath intervals and m key tool axis vectors are obtained, taking one of the intervals [e, f] as an example to illustrate the tool axis vector optimization method. At CC points PCe and PCf, the tool axis vectors are set as Ve and Vf. The tool axis vectors in [e, f] can be calculated by formula interpolation.

$$ {\mathbf{V}}_i=\kappa \left(\lambda \right)\cdot {\mathbf{V}}_e+\mu \left(\lambda \right)\cdot {\mathbf{V}}_f\kern1.9em \lambda \in \left[0,1\right] $$
(36)

In which Vi represent the tool axis vectors in the interval [e, f]. κ(λ) and μ(λ) represent coefficients on variable λ, λ ∈ [0, 1].

To avoid the problem of uneven angles of adjacent tool axis vectors caused by linear interpolation, the spherical interpolation method is adopted, as shown in the Fig. 14.

Fig. 14
figure 14

Spherical interpolation method

The coefficients are related to the position of tool axis vectors. Equation (36) should be dotted product with Ve and Vf respectively to calculate coefficients, which can be expressed as:

$$ \left\{\begin{array}{l}{\mathbf{V}}_e\cdot {\mathbf{V}}_i=\kappa \left(\lambda \right){\mathbf{V}}_e\cdot {\mathbf{V}}_e+\mu \left(\lambda \right){\mathbf{V}}_e\cdot {\mathbf{V}}_f\\ {}{\mathbf{V}}_f\cdot {\mathbf{V}}_i=\kappa \left(\lambda \right){\mathbf{V}}_f\cdot {\mathbf{V}}_e+\mu \left(\lambda \right){\mathbf{V}}_f\cdot {\mathbf{V}}_f\end{array}\right. $$
(37)

Since Ve, Vf, and Vi are unit tool axis vectors, Eq. (37) can be translated as:

$$ \left\{\begin{array}{l}\cos \lambda {\theta}_Q=\kappa \left(\lambda \right)\cdot 1+\mu \left(\lambda \right)\cdot \cos {\theta}_Q\\ {}\cos \left[\left(1-\lambda \right){\theta}_Q\right]=\kappa \left(\lambda \right)\cdot \cos {\theta}_Q+\mu \left(\lambda \right)\cdot 1\end{array}\right. $$
(38)

From Eq. (38), the coefficient calculation can be obtained as:

$$ \left\{\begin{array}{l}\kappa \left(\lambda \right)=\frac{\sin \left({\theta}_Q\cdot \left(1-\lambda \right)\right)}{\sin {\theta}_Q}\\ {}\mu \left(\lambda \right)=\frac{\sin \left({\theta}_Q\cdot \lambda \right)}{\sin {\theta}_Q}\end{array}\right. $$
(39)

In order to make the optimization function take the minimum value, the calculations of the variables λand θQ are obtained as:

$$ \left\{\begin{array}{l}\lambda =\frac{\sum \limits_{i=e}^i{L}_i}{\sum \limits_{i=e}^f{L}_i}\\ {}{\theta}_Q=\operatorname{arccos}\frac{{\mathbf{V}}_e\cdotp {\mathbf{V}}_f}{\mid {\mathbf{V}}_e\Big\Vert {\mathbf{V}}_f\mid}\end{array}\right. $$
(40)

By Eqs. (36)–(40), the improved calculation method of tool axis vectors considering the distance of adjacent CC points can be derived as:

$$ {\mathbf{V}}_i=\frac{\sin \left({\theta}_Q-\frac{\sum \limits_{i=e}^i{L}_i}{\sum \limits_{i=e}^f{L}_i}{\theta}_Q\right)}{\sin {\theta}_Q}{\mathbf{V}}_e+\frac{\sin \left(\frac{\sum \limits_{i=e}^i{L}_i}{\sum \limits_{i=e}^f{L}_i}{\theta}_Q\right)}{\sin {\theta}_Q}{\mathbf{V}}_f,\kern1.32em i\in \left[e+1,f-1\right] $$
(41)

Equation (41) considers the problem of rotary axes’ kinematical fluctuation due to the difference in machining time caused by the unequal arc length of adjacent CC points, so that the kinematical parameters of the rotary axes become more stable.

From the above analysis, the optimized tool axis vectors in the interval are obtained by the improved tool axis vector optimization method in each tool axis vector optimizing interval [ei, fi], and overall tool axis vector optimization process is shown in Fig. 15.

Fig. 15
figure 15

Tool axis vector optimization flowchart

When the proposed global optimization method is adopted directly to optimize tool axis vectors, it is easy to cause the large tilt angle of tool axis vectors because of the asymmetrical distribution of the convex section on the toolpath, as shown in Fig. 16, which is not conducive to the machining.

Fig. 16
figure 16

Large tilt angle of tool axis vectors due to asymmetrical distribution of convex section in toolpath

In order to avoid the above issue, when the curvature of toolpath interval changes greatly, the extreme point should be guaranteed to be in the middle of the interval of toolpath. For the position in Fig. 16, an additional tool axis vector is inserted on convex section of the toolpath to make it symmetric, as shown in Fig. 17. Therefore, the toolpath curve is further divided and tool axis vectors are optimized by global optimization method as shown in Fig. 18.

Fig. 17
figure 17

Division of tool axis vector optimizing interval

Fig. 18
figure 18

Optimized tool axis vectors

Through the above method, tool axis vectors in each interval are optimized, and the rotary axes’ angular acceleration is minimized. However, when optimizing the tool axis vectors, only the tool axis vector smoothing in one interval is considered, but the tool axis vectors smoothing at adjacent intervals are not considered. To solve the abrupt change of the angular velocity between the adjacent interval segments [ei, fi] and [ei + 1, fi + 1], as shown in Fig. 19, the tool axis vectors in this region are re-optimized by the tool axis homogenization idea to meet the smooth transition at adjacent sections, so as to ensure the smooth transition of tool axis vectors on the entire toolpath.

Fig. 19
figure 19

Schematic diagram of tool axis vector global optimization

4 Experiment results and discussion

In order to verify the correctness and validity of the proposed global tool axis vector optimization method, a sine surface is designed in Fig. 9 for experimental verification. The initial cutter location files are obtained after setting the residual height and the step-size by using the line cutting method. And the rotary axes’ angular velocity and angular acceleration are calculated by finite difference method. According to the improved tool axis vector optimization algorithm, the effectiveness of the method is verified from both simulation and experimental verification.

4.1 Simulation analysis

Commercial CAM software, such as UG, sets fixed tilt angle and yaw angle to generate a machining toolpath. To make tool axis vectors smooth, the global optimization method is given in Section 3. In this section, the rotary axes’ kinematical parameters of the machine tool are estimated and simulated to prove the validity of proposed method.

The experimental machining model is shown in Fig. 9; a sinusoidal surface is established by UG; the tilt angle is set to 5° to generate machining toolpath. In order to simulate accurately, the processing parameters are consistent with the experiment. The spindle speed is set to 3000 r/min, the feed speed is 250 mm/min, the maximum residual scallop height during machining is set to 0.02 mm, the cutting mode is one-way row cutting, and the SANDVIK two-blade ball-end milling cutter with a diameter of 6 mm is used for machining. So the cutter location files are obtained, and the angle values of rotary axes are obtained by inverse kinematics transformation as shown in Fig. 20. According to Sections 3.1 and 3.2, the feasible spaces of tool axis vectors and key tool axis vectors on the toolpath are obtained. Then, the tool axis vectors are optimized by global optimization method proposed in Section 3.3. Taking the CC points sequences {1–8} of the toolpath as an example, the initial tool axis vectors before optimization are {(0, − 03281, 0.9447), (0, − 0.6063, 0.7952), (0, − 0.7259, 0.6878), (0, − 0.7870, 0.6169), (0, − 0.8267, 0.5626), (0, − 0.8500, 0.5268), (0, − 0.8679, 0.4968), (0, − 0.8804, 0.4742)}, and the corresponding rotary axes’ angles of the machine tool are {(− 19.1507, 180), (− 37.3222, 180), (− 46.5477, 180), (− 51.9082, 180), (− 55.7644, 180), (− 58.2102, 180), (− 60.2138, 180), (− 61.6904, 180)}. According to the global optimization method proposed in Section 3.3, the tool axis vectors are optimized as {(0, − 03281, 0.9447), (0, − 0.3512, 0.9363), (0, − 0.3737, − 0.9276), (0, − 0.3952, 0.9186), (0, − 0.4185, 0.9082), (0, − 0.4390, 0.8985), (0, − 0.4611, 0.8874), (0, − 0.4816, 0.8764)}, and the corresponding angles of the rotary axes are {(− 19.1507, 180), (− 20.5602, 180), (− 21.9411, 180), (− 23.2801, 180), (− 24.7359, 180), (− 26.0394, 180), (− 27.4562, 180), (− 28.7914, 180)}.

Fig. 20
figure 20

Rotation axes’ angle before tool axis vector optimization

To explain the effectiveness of global optimization from the simulation point of view, the feed speed is set to 250 mm/min during the simulation. And the angle coordinate value and the rotary axes’ synthetic kinematical parameters (angular velocity and angular acceleration) are calculated through Section 2.3 in MATLAB. The cumulative arc length of the toolpath is taken as the horizontal coordinate, and the kinematical parameters of the AC axis are taken as the vertical coordinate; the rotary axes’ synthetic angular velocity and angular acceleration before optimization are as shown in Fig. 21.

Fig. 21
figure 21

Rotary axes’ synthetic kinematical parameters before tool axis vector optimization

In order to make the rotary axes of machine tools smoothly, an improved global optimization method aiming at minimizing angular acceleration is proposed in Section 3. After global optimization for the tool axis vectors, the rotary axes’ angle values are obtained by inverse kinematics transformation as shown in Fig. 22. And the synthetic kinematical parameters of rotary axes are calculated after optimization, which are shown in Fig. 23.

Fig. 22
figure 22

Rotation axes’ angle after tool axis vector optimization

Fig. 23
figure 23

Rotary axes’ synthetic kinematical parameters after tool axis vector optimization

The rotary axes’ synthetic kinematical parameters before and after optimizing tool axis vectors are estimated as shown in Figs. 21 and 23. It can be clearly seen that there are three large fluctuations in the figures. The reason for the large fluctuation of this position is that the limitation of the A-axis rotation range causes the C-axis to produce three times of 180° large rotations. According to the above simulation, the rotary axes’ synthetic angular velocity and angular acceleration are reduced after the global tool axis vector optimization. Since the feed speed is consistent before and after optimizing tool axis vectors, the machining efficiency will not be reduced. After the tool axis vector optimization, the maximum rotary axes’ angular velocity is decreased from 1010 to 900°/s, which is reduced by 10.9%, and the maximum angular acceleration is decreased from 6110 to 4590°/s2, which is reduced by 24.8%. It can be seen from the simulation analysis that after tool axis vector optimization, the rotary axes of machine tools have better stability, and the angular velocity and angular acceleration fluctuation are also significantly reduced, which theoretically improve the surface quality.

4.2 Experimental verification

An actual processing experiment is conducted to prove the validity of global optimization method for tool axis vectors. For the sine surface with the sharp-curvature characteristics as shown in Fig. 9, the aviation 7075 aluminum alloy was used as the raw material to carry on the test verification on the five-axis NC milling machine. The processing parameters are consistent with those set in simulation. The machining cutter is shown in Fig. 24.

Fig. 24
figure 24

SANDVIK 1B230-0600-XA 1630 type ball-end milling cutter

In order to avoid the machining errors caused by positioning and convenient to compare the machining effects, the global tool axis vector control method proposed in the study and the traditional method of tool axis vector planning are used for finish machining on the same rough piece in the experiment. Figure 25 is the experimental machining process. And the machining results are shown in Fig. 26, and it can be found that the machining quality is better after the global optimization.

Fig. 25
figure 25

Experimental machining process of workpiece

Fig. 26
figure 26

Comparison of machining results

Due to the large change of the rotary axes’ angular velocity and angular acceleration, the kinematical performances are difficult to meet the requirements, so the machined surface has obvious chatter marks, affecting the machining quality. In Section 4.1, it is verified by simulation analysis that the global optimization method based on the minimum rotary axes’ angular acceleration proposed in this paper can significantly reduce the rotary axes’ kinematical parameters, so it is of great significance to improve the quality of machining.

To prove the validity of the global tool axis vector optimization method proposed in this study for improving the machining quality, the contact roughness profiler (PGI 840) was used to measure the roughness of the surface. As the measurement position is shown in Fig. 26, the direction A reflects the surface roughness along side-step length, which is determined by the scallop height between adjacent toolpaths, so before and after optimization, the surface roughness of the A direction is unchanged. And the direction of B reflects the machining contour, which can reflect the machining quality before and after optimization. The measured surface roughness in the A and B direction is shown in Figs. 27 and 28, respectively. It can be seen from Fig. 27 that the surface machining quality does not change substantially along the A direction. As shown in Fig. 28, the surface roughness in B direction after the global optimization is slightly better than that before the tool axis vector optimization. The main reason is that the curvature of this area is relatively small, and the effect of the tool axis vector optimization is relatively small.

Fig. 27
figure 27

Surface roughness in direction A. a Before optimization. b After optimization

Fig. 28
figure 28

Surface roughness in direction B. a Before optimization. b After optimization

In order to better reflect the surface quality after processing, the Alicona three-dimensional shape measuring instrument is used to scan and measure the position with large curvature on curved surface, and the measurement results are shown in Fig. 26. The cross-sectional analysis is performed on the scan area to obtain the cross-sectional profile curves as shown in Fig. 29. In order to obtain the measured cross-sectional profiles, the measured data points are fitted in the MATLAB to obtain the contours after surface machining, as shown in Fig. 30. The maximum machining error is defined as the difference between the actual machined surface and the ideal surface at the same position, so it can be seen that the contour of the machined surface which tool axis vectors are optimized is closer to the ideal surface. And the maximum machining error is decreased from 0.7 to 0.2 mm after the tool axis vector optimization, which is reduced by 70%.

Fig. 29
figure 29

Scanning section and contour before and after tool axis vector optimization

Fig. 30
figure 30

Surface contour fitting curve

5 Conclusions

In the process of machining complex surface with 5-axis machine, affected by the shape of the surface, the local optimization method of the tool axis vector may not reduce the rotary axes’ angular velocity and acceleration because the optimization intervals are too much. To solve this issue effectively, the global tool axis vector optimization method for curved surface machining is presented in this paper. Without changing the CC points at the machined surface, the rotary axes’ angular velocity and angular acceleration can be reduced by the global tool axis vector optimization method aiming at minimum angular acceleration, which can improve the machining quality of complex curved surface. At first, the feasible spaces of tool axis vectors at the CC points are obtained. And the toolpath is divided by the concavity and convexity of the toolpath curve, and then, key tool axis vectors on the toolpath curve is determined. Then, the tool axis vectors are optimized aiming at minimizing angular acceleration in each interval, and the tool axis vectors at the joint position of the adjacent segment are adjusted to avoid the abrupt change of tool axis vectors. Finally, simulation and experiment results verify that the global optimization method can effectively reduce the rotary axes’ kinematical parameters of machine tools, reduce machining errors, and improve the quality of machined surface. In summary, the research results in this paper can remarkably improve the machining quality of a surface and provide a guarantee for high-quality and high-efficiency machining.