Add Brio tunnel
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
// BRIO-compatible tunnel.
|
||||
//
|
||||
// A straight track whose bed is widened into a solid block, carved out by an arched
|
||||
// bore, with the female/male BRIO connectors kept at the normal height: a solid
|
||||
// arched profile -> subtract the bore -> subtract the rail wells and the nest ->
|
||||
// add the plug. The bore floor is flush with the top of the track, so the running
|
||||
// surface stays a regular BRIO straight and the 45 mm bore gives the stock 2.5 mm
|
||||
// of lateral clearance on each side.
|
||||
//
|
||||
// Construction follows ascending_n_v2.scad: extrude a track profile, cut the nest,
|
||||
// add the plug.
|
||||
//
|
||||
// Driving dimensions: the outer shape (width, `outer_wall` straight height, `total_height`
|
||||
// crown) and one shell thickness, `ceiling`, which is applied as a parallel offset —
|
||||
// the bore arc is concentric with the outer barrel and 6 mm inside it everywhere. The
|
||||
// shell is therefore a true uniform 6 mm: side walls 6 mm, roof 6 mm at the crown and
|
||||
// 6 mm normal to the arch all the way round.
|
||||
//
|
||||
// Everything on the inside follows from that. At the defaults the inner wall springs at
|
||||
// z 56.5 mm (derived, not a parameter), the bore crown is at z 62 mm, headroom is 50 mm
|
||||
// at the crown and 44.5 mm at the walls, and the wall->roof junction breaks 62 deg —
|
||||
// a crisp inner edge like the original wooden tunnel rather than a tangent sweep.
|
||||
// A deeper, rounder bore would need a shallower barrel or a thicker roof; with a
|
||||
// parallel shell the two arcs can never disagree about where the curve starts.
|
||||
//
|
||||
// Prints upright as modelled, no supports: the roof is a self-supporting vault — at
|
||||
// 0.2 mm layers each ring of the band rests on ~99% of the ring below it, and the most
|
||||
// any layer bridges is ~1.3 mm where the vault closes. Loads on the roof run along the
|
||||
// layers, and the walls are printed under compression, which is the strong direction
|
||||
// for FDM.
|
||||
//
|
||||
// `portal_chamfer` breaks the portal edges all the way round except the underside:
|
||||
// the bed is a mating face and its bottom corner has to stay square so the male plug
|
||||
// is bonded along its whole height where it leaves the far portal.
|
||||
|
||||
include <train_tracks_generator.scad>
|
||||
|
||||
/* https://github.com/BelfrySCAD/BOSL2 */
|
||||
include <BOSL2/std.scad>
|
||||
|
||||
/* [Tunnel] */
|
||||
// Length of the track body: portal face to portal face, EXCLUDING the connectors.
|
||||
// 216 = BRIO "D" long straight. The male plug adds 18 mm protruding from one portal
|
||||
// and the female end is a cavity cut inside the body, so neither is counted here.
|
||||
// Keep this at or below 238 to stay on a 256 mm bed.
|
||||
length = 216; // [108:2:238]
|
||||
// Overall width across the walls
|
||||
outer_width = 57; // [45:1:150]
|
||||
// Clear width of the bore; must exceed the 40 mm track to give clearance
|
||||
inner_width = 45; // [41:0.5:140]
|
||||
// Height of the crown above the build plate, 12 mm track included
|
||||
total_height = 68; // [30:1:200]
|
||||
// Height at which the outer wall stops being straight and the roof barrel starts
|
||||
outer_wall = 60; // [13:1:190]
|
||||
// Shell thickness: side walls, and roof measured normal to the arch (uniform)
|
||||
ceiling = 6; // [2:0.5:20]
|
||||
// Chamfer breaking the portal edges
|
||||
portal_chamfer = 1; // [0:0.25:3]
|
||||
|
||||
/* [Hidden] */
|
||||
$fn = 256; // finished part
|
||||
epsilon = 0.01; // extend cutters past coplanar faces
|
||||
layer_height = 0.2; // general utility/ornament print; not a Customizer param
|
||||
arc_steps = 96; // facets per arch, independent of $fn
|
||||
min_wall = 2; // thinnest wall or roof the Customizer ranges may produce
|
||||
|
||||
// ### Derived geometry — the inside is fully determined by the outside + `ceiling`
|
||||
half_out = outer_width / 2;
|
||||
half_in = inner_width / 2;
|
||||
|
||||
// Bed is flush with the top of the track, so the track stays a working straight.
|
||||
floor_z = track_height;
|
||||
|
||||
// Outer arc through (+-half_out, outer_wall) and (0, total_height)
|
||||
out_rise = total_height - outer_wall;
|
||||
out_r = (half_out * half_out + out_rise * out_rise) / (2 * out_rise);
|
||||
out_z = total_height - out_r; // centre height, shared by both arcs
|
||||
|
||||
// Bore arc: concentric, `ceiling` inside the outer one -> constant shell thickness
|
||||
in_r = out_r - ceiling;
|
||||
inner_crown = out_z + in_r; // == total_height - ceiling
|
||||
inner_wall = out_z + sqrt(in_r * in_r - half_in * half_in);
|
||||
bore_crease = 90 - asin(half_in / in_r); // wall->roof break, degrees
|
||||
printed_length = length + track_plug_neck_length + track_plug_radius;
|
||||
|
||||
assert(inner_width > track_width, "bore must be wider than the 40 mm track");
|
||||
assert(outer_width - inner_width >= 2 * min_wall, "side walls would be under min_wall thick");
|
||||
assert(ceiling >= min_wall, "roof would be under min_wall thick");
|
||||
assert(out_rise > 0, "total_height must be above outer_wall");
|
||||
assert(out_r >= half_out, "outer arch never reaches the walls: raise the tunnel or narrow it");
|
||||
assert(in_r >= half_in, "bore arc cannot reach the inner walls: thinner roof, narrower bore or taller tunnel");
|
||||
assert(inner_wall > floor_z, "bore arch springs below the track bed: taller tunnel or narrower bore");
|
||||
|
||||
echo(str("tunnel ", length, " x ", outer_width, " x ", total_height, " mm; uniform shell ",
|
||||
ceiling, " mm; bore ", inner_width, " mm wide springing at z ",
|
||||
round(inner_wall * 10) / 10, " (derived), crown at z ", round(inner_crown * 10) / 10,
|
||||
"; headroom ", round((inner_crown - floor_z) * 10) / 10, " mm at the crown, ",
|
||||
round((inner_wall - floor_z) * 10) / 10, " mm at the walls, ",
|
||||
round((inner_width - track_width) * 10) / 10, " mm across for the stock"));
|
||||
echo(str("outer barrel R", round(out_r * 10) / 10, " springing at z ", outer_wall,
|
||||
", bore arc R", round(in_r * 10) / 10, ", wall->roof crease ",
|
||||
round(bore_crease * 10) / 10, " deg"));
|
||||
echo(str("body ", length, " mm between the portals; ",
|
||||
round(printed_length * 10) / 10, " mm overall including the protruding plug; ",
|
||||
printed_length <= 256 ? "fits a 256 mm bed"
|
||||
: "TOO LONG for a 256 mm bed"));
|
||||
|
||||
// Closed outline of a solid arch, in the across/up plane, centred on the track axis:
|
||||
// straight walls up to where the arc takes over, circular arc over the crown, flat floor.
|
||||
function arch_outline(half_w, r, z_centre, z_floor) =
|
||||
let (z_wall = z_centre + sqrt(r * r - half_w * half_w),
|
||||
amax = asin(half_w / r))
|
||||
concat(
|
||||
[[-half_w, z_floor], [-half_w, z_wall]],
|
||||
[for (i = [0:arc_steps])
|
||||
let (a = -amax + 2 * amax * i / arc_steps)
|
||||
[r * sin(a), z_centre + r * cos(a)]],
|
||||
[[half_w, z_wall], [half_w, z_floor]]
|
||||
);
|
||||
|
||||
// Extrude an arch profile along the track axis, from x = x0 to x = x1, centred on the
|
||||
// track (the generator puts the track body at y = 0 .. track_width).
|
||||
module extrude_arch(profile, x0, x1) {
|
||||
translate([0, track_width / 2, 0])
|
||||
rotate([90, 0, 90])
|
||||
translate([0, 0, x0])
|
||||
linear_extrude(x1 - x0)
|
||||
polygon(profile);
|
||||
}
|
||||
|
||||
// One object for the slicer
|
||||
union() {
|
||||
difference() {
|
||||
// Solid arched block. The outline is convex, so a hull of the three sections
|
||||
// lofts them exactly: 45 degree chamfers break the edges of both portal faces.
|
||||
// The inset sections keep their floor at z = 0 rather than lifting by the
|
||||
// chamfer width, so the end faces stay full height: lifting it would shave the
|
||||
// bottom of the bed and leave the root of the male plug standing over a void.
|
||||
if (portal_chamfer > 0) {
|
||||
hull() {
|
||||
extrude_arch(arch_outline(half_out - portal_chamfer,
|
||||
out_r - portal_chamfer, out_z, 0),
|
||||
0, portal_chamfer);
|
||||
extrude_arch(arch_outline(half_out, out_r, out_z, 0),
|
||||
portal_chamfer, length - portal_chamfer);
|
||||
extrude_arch(arch_outline(half_out - portal_chamfer,
|
||||
out_r - portal_chamfer, out_z, 0),
|
||||
length - portal_chamfer, length);
|
||||
}
|
||||
} else {
|
||||
extrude_arch(arch_outline(half_out, out_r, out_z, 0), 0, length);
|
||||
}
|
||||
|
||||
// Bore: arched vault concentric with the outer barrel, floor flush with the top
|
||||
// of the track
|
||||
extrude_arch(arch_outline(half_in, in_r, out_z, floor_z),
|
||||
-epsilon, length + epsilon);
|
||||
|
||||
// Rail wells, along the whole length, so the floor is a working BRIO straight
|
||||
rotate([90, 0, 90])
|
||||
translate([0, 0, -epsilon])
|
||||
linear_extrude(length + 2 * epsilon)
|
||||
grooves(both_sides = false);
|
||||
|
||||
// Female connector in the near portal
|
||||
install_nest(nest_rotate = 0, length = 0);
|
||||
}
|
||||
|
||||
// Male connector protruding from the far portal, below the bore floor
|
||||
install_plug(0, length);
|
||||
}
|
||||
Reference in New Issue
Block a user