Optimal Linear Interpolation of Planar Curves for NC Contour Machining

In NC machining of planar contours, the cutter path is frequently approximated by linear interpolation to a contour curve as target. In this situation, the interpolation error should be measured along the normal direction of the contour curve, and it is desired that only the fewest linear segments are needed with respect to the specified accuracy. However, how to determine the parameters of segment to match these requirements has not been completely solved. This paper presents a new linear interpolation approach for this problem. The approach is named as the optimal linear interpolation method and has three features which include: (1) the interpolation error along the normal direction of object curve satisfies the specified accuracy, and the number of the required segments is the fewest simultaneously; (2) the connection between any two adjacent segments on generated cutter path is natural and smooth, and the generation of extremely short segment is avoided as much as possible; (3) the algorithm is simple and with a high computation efficiency. The effectiveness of the proposed approach has been sufficiently confirmed by applying it to two interpolation examples of planar cam contours. At the same time, the reduction effect of interpolation data has also been verified through comparing the segment number required by the proposed method and Nishioka’s method, which is specially developed to precision machining of planar cam contour, relative to the same interpolation conditions.


Introduction
In science and engineering fields such as numerical analysis, image processing and numerical function generator design, a complex curve defined in a real interval [x L , x R ], which is described as y = f (x), is often fitted with piecewise linear approximation, in order to improve the calculation efficiency and save the memories. In such situation, the interpolation error for a linear segment of y = a i x + b i is usually expressed as Through evaluating the interpolation error in some form of average value over the interval, several methods have been proposed to calculate and determine the parameters of interpolation segments [1]∼ [7].
On the other hand, in the design and manufacturing of planar contours, the profile is also frequently approximated by linear interpolation. In this case, the interpolation error should be measured along the normal direction of the profile curve [8] [9]. However, the calculation of such the interpolation error is complicated and costly. Therefore, a method of generating NC cutter path in an incremental form has been proposed, where the interpolation error is checked along each feed direction and the increment of cutter path * Corresponding: chiu@ip.kyusan-u.ac.jp † Kyushu Sangyo University 2-3-1, Matsukadai, Higashi-ku, Fukuoka City, Japan 813-8503 is determined in each sampling step relative to the contour curve to be machined [10]. Moreover, in the field of graphic processing, a linear interpolation approach has also been published, in which the object curve is replaced with a finite number of discrete points and the distance from each point to its corresponding segment is taken as the interpolation error [11]. The handling of interpolation error is different from the definition of the ISO and JIS standard. Furthermore, from the standpoint of NC machining, if the required interpolation accuracy is satisfied, the fewer the number of interpolation segments, the more advantageous [12]∼ [14]. For this purpose, Nishioka has developed a linear interpolation approach dedicated to precision machining of planar cam contours [15]. However, in Nishioka's method, the function form of the object curve is limited to the parametric type, and an approximation way shown in Appendix A is adopted to simplify the calculation of interpolation error. In addition, for contour portions with different concave or convex characteristic the corresponding linear segments are respectively located on both sides of the contour curve. And thus, the value of the interpolation error for whole contour is twice the specified interpolation accuracy value. Similar handling for interpolation error can be seen in other NC tool path generation approaches [16] [17].
This paper presents a new linear interpolation approach of planar curves for NC contour machining. By this ap-proach, the obtained interpolation error, which is measured along the normal direction of the object curve, strictly satisfies the specified interpolation accuracy and the linear segment number required is the fewest simultaneously. Chapter 2 first explains the basic interpolation concepts, and then develops a simple and efficient calculation algorithm. In Chapter 3, the effect of the proposed approach is discussed and verified by comparing the interpolation results from the proposed method and Nishioka's method, for two examples of planar cam contouring. Finally, Chapter 4 summarizes the main results of this research. In this chapter, we first explain some basic concepts of the linear interpolation for a planar curve f (x) that is a single-valued function defined by the following equation.

Optimal Linear
In the domain of f (x) , [x L , x R ], the first derivative dy/dx is continuous, and the second derivative d 2 y/dx 2 is also continuous except for a finite number of points. And, the number of inflection points of d 2 y/dx 2 = 0 is limited, too. Therefore, the domain [x L , x R ] can be divided into a finite number of single-concave and single-convex interval, i.e., an interval whose all internal points are d 2 y/dx 2 ≥ 0 or d 2 y/dx 2 ≤ 0 except for both end points. Without causing confusion, we only call a single-concave or single-convex interval as a concave or convex one in the following. According to the definition on the form deviation of planar contour in the ISO and JIS standard [8] [9], as shown in Fig. 1, relative to the contour curve f (x), the shape error, i.e., form deviation, of a Point C outside the curve is taken as the distance between Point C and Point D. Here, Point D is a point on the curve f (x) and the normal line of f (x) at Point D, n d , passes through Point C. In this study, the value of the shape error is defined as negative if Point C is located on the substantial side or as positive if located on the non-substantial side of the object contour.
On the other hand, the curve shown in Fig. 1 is considered as a portion limited to one convex interval, or one concave interval, of the contour curve f (x), and a straight line indicated as l intersects the curve at two points, Point M and Point N. Here, it is assumed that the shape error of the line l between Point M and Point N is sufficiently smaller than the radius of curvature of the curve f (x). If the tangent line of Point P on the curve is parallel to l and the normal line of f (x) at Point P, n p , intersects l at Point Q, the distance PQ is the extremum value of the shape error within the part MN of l. In addition, for a point of l outside the part MN, the farther away from Point M or Point N, the greater the absolute value of the shape error becomes.
In the following, the shape error of the interpolation straight line with respect to the object curve is taken as the interpolation error, corresponding to the definition mentioned above. In addition, considering the difference be-  tween the substantial side and non-substantial side of the object contour, in this study, we call a contour curve portion as convex one if a straight line segment formed by any two points on the portion is located on the substantial side of the contour; Conversely, if the straight line segment is located on the non-substantial side, the contour curve portion is called as concave one. Figure 2 shows a contour curve f (x) which is limited to a single-convex or a singleconcave interval. Here, n a is the normal line at the start point A (x a , y a ) of f (x), and y ′ p is the derivative of Point P on the f (x), i.e., y ′ p = dy/dx| x=xp . A straight line l which has a slope equal to y ′ p and passes through Point S (x s , y s ) designated on n a can be presented by the following equation.

Determination of a Linear Segment Having a Required Interpolation Accuracy Value and Passing through a Designated Point
The intersection point of n p , the normal line of Point P, with l is Point Q. The distance e from Point P to the line l is the extremum of the interpolation error of l, and its value can be calculated by the following equation.
Where the value of the sign coefficient m is set as −1 if the point Q is inside the substantial side of the contour, otherwise it is set as +1. In other words, m = −1 for a convex interval of f (x) and m = +1 for a concave interval. Therefore, when the required interpolation accuracy value is ±E 0 , the position of Point P and the slope k of l can be determined by solving the following equation. The position of the intersection R (x r , y r ) between l and f (x) can be determined by solving the following equation.
On the other hand, if the derivative of a point on the contour, Point T , whose position is on the outside of Point R, is written as y ′ t , i.e., y ′ t = dy/dx| x=xt , the normal n t of Point T can be written as follows: Solving the simultaneous equations of Eq. 6 and Eq. 2, the position of Point V, i.e., the intersection point of n t and l, can be determined. Therefore, the position of Point T can be obtained by solving the following equation together with Eq. 6 under a condition of making the absolute value of the interpolation error of Point V equal to the required accuracy value E 0 .
When the portion of the straight line l between Point S and Point V is used as an interpolation segment, in order to guarantee the interpolation error of the entire segment within the required accuracy value, the position of Point S must be limited within a range, i.e., the distance from Point S to Point A along the normal n a is between ±E 0 .

