diff --git a/feedthrough1.FCStd b/feedthrough1.FCStd index a59340d..42bb5dc 100644 Binary files a/feedthrough1.FCStd and b/feedthrough1.FCStd differ diff --git a/secondary_mesh_planning.py b/secondary_mesh_planning.py index c7184c5..4612de8 100644 --- a/secondary_mesh_planning.py +++ b/secondary_mesh_planning.py @@ -5,6 +5,8 @@ import textwrap import math from pathlib import Path import webbrowser +import scipy +import numpy as np import click @@ -257,26 +259,46 @@ def cli(out_svg, out_txt, mesh_thickness, offset, mesh_space, mesh_width, start, points = [(0, 0, 0)] radii.append(radii[-1] + 20) - rt = 10 - dx = rt - offset - n = 0 - e = 30 + h = 18 with open(out_txt, 'w') as f: - for i in range(steps): - rp, rt = rt, (radii[i] + radii[i+1])/2 + for i, r in enumerate(radii): + sign_i = (i%2)*2 - 1 + offset_i = 0 if i%2 == 0 else offset + a = math.pi/3 if i == 0 else -sign_i * math.pi/2 - for j in range(e): - k = i + j/e - a = k**0.85 * math.pi # - k/steps * math.pi * 0.3 - r = rp + (rt-rp)*j/e - x = dx + offset - math.cos(a)*r - y = math.sin(a)*r - points.append((x, y)) + x = offset_i + math.cos(a)*r + y = math.sin(a)*r + z = sign_i*h/2 + points.append((x, y, z)) - z = (math.cos(a/2 + 0.3*math.pi)**4) * 18 - f.write(f'[{x}, {y}, {z}],') - n += 1 - print(f'wrote {n} points') + a = -sign_i * math.pi/2 + a -= math.pi/4 + r += 15 + x = offset_i + math.cos(a)*r + y = math.sin(a)*r + z = sign_i*h/2 + points.append((x, y, z)) + + if i == len(radii)-1: + break + + a -= math.pi/2 + x = offset_i + math.cos(a)*r + y = math.sin(a)*r + z = -sign_i*h/2 + points.append((x, y, z)) + + lens_cum = np.zeros(len(points)) + total = 0 + for i, (p1, p2) in enumerate(zip(points[:-1], points[1:])): + total += math.dist(p1, p2) + lens_cum[i+1] = total + lens_cum /= lens_cum[-1] + print(lens_cum) + + points = scipy.interpolate.make_interp_spline(lens_cum, points)(np.linspace(0, 1, 500)) + f.write(', '.join(f'[{x:.3f},{y:.3f},{z:.3f}]' for x, y, z in points)) + print(f'wrote {len(points)} points') tags.append(Tag('path', fill='none', stroke='magenta', stroke_width='0.5mm', stroke_linecap='round', stroke_linejoin='round', d='M ' + ' L '.join(f'{x:.3f},{y:.3f}' for x, y, z in points)))