1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-17 20:11:50 +02:00
This commit is contained in:
Justin Lin
2021-08-10 19:30:07 +08:00
parent 091f071cb5
commit 26a0d7a62e

View File

@@ -1,14 +1,10 @@
use <ptf/ptf_rotate.scad>;
use <hull_polyline2d.scad>;
module tile_penrose3(radius, fn, n) {
// triangle: [type, pa, pb pc], c: false(36) or true(108)
PHI = 1.618033988749895; // golden ratio
n = 12;
a0 = 360 / n;
a2 = 180 - a0 * 2;
function _subdivide(triangles) =
[
@@ -38,7 +34,15 @@ function _penrose3(triangles, n, i = 0) =
_penrose3(_subdivide(triangles), n, i+ 1);
module tile_penrose3(triangles, n) {
a0 = 360 / fn;
a2 = 180 - a0 * 2;
shape_tri0 = [[0, 0], [radius, 0], ptf_rotate([radius, 0], a0)];
triangles = [
for(i = [0:fn - 1])
let(t = [for(p = shape_tri0) ptf_rotate(p, i * a0)])
i % 2 == 0 ? [false, t[0], t[1], t[2]] : [false, t[0], t[2], t[1]]
];
tris = _penrose3(triangles, n);
for(t = tris) {
color(t[0] ? "white" : "black")
@@ -48,28 +52,22 @@ module tile_penrose3(triangles, n) {
}
}
side = 10;
radius = 10;
fn = 12;
shape_tri0 = [[0, 0], [side, 0], ptf_rotate([side, 0], a0)];
triangles = [
for(i = [0:n - 1])
let(t = [for(p = shape_tri0) ptf_rotate(p, i * a0)])
i % 2 == 0 ? [false, t[0], t[1], t[2]] : [false, t[0], t[2], t[1]]
];
tile_penrose3(triangles, 0);
tile_penrose3(radius, fn, 0);
translate([30, 0])
tile_penrose3(triangles, 1);
tile_penrose3(radius, fn, 1);
translate([60, 0])
tile_penrose3(triangles, 2);
tile_penrose3(radius, fn, 2);
translate([0, -30])
tile_penrose3(triangles, 3);
tile_penrose3(radius, fn, 3);
translate([30, -30])
tile_penrose3(triangles, 4);
tile_penrose3(radius, fn, 4);
translate([60, -30])
tile_penrose3(triangles, 5);
tile_penrose3(radius, fn, 5);