/* [General] */

// Resolution
$fn=120; // [36:6:180]

/* [Outer and inner tubes] */
// Diameter of outer tube.
outer_tube_diameter = 22;
// Wall thickness of the outer tube.
outer_tube_wall = 2;
// Diameter of inner tube.
inner_tube_diameter = 20;
// Wall thickness of the inner tube.
inner_tube_wall = 2;

/* [Bolt drilling] */
// Diameter of the used screw
drill_hole_diameter = 5;
// Position measured from the end of the tube
drill_hole_position = 20;

/* [Rubber cord] */
rubber_band_diameter = 2.5;

/* [3D printput] */
holder_wall_thickness = 1.5;

/* [Hidden] */

d_a = outer_tube_diameter;
d_i = inner_tube_diameter - 2*inner_tube_wall;


/////////////////////////////////////////////////////////////////////////////


module aussen() {
  // Sockel angerundet
  translate([0,0,-holder_wall_thickness]) union() {
    cylinder( d=d_a, h=holder_wall_thickness );
    hull() 
      rotate_extrude() 
        translate([ (d_a-holder_wall_thickness)/2, 0 ]) 
          circle( d=holder_wall_thickness );
  }
  // Zapfen Außenform
  hull() {
    cylinder( d=d_i, h=holder_wall_thickness );
    translate([0, 0, drill_hole_position+drill_hole_diameter]) 
      sphere( d=d_i );
  }
}

module innen() {
  // Zapfen innen hohl
  hull() {
    translate([0, 0, -0.01]) 
      cylinder( d=(d_i-2*holder_wall_thickness), h=holder_wall_thickness );
    translate([0, 0, drill_hole_position+drill_hole_diameter]) 
      sphere( d=(d_i-2*holder_wall_thickness) );
  }
  // Bohrung
  translate([0, 0, drill_hole_position]) 
    rotate([0, 90, 0]) 
      cylinder( d1=drill_hole_diameter, d2=max(drill_hole_diameter, 3*rubber_band_diameter), h=(d_i+holder_wall_thickness), center=true);
  // Schlitz um Gummi einzulegen
  translate([0, -rubber_band_diameter/2, drill_hole_position]) 
    cube([d_i, rubber_band_diameter, d_i]);
  // Loch oben fürs Gummiband 
  translate([0, 0, drill_hole_position]) 
    cylinder( d=rubber_band_diameter, h=drill_hole_position);
}

difference() {
  aussen();
  innen();
  //translate([-50,-100,-10]) cube(100); // Schnittsicht, Debug
}
