mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 10:14:41 +02:00
add delaunay_fibonacci
This commit is contained in:
55
examples/voronoi/delaunay_fibonacci.sccad
Normal file
55
examples/voronoi/delaunay_fibonacci.sccad
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
use <golden_spiral.scad>;
|
||||||
|
use <ptf/ptf_rotate.scad>;
|
||||||
|
use <triangle/tri_delaunay.scad>;
|
||||||
|
use <triangle/tri_incentre.scad>;
|
||||||
|
use <util/dedup.scad>;
|
||||||
|
|
||||||
|
spirals = 2;
|
||||||
|
tri_thickness = 2;
|
||||||
|
tri_top_scale = 0.8;
|
||||||
|
|
||||||
|
from = 3;
|
||||||
|
to = 10;
|
||||||
|
point_distance = 10;
|
||||||
|
|
||||||
|
delaunay_fibonacci();
|
||||||
|
|
||||||
|
module delaunay_fibonacci() {
|
||||||
|
points_angles = golden_spiral(
|
||||||
|
from = from,
|
||||||
|
to = to,
|
||||||
|
point_distance = point_distance
|
||||||
|
);
|
||||||
|
spiral = [for(pa = points_angles) pa[0]];
|
||||||
|
|
||||||
|
a_step = 360 / spirals;
|
||||||
|
|
||||||
|
pts = dedup([
|
||||||
|
for(a = [0:a_step:360 - a_step])
|
||||||
|
each [for(p = spiral) ptf_rotate(p, a)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
lst_r = norm(spiral[len(spiral) - 1]) * 1.25;
|
||||||
|
half_tri_thickness = tri_thickness * 0.5;
|
||||||
|
|
||||||
|
cells = tri_delaunay(pts, ret = "TRI_SHAPES");
|
||||||
|
for(i = [0:len(cells) - 1]) {
|
||||||
|
cell = cells[i];
|
||||||
|
p = tri_incentre(cell);
|
||||||
|
|
||||||
|
color(rands(0, 1, 3))
|
||||||
|
translate(p)
|
||||||
|
linear_extrude(tri_thickness, scale = tri_top_scale)
|
||||||
|
translate(-p)
|
||||||
|
intersection() {
|
||||||
|
polygon(cell);
|
||||||
|
circle(lst_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
linear_extrude(half_tri_thickness)
|
||||||
|
intersection() {
|
||||||
|
polygon(cell);
|
||||||
|
circle(lst_r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user