How to create polygons with arcs in a slender (or better library)

I am trying to use shapely to determine the area used by the shape and the area used by the tools that will cut it on the CNC router. The form is imported from the dxf drawing using ezdxf .

Tool paths can be either rectangles (if they are cut by a saw blade, which follows in a straight line), or a set of segments (if they are routed with a milling bit). In both cases, I can use LineString.buffer () to automatically create offsets and find the area used by the tool.

I use the form because I think this is the best tool available to find out if the shapes overlap with each other (using union()to combine all the tools into one shape and overlaps()to find the interference). Please let me know if there is a better tool for this.

buffer() does a good job of creating segments for representing arcs in corners.

Is there a way to create segments to represent arcs in the form itself?

For example, how do I create an arc to the left of this shape? Do I need to create my own (slow) python function? Or is the optimal way optimized?

Green is the part, yellow are the saw disk cuts, magenta are the milling bit cuts

+4
source share
2 answers

python . Numpy , numpy.

,

import numpy as np
import shapely.geometry as geom

# Define the arc (presumably ezdxf uses a similar convention)
centerx, centery = 3, 4
radius = 2
start_angle, end_angle = 30, 56 # In degrees
numsegments = 1000

# The coordinates of the 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]))

1000 3 ( LineString).

+2

All Articles