**4. Conclusions**

An efficient and effective method to compensate for the errors of free-form surfaces is needed in the current machining industry. In this study, we developed a program based on mirror compensation by using the API function of NX, a CAD/CAM system, to integrate the machining, measurement, and compensation. After performing the semi-finishing machining, we used on-machine measurement to obtain the locations of the measurement points, which were then mirrored to generate the locations of the compensation points. The points were used to construct a new surface in CAD to allow NX to generate the tool paths for finishing machining. Five functions in NX for surface fitting were evaluated, and the function, Through Curve Mesh, performed the best. Experiments on three different free-form surfaces were conducted, and the average standard deviations of the errors of the compensated surfaces can be reduced by 61%, 61%, and 32%, respectively, compared to those of the uncompensated surfaces. Although the popular tool radius compensation method can reduce the mean of the errors, it can only reduce the standard deviation of the errors by a little. In terms of the surface profile error defined in ISO 1011, the mirror compensation method proposed in the paper outperformed the tool radius compensation method by at least 21%. Based on the results, the mirror compensation method proposed in the paper can provide an effective way to reduce the variation and surface profile error of the machined free-form surface.

The program can complete the error compensation and generate the tool paths for finishing machining in about 30 s on a regular PC, which means that the processing time and technical difficulty can also be reduced significantly.

**Author Contributions:** Conceptualization, W.-c.L., Y.-t.L., and C.-C.W.; methodology, W.-c.L. and Y.-t.L.; software, Y.-t.L. and C.-C.W.; validation, Y.-t.L.; formal analysis, Y.-t.L.; investigation, Y.-t.L.; resources, W.-c.L.; data curation, Y.-t.L. and W.-c.L.; writing—original draft preparation, W.-c.L. and Y.-t.L.; writing—review and editing, W.-c.L.; visualization, W.-c.L. and Y.-t.L.; supervision, W.-c.L.; project administration, W.-c.L.; funding acquisition, W.-c.L.

**Funding:** This research was supported by the Ministry of Science and Technology, Taiwan, Republic of China, under Grant number MOST 107-2218-E-011-002.

**Conflicts of Interest:** The authors declare no conflict of interest.
