
//------------------------------------------------------------
// Parametric pendulum rod coupling to increase frame stiffness
//
// http://www.thingiverse.com/wardwouts
//
//------------------------------------------------------------

bar1_diameter = 6.5;
bar2_diameter = 6.5;

M3 = 3.2;

thickness = 3;
spacing = 1;
compat = 3; // 3 for compatible with reprappro pieces; 0 a bit smaller

open=1;


FN=80*1; // 80 for nice prints; 16 for speed

bar1r = bar1_diameter/2;
bar2r = bar2_diameter/2;

height=bar1_diameter+2*thickness;

// I really need nut or rivetsize to make bar1mount the right size
module bar1mount(){
	translate([-(bar1_diameter+2*thickness+compat),-thickness/2,0]){
		difference(){
			cube([bar1_diameter+2*thickness+compat+1,thickness,height]);
			union(){
				translate([thickness + bar1r,-thickness,thickness+bar1r]){
					rotate([-90,0,0]){
						cylinder(h=(thickness*4), r=bar1r, $fn=FN);
					}
					if (open ==1){
						translate([-bar1r,0,0]){
							rotate([0,10,0]){
								cube([2*bar1r,thickness*4,30]);
							}
						}
					}
				}
			}
		}
	}
}

module bar2mount(){
	translate([bar2r+thickness,0,0]){
		difference(){
			cylinder(h=height, r=bar2r+thickness, $fn=FN);
			translate([0,0,-height]){
				cylinder(h=height*3, r=bar2r, $fn=FN);
			}
		}
	}
}

module screwmount(){
	translate([bar2_diameter+2*thickness-1,-(thickness+spacing/2),0]){
		difference(){
			cube([thickness*2+M3, thickness*2+spacing, height]);
			translate([thickness+M3/2, -thickness, height/2]){
				rotate([-90,0,0]){
					cylinder(h=thickness*5+spacing, r=M3/2, $fn=FN);
				}
			}
		}
	}
}

module cutout(){
	translate([bar2r+thickness,-spacing/2,-height]){
		cube([thickness*5+M3*2, spacing, height*3]);
	}
}

module crossbar_coupling(){
	difference(){
		union(){
			bar1mount();
			bar2mount();
			screwmount();
		}
		cutout();
	}
}

crossbar_coupling();
