diff --git a/helper/matrix.scad b/helper/matrix.scad new file mode 100644 index 0000000..d29d820 --- /dev/null +++ b/helper/matrix.scad @@ -0,0 +1,110 @@ +// Common matrix transformations + +identity = [ + [1,0,0,0], + [0,1,0,0], + [0,0,1,0], + [0,0,0,1], + ]; + +function scale(v) = [ + [v[0],0,0,0], + [0,v[1],0,0], + [0,0,v[2],0], + [0,0,0,1] + ]; + +function rotatex(a) = [ + [1,0,0,0], + [0,cos(a),-sin(a),0], + [0,sin(a),cos(a),0], + [0,0,0,1] + ]; + +function rotatey(a) = [ + [cos(a),0,sin(a),0], + [0,1,0,0], + [-sin(a),0,cos(a),0], + [0,0,0,1] + ]; + +function rotatez(a) = [ + [cos(a),-sin(a),0,0], + [sin(a),cos(a),0,0], + [0,0,1,0], + [0,0,0,1] + ]; + +function rotate(a,v) = + (v == undef) + ? rotatez(a[2])*rotatey(a[1])*rotatex(a[0]) + : rotateanv(a,v/sqrt(v*v)); + +function translate(v) = [ + [1,0,0,v[0]], + [0,1,0,v[1]], + [0,0,1,v[2]], + [0,0,0,1] + ]; + +function mirrorabc(a,b,c) = [ + [1-2*a*a,-2*a*b,-2*a*c,0], + [-2*a*b,1-2*b*b,-2*b*c,0], + [-2*a*c,-2*b*c,1-2*c*c,0], + [0,0,0,1] + ]; + +function mirrornv(nv) = mirrorabc(nv[0],nv[1],nv[2]); + +function mirror(v) = mirrornv(v/sqrt(v*v)); + + +// taken from https://github.com/openscad/openscad/issues/1040#issuecomment-233208606 +function det4x4(a) = +a[0][0]*a[1][1]*a[2][2]*a[3][3] + a[0][0]*a[1][2]*a[2][3]*a[3][1] + a[0][0]*a[1][3]*a[2][1]*a[3][2] + + a[0][1]*a[1][0]*a[2][3]*a[3][2] + a[0][1]*a[1][2]*a[2][0]*a[3][3] + a[0][1]*a[1][3]*a[2][2]*a[3][0] + + a[0][2]*a[1][0]*a[2][1]*a[3][3] + a[0][2]*a[1][1]*a[2][3]*a[3][0] + a[0][2]*a[1][3]*a[2][0]*a[3][1] + + a[0][3]*a[1][0]*a[2][2]*a[3][1] + a[0][3]*a[1][1]*a[2][0]*a[3][2] + a[0][3]*a[1][2]*a[2][1]*a[3][0] + - a[0][0]*a[1][1]*a[2][3]*a[3][2] - a[0][0]*a[1][2]*a[2][1]*a[3][3] - a[0][0]*a[1][3]*a[2][2]*a[3][1] + - a[0][1]*a[1][0]*a[2][2]*a[3][3] - a[0][1]*a[1][2]*a[2][3]*a[3][0] - a[0][1]*a[1][3]*a[2][0]*a[3][2] + - a[0][2]*a[1][0]*a[2][3]*a[3][1] - a[0][2]*a[1][1]*a[2][0]*a[3][3] - a[0][2]*a[1][3]*a[2][1]*a[3][0] + - a[0][3]*a[1][0]*a[2][1]*a[3][2] - a[0][3]*a[1][1]*a[2][2]*a[3][0] - a[0][3]*a[1][2]*a[2][0]*a[3][1]; + +function invb00(a) = a[1][1]*a[2][2]*a[3][3] + a[1][2]*a[2][3]*a[3][1] + a[1][3]*a[2][1]*a[3][2] - a[1][1]*a[2][3]*a[3][2] - a[1][2]*a[2][1]*a[3][3] - a[1][3]*a[2][2]*a[3][1]; + +function invb01(a) = a[0][1]*a[2][3]*a[3][2] + a[0][2]*a[2][1]*a[3][3] + a[0][3]*a[2][2]*a[3][1] - a[0][1]*a[2][2]*a[3][3] - a[0][2]*a[2][3]*a[3][1] - a[0][3]*a[2][1]*a[3][2]; + +function invb02(a) = a[0][1]*a[1][2]*a[3][3] + a[0][2]*a[1][3]*a[3][1] + a[0][3]*a[1][1]*a[3][2] - a[0][1]*a[1][3]*a[3][2] - a[0][2]*a[1][1]*a[3][3] - a[0][3]*a[1][2]*a[3][1]; + +function invb03(a) = a[0][1]*a[1][3]*a[2][2] + a[0][2]*a[1][1]*a[2][3] + a[0][3]*a[1][2]*a[2][1] - a[0][1]*a[1][2]*a[2][3] - a[0][2]*a[1][3]*a[2][1] - a[0][3]*a[1][1]*a[2][2]; + +function invb10(a) = a[1][0]*a[2][3]*a[3][2] + a[1][2]*a[2][0]*a[3][3] + a[1][3]*a[2][2]*a[3][0] - a[1][0]*a[2][2]*a[3][3] - a[1][2]*a[2][3]*a[3][0] - a[1][3]*a[2][0]*a[3][2]; + +function invb11(a) = a[0][0]*a[2][2]*a[3][3] + a[0][2]*a[2][3]*a[3][0] + a[0][3]*a[2][0]*a[3][2] - a[0][0]*a[2][3]*a[3][2] - a[0][2]*a[2][0]*a[3][3] - a[0][3]*a[2][2]*a[3][0]; + +function invb12(a) = a[0][0]*a[1][3]*a[3][2] + a[0][2]*a[1][0]*a[3][3] + a[0][3]*a[1][2]*a[3][0] - a[0][0]*a[1][2]*a[3][3] - a[0][2]*a[1][3]*a[3][0] - a[0][3]*a[1][0]*a[3][2]; + +function invb13(a) = a[0][0]*a[1][2]*a[2][3] + a[0][2]*a[1][3]*a[2][0] + a[0][3]*a[1][0]*a[2][2] - a[0][0]*a[1][3]*a[2][2] - a[0][2]*a[1][0]*a[2][3] - a[0][3]*a[1][2]*a[2][0]; + +function invb20(a) = a[1][0]*a[2][1]*a[3][3] + a[1][1]*a[2][3]*a[3][0] + a[1][3]*a[2][0]*a[3][1] - a[1][0]*a[2][3]*a[3][1] - a[1][1]*a[2][0]*a[3][3] - a[1][3]*a[2][1]*a[3][0]; + +function invb21(a) = a[0][0]*a[2][3]*a[3][1] + a[0][1]*a[2][0]*a[3][3] + a[0][3]*a[2][1]*a[3][0] - a[0][0]*a[2][1]*a[3][3] - a[0][1]*a[2][3]*a[3][0] - a[0][3]*a[2][0]*a[3][1]; + +function invb22(a) = a[0][0]*a[1][1]*a[3][3] + a[0][1]*a[1][3]*a[3][0] + a[0][3]*a[1][0]*a[3][1] - a[0][0]*a[1][3]*a[3][1] - a[0][1]*a[1][0]*a[3][3] - a[0][3]*a[1][1]*a[3][0]; + +function invb23(a) = a[0][0]*a[1][3]*a[2][1] + a[0][1]*a[1][0]*a[2][3] + a[0][3]*a[1][1]*a[2][0] - a[0][0]*a[1][1]*a[2][3] - a[0][1]*a[1][3]*a[2][0] - a[0][3]*a[1][0]*a[2][1]; + +function invb30(a) = a[1][0]*a[2][2]*a[3][1] + a[1][1]*a[2][0]*a[3][2] + a[1][2]*a[2][1]*a[3][0] - a[1][0]*a[2][1]*a[3][2] - a[1][1]*a[2][2]*a[3][0] - a[1][2]*a[2][0]*a[3][1]; + +function invb31(a) = a[0][0]*a[2][1]*a[3][2] + a[0][1]*a[2][2]*a[3][0] + a[0][2]*a[2][0]*a[3][1] - a[0][0]*a[2][2]*a[3][1] - a[0][1]*a[2][0]*a[3][2] - a[0][2]*a[2][1]*a[3][0]; + +function invb32(a) = a[0][0]*a[1][2]*a[3][1] + a[0][1]*a[1][0]*a[3][2] + a[0][2]*a[1][1]*a[3][0] - a[0][0]*a[1][1]*a[3][2] - a[0][1]*a[1][2]*a[3][0] - a[0][2]*a[1][0]*a[3][1]; + +function invb33(a) = a[0][0]*a[1][1]*a[2][2] + a[0][1]*a[1][2]*a[2][0] + a[0][2]*a[1][0]*a[2][1] - a[0][0]*a[1][2]*a[2][1] - a[0][1]*a[1][0]*a[2][2] - a[0][2]*a[1][1]*a[2][0]; + +function inv4x4(a)= (1/det4x4(a))*[ + [invb00(a),invb01(a),invb02(a),invb03(a)], + [invb10(a),invb11(a),invb12(a),invb13(a)], + [invb20(a),invb21(a),invb22(a),invb23(a)], + [invb30(a),invb31(a),invb32(a),invb33(a)]]; + diff --git a/rack/assembly/fullAssembly.scad b/rack/assembly/fullAssembly.scad deleted file mode 100644 index 0fbca28..0000000 --- a/rack/assembly/fullAssembly.scad +++ /dev/null @@ -1,7 +0,0 @@ -include <../helper/math.scad> -include <./config.scad> -include <./mainRail.scad> -include <./yBar.scad> -include <./xBar.scad> - -// TODO \ No newline at end of file diff --git a/rack/assemblyGuide.scad b/rack/assemblyGuide.scad new file mode 100644 index 0000000..4d2e217 --- /dev/null +++ b/rack/assemblyGuide.scad @@ -0,0 +1,78 @@ +include <../helper/math.scad> +include <./config.scad> +include <./mainRail.scad> +include <./yBar.scad> +include <./xBar.scad> + + +attachXBarWithYBar(); + + +module attachXBarWithYBar() { + // assemble x-y bar trays + + yBar(); + + xBarSpaceToYBarSpace = + yBarXBarConnectorTrans * + xBarConnectorToYBarConnectorTrans * + inv4x4(xBarYBarConnectorTrans); + + yBarSpaceToXBarSpace = + xBarYBarConnectorTrans * + yBarConnectorToXBarConnectorTrans * + inv4x4(yBarXBarConnectorTrans); + + multmatrix( + xBarSpaceToYBarSpace * + xBarMirrorOtherCornerTrans * + yBarSpaceToXBarSpace + ) + yBar(); + + multmatrix( + translate(v=[0,0,20]) * + xBarSpaceToYBarSpace + ) + xBar(); + + + multmatrix( + translate(v=[0,0,20]) * + yBarMirrorOtherCornerTrans * + xBarSpaceToYBarSpace + ) + xBar(); +} + + +module screwXBarAndYBar() { + // screw to connect x and y bars +} + + +module attachSideConnectorModulesToYBars() { + // attach side connector modules to y bars +} + + +module insertDowelsIntoSideWall() { + +} + +module connectXYTraysWithMainRailAndSideWall() { + +} + +module screwMainRailAndYBar() { + +} + + +module attachFeet() { + +} + +module attachTops() { + +} \ No newline at end of file diff --git a/rack/yBarBasePlateConnector.scad b/rack/connector/basePlateYBarConnectors.scad similarity index 67% rename from rack/yBarBasePlateConnector.scad rename to rack/connector/basePlateYBarConnectors.scad index e63e34e..be19ccd 100644 --- a/rack/yBarBasePlateConnector.scad +++ b/rack/connector/basePlateYBarConnectors.scad @@ -1,9 +1,13 @@ -include <../helper/common.scad> -include <../helper/slack.scad> -include <../helper/halfspace.scad> -include <../helper/screws.scad> -include <./config.scad> -include <./sharedVariables.scad> +include <../../helper/screws.scad> +include <../../helper/common.scad> +include <../../helper/matrix.scad> +include <../../helper/slack.scad> +include <../../helper/dovetail.scad> +include <../../helper/halfspace.scad> + +include <../sharedVariables.scad> + +include <../config.scad> _mountX = 12; _mountY = 14; @@ -27,14 +31,15 @@ _heatSetY = _mountY - _innerYFaceToScrew; basePlateScrewMountToYBarXZFace = _heatSetY + joinCornerDepth; // Distance to the nearest YBar XZ face basePlateScrewMountToYBarYZFace = (yBarWidth+_heatSetX) - yBarBasePlateConnectorWidth; -module yBarBasePlateMount_P() { +module onYBarBasePlateConnectorPositive() { + translate(v=[0,0,yBarWallThickness]) intersection() { cube(size = [_mountX, _mountY, _mountZ]); halfspace(vpos=[0, -1, -1], p=[0, _mountY-1, _mountZ-1]); } } -module yBarBasePlateMount_N() { +module onYBarBasePlateConnectorNegative() { translate(v=[_heatSetX, _heatSetY, m3HeatSetInsertSlotHeightSlacked + _baseConnRecession]) mirror(v=[0,0,1]) @@ -48,14 +53,16 @@ module yBarBasePlateMount_N() { roundCutSlice(radius = _baseConnY/2 + radiusXYSlack); } -} -module roundCutSlice(radius, length=inf50) { - hull() { - cylinder(r = radius, h = eps); + module roundCutSlice(radius, length=inf50) { - translate(v = [length, -radius, 0]) - cube(size = [eps, radius*2, eps]); + hull() { + cylinder(r = radius, h = eps); + + translate(v = [length, -radius, 0]) + cube(size = [eps, radius*2, eps]); + } } + } diff --git a/rack/connector/connectors.scad b/rack/connector/connectors.scad index 0b1a4ab..021b911 100644 --- a/rack/connector/connectors.scad +++ b/rack/connector/connectors.scad @@ -1,46 +1,77 @@ /* Connector factory */ -include <../helper/screws.scad> -include <../helper/slack.scad> -include <../helper/dovetail.scad> -include <../helper/halfspace.scad> -include <./config.scad> +include <../../helper/screws.scad> +include <../../helper/common.scad> +include <../../helper/matrix.scad> +include <../../helper/slack.scad> +include <../../helper/dovetail.scad> +include <../../helper/halfspace.scad> +include <../config.scad> + +include <./xBarYBarConnectors.scad> +include <./mainRailYBarConnectors.scad> +include <./sideModuleYBarConnectors.scad> +include <./stackYBarConnectors.scad> +include <./basePlateYBarConnectors.scad> // WIP - partList = ["yBar", "xBar", "mainRail", "xyPlate", "sideModule"]; +mirror(v=[1,0,0]) +*connectorDebug(on="xBar", to="yBar", trans=identity); + +*connectorDebug(on="yBar", to="xBar", trans=identity); + // Default is to apply the positive first -module applyConnector(on,to, trans) { +module applyConnector(on, to, trans) { - //apply_pn() { + apply_pn() { + multmatrix(trans) + connectorPositive(on=on, to=to); - //} + multmatrix(trans) + connectorNegative(on=on, to=to); + + children(0); + } +} + + +module connectorDebug(on, to, trans) { + + color([0,1,0]) + multmatrix(trans) + connectorPositive(on=on, to=to); + + color([1,0,0]) + multmatrix(trans) + connectorNegative(on=on, to=to); + +} + + +module applyConnectorDebug(on,to,trans) { + + echo("on: ", on, "-- to:", to); + + apply_p() { + multmatrix(trans) + connectorDebug(on=on,to=to,trans=trans); + + children(0); + } } module connectorPositive(on, to) { if (on == "yBar" && to == "xBar") { onYBarToXBarPositive(); + } else if (on == "yBar" && to == "basePlate") { + onYBarBasePlateConnectorPositive(); + } else if (on == "mainRail" && to == "yBar") { + onMainRailYBarConnectorPositive(); } - - - module onYBarToXBarPositive() { - rotate(a=[0,0,-90]) - dovetail( - topWidth = 15, - bottomWidth = 12, - height = 2, - length = yBarHeight, - headExtension = 1, - baseExtension = 2, - frontFaceLength = 2, - frontFaceScale = 0.95, - backFaceLength = 5, - backFaceScale = 1.2); - } - } module connectorNegative(on, to) { @@ -51,44 +82,14 @@ module connectorNegative(on, to) { onXBarToYBarNegative(); } else if (on == "yBar" && to == "sideModule") { onYBarSideModuleNegative(); + } else if (on == "yBar" && to == "mainRail") { + onYBarToMainRailNegative(); + } else if (on == "yBar" && to == "stackConnector") { + onYBarStackConnectorNegative(); + } else if (on == "yBar" && to == "basePlate") { + onYBarBasePlateConnectorNegative(); + } else if (on == "mainRail" && to == "yBar") { + onMainRailYBarConnectorNegative(); } - - module onYBarToXBarNegative() { - y = 27; - z = 6; - translate(v = [-m3HeatSetInsertSlotHeightSlacked, y, z]) - rotate(a = [0, 90, 0]) - heatSetInsertSlot_N(rackFrameScrewType); - - } - - module onXBarToYBarNegative() { - y = 27; - z = 6; - slack = xySlack; - - translate(v=[-0.5,14,0]) - mirror(v=[1,0,0]) - rotate(a=[0,0,-90]) - dovetail(topWidth = 15+slack, bottomWidth = 12+slack, height = 2+slack, length = yBarHeight, - headExtension = 1, baseExtension = 2, frontFaceLength = 0.5, frontFaceScale = 1.05, - backFaceLength = 5, backFaceScale = 1.2); - - // TODO clean this up - translate(v = [-6, y, z]) - rotate(a = [0, -90, 0]) - counterSunkHead_N(rackFrameScrewType, screwExtension=inf10, headExtension=inf10); - } - - module onYBarSideModuleNegative() { - translate(v = [-xySlack/2, -xySlack/2, -sideWallConnLugDepression]) - cube(size = [sideWallConnW+xySlack, sideWallConnD+xySlack, sideWallConnLugDepression]); - - translate(v = [yBarScrewHoleToOuterYEdge, yBarScrewHoleToFrontXEdge, -(m3HeatSetInsertSlotHeightSlacked+sideWallConnLugDepression)]) - heatSetInsertSlot_N(rackFrameScrewType); - } - - } - diff --git a/rack/connector/mainRailYBarConnectors.scad b/rack/connector/mainRailYBarConnectors.scad new file mode 100644 index 0000000..c543327 --- /dev/null +++ b/rack/connector/mainRailYBarConnectors.scad @@ -0,0 +1,37 @@ +include <../../helper/screws.scad> +include <../../helper/common.scad> +include <../../helper/matrix.scad> +include <../../helper/slack.scad> +include <../../helper/dovetail.scad> +include <../../helper/halfspace.scad> + +include <../sharedVariables.scad> + +include <../config.scad> + +module onYBarToMainRailNegative() { + + slotSlack = xySlack; + slotZSlack = zSlack; + + union() { + translate(v=[-slotZSlack/2, -slotSlack/2,0]) + cube(size = [railTotalWidth+slotZSlack, railTotalDepth + slotSlack, railFootThickness]); + + translate(v = [railSideMountThickness + 5, railFrontThickness + 4 , -m3HeatSetInsertSlotHeightSlacked]) + heatSetInsertSlot_N(rackFrameScrewType); + } +} + + +module onMainRailYBarConnectorPositive() { + + cube(size = [frontFaceWidth, sideSupportDepth+railFrontThickness, railFootThickness]); +} + + +module onMainRailYBarConnectorNegative() { + + translate(v = [5+railSideMountThickness, 4+railFrontThickness, railFootThickness]) + counterSunkHead_N(rackFrameScrewType, screwExtension=inf10, headExtension=inf10); +} \ No newline at end of file diff --git a/rack/connector/sideModuleYBarConnectors.scad b/rack/connector/sideModuleYBarConnectors.scad new file mode 100644 index 0000000..88a2175 --- /dev/null +++ b/rack/connector/sideModuleYBarConnectors.scad @@ -0,0 +1,19 @@ +include <../../helper/screws.scad> +include <../../helper/common.scad> +include <../../helper/matrix.scad> +include <../../helper/slack.scad> +include <../../helper/dovetail.scad> +include <../../helper/halfspace.scad> + +include <../sharedVariables.scad> + +include <../config.scad> + +module onYBarSideModuleNegative() { + + translate(v = [-xySlack/2, -xySlack/2, -sideWallConnLugDepression]) + cube(size = [sideWallConnW+xySlack, sideWallConnD+xySlack, sideWallConnLugDepression]); + + translate(v = [yBarScrewHoleToOuterYEdge, yBarScrewHoleToFrontXEdge, -(m3HeatSetInsertSlotHeightSlacked+sideWallConnLugDepression)]) + heatSetInsertSlot_N(rackFrameScrewType); +} \ No newline at end of file diff --git a/rack/stackConnector.scad b/rack/connector/stackYBarConnectors.scad similarity index 89% rename from rack/stackConnector.scad rename to rack/connector/stackYBarConnectors.scad index 135b6ed..579675d 100644 --- a/rack/stackConnector.scad +++ b/rack/connector/stackYBarConnectors.scad @@ -1,9 +1,13 @@ -include <../helper/math.scad> -include <../helper/common.scad> -include <../helper/magnet.scad> -include <../helper/screws.scad> +include <../../helper/screws.scad> +include <../../helper/common.scad> +include <../../helper/matrix.scad> +include <../../helper/slack.scad> +include <../../helper/dovetail.scad> +include <../../helper/halfspace.scad> -include <./config.scad> +include <../sharedVariables.scad> + +include <../config.scad> connectorYEdgeToYBarYEdge = 5; connectorXEdgeToYBarXEdge = 5; @@ -21,8 +25,6 @@ connectorRectSocketSlack = 0.2; connectorBottomToScrew = 6; -*stackConnectorBottom(); - module stackConnectorBase(rectSlack, topSlack=0.0) { wSlacked = connectorRectWidth + rectSlack; @@ -56,7 +58,7 @@ module stackConnectorBase(rectSlack, topSlack=0.0) { } -module stackConnectorSocket_N() { +module onYBarStackConnectorNegative() { wSlacked = connectorRectWidth + connectorRectSocketSlack; dSlacked = connectorRectDepth + connectorRectSocketSlack; @@ -89,6 +91,7 @@ module stackConnectorSocket_N() { } } + module stackConnectorPlug() { difference() { @@ -122,4 +125,4 @@ module stackConnectorBottom() { stackConnectorPlug(); translate(v=[0,0,-height]) cube(size=[connectorRectWidth+connectorRectPlugSlack, connectorRectDepth+connectorRectPlugSlack, height]); -} \ No newline at end of file +} diff --git a/rack/connector/transformations.scad b/rack/connector/transformations.scad new file mode 100644 index 0000000..c93b826 --- /dev/null +++ b/rack/connector/transformations.scad @@ -0,0 +1,10 @@ +// Spatial transformations between various parts' local spaces +include <./connectors.scad> + + +function transform(from, to) = + (from == "yBar" && to == "xBar") + ? identity + : (from == "xBar" && to == "yBar") + ? identity + : identity; diff --git a/rack/connector/xBarYBarConnectors.scad b/rack/connector/xBarYBarConnectors.scad new file mode 100644 index 0000000..2da52b5 --- /dev/null +++ b/rack/connector/xBarYBarConnectors.scad @@ -0,0 +1,71 @@ +include <../../helper/screws.scad> +include <../../helper/common.scad> +include <../../helper/matrix.scad> +include <../../helper/slack.scad> +include <../../helper/dovetail.scad> +include <../../helper/halfspace.scad> + +include <../sharedVariables.scad> + +include <../config.scad> + +// On xBar +module onXBarToYBarNegative() { + y = 27; + z = 6; + slack = xBarYBarDovetailSlack; + + translate(v=[-slack,14,0]) + mirror(v=[1,0,0]) + rotate(a=[0,0,-90]) + dovetail( + topWidth = 15+slack, + bottomWidth = 12+slack, + height = 2+slack, + length = yBarHeight, + headExtension = 1, + baseExtension = 2, + frontFaceLength = 0.5, + frontFaceScale = 1.05, + backFaceLength = 5, + backFaceScale = 1.2 + ); + + // TODO clean this up + translate(v = [-xBarSideThickness, y, z]) + rotate(a = [0, -90, 0]) + counterSunkHead_N(rackFrameScrewType, screwExtension=inf10, headExtension=inf10); +} + + +// On yBar +module onYBarToXBarNegative() { + y = 27; + z = 6; + translate(v = [-m3HeatSetInsertSlotHeightSlacked, y, z]) + rotate(a = [0, 90, 0]) + heatSetInsertSlot_N(rackFrameScrewType); + +} + +module onYBarToXBarPositive() { + + translate(v=[xBarYBarDovetailSlack, 14,0]) // TODO: variable for the 14 + rotate(a=[0,0,-90]) + dovetail( + topWidth = 15-xySlack, // figure out why we need this + bottomWidth = 12, + height = 2, + length = yBarHeight, + headExtension = 1, + baseExtension = 2, + frontFaceLength = 2, + frontFaceScale = 0.95, + backFaceLength = 5, + backFaceScale = 1.2 + ); +} + + +xBarConnectorToYBarConnectorTrans = mirror(v=[1,0,0]); +yBarConnectorToXBarConnectorTrans = mirror(v=[-1,0,0]); \ No newline at end of file diff --git a/rack/mainRail.scad b/rack/mainRail.scad index f08a5a5..f687dd4 100644 --- a/rack/mainRail.scad +++ b/rack/mainRail.scad @@ -4,81 +4,69 @@ include <../helper/slack.scad> include <../helper/math.scad> include <../helper/halfspace.scad> include <./sharedVariables.scad> +include <../helper/matrix.scad> -*mainRail(); +include <./connector/connectors.scad> + +//mainRail(); module mainRail() { - b = 0.5; // 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]); - } + applyBevels() + applyConnector(on="mainRail", to="yBar", trans=yBarConnectorTrans) + applyConnector(on="mainRail", to="yBar", trans=mirrorOtherSideTrans * yBarConnectorTrans) + mainRailBase(); - module mainRailSharp() { + module mainRailBase() { 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]) - mirror(v=[0,0,1]) - railFeet(); + module frontRailSegment() { + difference() { + cube(size = [frontFaceWidth, railFrontThickness, railTotalHeight]); + + for (i = [1:numRailScrews]) { + translate(v = [railScrewHoleToOuterEdge, railFrontThickness / 2, i * screwDiff + railFootThickness]) + rotate(a = [90, 0, 0]) + hexNutPocket_N(mainRailScrewType); + } } } - } - module frontRailSegment() { - difference() { - cube(size = [frontFaceWidth, railFrontThickness, railTotalHeight]); + module sideSupportSegment() { + difference() { + cube(size = [sideSupportDepth, railSideMountThickness, railTotalHeight]); - for (i = [1:numRailScrews]) { - translate(v = [railScrewHoleToOuterEdge, railFrontThickness / 2, i * screwDiff + railFootThickness]) - rotate(a = [90, 0, 0]) - hexNutPocket_N(mainRailScrewType); + for (i = [1:numRailScrews]) { + translate(v = [frontScrewSpacing, railFrontThickness/2, i*screwDiff+railFootThickness]) + rotate(a = [90, 0, 0]) + cylinder(r = screwRadiusSlacked(mainRailSideMountScrewType), h = inf10, $fn = 32); + } } } + } - module sideSupportSegment() { - difference() { - cube(size = [sideSupportDepth, railSideMountThickness, railTotalHeight]); - - for (i = [1:numRailScrews]) { - translate(v = [frontScrewSpacing, railFrontThickness/2, i*screwDiff+railFootThickness]) - rotate(a = [90, 0, 0]) - cylinder(r = screwRadiusSlacked(mainRailSideMountScrewType), h = inf10, $fn = 32); + yBarConnectorTrans = identity; + + mirrorOtherSideTrans = translate(v = [0, 0, railTotalHeight]) * mirror(v=[0,0,1]); + + module applyBevels() { + b = 0.5; // bevel value + apply_n() { + union() { + 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]); } + + children(0); } } - module railFeet() { - difference() { - cube(size = [frontFaceWidth - railSideMountThickness, sideSupportDepth, railFootThickness]); - - translate(v = [5, 4, railFootThickness]) - counterSunkHead_N(rackFrameScrewType, screwExtension=inf10, headExtension=inf10); - } - } -} - -module railFeetSlot_N() { - - slotSlack = xySlack; - slotZSlack = zSlack; - - union() { - translate(v=[-slotZSlack/2, -slotSlack/2,0]) - cube(size = [railTotalWidth+slotZSlack, railTotalDepth + slotSlack, railFootThickness]); - - translate(v = [railSideMountThickness + 5, railFrontThickness + 4 , -m3HeatSetInsertSlotHeightSlacked]) - heatSetInsertSlot_N(rackFrameScrewType); - } } diff --git a/rack/xBar.scad b/rack/xBar.scad index 1703616..93692e0 100644 --- a/rack/xBar.scad +++ b/rack/xBar.scad @@ -1,16 +1,17 @@ include <../helper/cylindricalFilet.scad> include <../helper/screws.scad> +include <../helper/matrix.scad> + include <./config.scad> -include <./xyBarConnector.scad> include <./sharedVariables.scad> -// Temporary -include <./yBar.scad> +include <./connector/connectors.scad> *xBar(); module xBar() { - applyYBarConnector() + applyConnector(on="xBar", to="yBar", trans=xBarMirrorOtherCornerTrans * xBarYBarConnectorTrans) + applyConnector(on="xBar", to="yBar", trans=xBarYBarConnectorTrans) xBarBase(); module xBarBase() { @@ -29,24 +30,8 @@ module xBar() { } } - module mirrorOtherCorner() { - children(0); +} - translate(v = [0, xBarX, 0]) - mirror(v = [0, 1, 0]) { - children(0); - } - } +xBarYBarConnectorTrans = rotate(a=[0,0,-90]); - module applyYBarConnector() { - apply_n() { - - mirrorOtherCorner() - rotate(a=[0,0,-90]) - yBarConnectorFromX_N(); - - children(0); - } - } - -} \ No newline at end of file +xBarMirrorOtherCornerTrans = translate(v = [0, xBarX, 0]) * mirror(v = [0, 1, 0]); \ No newline at end of file diff --git a/rack/xyBarConnector.scad b/rack/xyBarConnector.scad deleted file mode 100644 index 7ceed32..0000000 --- a/rack/xyBarConnector.scad +++ /dev/null @@ -1,57 +0,0 @@ -include <../helper/screws.scad> -include <../helper/slack.scad> -include <../helper/dovetail.scad> -include <../helper/halfspace.scad> -include <./config.scad> - -module xBarConnectorFromY_N() { - y = 27; - z = 6; - translate(v = [-m3HeatSetInsertSlotHeightSlacked, y, z]) - rotate(a = [0, 90, 0]) - heatSetInsertSlot_N(rackFrameScrewType); - -} - -module xBarConnectorFromY_P() { - rotate(a=[0,0,-90]) - dovetail( - topWidth = 15, - bottomWidth = 12, - height = 2, - length = yBarHeight, - headExtension = 1, - baseExtension = 2, - frontFaceLength = 2, - frontFaceScale = 0.95, - backFaceLength = 5, - backFaceScale = 1.2); -} - - -module yBarConnectorFromX_N() { - y = 27; - z = 6; - slack = xBarYBarDovetailSlack; - - translate(v=[-0.5,14,0]) - mirror(v=[1,0,0]) - rotate(a=[0,0,-90]) - dovetail( - topWidth = 15+slack, - bottomWidth = 12+slack, - height = 2+slack, - length = yBarHeight, - headExtension = 1, - baseExtension = 2, - frontFaceLength = 0.5, - frontFaceScale = 1.05, - backFaceLength = 5, - backFaceScale = 1.2); - - // TODO clean this up - translate(v = [-xBarSideThickness, y, z]) - rotate(a = [0, -90, 0]) - counterSunkHead_N(rackFrameScrewType, screwExtension=inf10, headExtension=inf10); -} - diff --git a/rack/yBar.scad b/rack/yBar.scad index 2740fed..959b639 100644 --- a/rack/yBar.scad +++ b/rack/yBar.scad @@ -1,4 +1,5 @@ include <../helper/math.scad> +include <../helper/matrix.scad> include <../helper/sphericalFilet.scad> include <../helper/cylindricalFilet.scad> include <../helper/screws.scad> @@ -6,10 +7,9 @@ include <../helper/magnet.scad> include <./config.scad> include <./mainRail.scad> +include <./connector/connectors.scad> + // Connectors -include <./stackConnector.scad> -include <./xyBarConnector.scad> -include <./yBarBasePlateConnector.scad> include <./side/yBarSideWallConnector.scad> include <./sharedVariables.scad> @@ -17,11 +17,11 @@ include <./sharedVariables.scad> module yBar() { - applyBasePlateConnector() - applyStackConnector() - applySideWallConnector() - applyRailConnector() - applyXBarConnector() + applyOnYBarBothCorners(to="basePlate", trans=yBarBasePlateConnectorTrans) + applyOnYBarBothCorners(to="stackConnector", trans=yBarStackConnectorTrans) + applyOnYBarBothCorners(to="sideModule", trans=yBarSideModuleConnectorTrans) + applyOnYBarBothCorners(to="mainRail", trans=yBarMainRailConnectorTrans) + applyOnYBarBothCorners(to="xBar", trans=yBarXBarConnectorTrans) yBarBase(); module yBarBase() { @@ -37,78 +37,28 @@ module yBar() { } } - module applyBasePlateConnector() { - apply_pn() { - mirrorOtherCorner() { - translate(v = [yBarWidth-yBarBasePlateConnectorWidth, joinCornerDepth, yBarWallThickness]) - yBarBasePlateMount_P(); - } - - mirrorOtherCorner() { - translate(v = [yBarWidth-yBarBasePlateConnectorWidth, joinCornerDepth, 0]) - yBarBasePlateMount_N(); - } - - children(0); - } - } - - module applyStackConnector() { - apply_n() { - mirrorOtherCorner() - translate(v = [connectorXEdgeToYBarXEdge, connectorYEdgeToYBarYEdge, 0]) - stackConnectorSocket_N(); - - children(0); - } - } - - module applySideWallConnector() { - apply_n() { - mirrorOtherCorner() - translate(v = [ - yBarWidth-(railTotalWidth+railSlotToInnerYEdge+railSlotToSideWallSlot+sideWallConnectorSlotWidth), - sideWallSlotToXZ, - yBarHeight - ]) - yBarSideWallConnector_N(); - - children(0); - } - } - - module applyRailConnector() { - - apply_n() { - mirrorOtherCorner() - translate(v = [yBarWidth-(railTotalWidth+railSlotToInnerYEdge), railSlotToXZ, yBarHeight-railFootThickness]) - railFeetSlot_N(); - - children(0); - } - } - - module applyXBarConnector() { - apply_pn() { - - mirrorOtherCorner() - translate(v=[yBarWidth + 0.5,14,0]) - xBarConnectorFromY_P(); - - mirrorOtherCorner() - translate(v = [yBarWidth+eps, 0, 0]) - xBarConnectorFromY_N(); - - children(0); - } - } - - module mirrorOtherCorner() { - children(0); - - translate(v = [0, yBarDepth, 0]) - mirror(v = [0, 1, 0]) + // Helper module to apply connectors to both corners + module applyOnYBarBothCorners(to, trans) { + applyConnector(on="yBar", to=to, trans=trans) + applyConnector(on="yBar", to=to, trans=yBarMirrorOtherCornerTrans * trans) children(0); } - } + +yBarMirrorOtherCornerTrans = translate(v = [0, yBarDepth, 0]) * mirror(v = [0, 1, 0]); + +yBarBasePlateConnectorTrans = translate(v = [yBarWidth-yBarBasePlateConnectorWidth, joinCornerDepth, 0]); + +yBarStackConnectorTrans = translate(v = [connectorXEdgeToYBarXEdge, connectorYEdgeToYBarYEdge, 0]); + +yBarSideModuleConnectorTrans = translate(v = [ + yBarWidth-(railTotalWidth+railSlotToInnerYEdge+railSlotToSideWallSlot+sideWallConnectorSlotWidth), + sideWallSlotToXZ, + yBarHeight]); + +yBarMainRailConnectorTrans = translate(v = [ + yBarWidth-(railTotalWidth+railSlotToInnerYEdge), + railSlotToXZ, + yBarHeight-railFootThickness]); + +yBarXBarConnectorTrans = translate(v = [yBarWidth+eps, 0, 0]);