Browse Source

add some examples

master
Nicolas Massé 8 years ago
parent
commit
827290372f
  1. 14
      examples/reinforcement/README.md
  2. BIN
      examples/reinforcement/images/example_circular_botton.png
  3. BIN
      examples/reinforcement/images/example_circular_top.png
  4. BIN
      examples/reinforcement/images/example_square_bottom.png
  5. BIN
      examples/reinforcement/images/example_square_top.png
  6. 44
      examples/reinforcement/reinforcement.scad
  7. 52
      examples/tutorial/tutorial.scad

14
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)

BIN
examples/reinforcement/images/example_circular_botton.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
examples/reinforcement/images/example_circular_top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
examples/reinforcement/images/example_square_bottom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
examples/reinforcement/images/example_square_top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

44
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);
}

52
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]);
}
Loading…
Cancel
Save