Dynamic toolpaths for optimized CNC machining