1. A method for controlling a laser cutting machine according to a pattern of disconnected contours, comprising: determining a set of exit and entry points on the contours of the pattern; determining at least one velocity vector for each point in the set of exit and entry points to produce a plurality of velocity vectors, wherein a direction of the velocity vector for a point is tangential to a shape of the contour at a location of the point, and wherein a magnitude of the velocity vector is a maximum velocity of the laser cutting machine suitable for machining a segment of the contour connected to the location of the point; determining, using dynamics of the laser cutting machine, a set of costs representing operations of the machine along a set of trajectories connecting points in the set of exit and entry points on the contours of the pattern, wherein each trajectory represents an operation of the machine proceeding from an exit point with an exit velocity of the velocity vector at the exit point to an entry point with an entry velocity of the velocity vector at the entry point according to dynamics of the machine, wherein the set of trajectories includes at least one trajectory representing the operation along a contour with non-zero velocities at corresponding exit and entry points, and at least one trajectory representing the operation between different contours with non-zero velocities at the corresponding exit and entry points; determining, based on a set of costs representing the operation of the laser cutting machine along each trajectory, a sequence of the trajectories optimizing a total cost of operation of the machine tracking the pattern; and determining a set of instructions for controlling the laser cutting machine according to the sequence, wherein steps of the method are performed by a processor.