1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00

remove swap_surface param

This commit is contained in:
Justin Lin 2021-06-22 17:45:25 +08:00
parent 629edc0422
commit 0aaf599868
2 changed files with 85 additions and 2 deletions

78
docs/lib3x-sf_thicken.md Normal file
View File

@ -0,0 +1,78 @@
# sf_thicken
It thickens a surface, described by a m * n list of `[x, y, z]`s.
## Parameters
- `points` : A m * n list of `[x, y, z]`s. See examples below.
- `thickness` : The depth of the thickening.
- `direction` : The direction of thickening. It accepts `"BOTH"` (default), `"FORWARD"` or `"BACKWARD"`. Thickening is applied in both directions from the surface, the direction of the surface normals or the opposite direction to the surface normals. It also accept a direction vector `[x, y, z]`. Thickening is only applied in the direction you give.
- `swap_surface` : The direction of thickening.
## Examples
use <sf_thicken.scad>;
points = [
[[0, 0, 1], [1, 0, 2], [2, 0, 2], [3, 0, 3]],
[[0, 1, 1], [1, 1, 4], [2, 1, 0], [3, 1, 3]],
[[0, 2, 1], [1, 2, 3], [2, 2, 1], [3, 2, 3]],
[[0, 3, 1], [1, 3, 3], [2, 3, 1], [3, 3, 3]]
];
thickness = 0.5;
sf_thicken(points, thickness);
![sf_thicken](images/lib3x-sf_thicken-1.JPG)
use <sf_thicken.scad>;
function f(x, y) =
30 * (
cos(sqrt(pow(x, 2) + pow(y, 2))) +
cos(3 * sqrt(pow(x, 2) + pow(y, 2)))
);
thickness = 2;
min_value = -200;
max_value = 200;
resolution = 10;
points = [
for(y = [min_value:resolution:max_value])
[
for(x = [min_value:resolution:max_value])
[x, y, f(x, y)]
]
];
sf_thicken(points, thickness);
![sf_thicken](images/lib3x-sf_thicken-2.JPG)
use <sf_thicken.scad>;
function f(x, y) =
30 * (
cos(sqrt(pow(x, 2) + pow(y, 2))) +
cos(3 * sqrt(pow(x, 2) + pow(y, 2)))
);
thickness = 2;
min_value = -200;
max_value = 200;
resolution = 10;
style = "LINES";
points = [
for(y = [min_value:resolution:max_value])
[
for(x = [min_value:resolution:max_value])
[x, y, f(x, y)]
]
];
sf_thicken(points, thickness, style);
![sf_thicken](images/lib3x-sf_thicken-3.JPG)

View File

@ -11,7 +11,7 @@
use <../util/sum.scad>;
use <sf_solidify.scad>;
module sf_thicken(points, thickness, direction = "BOTH", swap_surface = false) {
module sf_thicken(points, thickness, direction = "BOTH") {
function tri_normal(tri) =
let(v = cross(tri[2] - tri[0], tri[1] - tri[0])) v / norm(v);
@ -45,7 +45,12 @@ module sf_thicken(points, thickness, direction = "BOTH", swap_surface = false) {
dir_v
]
];
if(swap_surface) {
midy = len(points) / 2;
midx = len(points[0]) / 2;
nv = tri_normal([points[midy][midx], points[midy + 1][midx], points[midy][midx + 1]]);
if(nv * dir_v > 0) {
sf_solidify(surface_bottom, points);
}
else {