1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 13:01:37 +02:00

add bauer_spiral

This commit is contained in:
Justin Lin
2020-10-25 14:42:04 +08:00
parent afaf8eaeb9
commit a307fcd565

View File

@@ -0,0 +1,20 @@
function bauer_spiral(n, dir = "CT_CLK") =
let(
L = sqrt(n * PI),
toRadians = PI / 180,
toDegrees = 180 / PI,
clk = dir == "CT_CLK" ? 1 : -1
)
[
for(k = 1; k <= n; k = k + 1)
let(
zk = 1 - (2 * k - 1) / n,
phik = acos(zk) * toRadians,
thetak = L * phik * clk,
phikDegrees = toDegrees * phik,
thetakDegrees = toDegrees * thetak,
xk = sin(phikDegrees) * cos(thetakDegrees),
yk = sin(phikDegrees) * sin(thetakDegrees)
)
[xk, yk, zk]
];