Optimal Linear Interpolation Algorithm
In this study, the linear interpolation calculation is performed for each convex and concave interval of the contour curve f (x) in turn. With a specified interpolation accuracy value ±E, the interpolation calculation algorithm can be summarized as follows.
Firstly, the domain of the contour curve f (x) is divided into single-convex and single-concave intervals based on the value of the second derivative. As the details of the division processing, sample points are determined in order from the left end x L of the domain [x L , x R ] of f (x) with an appropriate increment, and the value of the second derivative at each point is calculated. For two adjacent points whose sign of the second derivative is opposite, one inflection point of d 2 y/dx 2 = 0 between these two points is determined by using the bisection technique [18]. The obtained inflection point is exactly the demarcation point between convex interval and concave interval. Then, the convex-concave characteristics of each interval is decided corresponding to the substantial side position of the contour. For the contour curve portion due to the j-th interval x a j , x b j , the start point is described as A j x a j , y a j and the end point as B j x b j , y b j in the following.
The interpolation calculation of the j-th interval consists of two processes. In Process I, the needed number of segments is decided, and the parameter for each segment is computed and recorded. In Process II, the bisection method is used to minimize the extremum value of the interpolation error of the segment. At the beginning of the calculation the initial value of E 0 in Eq. 4 and Eq. 7 is set at E.
(1) Process I Each segment is determined through the operation process shown in Fig. 3 by solving Eq. 4, Eq. 5 and Eq. 7 in turn. That is, after determining the first segment by taking Point A j as the start point, the end point of the previous segment is used as the start point of the next segment, and the parameters of each segment are calculated and recorded in order. In the calculation of the i-th segment, three feature points P i x pi , y pi , R i (x ri , y ri ), and T i (x ti , y ti ) are sequentially obtained and judged by step 1, step 2 and step 3.
Step1 : Solve Eq. 4 to decide Point P i x pi , y pi . If x pi ≥ x b j , take the needed number of segments n as n = i and go to Process II; Otherwise, go to Step 2.
Step2 : Solve Eq. 5 to decide Point R i (x ri , y ri ). If where ε is a pre-defined convergence limit value, take the number n of segments as i and the extremum of the interpolation error as ±E 0 , and finish the interpolation calculation for the j-th interval. In a case of x ri − x b j > ε, if x ri > x b j , take the needed number of segments n as n = i and go to Process II; Otherwise, go to Step 3.
Step3 : Solve Eq. 7 to decide Point T i (x ti , y ti ). If x ti ≥ x b j , take the needed number of segments n as n = i + 1 and go to Process II; Otherwise, renew i as i + 1 and go to Step 1 for calculating the next segment.
(2) Process II Process II consists of Step 4 to determine the initial condition of the bisection optimization and Step 5 to minimize the extremum value of the interpolation error.
Step4 : Record the current value of E 0 in E 2 , update a new value of E 0 as 0.95E 0 and return to Process I. In the calculation returning to Process I, fix the number of segments to n, calculate and update the parameters of each segment, but only judge the x coordinate of the feature point R n (x rn , y rn ) of the n-th segment. If x rn − x b j ≤ ε, take the extremum of the interpolation error as ±E 0 and finish the interpolation calculation for the j-th interval. In a case of x rn − x b j > ε, if x rn > x b j return to the beginning of Step 4; Otherwise, record the current value of E 0 in E 1 and go to Step 5.
Step5 : Set a new value of E 0 as 0.5(E 1 +E 2 ) and return to Process I. In the calculation returning to Process I, fix the number of segments to n, calculate and update the parameters of each segment, but only judge the x coordinate of the feature point R n (x rn , y rn ) of the n-th segment, just the same with Step 4. If x rn − x b j ≤ ε, take the extremum of the interpolation error as ±E 0 and finish the interpolation calculation for the j-th interval.
In a case of x rn − x b j > ε, if x rn > x b j renew the value of E 2 as the current value of E 0 and return to the beginning of Step 5; Otherwise, renew the value of E 1 as the current value of E 0 and return to the beginning of Step 5.
In Process I, Newton-Raphson's method [19] is applied for solving Eq. 4, Eq. 5 and Eq. 7 with a convergence limit value, i.e., the ε value mentioned above. The value of derivative dF (x) /dx required in the processing is obtained by numerical differentiation technique. Applying the bisection method in Process II is to make the processing to minimize the extremum of the interpolation error robust.
In addition, when the value of x involved in the calculations of Step 1 to Step 3 exceeds x b j , it is necessary to extend the definition of f (x) in order to carry out the calculation smoothly. In this study, as the extension of the contour curve for such situation, a circular arc f (x) * of radius R tangent to f (x) at the interval end point B j x b j , y b j is introduced, as shown in Fig. 3. That is, the original contour curve f (x) is used in the calculation of x ≤ x b j and f (x) * is used as the contour curve for the calculation of x > x b j . f (x) * has the same concave-convex characteristic as the j-th interval of f (x), and its center position (x c , y c ) is decided by Eq. 8.
Where the values of the angle α and the sign coefficient m * is given by the following equation.
And, as a single-valued function, f (x) * is defined by Eq. 10.
Obviously, the linear segments obtained by the above algorithm satisfy the specified interpolation accuracy and at the same time the segment number required is the fewest. Moreover, since the start point of the first segment and the end point of the last one overlap with the start and end point of the contour curve portion, respectively, the segment connection between every two intervals of the contour curve is made smoothly and naturally. Furthermore, by setting the extremum of the interpolation error of each segment to the same value, the generation of extremely short segments can be avoided as much as possible. Therefore, we call the proposed linear interpolation approach as the optimal linear interpolation method.

Planar Contour Curves Defined in Parametric Form
The optimal linear interpolation approach can be also easily applied to the parametric planar curves that are quite commonly adopted to express contour shape of machine parts. For example, as the linear interpolation procession of a parametric curve defined by Eq. 11, the above proposed algorithm can be applied almost without any modification if the differential relation of Eq. 12 is used.

Interpolation Results and Discussions for Planar Cam Contouring 3.1 Object Planar Cam Contours
In this chapter, we verify and discuss the effectiveness and the effect of data reduction of the optimal linear interpolation method through two examples of planar cam contour interpolation that also were dealt with in [15]. Cam 1 is a translating cam with reciprocating roller follower as shown in Fig. 4. The pitch curve of the cam, i.e., the locus of the follower roller center in the coordinate system O-xy fixed to the cam, is given by the following equation. , the left part has a concave shape, and the right part has a convex shape, as shown in Fig. 4. However, the interpolation calculation was performed independently for both the portions, respectively, to verify the calculation program. Cam 2 is a rotating cam with reciprocating roller follower whose contour shape is outlined in Fig. 5. As a parametric function of the cam rotation angle θ, the pitch curve, A-B-C-D, can be described by Eq. 14 in the cam coordinate system O-xy.
Where r 0 is the radius of prime circle, h is the lift of follower, θ d is the rotation angle for rise of cam, and their values are r 0 = 40 mm, h = 30 mm and θ d = 100 • . Two inflection points, Point B and Point C, divide the pitch curve into three parts. The AB part indicated as Portion I and the CD part as Portion III have convex shape and the BC part as Portion II has concave shape. The rotation angle of the cam corresponding to Point B and Point C is 6.656011 • and 19.825680 • , respectively. From the viewpoint of ensuring the performance of cam mechanism, an endmill tool with the same diameter as the follower roller is usually used in contour finishing of planar cams. Therefore, in NC machining, the cutter path is generated by interpolating the pitch line of the cam to be machined.
The calculation program was coded in Fortran Language with double precision. All interpolation calculations were performed on an NEC Mate M33A personal computer (Intel (R) Core (TM) i5 CPU 660@3.33GHz, 2.99GB RAM) and for each specified condition, the calculation time did not exceed 0.5 second. In the calculation, the convergence limit value ε is set at 10 −8 mm and the radius R of the circular arc to extend the contour definition at 50 mm. Table 1 summarizes the interpolation results of Cam 1 by the optimal linear interpolation method to different interpolation accuracy values specified. According to [15], the number of required segments from Nishioka's method is 180 with a specified interpolation accuracy value of 0.0005 mm. But, as shown in Appendix A, the actual value of interpolation error is ±0.0005 mm for whole pitch curve. From Table 1, the number of segments by the proposed method with the specified interpolation accuracy value of ±0.0005 mm is only 124, and the obtained interpolation error value is ±0.000489 mm. Compared with the Nishioka's method, the number of segments decreased by 31.1%. Figure 6 shows the obtained interpolation error curve, where all characteristics abovementioned of the optimal linear interpolation can be clearly confirmed, as well as the following Fig. 8. As a further discussion, the comparison of the interpolation results to a single concave or convex interval, for example, the concave portion on the left half of the pitch curve, has also been carried out. From the result of Nishioka's method, 90 segments were required with the specified interpolation accuracy value of 0.0005 mm, while the number of segments generated by the optimal linear interpolation method is 87 with the same accuracy value of ±0.00025 mm.

