# HG changeset patch # User Paul Boddie # Date 1418322489 -3600 # Node ID 8db0d3d41b7358c75e4330ad8fc77c1e2e58806f # Parent ed7b8c2c11bb82c46f3ebd0ba0c01ef15f549364 Introduced explicit variables for the lower and upper extents of the cartridge. diff -r ed7b8c2c11bb -r 8db0d3d41b73 cartridge.scad --- a/cartridge.scad Thu Dec 11 18:48:02 2014 +0100 +++ b/cartridge.scad Thu Dec 11 19:28:09 2014 +0100 @@ -182,8 +182,10 @@ connector_height = bottom + int_connector_height; height = payload_height + bottom + int_connector_height; depth = int_payload_depth + front + payload_back; - int_payload_upper_extent = height / 2 - top; - int_payload_lower_extent = -height / 2 + int_connector_height + bottom; + upper_extent = height / 2; + lower_extent = -upper_extent; + int_payload_upper_extent = upper_extent - top; + int_payload_lower_extent = lower_extent + int_connector_height + bottom; /* Where the payload is wider than the connector, the payload expands to the left. */ @@ -505,7 +507,7 @@ cube_at(int_connector_width, int_front_depth, bottom, 0, -1, 1, - 0, 0, -height / 2 + int_connector_height); + 0, 0, lower_extent + int_connector_height); /* Left cutout. */ @@ -515,7 +517,7 @@ 1, -1, 1, -int_connector_width / 2, 0, - -height / 2 + int_connector_height); + lower_extent + int_connector_height); /* Right cutout. */ @@ -525,7 +527,7 @@ -1, -1, 1, int_connector_width / 2, 0, - -height / 2 + int_connector_height); + lower_extent + int_connector_height); } /* Extended floor. */ @@ -534,7 +536,7 @@ cube_at(payload_width - connector_width, front_depth, bottom, 1, -1, 1, - payload_left_extent, 0, -height / 2 + int_connector_height); + payload_left_extent, 0, lower_extent + int_connector_height); } /* PCB supports. */ @@ -571,7 +573,7 @@ if (FRONT_LABEL_INSET) translate([front_label_left_extent, -front_depth, - front_label_offset_from_bottom - height / 2]) + lower_extent + front_label_offset_from_bottom]) cube([front_label_width, front_label_depth, front_label_height]); @@ -580,14 +582,14 @@ if (TOP_LABEL_INSET) translate([top_label_left_extent, -front_depth + top_label_offset_from_front, - height / 2 - top_label_depth]) + upper_extent - top_label_depth]) cube([top_label_width, top_label_height, top_label_depth]); } /* Inner front edge cavity. */ - translate([inner_front_edge_width / 2, -int_front_depth, -height / 2]) + translate([inner_front_edge_width / 2, -int_front_depth, lower_extent]) rotate([0, -90, 0]) linear_extrude(height = inner_front_edge_width) polygon([ @@ -635,17 +637,17 @@ /* Top left and right rounding. */ - translate([payload_left_extent + ro, -front_depth / 2, height / 2 - ro]) + translate([payload_left_extent + ro, -front_depth / 2, upper_extent - ro]) rotate([0, 0, 180]) rotate([90, 0, 0]) fillet(rr, front_depth); - translate([payload_right_extent - ro, -front_depth / 2, height / 2 - ro]) + translate([payload_right_extent - ro, -front_depth / 2, upper_extent - ro]) rotate([90, 0, 0]) fillet(rr, front_depth); /* Top front rounding. */ - translate([payload_centre, -front_depth + ro, height / 2 - ro]) + translate([payload_centre, -front_depth + ro, upper_extent - ro]) rotate([0, 0, 180]) rotate([0, -90, 0]) fillet(rr, payload_width); @@ -660,11 +662,11 @@ rotate([0, 0, 180]) fillet_justified(rr, payload_height + bottom + extra); - translate([connector_width / 2 - ro, -front_depth + ro, -height / 2]) + translate([connector_width / 2 - ro, -front_depth + ro, lower_extent]) rotate([0, 0, 270]) fillet_partitioned(rr, connector_height - bottom); - translate([-connector_width / 2 + ro, -front_depth + ro, -height / 2]) + translate([-connector_width / 2 + ro, -front_depth + ro, lower_extent]) rotate([0, 0, 180]) fillet_partitioned(rr, connector_height - bottom); } @@ -769,7 +771,7 @@ -1, 1, -1, -int_connector_width / 2, -groove_width_extra, int_payload_lower_extent); translate([-int_connector_width / 2 - groove_ro, -groove_width_extra + groove_ro, - -height / 2]) + lower_extent]) rotate([0, 0, -90]) fillet_partitioned(groove_rr, inner_connector_front_cutout_height + extra); } @@ -781,7 +783,7 @@ 1, 1, -1, int_connector_width / 2, -groove_width_extra, int_payload_lower_extent); translate([int_connector_width / 2 + groove_ro, -groove_width_extra + groove_ro, - -height / 2]) + lower_extent]) rotate([0, 0, 180]) fillet_partitioned(groove_rr, inner_connector_front_cutout_height + extra); } @@ -806,7 +808,7 @@ cube_at(int_connector_width, int_connector_back_depth, bottom, 0, 1, 1, - 0, 0, -height / 2 + int_connector_height); + 0, 0, lower_extent + int_connector_height); /* Edge connector cutout. */ @@ -814,7 +816,7 @@ edge_connector_cutout_back_depth, bottom, 0, 1, 1, - 0, 0, -height / 2 + int_connector_height); + 0, 0, lower_extent + int_connector_height); } /* Extended floor. */ @@ -825,11 +827,11 @@ cube_at(payload_width - connector_width, back_depth, bottom, 1, 1, 1, - payload_left_extent, 0, -height / 2 + int_connector_height); + payload_left_extent, 0, lower_extent + int_connector_height); cube_at(payload_width - connector_width, edge_connector_cutout_front_depth, bottom, 1, 1, 1, - payload_left_extent, 0, -height / 2 + int_connector_height); + payload_left_extent, 0, lower_extent + int_connector_height); } } @@ -857,7 +859,7 @@ if (TOP_LABEL_INSET) translate([top_label_left_extent, -front_depth + top_label_offset_from_front, - height / 2 - top_label_depth]) + upper_extent - top_label_depth]) cube([top_label_width, top_label_height, top_label_depth]); } @@ -882,11 +884,11 @@ cube_at(payload_width, groove_width_normal, groove_depth, 0, 1, -1, - payload_centre, 0, height / 2); + payload_centre, 0, upper_extent); cube_at(payload_width, top_groove_width, top_groove_depth, 0, 1, -1, - payload_centre, -groove_width_extra, height / 2); + payload_centre, -groove_width_extra, upper_extent); } /* Back cavity. */ @@ -896,7 +898,7 @@ /* From the bottom upwards. */ - translate([0, back_depth, -height / 2]) + translate([0, back_depth, lower_extent]) linear_extrude(height = back_cavity_height) translate([-int_connector_width / 2, 0, 0]) polygon([ @@ -912,7 +914,7 @@ /* From left to right. */ - translate([back_cavity_width / 2, back_depth, -height / 2]) + translate([back_cavity_width / 2, back_depth, lower_extent]) rotate([0, -90, 0]) linear_extrude(height = back_cavity_width) polygon([ @@ -926,7 +928,7 @@ /* Inner back cavities. */ - translate([0, int_connector_back_depth, -height / 2]) + translate([0, int_connector_back_depth, lower_extent]) linear_extrude(height = int_connector_height) translate([-int_connector_width / 2, 0, 0]) polygon([ @@ -937,7 +939,7 @@ [0, inner_back_slope_depth] ]); - translate([0, int_connector_back_depth, -height / 2]) + translate([0, int_connector_back_depth, lower_extent]) linear_extrude(height = int_connector_height) translate([int_connector_width / 2, 0, 0]) polygon([ @@ -951,7 +953,7 @@ /* Inner back edge cavity. */ translate([inner_back_edge_width / 2, - int_connector_back_depth + inner_back_edge_depth, -height / 2]) + int_connector_back_depth + inner_back_edge_depth, lower_extent]) rotate([0, -90, 0]) linear_extrude(height = inner_back_edge_width) polygon([ @@ -967,17 +969,17 @@ /* Top left and right rounding. */ - translate([payload_left_extent + ro, back_depth / 2, height / 2 - ro]) + translate([payload_left_extent + ro, back_depth / 2, upper_extent - ro]) rotate([0, 0, 180]) rotate([90, 0, 0]) fillet(rr, back_depth); - translate([payload_right_extent - ro, back_depth / 2, height / 2 - ro]) + translate([payload_right_extent - ro, back_depth / 2, upper_extent - ro]) rotate([90, 0, 0]) fillet(rr, back_depth); /* Top back rounding. */ - translate([payload_centre, back_depth - ro, height / 2 - ro]) + translate([payload_centre, back_depth - ro, upper_extent - ro]) rotate([0, -90, 0]) fillet(rr, payload_width); @@ -990,10 +992,10 @@ rotate([0, 0, 90]) fillet_justified(rr, payload_height + bottom + extra); - translate([connector_width / 2 - ro, back_depth - ro, -height / 2]) + translate([connector_width / 2 - ro, back_depth - ro, lower_extent]) fillet_partitioned(rr, connector_height - bottom); - translate([-connector_width / 2 + ro, back_depth - ro, -height / 2]) + translate([-connector_width / 2 + ro, back_depth - ro, lower_extent]) rotate([0, 0, 90]) fillet_partitioned(rr, connector_height - bottom); @@ -1020,12 +1022,12 @@ /* Sides of connector. */ translate([-connector_width / 2 + groove_depth + groove_ro, -groove_width_extra + groove_ro, - -height / 2]) + lower_extent]) rotate([0, 0, 180]) fillet_partitioned(groove_rr, inner_connector_front_cutout_height); translate([connector_width / 2 - groove_depth - groove_ro, -groove_width_extra + groove_ro, - -height / 2]) + lower_extent]) rotate([0, 0, -90]) fillet_partitioned(groove_rr, inner_connector_front_cutout_height);