In view of smooth trajectory generation for a 3-axis machine tool, many methods have been presented. Among them, the optimal control based method is increasingly concerned, because it is considered to be able to make full use of kinematic abilities of machine tools. Under the unified framework of optimal control, the feedrate can be adjusted flexibly by adding or removing axial constraints and tangential constraints. But the problem of smooth trajectory generation (PSTG) based on optimal control for a machine tool is not easily to be solved. In this article, to efficiently solve the PSTG, it is divided into two sub-problems: the problem of minimum time trajectory planning (PMTTP) and the pseudo problem of smooth trajectory generation (PPSTG). Since both sub-problems are convex, the existence of unique solutions can be guaranteed. Then, the PMTTP and the PPSTG are transformed into nonlinear programming (NLP) problems with radau-pseudo-spectral (RPM) method successively. Due to convexity, the two NLP problems can be efficiently solved with mature optimization methods. In addition, the RPM method allows two sub-problems to have different Legendre-Gauss-Radau (LGR) points, thereby further saving computational costs. Finally, three different predefined paths are employed to test the proposed method, and simulation results show the effectiveness of proposed method.