diff --git a/examples/reinforcement/README.md b/examples/reinforcement/README.md new file mode 100644 index 0000000..27fafa3 --- /dev/null +++ b/examples/reinforcement/README.md @@ -0,0 +1,14 @@ +# An alveolar reinforcement + +This example shows how to reinforce the bottom of a box with an alveolar +structure. + +## Showcase + +A round box with reinforced bottom: +![bottom](images/example_circular_bottom.png?raw=true) +![top](images/example_circular_top.png?raw=true) + +A square box with reinforced bottom: +![bottom](images/example_square_bottom.png?raw=true) +![top](images/example_square_top.png?raw=true) diff --git a/examples/reinforcement/images/example_circular_botton.png b/examples/reinforcement/images/example_circular_botton.png new file mode 100644 index 0000000..1c51871 Binary files /dev/null and b/examples/reinforcement/images/example_circular_botton.png differ diff --git a/examples/reinforcement/images/example_circular_top.png b/examples/reinforcement/images/example_circular_top.png new file mode 100644 index 0000000..fc44587 Binary files /dev/null and b/examples/reinforcement/images/example_circular_top.png differ diff --git a/examples/reinforcement/images/example_square_bottom.png b/examples/reinforcement/images/example_square_bottom.png new file mode 100644 index 0000000..aca7af7 Binary files /dev/null and b/examples/reinforcement/images/example_square_bottom.png differ diff --git a/examples/reinforcement/images/example_square_top.png b/examples/reinforcement/images/example_square_top.png new file mode 100644 index 0000000..1f25c56 Binary files /dev/null and b/examples/reinforcement/images/example_square_top.png differ diff --git a/examples/reinforcement/reinforcement.scad b/examples/reinforcement/reinforcement.scad new file mode 100644 index 0000000..e1ece7c --- /dev/null +++ b/examples/reinforcement/reinforcement.scad @@ -0,0 +1,44 @@ +use <../../pattern.scad> + +thickness = 0.5; +alveolus_size = 5; +xstep = cos(30) * (thickness + sqrt(3) * alveolus_size / 2); +ystep = sin(30) * (thickness + sqrt(3) * alveolus_size / 2); +xmove = [ 2 * xstep, 0 ]; +ymove = [ xstep, ystep ]; +reinforcement_height = 2; +height = 10; + +module reinforced_box(thickness, height, reinforcement_height) { + // Reinforce the bottom + difference() { + linear_extrude(height = reinforcement_height) + children(0); + translate([0,0, thickness]) + children(1); + } + + // Build the walls + linear_extrude(height = height) { + difference() { + children(0); + offset(-thickness) + children(0); + } + } +} + +// The first box has a square base +translate([100, 0]) +reinforced_box(thickness, height, reinforcement_height) { + square([40, 40], center=true); + spray_pattern([[-20,-20], [20, 20]], [ xmove, ymove]) + cylinder(d = alveolus_size, h = reinforcement_height, center = true, $fn = 6); +} + +// The second one has a circular base +reinforced_box(thickness, height, reinforcement_height) { + circle(d=40, center=true); + spray_pattern([[-20,-20], [20, 20]], [ xmove, ymove]) + cylinder(d = alveolus_size, h = reinforcement_height, center = true, $fn = 6); +} diff --git a/examples/tutorial/tutorial.scad b/examples/tutorial/tutorial.scad new file mode 100644 index 0000000..b47a80c --- /dev/null +++ b/examples/tutorial/tutorial.scad @@ -0,0 +1,52 @@ +/* + * Pattern spraying tutorial + * + * In this tutorial, we will spray the famous pattern of a football ball. + */ + +// First, include the module +use <../../pattern.scad> + +// Define the base shape: an octogon and a square +// "r" is the radius of the circle defining the octogon +// The size and the position of the square is determined also from this value +module mypattern(r) { + // The octogon + rotate([0,0,22.5]) + circle(r=r, center=true, $fn=8); + + // The square + l = 2 * r * sin(22.5); + translate([r,r,0]) + rotate([0,0,45]) + square([l,l], center=true); +} + +// Instanciate the base shape, once. +r = 2; +mypattern(r); + +// Define our moves: how the pattern is sprayed +moves = [ + [ 2*r, 0], // For the first move, we will translate on x by two times the radius + [ 0, 2*r], // For the second move, we will translate on y by two times the radius +]; + +// Define the boundaries: the area to spray is defined by a rectangle +bounding_box = [ + [0,0], // Lower left corner + [20, 20] // upper right corner +]; + +// Spray our pattern in the bounding box +translate([-40, 0, 0]) +spray_pattern(bounding_box, moves) + mypattern(r); + +// Because we love clean edges, we cut the sprayed pattern at the bounding box size. +translate([20, 0, 0]) +intersection() { + spray_pattern(bounding_box, moves) + mypattern(r); + square(bounding_box[1] - bounding_box[0]); +}