/** * tub.scad * * The tub of a microcar. */ include $fn = $preview ? 32 : 256; a_pillar_y = -400; // y location of face of 'A' pillar bb_height = 274; // internal height of battery box bb_width = 260; // internal width of battery box /***************************************************** * the 'cowl' is the near-horizontal panel which the * bottom of the windscreen is mounted to. In practice * this probably slopes down forward, but for the * moment I'm making the simlifying assumption that it * is horizontal. ****************************************************/ // slope of the cowl cowl_angle = -70; // maximum height of the cowl (at the A pillar) cowl_height = 450; floor_length = 1100; floor_width = 1500; /***************************************************** * TODO: I need to calculate the lengths of everything * which bonds to the front or rear bulkhead from the * layback angles, but I'm being lazy for now ****************************************************/ // angle of the front bulkhead to vertical layback_angle_f = 30; // angle of the rear bulkhead to vertical layback_angle_r = 50; sheet_thickness = 8; sill_max_height = bb_height; sill_min_height = 125; sill_width = 150; module battery_box_side( floor_length = 1100) { fhl = (floor_length/2); top_hlf = (bb_height * tan(layback_angle_f)) + fhl; top_hlr = (bb_height * tan(layback_angle_r)) + fhl; rotate([90, 0 , 0]) linear_extrude( height=sheet_thickness) { polygon([[ 0 - fhl, 0], [ fhl, 0], [ top_hlr, bb_height], [ 0 - top_hlf, bb_height]]); } } module battery_box( floor_length = 1100) { top_hl = 800; // calculate this later hbbw = bb_width/2; bias = (layback_angle_f == layback_angle_r) ? 0 : bb_height * ( tan(layback_angle_r) - tan(layback_angle_f))/2; translate([0, hbbw, 0]) battery_box_side( floor_length); translate([0, 0 - (hbbw + sheet_thickness), 0]) battery_box_side( floor_length); translate([0, 0 - hbbw, 0]) cube([sheet_thickness, bb_width, bb_height]); translate([bias, 0 - sheet_thickness, bb_height]) cube([floor_length + (bb_height * tan(layback_angle_f)) + (bb_height * tan(layback_angle_r)), bb_width + (sheet_thickness * 2), sheet_thickness], center = true); } module sill( floor_length = 1100) { cr = 5000; fhl = (floor_length/2); top_hl = fhl + (cowl_height * tan(layback_angle_f)); top_hlr = fhl + (sill_max_height * tan(layback_angle_r)); difference() { rotate([90, 0 , 0]) linear_extrude( height=sill_width) { polygon([[ 0 - fhl, 0], [ fhl, 0], [ top_hlr, sill_max_height], [ 0, sill_min_height], [ a_pillar_y, sill_min_height], [ a_pillar_y, cowl_height], [ 0 - top_hl, cowl_height]]); } rotate([-3, 0, 0]) translate([0, cr - (sill_width/2), 0]) cylinder( h = cowl_height, r = cr); } } module front_bulkhead() { e = cowl_height / cos(layback_angle_f); translate([ 0 - floor_length/2, 0 -floor_width/2, 0]) rotate([0, 0- layback_angle_f, 0]) cube([sheet_thickness, floor_width, e]); } module rear_bulkhead() { } module tub(fl=floor_length, fw=floor_width, st=sheet_thickness, sw=sill_width) { cube([fl, fw, st], center=true); battery_box(); translate([0, ( fw/2) + (sw/2), 0]) sill(); mirror([0, 1, 0]) translate([0, ( fw/2) + (sw/2), 0]) sill(); front_bulkhead(); rear_bulkhead(); } // tub();