/[qspeakers]/branches/qtcharts/sealedbox_template.scad
ViewVC logotype

Contents of /branches/qtcharts/sealedbox_template.scad

Parent Directory Parent Directory | Revision Log Revision Log


Revision 298 - (show annotations)
Wed Nov 25 13:12:53 2020 UTC (6 months, 2 weeks ago) by ben
File size: 1697 byte(s)
Fixup openSCAD templates.

1 /* loudspeaker __MODEL__ */
2 loudspeaker_number = __NUMBER__;
3 margin = __MARGIN__; /* cm */
4 loudspeaker_diameter = __DIAMETER__; /* cm */
5 internal_closed_box_volume = __SEALEDBOXVOLUME__; /* dmĀ³ (Liter) */
6 wood_thick = __WOODTHICK__; /* cm */
7 wood_color = "wheat";
8
9 internal_closed_box_width = loudspeaker_diameter + margin; /* cm (x)*/
10 internal_closed_box_height = max((loudspeaker_diameter + margin) * loudspeaker_number, 1.618 * internal_closed_box_width); /* cm (z)*/
11 internal_closed_box_depth = internal_closed_box_volume * 1000 / (internal_closed_box_width * internal_closed_box_height); /* cm (y)*/
12
13 vertical_center = (internal_closed_box_height + (2 * wood_thick)) / 2;
14 horizontal_center = (internal_closed_box_width + (2 * wood_thick)) / 2;
15
16 module speaker_hole(diameter, x, z)
17 {
18 translate([x, 0, z]) {
19 rotate([90, 0, 0]) {
20 color("black") {
21 cylinder($fn=360, h = 2 * wood_thick, r1 = diameter / 2, r2 = diameter / 2, center=true);
22 }
23 }
24 }
25 }
26 module closed_enclosure(width, height, depth)
27 {
28
29 difference() {
30 /* external dimentions */
31 color(wood_color) {
32 cube([width + (2 * wood_thick), depth + (2 * wood_thick), height + (2 * wood_thick)]);
33 }
34
35 /* internal dimentions */
36 translate([wood_thick, wood_thick, wood_thick]) {
37 color(wood_color) {
38 cube([width, depth, height]);
39 }
40 }
41 }
42 }
43
44 difference() {
45 closed_enclosure(internal_closed_box_width, internal_closed_box_height, internal_closed_box_depth);
46 for (i = [0:loudspeaker_number-1]) {
47 speaker_hole(loudspeaker_diameter, horizontal_center, margin + (loudspeaker_diameter / 2) + i * (loudspeaker_diameter + margin));
48 }
49 }

  ViewVC Help
Powered by ViewVC 1.1.26