]> www.fi.muni.cz Git - things.git/blob - led-torch.scad
led torch - printed version
[things.git] / led-torch.scad
1 infty = 200;
2 eps = 0.01;
3
4 wall = 1;
5
6 led_d = 10 + 0.5;
7 int_d = 19/cos(30);
8 barrier_h = 8;
9 body_l = 70 + barrier_h;
10
11 clip_l = 2;
12 clip_w = 0.8;
13 clip_dist = 3;
14
15 // main cylinder
16 difference() {
17         cylinder(r = int_d/2 + wall/cos(30), $fn = 6, h = body_l);
18         translate([0, 0, wall])
19         cylinder(r = int_d/2, $fn = 6, h = body_l);
20         // hole for LED
21         translate([0, 0, -eps])
22                 cylinder(r = led_d/2, h = infty);
23 }
24
25 // battery front end stop
26 translate([0, 0, barrier_h-wall])
27 intersection() {
28         cylinder(r = int_d/2 + wall/(2*cos(30)), $fn = 6, h = wall);
29         for (angle = [0:360/3:360]) rotate ([0, 0, angle])
30                 translate([led_d/2+wall, -infty/2, -eps])
31                         cube(infty);
32 }
33
34 // rear end clip
35 for (angle = [0:60:360]) rotate([0, 0, angle])
36 translate([-clip_l/2, int_d*cos(30)/2+wall, body_l - clip_dist]) {
37         scale([1, 1, 3])
38         rotate([0, 90, 0])
39                 cylinder(r = clip_w, h = clip_l, $fn = 4);
40 }
41
42 // lid
43
44 switch_w = 14;
45 switch_h = 9;
46
47 lid_d = int_d + 2*wall/cos(30) + 2*clip_w/cos(30);
48 lid_h = clip_dist + 3*wall+3*clip_w + switch_h;
49
50 support_w = 4;
51 support_off = 3;
52 translate([0, int_d + 5, 0])
53 difference() {
54         cylinder(r = lid_d/2 + wall/cos(30), $fn = 6, h = lid_h);
55         translate([-switch_w/2, 0, wall+eps])
56                 cube([switch_w, infty, switch_h]);
57         difference() {
58                 union() {
59                         translate([0, 0, wall+switch_h])
60                                 cylinder(r = lid_d/2, $fn = 6, h = lid_h);
61                         translate([0, 0, wall])
62                                 cylinder(r = lid_d/2-2*wall/cos(30), $fn = 6, h = lid_h);
63                         intersection() { // switch side w/o support
64                                 translate([0, 0, wall])
65                                         cylinder(r = lid_d/2, $fn = 6, h = lid_h);
66                                 translate([-infty/2, 0, 0]) cube(infty);
67                         }
68                 }
69                 for (angle = [60:180:360]) rotate([0, 0, angle])
70                 translate([-clip_l/2, lid_d*cos(30)/2, switch_h+clip_dist + 2*wall]) {
71                         scale([1, 1, 3])
72                         rotate([0, 90, 0])
73                         cylinder(r = clip_w, h = clip_l, $fn = 4);
74                 }
75                 translate([-infty/2, -support_w-support_off, switch_h-eps])
76                         cube([infty, support_w, wall]);
77         }
78 }