1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 09:33:26 +01: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) = [
for(phi = [0:phi_step:PI * 2])
let(
degree = phi * 180 / PI,
r = cos(q * degree) + 2,
x = r * cos(p * degree),
y = r * sin(p * degree),
z = -sin(q * degree)
)
[x, y, z]
];
function torus_knot(p, q, phi_step) =
let(tau = PI * 2)
[
for(phi = 0; phi < tau; phi = phi + phi_step)
let(
degree = phi * 180 / PI,
r = cos(q * degree) + 2,
x = r * cos(p * degree),
y = r * sin(p * degree),
z = -sin(q * degree)
)
[x, y, z]
];