summaryrefslogtreecommitdiffstats
path: root/case/support.scad
blob: 6aa8a84fc01741eb8bccb2f01d01403f60855b7f (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
module support(dimensions, width) {
    aspect_ratio = 3.75 / 12.0;

    length = dimensions[0];
    height = dimensions[1];

    module right_triangle(base) {
        hypot = sqrt(2*(base^2));

        intersection() {
            square([base, base]);

            translate([-base, 0, 0])
            rotate([0, 0, -45])
            square([hypot, hypot]);
        }
    }

    module shape() {
        /* Height ratio of lower aspect to upper aspect */
        aspect_upper_height = height;
        aspect_lower_height = aspect_ratio * height;

        /* The length of each individual support aspect */
        aspect_length = 1/3 * length;

        hypotenuse     = sqrt(2*(aspect_length^2));
        lower_x_offset = aspect_length - (hypotenuse - aspect_length);

        right_triangle(height);

        square([length, aspect_lower_height], false);

        translate([3 * aspect_length, 0, 0])
        mirror([1, 0, 0])
        right_triangle(height);
    }

    translate([0, length, 0])
    rotate([-90, 0, -90])
    linear_extrude(width)
    intersection() {
        shape();
        square([length, height], false);
    }
}