Interpolation Results of Cam 1
On the other hand, in order to observe the influence of the interpolation error on actual machined contour, the pitch curve was interpolated in a specified accuracy of ±5 µm, and the obtained linear segments were used as the cutter path to finish the cam contour on a machining center with an endmill of 3 mm diameter. The calculated interpolation error extremum is ±4.82 µm, and the needed segment number is 40. Table 2 shows the machining conditions. The cam contour was measured on a coordinate measuring machine with a touch trigger probe whose tip diameter is 3 mm. The number of measurement points is 2461 for whole cam contour. Since the radius of both endmill and probe was not compensated in the machining and measurement    of the contour, it can be considered that the measured contour shape directly corresponds to the actual trajectory of the cutter path in machining. The comparison of the mea-sured contour shape error and the calculated interpolation error of cutter path is shown in Fig. 7. Some long-period waviness due to the motion error of machining center itself is observed in the measured contour error curve [20], but if ignoring this influence, the short-period undulation caused by linear interpolation along both curves corresponds well one and another. Table 3 summarizes the interpolation results of Cam 2 by the optimal linear interpolation method with respect to different interpolation accuracy values. With a specified accuracy value of 0.0005 mm, the number of required segments is 228 by Nishioka's method according to [15]. In the case of the similar interpolation error value, the corresponding interpolation accuracy value specified is ±0.0005 mm, and the obtained interpolation error value is ±0.000496 mm with 149 linear segments by the proposed method, as shown in Table 3. Compared with Nishioka's method, the number of the required segments decreased 34.6%. Figure 8 shows the interpolation error curve obtained by the optimal linear interpolation.

Relationship between Interpolation Error Extremum Value and Segment Number
In order to examine the relationship between the actually obtained interpolation error value 2e and the number of required segment n, the results shown in Table 1 and Table 3, the latter is based on each single concave-convex portion, are collated and summarized in Fig. 9, where the horizontal axis is set to 1/ √ 2e and the vertical axis is set to n. From this figure, it can be confirmed that a proportional relationship holds between n and 1/ √ 2e for each single concave-convex interval of the contour curve. In other words, to reduce the interpolation error value to 1/10 the number of segments increases √ 10 times. A similar proportional relationship was also reported in [4].

Conclusions
In this study, an optimal linear interpolation method for planar curves which strictly follows the ISO and JIS standards has been proposed for the NC machining of planar contours. The effectiveness of the proposed method has also been verified through interpolation examples of planar cam contours. The main research results can be concluded as follows: (a) With the proposed method, the interpolation error measured along the normal direction of object curve satisfies the specified interpolation accuracy value, and the number of segments required is the fewest simultaneously. (b) As a result of the optimal linear interpolation, the interpolation error extremum value of each segment is the same in a single-concave or single-convex interval of the object curve, and the start point of the first segment and the end point of the last segment match the start point and end point of the contour curve portion, respectively. Therefore, the smooth connection of the interpolation segment is naturally guaranteed between different contour parts defined by different functions or between adjacent single concave-convex intervals, and the generation of extremely short segment is avoided as much as possible.
(c) The algorithm of the proposed method is simple and with a high computation efficiency. Its implementation programming is easy.
(d) From the results of the comparative example, the number of interpolation segments required by the proposed method can be reduced by 30% or more than that of Nishioka's method under a condition of obtaining the same interpolation error; Even for a single-convex or single-concave portion of the object curve, the number of interpolation segments by the proposed method is fewer.
(e) With the proposed method, the required number of interpolation segments n is proportional to the value of 1/ √ 2e, where 2e is the actual value of the interpolation error. In other words, in order to reduce the interpolation error value to 1/10, the number of segments increases √ 10 times.
(f) From the finish machining experiment of cam contour, it was confirmed that there is a good correspondence between the interpolation error of cutter path and the measured contour shape error. (A-4) As a sequential repeat numerical calculation method, beginning from the start point of the contour curve which is taken as the start point of the first segment, the end point of each segment is determined in turn under a condition of making each δ i equal to the specified interpolation accuracy value.
Obviously, the interpolation error defined by Eq. A-4 does not exactly match the ISO and JIS standard [8] [9]. Moreover, as shown in Fig. 10, the interpolation segments generated for the intervals with different convex-concave characteristic are located on the different sides of the contour curve, respectively.

B. Modified Sine Cam Curve
The modified sine cam curve is defined in the form of the dimensionless displacement S with respect to the dimensionless time T as follows [21]: Each constant in the equation is given by Eq. A-6.