diff options
author | jaseg <git@jaseg.de> | 2023-06-14 12:05:33 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-06-14 12:05:33 +0200 |
commit | 0148db6249eee8721393344772040ead52666dd1 (patch) | |
tree | a958682a5610997919c4d526aee9c034ede04fc6 /coil_gen.py | |
parent | 5178eba26fea2b44996cd843a5fbf46597e1d630 (diff) | |
download | gerbonara-0148db6249eee8721393344772040ead52666dd1.tar.gz gerbonara-0148db6249eee8721393344772040ead52666dd1.tar.bz2 gerbonara-0148db6249eee8721393344772040ead52666dd1.zip |
Beautiful spirals!
Diffstat (limited to 'coil_gen.py')
-rw-r--r-- | coil_gen.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/coil_gen.py b/coil_gen.py index e0aecdb..16d3174 100644 --- a/coil_gen.py +++ b/coil_gen.py @@ -177,17 +177,31 @@ def generate(infile, outfile, polygon, start_angle, windings, trace_width, clear # spiral_points.append((cx + x1*r_pt, cy + y1*r_pt)) out = [spiral_points[0]] - for pa, pb, pc in zip(spiral_points, spiral_points[1:], spiral_points[2:]): + ndrop = 0 + for i, (pa, pb, pc) in enumerate(zip(spiral_points, spiral_points[1:], spiral_points[2:])): xa, ya = pa xb, yb = pb xc, yc = pc + if ndrop: + ndrop -= 1 + continue angle = angle_between_vectors((xa-xb, ya-yb), (xc-xb, yc-yb)) if angle > pi: - pass + ndrop += 1 + for pd, pe in zip(spiral_points[i+2:], spiral_points[i+3:]): + xd, yd = pd + xe, ye = pe + angle = angle_between_vectors((xa-xb, ya-yb), (xe-xd, ye-yd)) + if angle > pi: + ndrop += 1 + else: + out.append(line_line_intersection((pa, pb), (pd, pe))) + break else: out.append(pb) + spiral_points = out path_d = ' '.join([f'M {xy[0][0]} {xy[0][1]}', *[f'L {x} {y}' for x, y in xy[1:]], 'Z']) path_d2 = ' '.join(f'M {cx} {cy} L {x} {y}' for x, y in xy) |