From ba1dc567b78e4c1b35d843439abbef59b709e972 Mon Sep 17 00:00:00 2001 From: zhao Date: Fri, 13 Jan 2023 00:58:46 -0500 Subject: [PATCH] add to xBar, also refactor --- helper/halfspace.scad | 7 +--- helper/math.scad | 15 +++++++- rack/config.scad | 3 ++ rack/derivedConfig.scad | 4 +- rack/mainRail.scad | 39 ++++++++++++++----- rack/xBar.scad | 65 +++++++++++++++++++++++++++++--- rack/xBarBasePlateConnector.scad | 53 ++++++++++++++++++++++++++ rack/xyBarConnector.scad | 46 ++++++++++++++++++---- rack/yBar.scad | 4 +- 9 files changed, 204 insertions(+), 32 deletions(-) create mode 100644 rack/xBarBasePlateConnector.scad diff --git a/helper/halfspace.scad b/helper/halfspace.scad index 503a0a1..31d1ba2 100644 --- a/helper/halfspace.scad +++ b/helper/halfspace.scad @@ -5,10 +5,7 @@ include <./common.scad> module halfspace(vpos, p) { translate(p) - align(a=[0,0,1], b=vpos) + align(a=[0,0,-1], b=vpos) translate(v=[0,0,-inf/2]) cube(size=[inf, inf, inf], center=true); -} - - -halfspace(vpos=[1,1,1], p=[10,10,10]); \ No newline at end of file +} \ No newline at end of file diff --git a/helper/math.scad b/helper/math.scad index da7373d..2b9c8b3 100644 --- a/helper/math.scad +++ b/helper/math.scad @@ -13,9 +13,20 @@ function mirror4XY(midpoint, offsetX, offsetY) = module align(a,b) { + + echo("a", a); + echo("b", b); rot_axis = cross(a,b); - angle = acos(a*b/ (norm(a)*norm(b))); + + if (rot_axis == 0) { + error("Can't align - provided vectors are parallel"); + } + + echo("rot_axis", rot_axis); + + angle = acos(a*b/(norm(a)*norm(b))); + echo("angle", angle) rotate(v=rot_axis, a=angle) children(0); -} +} \ No newline at end of file diff --git a/rack/config.scad b/rack/config.scad index f1e81c4..6cf8cf1 100644 --- a/rack/config.scad +++ b/rack/config.scad @@ -32,3 +32,6 @@ mainRailSideMountScrewType = "m4"; rackFrameScrewType = "m3"; // Currently, only m3 screws are supported here (tolerance issues) assert(rackFrameScrewType == "m3"); + +// Fillet radius +baseRoundness = 5; \ No newline at end of file diff --git a/rack/derivedConfig.scad b/rack/derivedConfig.scad index b63f6ef..e01a531 100644 --- a/rack/derivedConfig.scad +++ b/rack/derivedConfig.scad @@ -1,4 +1,6 @@ // Config file for derived variables. These variables are calculated from profile variables and are used by // multiple components. -// TODO \ No newline at end of file +// TODO +include <./config.scad> + diff --git a/rack/mainRail.scad b/rack/mainRail.scad index 2432439..817db4d 100644 --- a/rack/mainRail.scad +++ b/rack/mainRail.scad @@ -1,6 +1,7 @@ include <./config.scad> include <../helper/screws.scad> include <../helper/math.scad> +include <../helper/halfspace.scad> /* Small horizontal planes at the top and bottom of the main rails. Used so we can fasten the rail to the frame Note that this value is also used for a depression at the bottom/top of the frame for aligning the rail */ @@ -29,25 +30,43 @@ frontFaceWidth = railScrewHoleToInnerEdge + railScrewHoleToOuterEdge; railTotalWidth = frontFaceWidth; railTotalDepth = railFrontThickness+sideSupportDepth; +*mainRail(); + echo("Total Rail Height: ", railTotalHeight); // Also known as the z-bar :) module mainRail() { - union() { - _frontRailSegment(); + mainRail(); - translate(v = [railSideMountThickness, railFrontThickness, 0]) - rotate(a = [0, 0, 90]) - _sideSupportSegment(); + module mainRail() { + b = 0.75; // bevel value + intersection() { + mainRailSharp(); + halfspace(vpos=[1,1,0], p=[b,b,0]); + halfspace(vpos=[1,0,1], p=[b,0,b]); + halfspace(vpos=[1,0,-1], p=[b,0,railTotalHeight-b]); - translate(v = [0, railFrontThickness, 0]) { + } + } - translate(v=[railSideMountThickness,0,0]) - _railFeet(); - translate(v = [railSideMountThickness, 0, railTotalHeight - railFootThickness]) - _railFeet(); + module mainRailSharp() { + union() { + _frontRailSegment(); + + translate(v = [railSideMountThickness, railFrontThickness, 0]) + rotate(a = [0, 0, 90]) + _sideSupportSegment(); + + translate(v = [0, railFrontThickness, 0]) { + + translate(v = [railSideMountThickness, 0, 0]) + _railFeet(); + + translate(v = [railSideMountThickness, 0, railTotalHeight-railFootThickness]) + _railFeet(); + } } } diff --git a/rack/xBar.scad b/rack/xBar.scad index 216479b..c0df29a 100644 --- a/rack/xBar.scad +++ b/rack/xBar.scad @@ -2,13 +2,24 @@ include <../helper/sphericalFilet.scad> include <../helper/cylindricalFilet.scad> include <../helper/screws.scad> include <./config.scad> +include <./derivedConfig.scad> +include <./xyBarConnector.scad> +include <./xBarBasePlateConnector.scad> + + +// Temporary +include <./yBar.scad> +include <./mainRail.scad> + +xBarDepth = maxUnitWidth - 2*(railSlotSpacing + railScrewHoleToInnerEdge); -xBarDepth = 180; xBarWidth = 32; xBarHeight = 15; -xBarWallThickness = 3; -xBarRoundness = 5; +xBarWallThickness = 2; +xBarRoundness = baseRoundness; + +//echo(xBarDepth); module xBar() { @@ -24,11 +35,55 @@ module xBar() { } module xBar() { - positive(); + + module mirrorOtherCorner() { + children(0); + + // TODO rename xBarDepth to xBarLength/xBarWidth + translate(v = [xBarDepth, 0, 0]) + mirror(v = [1, 0, 0]) { + children(0); + } + } + + // TODO refactor - probably better off mirroring the side faces and hulling the shell + difference() { + union() { + intersection () { + positive(); + halfspace(vpos = [1, 0, 1], p = [0.5, 0, 0]); + + halfspace(vpos = [-1, 0, 1], p = [xBarDepth-0.5, 0, 0]); + } + + yBarConnectorFromXLug(); + + mirrorOtherCorner() + yBarConnectorFromXLug(); + } + + union() { + yBarConnectorFromX_N(); + + mirrorOtherCorner() + yBarConnectorFromX_N(); + } + } + + + // TODO change me? + translate(v=[0,xBarWidth,0]) + basePlateMount(); + + translate(v=[xBarDepth,xBarWidth,0]) + mirror(v=[1,0,0]) + basePlateMount(); } xBar(); } +translate(v=[-30,0,0]) +*yBar(); +xBar(); -//xBar(); \ No newline at end of file diff --git a/rack/xBarBasePlateConnector.scad b/rack/xBarBasePlateConnector.scad new file mode 100644 index 0000000..82f4212 --- /dev/null +++ b/rack/xBarBasePlateConnector.scad @@ -0,0 +1,53 @@ +include <../helper/common.scad> +include <../helper/screws.scad> +include <./config.scad> + +module basePlateMount() { + + screwHoleToBase = 6; + mountHeight = 10; + mountWidth = 10; + mountThickness = 2; + + module support() { + r = 4; + + difference () { + translate(v = [0, mountThickness, r/2]) + rotate(a = [90, 0, 0]) + rotate(a = [0, 0, 90]) + cylinder(h = mountThickness, r = r, $fn = 3); + + cube(size=[inf10, inf10, inf10]); + } + + //translate([-r/2, -2,0]) + //cube(size=[r/2, 0.1, 0.1]); + } + + module positive() { + cube(size = [mountWidth, mountThickness, mountHeight]); + + translate(v=[mountWidth,0,0]) + mirror(v=[1,0,0]) + hull() { + support(); + } + } + + module basePlateMount() { + translate(v=[0,-mountThickness,0]) + difference() { + positive(); + + translate(v = [mountWidth/2, inf50/2, screwHoleToBase]) + rotate(a = [90, 0, 0]) + cylinder(h = inf50, r = screwRadiusSlacked(rackFrameScrewType)); + } + } + + basePlateMount(); + +} + + diff --git a/rack/xyBarConnector.scad b/rack/xyBarConnector.scad index 90241df..c80eed6 100644 --- a/rack/xyBarConnector.scad +++ b/rack/xyBarConnector.scad @@ -1,22 +1,54 @@ include <../helper/screws.scad> +include <../helper/halfspace.scad> include <./config.scad> -module frontBarConnector_N() { - +module xBarConnectorFromY_N() { y1 = 6; y2 = 27; z = 6; translate(v = [-m3HeatSetInsertSlotHeightSlacked, y1, z]) - rotate(a = [0, 90, 0]) - heatSetInsertSlot_N(rackFrameScrewType); + rotate(a = [0, 90, 0]) + heatSetInsertSlot_N(rackFrameScrewType); translate(v = [-m3HeatSetInsertSlotHeightSlacked, y2, z]) - rotate(a = [0, 90, 0]) - heatSetInsertSlot_N(rackFrameScrewType); + rotate(a = [0, 90, 0]) + heatSetInsertSlot_N(rackFrameScrewType); // TODO fix this up, no center=true translate(v = [-1, y1+(y2-y1)/2, 0]) + rotate(a = [0, 45, 0]) + cube(size = [3, 10, 6], center = true); +} + + +module yBarConnectorFromX_N() { + y1 = 6; + y2 = 27; + z = 6; + translate(v = [-inf50/2, y1, z]) + rotate(a = [0, 90, 0]) + cylinder(r = screwRadiusSlacked(rackFrameScrewType), h = inf50, $fn = 32); + + translate(v = [-inf50/2, y2, z]) + rotate(a = [0, 90, 0]) + cylinder(r = screwRadiusSlacked(rackFrameScrewType), h = inf50, $fn = 32); +} + +// TODO: figure out nice abstraction to apply both positive and negative mods +module yBarConnectorFromXLug() { + y1 = 6; + y2 = 27; + z = 6; + + intersection() { + // TODO fix this up, no center=true + translate(v = [-1, y1+(y2-y1)/2, 0]) rotate(a = [0, 45, 0]) - cube(size = [3, 10, 6], center = true); + scale(v=[0.90,0.90,0.95]) + cube(size = [3, 10, 6], center = true); + + mirror(v=[0,0,1]) + halfspace(vpos=[0,0,1], p=[0,0,0]); + } } \ No newline at end of file diff --git a/rack/yBar.scad b/rack/yBar.scad index 09a2a8a..0a96f4d 100644 --- a/rack/yBar.scad +++ b/rack/yBar.scad @@ -22,7 +22,7 @@ yBarWidth = railSlotSpacing + railTotalWidth + sideSpacing; yBarHeight = 15; yBarWallThickness = 3; -yBarRoundness = 5; +yBarRoundness = baseRoundness; echo("Bar total depth: ", yBarDepth); echo("Bar total width: ", yBarWidth); @@ -48,7 +48,7 @@ module yBar() { railFeetSlot_N(); translate(v = [yBarWidth+eps, 0, 0]) - frontBarConnector_N(); + xBarConnectorFromY_N(); translate(v = [yBarWidth-(railTotalWidth+railSlotSpacing)-9, railSlotSpacing, yBarHeight]) sideWallConnector_N();