1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 17:42:44 +01:00

add sf_torus

This commit is contained in:
Justin Lin 2020-02-19 17:36:27 +08:00
parent 4c3c027995
commit 4559145519

View File

@ -0,0 +1,41 @@
use <experimental/_impl/_sf_square_surfaces.scad>;
use <experimental/sf_solidify.scad>;
use <experimental/tf_torus.scad>;
/*
levels : A list of numbers (0 ~ 255).
radius: torus [R, r]
thickness: shell thickness
angle: torus [A, a].
twist: The number of degrees of through which the rectangle is twisted.
invert: inverts how the gray levels are translated into height values.
*/
module sf_torus(levels, radius, thickness, angle = [360, 360], twist = 0, invert = false) {
surface = _sf_square_surfaces(levels, thickness, invert);
rows = len(levels);
columns = len(levels[0]);
size = [columns - 1, rows - 1];
R = radius[0];
r = radius[1];
offset_z = invert ? thickness : 0;
tr1 = [R, r + offset_z];
tr2 = [R + thickness, r];
sf_solidify(
[
for(row = surface[0])
[
for(p = row) tf_torus(size, p, tr1, angle, twist)
]
],
[
for(row = surface[1])
[
for(p = row) tf_torus(size, p, tr2, angle, twist)
]
]
);
}