Adaptive nonlinear tool path optimization for five-axis machining