1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-07 07:16:36 +02:00

add sf_cylinder

This commit is contained in:
Justin Lin
2022-01-07 09:06:42 +08:00
parent 773dc87be9
commit eca8947822

View File

@@ -0,0 +1,30 @@
use <../sweep.scad>;
module sf_cylinder(levels, radius, thickness, depth, invert = false, convexity = 1) {
row_leng = len(levels[0]);
a_step = 360 / row_leng;
d_scale = (invert ? -depth : depth) / 255;
or = thickness + (invert ? radius + depth : radius - depth);
ir = radius;
row_range = [0:row_leng - 1];
sections = [
for(z = [0:len(levels) - 1])
concat(
[for(xi = row_range)
let(
r = or + levels[z][xi] * d_scale,
a = xi * a_step
)
[r * cos(a), r * sin(a), -z + row_leng]
],
[for(xi = row_range)
let(a = xi * a_step)
[ir * cos(a), ir * sin(a), -z + row_leng]
]
)
];
sweep(sections, "HOLLOW");
}