This PR fixes a bug in the raster organization modifier where the organizer was sorting waypoints by their global x positions and sorting tool paths by the global y positions of their first waypoints. This approach failed to organize rasters correctly when the tool paths are already nominally oriented along the x-axis and nominally stepping along the y-axis. This fix computes the average direction of travel of the first tool path, and sorts the waypoints in each tool path by distance along this vector. It then computes the raster direction by taking the cross product of first waypoint z-axis and the average direction of travel and sorts the tool paths by the distance of their first waypoint along this vector.
This PR fixes a bug in the raster organization modifier where the organizer was sorting waypoints by their global x positions and sorting tool paths by the global y positions of their first waypoints. This approach failed to organize rasters correctly when the tool paths are already nominally oriented along the x-axis and nominally stepping along the y-axis. This fix computes the average direction of travel of the first tool path, and sorts the waypoints in each tool path by distance along this vector. It then computes the raster direction by taking the cross product of first waypoint z-axis and the average direction of travel and sorts the tool paths by the distance of their first waypoint along this vector.