Skip to content

Instantly share code, notes, and snippets.

@mvirkkunen
Last active January 6, 2025 19:48
Show Gist options
  • Save mvirkkunen/81fd16617f419bc5a278e2eeb80ab9d9 to your computer and use it in GitHub Desktop.
Save mvirkkunen/81fd16617f419bc5a278e2eeb80ab9d9 to your computer and use it in GitHub Desktop.
include <BOSL2/std.scad>
module pomffo(path1, path2, ratio=1, spacing=10) {
path1 = resample_path(path1, spacing=spacing, closed=false);
path2 = resample_path(path2, n=len(path1), closed=false);
center = [for (i = [0 : len(path1) - 1]) (path1[i] + path2[i]) * 0.5];
tangents = path_tangents(center);
sweep(
circle(d=1, $fn=32),
[
for (i = [0 : len(center) - 1])
let(
vx = path_closest_point(path2, center[i])[1] - path_closest_point(path1, center[i])[1],
vz = tangents[i],
vy = cross(vx, vz),
s = norm(vx),
)
move(center[i]) * frame_map(vx, vy, vz) * scale([s, s * ratio])
]);
}
for (a = [0 : 90 : 270]) {
zrot(a) pomffo(
[[-16, 0, 0], [-0.5, 100, 0]],
[[ 16, 0, 0], [ 0.5, 100, 0]],
0.5,
);
}
pomffo(
arc(100, points=[[0, 99, 0], [100, 0, 0], [-99, 0, 0]]),
arc(100, points=[[0, 100, 0], [130, 0, 0], [-100, 0, 0]]),
0.5,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment