diff --git a/Stenen_kastje_Ruben/assembly.png b/Stenen_kastje_Ruben/assembly.png index 1a643a8..0b490ed 100644 Binary files a/Stenen_kastje_Ruben/assembly.png and b/Stenen_kastje_Ruben/assembly.png differ diff --git a/Stenen_kastje_Ruben/assembly.scad b/Stenen_kastje_Ruben/assembly.scad index 6de14c1..5c2d094 100644 --- a/Stenen_kastje_Ruben/assembly.scad +++ b/Stenen_kastje_Ruben/assembly.scad @@ -6,24 +6,29 @@ use use use -for (i=[1:nr_cells_vertical-1]){ - translate([0, 0, cell_height*i]) - horizontal_slat(); +translate([0, -outer_incut, 0]){ + for (i=[1:nr_cells_vertical-1]){ + translate([0, 0, cell_height*i]) + horizontal_slat(); + } } -for (i=[1:nr_cells_horizontal-1]){ - translate([0, cell_width*i, 0]) - vertical_slat(); +translate([0, 0, -outer_incut]){ + for (i=[1:nr_cells_horizontal-1]){ + translate([0, cell_width*i, 0]) + vertical_slat(); + } } -translate([0, -(outer_thickness-outer_incut), 0]) +translate([0, -(outer_thickness), 0]) vertical_outside(); -translate([0, cell_width*nr_cells_horizontal-outer_incut, 0]) +translate([0, cell_width*nr_cells_horizontal, 0]) vertical_outside(); -horizontal_outside(); -translate([0, 0, cell_height*nr_cells_vertical + outer_thickness - 2*outer_incut]) +translate([0, 0, -outer_thickness]) + horizontal_outside(); +translate([0, 0, cell_height*nr_cells_vertical]) horizontal_outside(); -translate([-back_thickness, -(outer_thickness - outer_incut), -(outer_thickness)]) +translate([-back_thickness, -(outer_thickness), -(outer_thickness)]) back_plane_fancy(); diff --git a/Stenen_kastje_Ruben/back_plane.scad b/Stenen_kastje_Ruben/back_plane.scad index 7f2e12c..8352efb 100644 --- a/Stenen_kastje_Ruben/back_plane.scad +++ b/Stenen_kastje_Ruben/back_plane.scad @@ -1,17 +1,16 @@ include +include module back_plane(){ color("lightblue") - cube(size=[back_thickness, 2*outer_thickness - 2*outer_incut + cell_width * nr_cells_horizontal, 2*outer_thickness - 2*outer_incut + cell_height * nr_cells_vertical], center=false); - echo("#### Back: thickness = ", back_thickness, " height = ", 2*outer_thickness - 2*outer_incut + cell_height * nr_cells_vertical, "width = ", 2*outer_thickness - 2*outer_incut + cell_width * nr_cells_horizontal); + cuben("Back", size=[back_thickness, 2*outer_thickness + cell_width * nr_cells_horizontal, 2*outer_thickness + cell_height * nr_cells_vertical]); } back_plane(); module back_plane_fancy(){ color("lightblue") - cube(size=[back_thickness, 2*outer_thickness - 2*outer_incut + cell_width * nr_cells_horizontal, 2*outer_thickness - 2*outer_incut + cell_height * nr_cells_vertical + back_fancy_height], center=false); - echo("#### Fancy back: thickness = ", back_thickness, " height = ", 2*outer_thickness - 2*outer_incut + cell_height * nr_cells_vertical + back_fancy_height, "width = ", 2*outer_thickness - 2*outer_incut + cell_width * nr_cells_horizontal); + cuben("Fancy back", size=[back_thickness, 2*outer_thickness + cell_width * nr_cells_horizontal, 2*outer_thickness + cell_height * nr_cells_vertical + back_fancy_height]); } back_plane_fancy(); diff --git a/Stenen_kastje_Ruben/dimensions.scad b/Stenen_kastje_Ruben/dimensions.scad index c49e2f7..bcafb6c 100644 --- a/Stenen_kastje_Ruben/dimensions.scad +++ b/Stenen_kastje_Ruben/dimensions.scad @@ -13,6 +13,6 @@ slat_depth = 40; back_thickness = 4; back_fancy_height = 50; -outer_thickness = 6; -outer_incut = 2; +outer_thickness = 12; +outer_incut = 5; outer_depth = slat_depth; diff --git a/Stenen_kastje_Ruben/functions.scad b/Stenen_kastje_Ruben/functions.scad new file mode 100644 index 0000000..2089daf --- /dev/null +++ b/Stenen_kastje_Ruben/functions.scad @@ -0,0 +1,17 @@ +// input : list of numbers +// output : sorted list of numbers +function quicksort(arr) = !(len(arr)>0) ? [] : let( + pivot = arr[floor(len(arr)/2)], + lesser = [ for (y = arr) if (y < pivot) y ], + equal = [ for (y = arr) if (y == pivot) y ], + greater = [ for (y = arr) if (y > pivot) y ] +) concat( + quicksort(lesser), equal, quicksort(greater) +); + +module cuben(name, size){ + cube(size=size, center=false); + // sizes should be ordered biggest to smallest + size_sorted=quicksort(size); + echo(str("#### ", name, ": " , size_sorted[2], "x", size_sorted[1], "x", size_sorted[0])); +}; diff --git a/Stenen_kastje_Ruben/horizontal_outside.scad b/Stenen_kastje_Ruben/horizontal_outside.scad index dff0092..55098ae 100644 --- a/Stenen_kastje_Ruben/horizontal_outside.scad +++ b/Stenen_kastje_Ruben/horizontal_outside.scad @@ -1,11 +1,10 @@ include +include module horizontal_outside(){ color("yellow") - translate([0, 0, -outer_thickness]) - cube(size=[outer_depth, cell_width * nr_cells_horizontal, outer_thickness], center=false); + cuben(" Horizontal outside", size=[outer_depth, cell_width * nr_cells_horizontal, outer_thickness]); - echo("#### Horizontal outside: length = ", cell_width * nr_cells_horizontal , " depth = ", outer_depth, "thickness = ", outer_thickness); } horizontal_outside(); diff --git a/Stenen_kastje_Ruben/horizontal_slat.scad b/Stenen_kastje_Ruben/horizontal_slat.scad index 8ffb145..97e1f2a 100644 --- a/Stenen_kastje_Ruben/horizontal_slat.scad +++ b/Stenen_kastje_Ruben/horizontal_slat.scad @@ -1,11 +1,11 @@ include +include module horizontal_slat(){ color("pink") translate([0, 0, -slat_thickness/2]) - cube(size=[slat_depth, cell_width * nr_cells_horizontal, slat_thickness], center=false); + cuben("Horizontal slat", size=[slat_depth, 2*outer_incut + cell_width * nr_cells_horizontal, slat_thickness]); - echo("#### Horizontal slat: length = ", cell_width * nr_cells_horizontal , " depth = ", slat_depth, "thickness = ", slat_thickness); } horizontal_slat(); diff --git a/Stenen_kastje_Ruben/parts b/Stenen_kastje_Ruben/parts index 36d1743..b0922f2 100644 --- a/Stenen_kastje_Ruben/parts +++ b/Stenen_kastje_Ruben/parts @@ -1,6 +1,6 @@ 0 x -1 x ECHO: "#### Fancy back: thickness = ", 4, " height = ", 308, "width = ", 308 -2 x ECHO: "#### Horizontal outside: length = ", 300, " depth = ", 40, "thickness = ", 6 -4 x ECHO: "#### Horizontal slat: length = ", 300, " depth = ", 40, "thickness = ", 4 -2 x ECHO: "#### Vertical outside: length = ", 262, " depth = ", 40, "thickness = ", 6 -5 x ECHO: "#### Vertical slat: length = ", 250, " depth = ", 40, "thickness = ", 4 +2 x ECHO: "#### Horizontal outside: 300x40x12" +1 x ECHO: "#### Fancy back: 324x324x4" +4 x ECHO: "#### Horizontal slat: 310x40x4" +2 x ECHO: "#### Vertical outside: 274x40x12" +5 x ECHO: "#### Vertical slat: 260x40x4" diff --git a/Stenen_kastje_Ruben/vertical_outside.scad b/Stenen_kastje_Ruben/vertical_outside.scad index 9fdeffe..5d83dd1 100644 --- a/Stenen_kastje_Ruben/vertical_outside.scad +++ b/Stenen_kastje_Ruben/vertical_outside.scad @@ -1,11 +1,11 @@ include +include module vertical_outside(){ color("green") - translate([0, 0, -outer_thickness]) - cube(size=[outer_depth, outer_thickness, (cell_height * nr_cells_vertical) + (2*outer_thickness) - 2*outer_incut], center=false); - - echo("#### Vertical outside: length = ", (cell_height * nr_cells_vertical) + (2*outer_thickness) , " depth = ", outer_depth, "thickness = ", outer_thickness); + translate([0, 0, -outer_thickness]) { + cuben("Vertical outside", size=[outer_depth, outer_thickness, (cell_height * nr_cells_vertical) + (2*outer_thickness) ]); + } } vertical_outside(); diff --git a/Stenen_kastje_Ruben/vertical_slat.scad b/Stenen_kastje_Ruben/vertical_slat.scad index 8b164f5..9a630f9 100644 --- a/Stenen_kastje_Ruben/vertical_slat.scad +++ b/Stenen_kastje_Ruben/vertical_slat.scad @@ -1,11 +1,10 @@ include +include module vertical_slat(){ color("red") - translate([0, 0, -slat_thickness/2]) - cube(size=[slat_depth, slat_thickness, cell_height * nr_cells_vertical], center=false); - - echo("#### Vertical slat: length = ", cell_height * nr_cells_vertical , " depth = ", slat_depth, "thickness = ", slat_thickness); + translate([0, -slat_thickness/2, 0 ]) + cuben("Vertical slat", size=[slat_depth, slat_thickness, 2*outer_incut + cell_height * nr_cells_vertical]); } vertical_slat();