From 75715369b56eec3cb610b4cac6de2bea64292966 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 15 Feb 2020 18:25:50 +0800 Subject: [PATCH] add tf_torus --- src/experimental/tf_torus.scad | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/experimental/tf_torus.scad diff --git a/src/experimental/tf_torus.scad b/src/experimental/tf_torus.scad new file mode 100644 index 00000000..6c936d9d --- /dev/null +++ b/src/experimental/tf_torus.scad @@ -0,0 +1,20 @@ +use ; + +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); \ No newline at end of file