$fn = 100;

bottle_dia = 45;

air_tank_mount_v2();

module air_tank_mount_v0() {
    difference() {
        translate([-24, -24, 0]) cube([48, 48, 8]);
        translate([0, 0, -1]) cylinder(r=22.5, h=72);
        translate([-20, -20, 4]) dualhole(true);
        translate([-20, 20, 4]) dualhole(true);
        translate([20, -20, 4]) dualhole(true);
        translate([20, 20, 4]) dualhole(true);
    }
}

module air_tank_mount_v1() {
    difference() {
        translate([-24, -24, 0]) cube([48, 48, 8]);
        translate([0, 0, -1]) cylinder(r=22.5, h=72);
        translate([-20, -20, 4]) dualhole();
        translate([-20, 20, 4]) dualhole();
        translate([20, -20, 4]) dualhole();
        translate([20, 20, 4]) dualhole();
    }
}

module air_tank_mount_v2() {
    sz = ceil((bottle_dia+2.4)/8)*8;
    difference() {
        translate([-sz/2, -sz/2, 0]) cube([sz, sz, 8]);
        translate([0, 0, -1]) cylinder(r=bottle_dia/2, h=72);
        translate([-sz/2+4, -sz/2+4, 4]) axleround(axleradius=2.6, axlemesh=2);
        translate([-sz/2+4, sz/2-4, 4]) axleround(axleradius=2.6, axlemesh=2);
        translate([sz/2-4, -sz/2+4, 4]) axleround(axleradius=2.6, axlemesh=2);
        translate([sz/2-4, sz/2-4, 4]) axleround(axleradius=2.6, axlemesh=2);
//        translate([-25, -25, 4]) cube([50, 50, 8]);
    }
}

module axleround(h = 24, axleradius = 2.3, axlemesh = 1.7) {
    translate([0, 0, -h/2]) difference() {
        cylinder($fn=16, r=axleradius, h=h);
        translate([axlemesh/2, axlemesh/2, -1]) cube([axleradius, axleradius, h+2]);
        translate([axlemesh/2, -axlemesh/2-axleradius, -1]) cube([axleradius, axleradius, h+2]);
        translate([-axlemesh/2-axleradius, axlemesh/2, -1]) cube([axleradius, axleradius, h+2]);
        translate([-axlemesh/2-axleradius, -axlemesh/2-axleradius, -1]) cube([axleradius, axleradius, h+2]);
    }
}

module hole() {
    union() {
        cylinder(r=2.4, h=8);
        translate([0, 0, -0.1]) cylinder(r=3, h=0.8+0.1);
        translate([0, 0, 7.2]) cylinder(r=3, h=0.8+0.1);
    };
}

module dualhole(both = false) {
    translate([0, 4, 0]) rotate([90, 0, 0]) hole();
    if (both) {
        translate([4, 0, 0]) rotate([0, -90, 0]) hole();
    }
}
