mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-18 04:21:16 +02:00
refactor
This commit is contained in:
@@ -1,14 +1,10 @@
|
|||||||
use <ptf/ptf_rotate.scad>;
|
use <ptf/ptf_rotate.scad>;
|
||||||
use <hull_polyline2d.scad>;
|
use <hull_polyline2d.scad>;
|
||||||
|
|
||||||
|
module tile_penrose3(radius, fn, n) {
|
||||||
// triangle: [type, pa, pb pc], c: false(36) or true(108)
|
// triangle: [type, pa, pb pc], c: false(36) or true(108)
|
||||||
|
|
||||||
PHI = 1.618033988749895; // golden ratio
|
PHI = 1.618033988749895; // golden ratio
|
||||||
|
|
||||||
n = 12;
|
|
||||||
|
|
||||||
a0 = 360 / n;
|
|
||||||
a2 = 180 - a0 * 2;
|
|
||||||
|
|
||||||
function _subdivide(triangles) =
|
function _subdivide(triangles) =
|
||||||
[
|
[
|
||||||
@@ -38,7 +34,15 @@ function _penrose3(triangles, n, i = 0) =
|
|||||||
_penrose3(_subdivide(triangles), n, i+ 1);
|
_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);
|
tris = _penrose3(triangles, n);
|
||||||
for(t = tris) {
|
for(t = tris) {
|
||||||
color(t[0] ? "white" : "black")
|
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)];
|
tile_penrose3(radius, fn, 0);
|
||||||
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);
|
|
||||||
|
|
||||||
translate([30, 0])
|
translate([30, 0])
|
||||||
tile_penrose3(triangles, 1);
|
tile_penrose3(radius, fn, 1);
|
||||||
|
|
||||||
translate([60, 0])
|
translate([60, 0])
|
||||||
tile_penrose3(triangles, 2);
|
tile_penrose3(radius, fn, 2);
|
||||||
|
|
||||||
translate([0, -30])
|
translate([0, -30])
|
||||||
tile_penrose3(triangles, 3);
|
tile_penrose3(radius, fn, 3);
|
||||||
|
|
||||||
translate([30, -30])
|
translate([30, -30])
|
||||||
tile_penrose3(triangles, 4);
|
tile_penrose3(radius, fn, 4);
|
||||||
|
|
||||||
translate([60, -30])
|
translate([60, -30])
|
||||||
tile_penrose3(triangles, 5);
|
tile_penrose3(radius, fn, 5);
|
Reference in New Issue
Block a user