]> www.fi.muni.cz Git - things.git/blob - nerf.scad
nerf.scad: optics holder for nerf gun
[things.git] / nerf.scad
1 eps = 0.01;
2 infty = 100;
3
4 wall = 1;
5
6 lens_d = 41.5;
7 lens_side_l = 25;
8 rail_in = 13.5;
9 rail_ex = 18.2;
10 rail_thick = 3.4;
11 rail_depth = rail_thick + wall;
12 body_l = 55;
13 rail_in_l = 15;
14
15 beam_l = 7;
16 beam_w = 0.8;
17
18 $fn = 120;
19
20 difference() {
21         union() {
22                 difference() {
23                         union() {
24                                 // outer cylinder
25                                 cylinder(r = lens_d/2 + 2*wall, h = body_l);
26                                 // rail base
27                                 translate([-rail_ex/2-wall, -lens_d/2-rail_depth-2*wall, 0])
28                                         cube([rail_ex+2*wall, lens_d/2+rail_depth+2*wall, body_l]);
29                         }
30                         // inner cylinder
31                         translate([0, 0, -eps])
32                                 cylinder(r = lens_d/2 + wall, h = body_l+2*eps);
33                         // cut the top third of the cylinder
34                         translate([-infty/2, lens_d/2*sin(30) + wall, -eps])
35                                 cube(infty);
36                         difference() {
37                                 // rail_ex -wide hole
38                                 translate([-rail_ex/2, -lens_d/2-2*wall-rail_thick, -eps])
39                                         cube([rail_ex, rail_thick, body_l+2*eps]);
40                                 // beam
41                                 translate([-rail_ex/2-eps, -lens_d/2-2*wall-beam_w, rail_in_l-beam_l])
42                                         cube([rail_ex+2*eps, beam_w+eps, beam_l]);
43                         }
44                         // rail_ex -wide top
45                         translate([-rail_ex/2, -lens_d/2-2*wall-rail_depth-eps, rail_in_l])
46                                 cube([rail_ex, rail_depth, body_l+2*eps]);
47                         // rail-in wide hole
48                         translate([-rail_in/2, -lens_d/2-2*wall-rail_depth-eps, -eps])
49                                 cube([rail_in, rail_depth+eps, body_l+2*eps]);
50                 }
51                 // inside supports
52                 for (angle = [-27, 27, 120, 240]) rotate([0, 0, angle])
53                         translate([0, -lens_d/2-wall, -2*eps])
54                                 cylinder(r = wall, h = body_l + 4*eps);
55         }
56         // slanted cylinder cut
57         translate([-infty/2, cos(60)*lens_d/2, body_l+lens_side_l])
58                 rotate([0, 90, 0])
59                 scale([2, 1.2, 1])
60                 cylinder(r = body_l/2, h = infty);
61 }
62