I am trying to use shapely to identify the area used by a shape and the area used by the tools that will cut it on a CNC router. The shape is imported from a dxf drawing using ezdxf.
The tool paths can be either rectangles (if they are cut by a saw disk that follows a straight line) or a set of segments (if they are routed by a milling bit). In both cases I can use a LineString.buffer() to automatically create the offsets and find the area used by the tool.
I am using shapely because I think it is the best tool available to find out if shapes overlap each other (using union()
to merge all the tools into one shape and overlaps()
to find the interference). Please let me know if there is a better tool for this purpose.
buffer()
does a good job at creating segments to represent arcs on the corners.
Is there a way to create the segments to represent arcs on the shape itself?
For example, how do I create the arc on the left of this shape? Do I need to create my own (slow) python function? Or is there an optimized shapely way?
Creating your own way of making the arc in python isn't necessarily slow. Numpy is excellent for operations along these lines, and shapely is deliberately intended to interoperate well with numpy.
For example,
Approximating the arc with 1000 points between the start and end angles takes ~3 milliseconds on my machine (that's including converting it to a shapely LineString).