1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 13:01:37 +02:00
This commit is contained in:
Justin Lin
2021-07-29 12:05:18 +08:00
parent 7d47d56bdd
commit 61f7988820
3 changed files with 22 additions and 71 deletions

View File

@@ -3,7 +3,7 @@ use <shape_trapezium.scad>;
use <arc.scad>;
use <shear.scad>;
use <util/rand.scad>;
use <experimental/tiles_wang_2e.scad>;
use <experimental/tile_w2e.scad>;
mask = [
[0, 1, 1, 0, 0, 0, 1, 1, 0],
@@ -24,7 +24,18 @@ random_city(rows, columns, mask);
module random_city(rows, columns, mask) {
tile_width = 30;
tiles_wang_2e(rows, columns, tile_width, mask) {
module tiles() {
for(tile = tile_w2e(rows, columns, mask)) {
x = tile[0];
y = tile[1];
i = tile[2];
translate([x, y] * tile_width)
children(i);
}
}
tiles() {
tile00();
tile01();
tile02();

View File

@@ -1,4 +1,4 @@
use <experimental/tiles_wang_2e.scad>;
use <experimental/tile_w2e.scad>;
use <box_extrude.scad>;
rows = 8;
@@ -12,25 +12,14 @@ module tube_box(rows, columns, tile_width) {
half_w = tile_width / 2;
quarter_w = tile_width / 4;
eighth_w = tile_width / 8;
translate([eighth_w, eighth_w, -eighth_w])
tiles_wang_2e(rows, columns, tile_width) {
tube_tile(0, tile_width);
tube_tile(1, tile_width);
tube_tile(2, tile_width);
tube_tile(3, tile_width);
tube_tile(4, tile_width);
tube_tile(5, tile_width);
tube_tile(6, tile_width);
tube_tile(7, tile_width);
tube_tile(8, tile_width);
tube_tile(9, tile_width);
tube_tile(10, tile_width);
tube_tile(11, tile_width);
tube_tile(12, tile_width);
tube_tile(13, tile_width);
tube_tile(14, tile_width);
tube_tile(15, tile_width);
translate([eighth_w, eighth_w, -eighth_w] + [tile_width, tile_width] / 2)
for(tile = tile_w2e(rows, columns)) {
x = tile[0];
y = tile[1];
i = tile[2];
translate([x, y] * tile_width)
tube_tile(i, tile_width);
}
box_extrude(height = tile_width, shell_thickness = eighth_w)

View File

@@ -1,49 +0,0 @@
// wang tiles - 2 edges
module tiles_wang_2e(rows, columns, tile_width, mask, seed) {
edges = is_undef(seed) ? [
for(y = [0:rows])
[
for(x = [0:columns])
let(rs = rands(0, 1, 2))
[round(rs[0]), round(rs[1])]
]
] : [
for(y = [0:rows])
[
for(x = [0:columns])
let(rs = rands(0, 1, 2, seed + y * columns + x))
[round(rs[0]), round(rs[1])]
]
];
m = is_undef(mask) ? [
for(y = [0:rows - 1])
[for(x = [0:columns - 1]) 1]
] : [
for(y = rows - 1; y > -1; y = y - 1)
[for(x = [0:columns - 1]) mask[y][x]]
];
/*
1
. .
8 | | 2
. .
4
*/
half_w = tile_width / 2;
translate([half_w, half_w])
for(y = [0:rows - 1]) {
for(x = [0:columns - 1]) {
if(m[y][x] == 1) {
i = (edges[y + 1][x][0] == 1 ? 1 : 0) +
(edges[y][x + 1][1] == 1 ? 2 : 0) +
(edges[y][x][0] == 1 ? 4 : 0) +
(edges[y][x][1] == 1 ? 8 : 0);
translate([x, y] * tile_width)
children(i);
}
}
}
}