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

c-style for loop

This commit is contained in:
Justin Lin
2019-06-14 13:44:47 +08:00
parent f5d813839b
commit 3be3a271e6

View File

@@ -8,14 +8,16 @@
* *
**/ **/
function torus_knot(p, q, phi_step) = [ function torus_knot(p, q, phi_step) =
for(phi = [0:phi_step:PI * 2]) let(tau = PI * 2)
let( [
degree = phi * 180 / PI, for(phi = 0; phi < tau; phi = phi + phi_step)
r = cos(q * degree) + 2, let(
x = r * cos(p * degree), degree = phi * 180 / PI,
y = r * sin(p * degree), r = cos(q * degree) + 2,
z = -sin(q * degree) x = r * cos(p * degree),
) y = r * sin(p * degree),
[x, y, z] z = -sin(q * degree)
]; )
[x, y, z]
];