mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 06:08:31 +01:00
add fibonacci_lattice2
This commit is contained in:
parent
0a5d64d999
commit
c93d1ae897
24
src/experimental/fibonacci_lattice2.scad
Normal file
24
src/experimental/fibonacci_lattice2.scad
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
function fibonacci_lattice2(n, radius = 1, rt_dir = "CT_CLK") =
|
||||||
|
let(
|
||||||
|
g = (1 + sqrt(5)) / 2,
|
||||||
|
dir = rt_dir == "CT_CLK" ? 1 : -1
|
||||||
|
)
|
||||||
|
[
|
||||||
|
for(i = [0:n - 1])
|
||||||
|
let(
|
||||||
|
k = (i + 0.5),
|
||||||
|
r = sqrt(k / n),
|
||||||
|
theta = dir * k * g * 180
|
||||||
|
)
|
||||||
|
[radius * r * cos(theta), radius * r * sin(theta)]
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
num_pts = 300;
|
||||||
|
pts = fibonacci_lattice2(num_pts);
|
||||||
|
|
||||||
|
for(p = pts) {
|
||||||
|
translate(p)
|
||||||
|
circle(.01, $fn = 24);
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user