A semi-infinite optimization approach to optimal spline trajectory planning of mechanical manipulators