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

add tf_torus

This commit is contained in:
Justin Lin
2020-02-15 18:25:50 +08:00
parent 37ee1d28c5
commit 75715369b5

View File

@@ -0,0 +1,20 @@
use <rotate_p.scad>;
function tf_torus(size, point, radius, angle = [360, 360], twist = 0) =
let(
xlen = size[0],
ylen = size[1],
x = point[0],
y = point[1],
R = radius[0],
r = radius[1],
A = angle[0],
a = angle[1],
ya_step = a / xlen,
za_step = A / ylen,
twa_step = twist / ylen,
ya = 180 - x * ya_step,
za = za_step * y,
twisted = rotate_p([r * cos(ya), 0, r * sin(ya)], [0, twa_step * y, 0])
)
rotate_p(twisted + [R + r, 0, 0], za);