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

add direction param

This commit is contained in:
Justin Lin
2021-06-20 15:29:01 +08:00
parent 3ba9e6a3ce
commit 81413584ad

View File

@@ -1,7 +1,7 @@
use <sf_solidify.scad>; use <sf_solidify.scad>;
use <util/sum.scad>; use <util/sum.scad>;
module sf_thicken(points, thickness, slicing = "SLASH") { module sf_thicken(points, thickness, direction = undef, slicing = "SLASH") {
function tri_normal(tri) = function tri_normal(tri) =
let(v = cross(tri[2] - tri[0], tri[1] - tri[0])) v / norm(v); let(v = cross(tri[2] - tri[0], tri[1] - tri[0])) v / norm(v);
@@ -26,6 +26,7 @@ module sf_thicken(points, thickness, slicing = "SLASH") {
) )
sum(normals) / len(normals); sum(normals) / len(normals);
if(direction == undef) {
vertex_normals = [ vertex_normals = [
for(y = [0:len(points) - 1]) for(y = [0:len(points) - 1])
[ [
@@ -33,14 +34,23 @@ module sf_thicken(points, thickness, slicing = "SLASH") {
vertex_normal(points, x, y) vertex_normal(points, x, y)
] ]
]; ];
half_thickness = thickness / 2; half_thickness = thickness / 2;
surface_top = points + half_thickness * vertex_normals; surface_top = points + half_thickness * vertex_normals;
surface_bottom = points - half_thickness * vertex_normals; surface_bottom = points - half_thickness * vertex_normals;
sf_solidify(surface_top, surface_bottom, slicing); sf_solidify(surface_top, surface_bottom, slicing);
} }
else {
dir_v = direction / norm(direction);
sf = points + thickness * [
for(y = [0:len(points) - 1])
[
for(x = [0:len(points[0]) - 1])
dir_v
]
];
sf_solidify(points, sf, slicing);
}
}
/* /*
use <surface/sf_thicken.scad>; use <surface/sf_thicken.scad>;