function rough_tin(obj) { return color(0.6, 0.6, 0.8, o_bump(0.03, 0.05, obj ) ); } function knee_arc(outer_dia, thickness, width, sweep) { return intersection( #translate(0,-outer_dia,-width/3,cube(outer_dia, outer_dia, width*3)), color(0,0,1,difference(cylinder(outer_dia,width), translate(0,0,-width/2,cylinder(outer_dia-thickness*2,width*2)))), color(1,0,0,translate(0,-outer_dia,-width/3,cube(outer_dia, outer_dia, width*3))), color(0,1,0,rotate(0,0,-sweep, translate(-outer_dia,-outer_dia*2,-width/3,cube(outer_dia*2,outer_dia*2,width*4)))) ); } function main(ARGV) { length_total = "2.0"; thickness = "0.3"; outer_dia = "0.8"; height = "1.0"; width = "0.4"; bend_angle = "15.0"; bend_start = "0.75"; diag_length = (height-outer_dia+outer_dia/2*sin(bend_angle/180*3.14159265359)+(outer_dia/2-thickness)*sin(bend_angle/180*3.14159265359))/cos(bend_angle/180*3.14159265359); bend_shift = diag_length*sin(bend_angle/180*3.14159265359)-(1-cos(bend_angle/180*3.14159265359))*(outer_dia/2-thickness)-(1-cos(bend_angle/180*3.14159265359))*outer_dia/2; knee1 = translate(bend_start,outer_dia/2,0,knee_arc(outer_dia, thickness, width, bend_angle)); knee2 = translate(length_total-bend_start+bend_shift,height-outer_dia/2,0,rotate(0,0,180, knee_arc(outer_dia, thickness, width, bend_angle))); commit(o_fn(30,union(leg1, knee1, leg2, knee2, leg3))); }