summaryrefslogtreecommitdiff
path: root/body/laser_holder.scad
blob: 34a6466c504f88d3df1d7eaa0bbbbed4393516ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
include <helpers.scad>
include <laser.scad>

default_laser_holder_padding = [4, 1.5, 1.5];

// d - laser body diameter
// l - laser body length
// padding - see `laser_holder_wo_holes` for details
function laser_holder_size(
    d = default_laser_d,
    l = 45,
    padding = default_laser_holder_padding) = ([d, l / 2, d] + padding * 2);

// create a holder for laser with diameter `d` and
// length `l`. no holes
// with one-side `padding` for each axis
module laser_holder_wo_holes(
    d = default_laser_d,
    l = 45,
    padding = default_laser_holder_padding)
{   
    translate([0, -l / 2 , 0])
    cube(laser_holder_size(d = d, l = l, padding = padding), center = true);
}

// create a hole for laser holder for laser with diameter `d`.
// hole will have diameter `hd` and height `hh`
module laser_holder_tension_hole(d = default_laser_d, hd = 4, hh = 4)
{
    //tension_holes_angle = -45;
    tension_holes_angle = -90;
    rotate([0, tension_holes_angle, 0])
    translate([0, 0, d / 2 - hh / 2])
    cylinder($fn = diameterToFn(hd), d = hd, h = hh * 3);
}

// d - laser body diameter
// hd - hole diameter
// hh - hole height
// padding - see `laser_holder_wo_holes` for details
module laser_holder_bottom_hole(
    d = default_laser_d,
    hd = 4,
    hh = 4,
    padding = default_laser_holder_padding)
{
    //translate([0, -10, -((d + hh) / 2)])
    z_padding = $tiny_padding;
    translate([0, 0, -d / 2 - padding[2] - z_padding])
    cylinder($fn = diameterToFn(hd), d = hd, h = hh + z_padding * 2);
}

// see `laser_holder_bottom_hole` for args details
module laser_holder_bottom_holes(
    d = default_laser_d,
    l = default_laser_l,
    hd = 4,
    hh = 4,
    padding = default_laser_holder_padding)
{
    x_mults = [-1, +1];
    y_mults = [1 / 3, 2 / 3];
    
    union()
    {
        for (x_mult = x_mults, y_mult = y_mults)
        {        
            x = (d / 2 + padding[0] / 2 - $tiny_padding) * x_mult;
            y = -l * y_mult;
            
            translate([x, y, 0])
            laser_holder_bottom_hole();
        }
    }
}

module laser_holder_holes(d = default_laser_d, l = default_laser_l, d_padding = 0.5)
{
    union()
    {
        laser_body(d = d + d_padding);
        // front tension hole
        translate([0, -l * 1 / 3, 0])
        laser_holder_tension_hole(d=d);
        // back tension hole
        translate([0, -l * 2 / 3, 0])
        laser_holder_tension_hole(d=d);
        // bottom holes
        laser_holder_bottom_holes();
    }
}

// create a holder for laser with diameter `d` and
// length `l`. with holes.
// hole for laser has diameter `d` + padding `d_padding`
module laser_holder(d = default_laser_d, l = default_laser_l, d_padding = 0.5)
{
    difference()
    {
        laser_holder_wo_holes();
        laser_holder_holes(d=d, l=l, d_padding = d_padding);
    }
}

//laser_holder_wo_holes();
//*#laser_body();
//laser_holder();
//laser_holder_bottom_holes();