From 52f6ce437cdc5f4f28f955c06f8243fd5e26e492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Sun, 25 Feb 2024 12:16:18 +0100 Subject: [PATCH] feat: improvements --- README.md | 26 ++++++------ track.scad | 116 ++++++++++++++++++++++++++--------------------------- 2 files changed, 70 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index a312c86..dde8915 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,20 @@ Parametric Lego-compatible monorail tracks, designed specifically for 3d printin Since the parts are made parametric, you can have any length or curve radius you want, but these are the original tracks you can replicate -| Lego Name | Parameters | -| ----------------- | ------------------------ | -| Straight Long | `monorailStraight(l=32)` | -| Straight Short | `monorailStraight(l=8)` | -| Curve Long | `monorailCurve90(r=28)` | -| Curve Short Left | ❌ | -| Curve Short Right | ❌ | -| Ramp Upper Part | ❌ | -| Ramp Lower Part | ❌ | -| Monoswitch | ❌ | -| Point Right | ❌ | -| Point Left | ❌ | +| Common Name | Supported | Material Cost | Print Time | +| ------------------- | --------- | ------------- | ---------- | +| Straight Long/Full | ✓ | | | +| Straight Short/Half | ✓ | | | +| Straight Quarter | ✓ | | | +| Straight 4-studs | ✓ | ~10ct | 15m | +| Curve Long | ✓ | | | +| Curve Short Left | ❌ | | | +| Curve Short Right | ❌ | | | +| Ramp Upper Part | ❌ | | | +| Ramp Lower Part | ❌ | | | +| Monoswitch | ❌ | | | +| Point Right | ❌ | | | +| Point Left | ❌ | | | ## Design differences diff --git a/track.scad b/track.scad index d824ede..d7db113 100644 --- a/track.scad +++ b/track.scad @@ -1,15 +1,19 @@ include ; include ; -Type="straight"; // [straight, curve] +// Enable built-in support for 3d printing +Support=true; +// Supports are generated with respect to the layer height +LayerHeight=0.2; // [0.05,0.1,0.2] + // Only applies to straight tracks Length=8; // [4:1:56] // Only applies to curves Radius=28; // [4:1:36] -// The angle at which the curve starts -StartAngle=0; // [0:15:360] -// The angle at which the curve ends -EndAngle=45; // [0:15:360] +// The angle at the y- axis +StartAngle=45; // [0:15:90] +// The angle at the y+ axis +EndAngle=0; // [0:15:90] module __CustomizerLimit__() {} @@ -65,23 +69,26 @@ module brickSlot(w=1, l=1, h=3) { cube([$stud, $stud, $studHeight * 2], anchor=BOTTOM); } -module endCapStraight() { +module endCapStraight(includeRail=true) { $width = $baseWidth - $plate * 2; union() { difference() { union() { cube([$width, $tile * 2, $tile], anchor=CENTER); - difference() { - mirror_copy([0, 1, 0]) - translate([0, $tile / 2, 0]) - cyl(l=$width + $studHeight * 2 + $LDU / 2, d=$stud + $LDU, orient=LEFT, $fn=24); - mirror_copy([1, 0, 0]) - translate([$tile * 2, 0, -$stud / 2 - 0.2]) - rotate([0, -7, 0]) - cube([$studHeight * 10, $tile * 4, $LDU], anchor=BOTTOM+RIGHT); - } + mirror_copy([0, 1, 0]) + translate([0, $tile / 2, 0]) + cyl(l=$width + $studHeight * 2 + $LDU / 2, d=$stud, orient=LEFT, $fn=24); translate([$tile, -$tile, 0]) cube([8 * $LDU, $LDU, $tile], anchor=LEFT+BACK); + + if (Support) { + mirror_copy([1, 0, 0]) difference() { + translate([$tile * 2 - $studHeight, 0, -$tile / 2]) cube([$LDU * 3, $tile * 2 - $LDU - 2, $LDU * 6], anchor=BOTTOM+RIGHT); + mirror_copy([0, 1, 0]) + translate([0, $tile / 2, 0]) + cyl(l=$width + $studHeight * 2 + $LDU / 2, d=$stud + LayerHeight * 2, orient=LEFT, $fn=24); + } + } } // Brick slots mirror_copy([1, 0, 0]) @@ -106,53 +113,41 @@ module endCapStraight() { cyl(d=$fillet, h=$tile, $fn=12); } - // Rail - translate([0, $teethTolerance / 2, $tile / 2]) cuboid([$teethRailWidth, $tile * 2 - $teethTolerance, $plate], anchor=BOTTOM); - translate([0, -$tile, $tile / 2]) group() { - for (i = [0:(2 * $teeth - 1)]) { - translate([0, i * $teethWidth, 0]) tooth(); - } - }; + if (includeRail) { + // Rail + translate([0, $teethTolerance / 2, $tile / 2]) cuboid([$teethRailWidth, $tile * 2 - $teethTolerance, $plate], anchor=BOTTOM); + translate([0, -$tile, $tile / 2]) group() { + for (i = [0:(2 * $teeth - 1)]) { + translate([0, i * $teethWidth, 0]) tooth(); + } + }; + } } } -module monorailCurve(p0, p1, p2, resolution=512) { - union() { - /*translate([r * $tile, $tile, 0]) endCapStraight(); - translate([$tile, r * $tile, 0]) rotate(-90) endCapStraight(); +module monorailCurve(r=28, sa, ea, p1) { + $n_teeth = round((PI * r * $tile) / (360 / abs(-sa - ea))); + angle = [180 - ea, 180 + sa]; + points = arc($n_teeth, r=(r * $tile), angle=angle); - $radius = (r - 2) * $tile;*/ - - bez = [p0, p1, p2]; - debug_bezier(bez, N=len(bez)-1); - $n_teeth = round(bezier_length(bez) / $tile * $teeth); - echo($n_teeth); - $points = bezier_curve(bez, $n_teeth); - - translate($points[0]) rot(from=[0, 1, 0], to=bezier_tangent(bez, 0)) fwd($tile) endCapStraight(); - translate($points[len($points) - 1]) rot(from=[0, -1, 0], to=bezier_tangent(bez, 1)) fwd($tile) endCapStraight(); - path_sweep([ - [-$teethRailWidth / 2, $tile / 2 + $plate], - [-$teethRailWidth / 2, $tile / 2], - [-2 * $tile, $tile / 2], - [-2 * $tile, -$tile / 2], - [2 * $tile, -$tile / 2], - [2 * $tile, $tile / 2], - [$teethRailWidth / 2, $tile / 2], - [$teethRailWidth / 2, $tile / 2 + $plate], - ], $points, tangent=bezier_tangent(bez, [0:1/$n_teeth:1])); - translate([0, 0, $tile / 2]) path_copies($points, n=$n_teeth) rotate([-90, 90, 0]) tooth(); - - //extrude_2d_shapes_along_bezier(path) square([4 * $tile, $tile]); - - /*translate([2 * $tile, 2 * $tile]) intersection() { - arced_slot(r=$radius, h=$tile, sd=4 * $tile, sa=sa, ea=ea, $fn=resolution); + translate([r * $tile, 0, 0]) union() { + translate(points[0]) rot(180 - ea) back($tile) endCapStraight(includeRail=false); + translate(points[len(points) - 1]) rot(sa) back($tile) endCapStraight(includeRail=false); + difference() { + path_sweep([ + [-$teethRailWidth / 2, $tile / 2 + $plate], + [-$teethRailWidth / 2, $tile / 2], + [-2 * $tile, $tile / 2], + [-2 * $tile, -$tile / 2], + [2 * $tile, -$tile / 2], + [2 * $tile, $tile / 2], + [$teethRailWidth / 2, $tile / 2], + [$teethRailWidth / 2, $tile / 2 + $plate], + ], points); + translate(points[0]) rot(-ea) cube([$tile * 6, $tile * 4, $tile], anchor=CENTER); + translate(points[len(points) - 1]) rot(sa) cube([$tile * 6, $tile * 4, $tile], anchor=CENTER); } - translate([2 * $tile, 2 * $tile, $tile / 2]) - arced_slot($radius, h=$plate, sd=$teethRailWidth, align=V_TOP, sa=sa, ea=ea, $fn=resolution); - translate([2 * $tile, 2 * $tile, $tile / 2]) - arc_of(n = round(((PI * $radius) / (180 / (ea - sa))) / $tile * $teeth), r=(r - 2) * $tile, rot=true, sa=sa, ea=ea, $fn=resolution) - tooth();*/ + translate([0, 0, $tile / 2]) arc_copies($n_teeth, r=(r * $tile), sa=angle[0], ea=angle[1]) tooth(); } } @@ -172,10 +167,11 @@ module monorailStraight(l) { } } -if (Type == "straight") +if (EndAngle == 0 && StartAngle == 0) monorailStraight(l=Length); -else if (Type == "curve") - monorailCurve(p0=[0, 0, 0], p1=[5, 40, 0], p2=[80, 80, 0]); +else + monorailCurve(Radius, sa=StartAngle, ea=EndAngle); // endCapStraight(); // translate([28.75, -232, -5.75]) rotate([0, 0, 90]) import("straight.stl"); +//translate([28.75, -232, -5.75]) rotate([0, 0, 90]) import("4dbrix_curve.stl");