Skip to content

Instantly share code, notes, and snippets.

@nfd9001
Created April 13, 2023 23:40
Show Gist options
  • Save nfd9001/88f419faee901eba9aafbf685283d464 to your computer and use it in GitHub Desktop.
Save nfd9001/88f419faee901eba9aafbf685283d464 to your computer and use it in GitHub Desktop.
Parametric tiled hexagons in scad
outer_hex = 1;
inner_hex = .9;
wall_depth = outer_hex - inner_hex;
tile_height = .5;
module hexagon(x) circle(r=x, $fn=6);
module hollow_hex(x, inner_x) difference(){hexagon(x); hexagon(inner_x);}
module hex_cylinder(height=0.1) linear_extrude(height=height, center=true) hollow_hex(outer_hex, inner_hex);
bump_y_vec = [0,(outer_hex * sqrt(3))-wall_depth/2,0];
bump_x_vec = [outer_hex * sqrt(2),0,0];
module hex_column(n) {
union() {
for (i =[0:n-1]){
translate(i * bump_y_vec) hex_cylinder(tile_height);
}
}
}
module hex_grid(n, m) {
union() {
for (i = [0:2:m-1]) {
translate(i*bump_x_vec) hex_column(n);
}
for (i = [1:2:m-1]) {
translate(i*(bump_x_vec) + bump_y_vec/2) hex_column(n);
}
}
}
hex_grid(10,10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment