python - How to create polygons with arcs in shapely (or a better library) -


i trying use shapely identify area used shape , area used tools cut on cnc router. shape imported dxf drawing using ezdxf.

the tool paths can either rectangles (if cut saw disk follows straight line) or set of segments (if routed milling bit). in both cases can use linestring.buffer() automatically create offsets , find area used tool.

i using shapely because think best tool available find out if shapes overlap each other (using union() merge tools 1 shape , overlaps() find interference). please let me know if there better tool purpose.

buffer() job @ creating segments represent arcs on corners.

is there way create segments represent arcs on shape itself?

for example, how create arc on left of shape? need create own (slow) python function? or there optimized shapely way?

green part, yellow saw disk cuts, magenta milling bit cuts

creating own way of making arc in python isn't slow. numpy excellent operations along these lines, , shapely deliberately intended interoperate numpy.

for example,

import numpy np import shapely.geometry geom  # define arc (presumably ezdxf uses similar convention) centerx, centery = 3, 4 radius = 2 start_angle, end_angle = 30, 56 # in degrees numsegments = 1000  # coordinates of arc theta = np.radians(np.linspace(start_angle, end_angle, numsegments)) x = centerx + radius * np.cos(theta) y = centery + radius * np.sin(theta)  arc = geom.linestring(np.column_stack([x, y])) 

approximating arc 1000 points between start , end angles takes ~3 milliseconds on machine (that's including converting shapely linestring).


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -