summaryrefslogtreecommitdiff
path: root/coil_gen.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-06-13 18:53:03 +0200
committerjaseg <git@jaseg.de>2023-06-13 18:53:03 +0200
commit86276490eb7c68d770a4b7280f90562eeef62833 (patch)
tree929996c09b6fc3e57e63937faa83a0c99980696b /coil_gen.py
parent070494a1c3bf682a457dd0ec3092d360825ec84c (diff)
downloadgerbonara-86276490eb7c68d770a4b7280f90562eeef62833.tar.gz
gerbonara-86276490eb7c68d770a4b7280f90562eeef62833.tar.bz2
gerbonara-86276490eb7c68d770a4b7280f90562eeef62833.zip
coil gen WIP
Diffstat (limited to 'coil_gen.py')
-rw-r--r--coil_gen.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/coil_gen.py b/coil_gen.py
index 4dd0847..df09be8 100644
--- a/coil_gen.py
+++ b/coil_gen.py
@@ -59,6 +59,17 @@ def generate(infile, outfile, polygon, start_angle, stop_radius, trace_width, cl
segment_heights = [point_line_distance((cx, cy), (x1, y1), (x2, y2)) for (x1, y1), (x2, y2) in segments]
+ closest_points = []
+ for h, ((x1, y1), (x2, y2)) in zip(segment_heights, segments):
+ dc1 = dist((x1, y1), (cx, cy))
+ d12 = dist((x1, y1), (x2, y2))
+ db = sqrt(dc1**2 - h**2)
+ xn = (x2 - x1) / d12
+ yn = (y2 - y1) / d12
+ xb = x1 + xn * db
+ yb = y1 + yn * db
+ closest_points.append((xb, yb))
+
smallest_radius = min(segment_heights)
#trace_radius = smallest_radius - stop_radius
trace_radius = smallest_radius
@@ -92,8 +103,11 @@ def generate(infile, outfile, polygon, start_angle, stop_radius, trace_width, cl
f.write(f'<svg version="1.1" width="200mm" height="200mm" viewBox="{vbx} {vby} {vbw} {vbh}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">>\n')
f.write(f'<path fill="none" stroke="#303030" stroke-width="0.05" d="{path_d}"/>\n')
f.write(f'<path fill="none" stroke="#a0a0a0" stroke-width="0.05" d="{path_d2}"/>\n')
- f.write(f'<path fill="none" stroke="#ff00ff" stroke-width="{trace_width}" d="{path_d3}"/>\n')
+ #f.write(f'<path fill="none" stroke="#ff00ff" stroke-width="{trace_width}" d="{path_d3}"/>\n')
f.write(f'<circle r="0.1" fill="red" stroke="none" cx="{cx}" cy="{cy}"/>\n')
+ for x, y in closest_points:
+ f.write(f'<circle r="0.1" fill="blue" stroke="none" cx="{x}" cy="{y}"/>\n')
+ f.write(f'<path fill="none" stroke="#a0a0ff" stroke-width="0.05" d="M {cx} {cy} L {x} {y}"/>')
f.write('</svg>\n')
if __name__ == '__main__':