mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 09:44:16 +02:00
add sf_bend
This commit is contained in:
51
src/experimental/sf_bend.scad
Normal file
51
src/experimental/sf_bend.scad
Normal file
@@ -0,0 +1,51 @@
|
||||
use <experimental/sf_solidify.scad>;
|
||||
use <experimental/tf_bend.scad>;
|
||||
|
||||
/*
|
||||
levels : A list of numbers (0 ~ 255).
|
||||
radius: The radius of the arc after being bent
|
||||
thickness: shell thickness
|
||||
angle: The central angle of the arc..
|
||||
invert: inverts how the gray levels are translated into height values.
|
||||
*/
|
||||
module sf_bend(levels, radius, thickness, angle, invert = false) {
|
||||
columns = len(levels);
|
||||
rows = len(levels[0]);
|
||||
|
||||
size = [columns - 1, rows - 1];
|
||||
|
||||
surface1 = [
|
||||
for(r = [0:rows - 1])
|
||||
[
|
||||
for(c = [0:columns - 1])
|
||||
let(lv = invert ? 255 - levels[c][r] : levels[c][r])
|
||||
[c, r, lv / 255 * thickness]
|
||||
]
|
||||
];
|
||||
|
||||
surface2 = [
|
||||
for(r = [0:rows - 1])
|
||||
[
|
||||
for(c = [0:columns - 1])
|
||||
[c, r, 0]
|
||||
]
|
||||
];
|
||||
|
||||
offset_z = invert ? thickness : 0;
|
||||
sf_solidify(
|
||||
[
|
||||
for(row = surface1)
|
||||
[
|
||||
for(p = row)
|
||||
tf_bend(size, p, radius + offset_z, angle)
|
||||
]
|
||||
]
|
||||
,
|
||||
[
|
||||
for(row = surface2)
|
||||
[
|
||||
for(p = row) tf_bend(size, p, radius, angle)
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user