Browse Source

using children and includes

master
Nicolas Massé 8 years ago
parent
commit
7d4f5490bb
  1. 16
      011-Children-Modularity/2d/rc_car.scad
  2. 40
      011-Children-Modularity/3d/alveolar_reinforcement.scad
  3. 38
      011-Children-Modularity/3d/square_reinforcement.scad
  4. 21
      011-Children-Modularity/main.scad

16
011-Children-Modularity/2d/rc_car.scad

@ -0,0 +1,16 @@
module rc_car(base, tip, junction) {
polygon(points = [
[base[0]/2, base[1]/2],
[base[0]/2, -base[1]/2],
[tip[0]/2, -base[1]/2-junction],
[tip[0]/2, -base[1]/2-junction-tip[1]],
[-tip[0]/2, -base[1]/2-junction-tip[1]],
[-tip[0]/2, -base[1]/2-junction],
[-base[0]/2, -base[1]/2],
[-base[0]/2, base[1]/2],
[-tip[0]/2, base[1]/2+junction],
[-tip[0]/2, base[1]/2+junction+tip[1]],
[tip[0]/2, base[1]/2+junction+tip[1]],
[tip[0]/2, base[1]/2+junction]
]);
}

40
011-Children-Modularity/3d/alveolar_reinforcement.scad

@ -0,0 +1,40 @@
module alveolar_reinforcement(bounding_box, thickness, height, alveolus_size) {
xstep = 2 * cos(30) * (thickness + sqrt(3) * alveolus_size / 2);
ystep = sin(30) * (thickness + sqrt(3) * alveolus_size / 2);
xn = ceil((bounding_box[1][0] - bounding_box[0][0]) / xstep);
yn = ceil((bounding_box[1][1] - bounding_box[0][1]) / ystep);
origin = bounding_box[0];
// Bounding box debug
/*
#polygon(points = [
[bounding_box[0][0], bounding_box[0][1]],
[bounding_box[1][0], bounding_box[0][1]],
[bounding_box[1][0], bounding_box[1][1]],
[bounding_box[0][0], bounding_box[1][1]]
]);
*/
difference() {
linear_extrude(height = height) {
children();
}
for (y = [0:1:yn]) {
for (x = [0:1:xn]) {
posx = origin[0] + (x * xstep) + (y % 2) * xstep / 2;
posy = origin[1] + (y * ystep);
translate([posx, posy, height / 2 + thickness])
cylinder(d = alveolus_size, h = height - thickness, center = true, $fn = 6);
}
}
}
linear_extrude(height = height) {
difference() {
children();
offset(-thickness)
children();
}
}
}

38
011-Children-Modularity/3d/square_reinforcement.scad

@ -0,0 +1,38 @@
module square_reinforcement(bounding_box, thickness, height, alveolus_size) {
step = alveolus_size+thickness;
xn = ceil((bounding_box[1][0] - bounding_box[0][0]) / step);
yn = ceil((bounding_box[1][1] - bounding_box[0][1]) / step);
origin = bounding_box[0];
// Bounding box debug
/*
#polygon(points = [
[bounding_box[0][0], bounding_box[0][1]],
[bounding_box[1][0], bounding_box[0][1]],
[bounding_box[1][0], bounding_box[1][1]],
[bounding_box[0][0], bounding_box[1][1]]
]);
*/
difference() {
linear_extrude(height = height) {
children();
}
for (y = [0:1:yn]) {
for (x = [0:1:xn]) {
posx = origin[0] + (x * step);
posy = origin[1] + (y * step);
translate([posx, posy, height / 2 + thickness])
cube(size = [alveolus_size, alveolus_size, height - thickness], center = true);
}
}
}
linear_extrude(height = height) {
difference() {
children();
offset(-thickness)
children();
}
}
}

21
011-Children-Modularity/main.scad

@ -0,0 +1,21 @@
use <3d/square_reinforcement.scad>
use <3d/alveolar_reinforcement.scad>
use <2d/rc_car.scad>
// Size of the RC Car plate
base = [135, 200];
tip = [50, 50];
junction = 25;
// Compute the bounding box size
size_x = base[0];
size_y = base[1]+2*tip[1]+2*junction;
bounding_box = [[-size_x/2, -size_y/2], [size_x/2, size_y/2]];
translate([-100, 0, 0])
square_reinforcement(bounding_box = bounding_box, thickness = 2, height = 10, alveolus_size = 30)
rc_car(base, tip, junction);
translate([100, 0, 0])
alveolar_reinforcement(bounding_box = bounding_box, thickness = 1, height = 10, alveolus_size = 15)
rc_car(base, tip, junction);
Loading…
Cancel
Save