From fb8251d995c96b3842ca9da95c7915b060ba857e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 07:57:23 +0000 Subject: [PATCH 01/15] Fan a counterbore's socket floor clear of its corners only With a screw counterbore, wallsAt(pad) handed the socket floor's refan the points where the BSP split each flat of the shank along the head's planes, 24 of them, as well as the shank's 12 corners. A 2.4 mm shank under a 4.8 mm head at 44.08 mm, loose, had one within FAN_CLEAR of every centre fanCentre tried, so the fan stayed put and the cell shipped six edges open with no warning. cornersAt keeps the points where two walls that are not in line meet; from those the fan moves 0.2 mm and the floor closes. Only an open cell's refan reads the list, so a cell that came out closed is built as before. Also says what settle's end-of-build check does not judge (the dovetail and puzzle tabs, the top-insert pass), in core.js and ENGINE.md, and that the fan stays put when fanCentre finds no clear point as well as when the spokes are already clear. The audit builds the 44.08 mm counterbore, which is 6 bad edges on main. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 10 +++++++++- src/core.js | 43 +++++++++++++++++++++++++++++++++++++++---- test/plate-audit.js | 12 ++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index 9e2d245..e47e095 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -738,6 +738,12 @@ currently installed): the fan moves, every cut is taken again on it. Only then: a 6 mm magnet from above at 42 mm has a spoke 2.3 microns from a corner in every cell and is closed, and a cell open somewhere else (a pocket meeting a joint's housing) gains nothing from a new floor. + Corners, not every point a wall stands on: where a counterbore and its shank were + unioned, the BSP split each flat of the shank along the head's planes, and with those + split points counted as well (24 on the socket floor, against the shank's 12 corners) + a 2.4 mm shank under a 4.8 mm head at 44.08 mm, loose, had a point within `FAN_CLEAR` + of every centre `fanCentre` tried. The fan stayed put and the cell shipped six edges + open. From the corners alone it moves 0.2 mm and the floor closes. - **A joint's cut is the same lottery, and below 16 mm it comes up often.** The socket's straight walls run only 2.5 mm either side of a cell's middle at 13.5 mm, so every housing, notch and clip pocket crosses its corner arcs and cones, at points that move @@ -775,7 +781,9 @@ currently installed): nothing cleared (10.1 to 11.1 mm magnets at 47.91 to 50.05 mm, clean on main). And once the cells are built, if the shells `settle` cut again have more bad edges with those beside them than they started with, or more open or turned over, they all go back to - their first cut. Two cups put in + their first cut. That check sees only those shells and their neighbours as the cells + left them: the dovetail and puzzle tabs are made after it, and the top-insert pass cuts + its housings out of shells after it, so neither is judged by it. Two cups put in from above from each side of a piece one cell deep meet face to face at 14.44 mm (twice a cup's reach), and there they are built as one solid with `csgUnion`. - **A face that is nothing but a straight line has no middle.** A weld that closes a diff --git a/src/core.js b/src/core.js index feee973..c04962a 100644 --- a/src/core.js +++ b/src/core.js @@ -2571,7 +2571,38 @@ function buildPiece(cfg, layout, piece, onStatus) { } return out; }; - const fastenerFoot = wallsAt(0), fastenerTop = pad > 0.01 ? wallsAt(pad) : []; + /* The same, its corners only. Where the walls of two bores were unioned (a counterbore, + its screw's shank), the BSP split each wall along the other's planes, and wallsAt + hands back those split points as well: two on every flat of the shank, 24 points on + the socket floor that are no corner of anything. A 2.4 mm shank under a 4.8 mm head + at 44.08 mm, with loose tolerance, had a spoke within FAN_CLEAR of one of them from + every point fanCentre tries, so the socket floor's fan never moved and the cell + shipped with six open edges. A corner is where two walls that are not in line meet; + a split point is where one wall was cut in two. From the corners alone the fan moves + 0.2 mm and the floor closes. Only the socket floor's list, which only an open cell's + refan reads (buildPiece), so every cell that came out closed is built as before. */ + const cornersAt = (z) => { + const ends = new Map(); // a wall end, to the directions of the walls that end there + for (const p of cellFastener || []) { + const zs = p.verts.map((v) => v[2]); + if (!(Math.min(...zs) < z && Math.max(...zs) > z) || Math.abs(p.plane.n[2]) > 1e-9) continue; + const d = [-p.plane.n[1], p.plane.n[0]]; // along the wall + let lo = null, hi = null; + for (const v of p.verts) { + const t = v[0]*d[0] + v[1]*d[1]; + if (!lo || t < lo[0]) lo = [t, v]; + if (!hi || t > hi[0]) hi = [t, v]; + } + for (const [, v] of [lo, hi]) { + const k = `${v[0].toFixed(6)} ${v[1].toFixed(6)}`; + if (!ends.has(k)) ends.set(k, { at: [v[0], v[1]], dirs: [] }); + ends.get(k).dirs.push(d); + } + } + return [...ends.values()].filter(({ dirs }) => + dirs.some((a) => dirs.some((b) => Math.abs(a[0]*b[1] - a[1]*b[0]) > 1e-6))).map((e) => e.at); + }; + const fastenerFoot = wallsAt(0), fastenerTop = pad > 0.01 ? cornersAt(pad) : []; // ---- connectors ---- const conn = pieceConnectors(cfg, layout, piece); @@ -2965,7 +2996,9 @@ function buildPiece(cfg, layout, piece, onStatus) { * And once every cell is built, the shells settle cut again are checked as a whole, with * those beside them: if they have more bad edges (checkManifold) than they had before, * or more open or turned over (healCsgSeams), every one goes back to its first cut. So - * settle never leaves a piece worse than it found it, whatever order the cells come in. + * settle never leaves those shells worse than it found them, whatever order the cells + * come in. What is made after the check is not judged by it: the dovetail and puzzle + * tabs, and what the top-insert pass cuts again (see the check below). * `alt` and `pocket` are the cuts a cell was last taken with, so a cell cut again for * one reason keeps what it was cut again for the other. */ const POCKET_TRIES = 7; @@ -3309,8 +3342,10 @@ function buildPiece(cfg, layout, piece, onStatus) { Only here, not on every cell: a 6 mm magnet from above at 42 mm has a spoke 2.3 microns from a corner in every cell and comes out closed, as most do. And only where the fan moves and the cell is open at the floor's height: a cell open - somewhere else, as a pocket that meets a joint's housing is, or one whose spokes - are already clear, would be cut again for the same result. A bowtie plate at + somewhere else, as a pocket that meets a joint's housing is, would be cut again + for the same result, and so would one whose fan stays where it was, either because + its spokes are already clear or because fanCentre finds no point clear of every + corner and keeps the centre. A bowtie plate at 45.57 mm with screws, open in every piece on main as well, took twice as long with every open cell cut again. */ if (region.open && floorAvoid.length && openAt(region, pad)) { diff --git a/test/plate-audit.js b/test/plate-audit.js index 279a6fe..30d0c87 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -1998,6 +1998,18 @@ console.log('\nthe other limits, built at their ends:'); console.log(` ${nm.padEnd(28)} ${leakText(r)}`); if (r.bad) bad++; } + /* A counterbore's floor fan (#61's round 4). Where a 4.8 mm head was unioned with its + 2.4 mm shank, the shank's flats came back split at the head's planes, and the socket + floor's fan was held clear of those split points as well as the corners: no point + fanCentre tried was clear of all of them, so the fan stayed put and the cell shipped + with 6 open edges, no warning. Only the corners count now. */ + { + const r = buildAll({ pitch: 44.08, drawerW: 137.49, drawerD: 91.53, mLeft: 1.96, mRight: 3.29, mFront: 0.58, + mBack: 2.79, bedW: 400, bedD: 400, connector: 'none', tolerance: 'loose', + screws: true, screwHoleD: 2.4, screwHeadD: 4.8, screwHeadDepth: 2 }); + console.log(` ${'counterbore at 44.08 mm'.padEnd(28)} ${leakText(r)}`); + if (r.bad) bad++; + } /* The clearance one step past its end, which leaked, and that was why the end is where it is. It no longer does: the joint's cut taken again when it comes out open (cutAgain in core.js) closes it, as it closes the steps past the ceilings below. So it From 21536a20fd54c16b14b6835b161e25c6155c3412 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 07:57:33 +0000 Subject: [PATCH 02/15] Keep mounting cuts out of a joint's cut in the floor A magnet pocket from beneath that reached a bowtie's recess at 42 mm built 12 bad edges a piece at 7.9 mm and 19 at 10, with no warning and Download on (#64); puzzle tabs at 36 to 40 mm did the same with the spec's 6.5 x 2.4 magnet, 26 to 86. The pocket had run into the cut with its ceiling level with the cut's (a 2 mm magnet or the default counterbore against a key's 2 mm recess, a 2.4 mm one against a tab's 2.4 mm notch), and the two ceilings share a face. At any other depth the pocket breaks in just the same and comes out closed, and the magnet and the key still want the same place, so the pocket breaking in is what is refused. mountLimits takes the layout and measures each whole cell's mounting sites against every cut buildPiece makes from beneath beside them: a key's or an H-clip's recess (keyPlan's 'recess', floor or wall) and a dovetail's or puzzle tab's notch (tabNotch, now shared with buildPiece). Magnets from beneath, counterbores and shanks are held to that room; a magnet from above too, unless its floor stands a layer over the cut. No wall: of 10,882 keyed designs none that stopped short of the cut was bad, and the first went bad 0.035 mm into it, where a 1 mm wall would refuse a 6 mm magnet beside a bowtie at 42 mm. The page reads the mounting sizes after the layout and the clearance are known, puts the room on the field's max, and says which joint: "a hole has to stay out of the recesses the bowtie keys fit into". The audit builds each case at the widest the page takes and refuses the tenth past it and the size that leaked: the 42 mm bowtie each way and with a counterbore, #61's bands, a key in the wall, the 38.13 mm puzzle-key link #61 left for later, both tabs with the spec's magnet, and half cells. The page specs take the new wording and field max; three old cases about the cell's own room take cn=none, since the default dovetail now stops them first. Closes #64 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 19 ++++ src/core.js | 170 +++++++++++++++++++++++++----- src/ui.js | 32 +++++- test/plate-audit.js | 45 ++++++++ test/ui/plates-robustness.spec.js | 57 ++++++++-- 5 files changed, 290 insertions(+), 33 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index e47e095..11fde69 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -744,6 +744,25 @@ currently installed): a 2.4 mm shank under a 4.8 mm head at 44.08 mm, loose, had a point within `FAN_CLEAR` of every centre `fanCentre` tried. The fan stayed put and the cell shipped six edges open. From the corners alone it moves 0.2 mm and the floor closes. +- **A pocket that reaches a joint's cut goes bad where the two ceilings are level.** A + key's recess, an H-clip's and a tab's notch are all cut up from under the plate, as a + magnet pocket from beneath and a counterbore are. Run into one, the pocket comes out + closed at any depth but one: the recess's 2 mm (a 2 mm magnet, the default counterbore) + or the notch's 2.4 (the spec's 6.5 × 2.4 magnet), where the two ceilings share a face + that two subtractions each split their own way. A bowtie in the floor at 42 mm left 12 + edges open at 7.9 mm and 19 at 10; puzzle tabs at 36 to 40 mm left 26 to 86 with the + spec's magnet. Over 768 such pockets 0.1 to 1.25 mm into a key's recess, magnets from + beneath and screw heads, four keys at four pitches, the 96 level with it went bad 74 + times, and the 672 at seven other depths, as near as 0.01 mm either side, never. It is + not mended, it is refused: the pocket has broken into the space the key or the other + piece's tab fills, and a magnet there would sit against it. + `mountLimits` measures every mounting site of a whole cell against each cut on the + layout and holds every size to the room, with no wall: of 10,882 designs over seven keyed + joints, 71 pitches and five cuts, none that stopped short of the cut built a bad edge, + and the first went bad 0.035 mm into it. A pocket from above meets a cut unless its + floor stands a layer over the cut's ceiling. The housings a key is dropped into from + above start 1.3 mm over the socket floor and nothing reaches them, and a pocket in a + corner boss is left out: the boss is a shell of its own, and no joint is cut from it. - **A joint's cut is the same lottery, and below 16 mm it comes up often.** The socket's straight walls run only 2.5 mm either side of a cell's middle at 13.5 mm, so every housing, notch and clip pocket crosses its corner arcs and cones, at points that move diff --git a/src/core.js b/src/core.js index c04962a..36e5684 100644 --- a/src/core.js +++ b/src/core.js @@ -1351,6 +1351,30 @@ function puzzleShape(edge, e, s, pz, grow, inward) { return [s + lt, e + g * dp]; }); } +/* The notch a tab fits into, cut up into the floor of the piece across the seam from it + (pieceConnectors' `notches` or `pnotches`), as one closed solid. buildPiece cuts it, and + mountLimits keeps the mounting sites out of it; one shape, so the two cannot drift. */ +function tabNotch(cfg, nb, pad) { + if (cfg.connector === 'puzzle') + return extrudePoly(puzzleShape(nb.edge, nb.e, nb.s, cfg.puzzle, cfg.puzzle.clr, true), + -0.5, pad - 0.4); + const t = cfg.tab, H = pad + cfg.plateHeight; + const nWr = t.wr + 2*t.clr, nWt = t.wt + 2*t.clr, nDp = t.dp + t.clr; + // 4-pt taper: no vertex sits exactly on the region side plane; jitter breaks + // residual coincidences with ring geometry + const J = 0.0017, BK = 1.0, e = nb.e, s = nb.s + J; + let pts; + if (nb.edge === '+x' || nb.edge === '-x') { + const g = nb.edge === '-x' ? 1 : -1; // cut extends INTO the piece + pts = [[e - g*BK, s - nWr/2], [e + g*nDp, s - nWt/2], + [e + g*nDp, s + nWt/2], [e - g*BK, s + nWr/2]]; + } else { + const g = nb.edge === '-y' ? 1 : -1; + pts = [[s - nWr/2, e - g*BK], [s - nWt/2, e + g*nDp], + [s + nWt/2, e + g*nDp], [s + nWr/2, e - g*BK]]; + } + return extrudePoly(pts, -0.503, Math.min(t.h + 0.2, H - 0.8)); +} // generic underside key halves (recess cut into one piece's edge region) function keyHalf(type, edge, e, s, prm, grow) { // returns polygon extending prm depth into the piece, 0.5 past the seam @@ -2312,11 +2336,15 @@ const MOUNT_WALL = 1.0; * - in a corner boss: it must stay in the boss, which is shorter than the solid floor * and does not grow with the pocket, so it also caps the depth. * + * And whichever way it opens, it must stay out of a joint's cut in the floor beside it: + * a key's recess, or the notch a tab fits into. That one needs `layout`, which says + * where the seams are; without it no joint is counted. + * * These are measurements, not field ranges, and can come out below the field's minimum * or negative — a screw shank at a 34 mm pitch has −0.1 mm. That means no cut of any size * fits there; the page turns it into a check on the design rather than a range for the * field (src/ui.js readNumber), since no number typed into the field could fix it. */ -function mountLimits(cfg) { +function mountLimits(cfg, layout) { const half = cfg.pitch / 2, off = cfg.holeOffset; const tol = cfg.tolerance === 'tight' ? +0.1 : cfg.tolerance === 'loose' ? -0.1 : 0; // distance from a point at (s, s) to the edge of a rounded square of half-size h, @@ -2342,18 +2370,129 @@ function mountLimits(cfg) { stop at 12.5 mm and the wall between two pockets is at least MOUNT_WALL, 1 mm. */ const beside = off - MOUNT_WALL / 2; const fit = (r) => Math.min(r, beside); - const room = fit(cfg.magnetSide === 'top' ? top : under); + /* A joint cut up into the solid floor beside the sites: the recess a key or an H-clip + is put into from beneath (keyPlan's 'recess', in the floor or in the wall), or the + notch a dovetail or puzzle tab fits into (tabNotch). Each starts under the plate, as + a magnet pocket from beneath, a counterbore and a shank do, so any of those that + reaches one in plan has broken into it. A magnet from above meets it unless the + pocket's floor stands at least MOUNT_SKIN over the cut's ceiling. The housings a key + is dropped into from above (keySiteOps' 'cup' and 'snaptop') start 1.3 mm or more + over the socket floor: a pocket from above stops under them, and a shank, which + stays on the socket floor, is in the socket's open air up there. + + Measured off the solids buildPiece cuts, at the sites it cuts pockets at: whole cells + only, so a housing beside a half cell or a margin is measured from the whole cell on + the other side of it, which is the only one with pockets. A corner boss is left out: + its pocket is cut in the boss, a shell of its own that no joint is cut from. + + Issue #64: a bowtie in the floor at 42 mm, with magnets from beneath, built 12 bad + edges at 7.9 mm and 19 at 10, with Download on; puzzle tabs at 36 to 40 mm built 26 + to 86 with the spec's 6.5 × 2.4 magnet. The pocket had run into the cut with its + ceiling level with the cut's: a 2 mm magnet or the default counterbore with a key's + 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face + that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a + key's recess, the 96 level with it went bad 74 times and the 672 at seven other + depths never, as near as 0.01 mm either side. So it is the pocket breaking in that + is refused here, not the depth that shows it: the magnet and the key, or the shank + and the other piece's tab, would want the same place. + + No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that + was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five + cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first + went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath + with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ + const jointCuts = []; // { room, top }: the nearest a site comes to one cut, its ceiling + /* Room past the most the cell or the floor leaves cannot stop a size, so nothing + further off than that is measured, and nothing at all where neither leaves any. A + plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this + is a few milliseconds, on every redraw. */ + const reach = Math.max(fit(top), fit(under)); + if (layout && !bosses && cfg.connector !== 'none' && reach > 0) { + const plan = keyPlan(cfg), pad = platePad(cfg), H = pad + cfg.plateHeight; + /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, + for each seam it can be cut from. Every cut from one seam is the same solid moved + along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once + and each site is moved the other way instead. */ + const shapes = {}; + const shapeOf = (edge) => { + if (shapes[edge]) return shapes[edge]; + const at = { edge, e: 0, s: 0 }; + const solid = plan.kind === 'recess' + ? keySiteOps(plan.kind, plan.shape, plan.prm, plan.clr, edge, 0, 0, H).cut + : tabNotch(cfg, at, pad); + const segs = [], bb = [Infinity, Infinity, -Infinity, -Infinity]; + let ceiling = -Infinity; + for (const p of solid) { + for (const v of p.verts) { + ceiling = Math.max(ceiling, v[2]); + bb[0] = Math.min(bb[0], v[0]); bb[1] = Math.min(bb[1], v[1]); + bb[2] = Math.max(bb[2], v[0]); bb[3] = Math.max(bb[3], v[1]); + } + if (Math.abs(p.plane.n[2]) > 1e-9) continue; + const a = p.verts[0], b = p.verts.find((v) => Math.hypot(v[0] - a[0], v[1] - a[1]) > 1e-9); + if (b) segs.push([a, b]); + } + return (shapes[edge] = { segs, bb, ceiling }); + }; + // how far a point is from the footprint, less than none inside it + const from = (segs, x, y) => { + let d = Infinity, inside = false; + for (const [a, b] of segs) { + const dx = b[0] - a[0], dy = b[1] - a[1]; + const t = Math.max(0, Math.min(1, ((x - a[0])*dx + (y - a[1])*dy) / (dx*dx + dy*dy))); + d = Math.min(d, Math.hypot(a[0] + t*dx - x, a[1] + t*dy - y)); + if ((a[1] > y) !== (b[1] > y) && x < a[0] + (y - a[1]) * dx / dy) inside = !inside; + } + return inside ? -d : d; + }; + for (const piece of layout.pieces) { + const conn = pieceConnectors(cfg, layout, piece); + // the cuts buildPiece makes in this piece: notches for tabs, recesses for keys + const cuts = [...conn.notches, ...conn.pnotches, ...(plan.kind !== 'recess' ? [] + : conn.keyed.filter((bo) => !(plan.junction && offJunction(bo, cfg.pitch, piece))))]; + for (const bo of cuts) { + const { segs, bb, ceiling } = shapeOf(bo.edge); + const across = bo.edge === '+x' || bo.edge === '-x'; + const ox = across ? bo.e : bo.s, oy = across ? bo.s : bo.e; + // the whole cells with a site in reach of it (a half cell has none; see buildPiece) + const cells = (lo, hi, m, n) => [Math.max(0, Math.floor((lo - reach - off - half - m) / cfg.pitch)), + Math.min(n - 1, Math.ceil((hi + reach + off - half - m) / cfg.pitch))]; + const [i0, i1] = cells(bb[0] + ox, bb[2] + ox, piece.mL, piece.nx); + const [j0, j1] = cells(bb[1] + oy, bb[3] + oy, piece.mF, piece.ny); + let room = Infinity; + for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) + for (const sx of [-1, 1]) for (const sy of [-1, 1]) { + const x = piece.mL + i*cfg.pitch + half + sx*off - ox; + const y = piece.mF + j*cfg.pitch + half + sy*off - oy; + if (x < bb[0] - reach || x > bb[2] + reach || y < bb[1] - reach || y > bb[3] + reach) continue; + room = Math.min(room, from(segs, x, y)); + } + jointCuts.push({ room, top: ceiling }); + } + } + } + // the nearest the cuts come that a pocket with its floor at z meets + const jointRoom = (z) => jointCuts.reduce((m, c) => + c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); + const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank + const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length + ? jointRoom(platePad(cfg) - cfg.magnetH) : below; + const own = fit(cfg.magnetSide === 'top' ? top : under); + const room = Math.min(own, magnetJoint); return { // a magnet pocket's corners are 0.1 mm over the magnet's radius, or out to where its // flats stand on that radius if that is further (fastenerCutter) magnetD: r10(2 * Math.min(room - 0.1, room * Math.cos(Math.PI / 14))), // a screw's bores have their corners on its size - screwHoleD: r10(2 * fit(top)), - screwHeadD: r10(2 * fit(under)), + screwHoleD: r10(2 * Math.min(fit(top), below)), + screwHeadD: r10(2 * Math.min(fit(under), below)), // in the solid floor the pad grows to suit, so only a boss caps the depth depth: bosses ? r10(BOSS_H - MOUNT_SKIN) : Infinity, // which of the sizes the cut beside it stops, rather than the floor, cell or boss - beside: { magnetD: room === beside, screwHoleD: top >= beside, screwHeadD: under >= beside }, + beside: { magnetD: room === beside, screwHoleD: top >= beside && below >= beside, + screwHeadD: under >= beside && below >= beside }, + // and which a joint's cut stops, before any of those + joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, }; } @@ -3171,22 +3310,7 @@ function buildPiece(cfg, layout, piece, onStatus) { (nb.edge === '+x' ? Math.abs(x1 - W) : Math.abs(x0)) < nDp + 0.2) : (nb.s > x0 - nWt && nb.s < x1 + nWt && (nb.edge === '+y' ? Math.abs(y1 - D) : Math.abs(y0)) < nDp + 0.2); - if (near) { - // 4-pt taper: no vertex sits exactly on the region side plane; jitter breaks - // residual coincidences with ring geometry - const J = 0.0017, BK = 1.0, e = nb.e, s = nb.s + J; - let pts; - if (nb.edge === '+x' || nb.edge === '-x') { - const g = nb.edge === '-x' ? 1 : -1; // cut extends INTO the piece - pts = [[e - g*BK, s - nWr/2], [e + g*nDp, s - nWt/2], - [e + g*nDp, s + nWt/2], [e - g*BK, s + nWr/2]]; - } else { - const g = nb.edge === '-y' ? 1 : -1; - pts = [[s - nWr/2, e - g*BK], [s - nWt/2, e + g*nDp], - [s + nWt/2, e + g*nDp], [s + nWr/2, e - g*BK]]; - } - cuts.notch.push(...extrudePoly(pts, -0.503, Math.min(t.h + 0.2, H - 0.8))); - } + if (near) cuts.notch.push(...tabNotch(cfg, nb, pad)); } for (const bo of keyed) { if (plan.junction && offJunction(bo, pitch, piece)) @@ -3216,9 +3340,7 @@ function buildPiece(cfg, layout, piece, onStatus) { (pn.edge === '+x' ? Math.abs(x1 - W) : Math.abs(x0)) < reach) : (pn.s > x0 - cfg.puzzle.lobeR*2 && pn.s < x1 + cfg.puzzle.lobeR*2 && (pn.edge === '+y' ? Math.abs(y1 - D) : Math.abs(y0)) < reach); - if (near) cuts.puzzle.push( - ...extrudePoly(puzzleShape(pn.edge, pn.e, pn.s, cfg.puzzle, cfg.puzzle.clr, true), - -0.5, pad - 0.4)); + if (near) cuts.puzzle.push(...tabNotch(cfg, pn, pad)); } /* None in a half cell. A half-size bin's quarter feet carry no holes (feetHolesOff in bins/bin.js), and where a half socket's would go is not settled: a whole diff --git a/src/ui.js b/src/ui.js index ac56878..d35fe29 100644 --- a/src/ui.js +++ b/src/ui.js @@ -44,6 +44,8 @@ const PIECE_COLORS = ['#4fc3e8','#e8b34f','#7fd8a5','#e88a8a','#b18ae8','#7fb5e8 const numIds = ['drawerW','drawerD','bedW','bedD','bedH','mLeft','mRight','mFront','mBack', 'pitch','outerRadius','bottomPad','topCutoff','magnetD','magnetH', 'screwHoleD','screwHeadD','screwHeadDepth','infill']; +// the ones readControls reads after the rest, in this order (see there) +const MOUNT_LAST = ['magnetH', 'screwHeadDepth', 'screwHoleD', 'screwHeadD', 'magnetD']; /* The fields that carry a real-world size, and the range one can be. * @@ -77,13 +79,22 @@ const numIds = ['drawerW','drawerD','bedW','bedD','bedH','mLeft','mRight','mFron * the pitch has no room for. */ const RANGES = PLATE_RANGES; const customMargins = () => state.marginMode === 'custom' && !state.noMargin; -const mount = () => mountLimits(state); +/* The sizes a joint's cut in the floor leaves room for depend on where the seams are and + on the clearance, so mountLimits takes the layout, and readControls reads the mounting + sizes after everything that moves either. One answer per size it reads, kept here + meanwhile: the layout and the cuts are measured once, not once for the range and + again for the reason. */ +let mountNow = null; +const mount = () => mountNow || (mountNow = mountLimits(state, computeLayout(state))); // "an 18 mm pitch", "an 80 mm pitch": the article goes by how the number is said const atPitch = () => `at ${/^(8|1[18](\.|$))/.test(String(state.pitch)) ? 'an' : 'a'} ` + `${state.pitch} mm pitch`; const mountWhy = (opens, field) => `${atPitch()} — mounting holes sit ` + `${state.holeOffset} mm from each cell centre, where the Gridfinity spec puts them, and ` + - (mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' + (mount().joint[field] ? `a hole has to stay out of the ` + + `${['dovetail', 'puzzle'].includes(state.connector) ? 'notches' : 'recesses'} the ` + + `${CONNECTOR_NAMES[state.connector]} fit into` + : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' : opens ? 'a cut open to the socket has to stay on the socket floor' : 'a pocket under the floor has to stay inside its cell'); @@ -270,7 +281,7 @@ function readControls() { state.magnets = $('magnets').checked; state.screws = $('screws').checked; state.magnetSide = $('magnetSide').value; - for (const id of numIds) state[id] = readNumber(id); + for (const id of numIds) if (!MOUNT_LAST.includes(id)) state[id] = readNumber(id); if (state.noMargin) { state.marginMode = 'custom'; state.mLeft = state.mRight = state.mFront = state.mBack = 0; } // the per-corner radii need no range here: buildPiece caps each one at the socket's rim if ($('perCorner').checked) { @@ -290,6 +301,21 @@ function readControls() { state.key = Object.assign({}, DEFAULTS.key, { clr: fit.key }); state.hclip = Object.assign({}, DEFAULTS.hclip, { clr: fit.hclip }); state.puzzle = Object.assign({}, DEFAULTS.puzzle, { clr: fit.puzzle }); + /* The mounting sizes last, since a joint's cut beside the sites moves with the margins, + the split and the clearance (see mount). The magnet's is the very last, and measured + again: a pocket from above meets a cut by how thick the floor is, which the screws + and the magnet's own depth set. */ + mountNow = null; + for (const id of MOUNT_LAST) { + if (id === 'magnetD') mountNow = null; + state[id] = readNumber(id); + } + // and Checks says what is wrong in the panel's order, not the order it was read in + for (const m of [fieldErrors, noRoom]) { + const read = new Map(m); + m.clear(); + for (const id of [...numIds, 'connClr']) if (read.has(id)) m.set(id, read.get(id)); + } // half cells keep the alignment: it places what is left after them $('alignRow').style.display = mm === 'auto' || mm === 'half' ? '' : 'none'; $('halfHint').style.display = mm === 'half' ? '' : 'none'; diff --git a/test/plate-audit.js b/test/plate-audit.js index 30d0c87..18eb9bb 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -1998,6 +1998,51 @@ console.log('\nthe other limits, built at their ends:'); console.log(` ${nm.padEnd(28)} ${leakText(r)}`); if (r.bad) bad++; } + /* A pocket against a joint's cut in the floor (#64). A bowtie housed in the floor at + 42 mm, with magnets from beneath, built 12 bad edges at 7.9 mm and 19 at 10 with + Download on: the pocket reached the key's recess, and with both ceilings 2 mm up the + two shared a face. mountLimits keeps every mounting cut out of a joint's cut now, + measured on the layout, so each case is built at the widest the page takes, which + has to come out watertight, and the first tenth past it, and a size main took that + reaches the cut (the first that leaked, where one did), have to be refused. Two + pieces side by side, so the seam between them is cut. The bands are #61's, where its + wider pocket brought the leak 0.1 to 0.4 mm lower. From above, an 8 mm magnet meets + the recess under it without a bad edge, and would sit on the key; in the wall, main's + widest leaked. The 38.13 mm link is the one #61 left for later: its + 6.5 mm counterbore stood 0.7 mm into a puzzle key's recess. The last two are the + spec's 6.5 × 2.4 magnet beside a tab, whose notch stops 2.4 mm up as well. And the + same bowtie in four pieces with strips of half cells and margins round them, whose + whole cells are the ones measured. */ + const pair = (p, o) => ({ pitch: p, drawerW: 4 * p, drawerD: 2 * p, bedW: 2 * p + 16, bedD: 400, ...o }); + const JOINTED = [ // [what, design, field, a size main took into the cut] + ['bowtie, magnet below, 42', pair(42, { connector: 'bowtie', magnets: true }), 'magnetD', 7.9], + ['bowtie, magnet above, 42', pair(42, { connector: 'bowtie', magnets: true, magnetSide: 'top' }), 'magnetD', 8], + ['bowtie, screw head, 42', pair(42, { connector: 'bowtie', screws: true }), 'screwHeadD', 8.2], + ['snap, magnet below, 49.02', pair(49.02, { connector: 'snap', magnets: true }), 'magnetD', 17.2], + ['puzzle key, below, 46', pair(46, { connector: 'puzzlekey', magnets: true }), 'magnetD', 16], + ['puzzle key, below, 49.02', pair(49.02, { connector: 'puzzlekey', magnets: true }), 'magnetD', 20.2], + ['bowtie in the wall, 44.17', pair(44.17, { connector: 'bowtie', keyMount: 'wall', magnets: true }), 'magnetD', 15.7], + ['38.13 mm link, counterbore', { drawerW: 134.56, drawerD: 120.48, mLeft: 11.96, mRight: 8.21, mFront: 5.39, + mBack: 0.7, bedW: 67.2, bedD: 86.26, connector: 'puzzlekey', clr: 0.2, screws: true, screwHoleD: 3, + screwHeadD: 6.5, pitch: 38.13, outerRadius: 3.49, topCutoff: 1 }, 'screwHeadD', 6.5], + ['puzzle tabs, 2.4 deep, 38', pair(38, { connector: 'puzzle', magnets: true, magnetH: 2.4 }), 'magnetD', 6.5], + ['dovetail, 2.4 deep, 36', pair(36, { connector: 'dovetail', magnets: true, magnetH: 2.4 }), 'magnetD', 6.5], + ['bowtie, half cells, 42', { pitch: 42, drawerW: 199, drawerD: 199, marginMode: 'half', bedW: 120, bedD: 120, + connector: 'bowtie', magnets: true }, 'magnetD', 7.9], + ]; + for (const [nm, o, f, into] of JOINTED) { + const cfg = designCfg(o); + const lims = G.mountLimits(cfg, G.computeLayout(cfg)), lim = lims[f]; + const takes = (d) => d <= lim + 1e-9; + const widest = buildAll(sized(o, f, lim)); + const past = Math.round(lim * 10 + 1) / 10; + const taken = [past, into].filter(takes) + .map((d) => `${d} mm TAKEN, and ${leakText(buildAll(sized(o, f, d)))}`); + console.log(` ${nm.padEnd(28)} widest ${lim} mm ${leakText(widest)}; ` + + (taken.join('; ') || `${past} and ${into} mm refused`)); + if (widest.bad) bad++; + bad += taken.length; + } /* A counterbore's floor fan (#61's round 4). Where a 4.8 mm head was unioned with its 2.4 mm shank, the shank's flats came back split at the head's planes, and the socket floor's fan was held clear of those split points as well as the corners: no point diff --git a/test/ui/plates-robustness.spec.js b/test/ui/plates-robustness.spec.js index 4edf962..db5c058 100644 --- a/test/ui/plates-robustness.spec.js +++ b/test/ui/plates-robustness.spec.js @@ -76,7 +76,10 @@ test.describe('Fewest plates on a big grid', () => { test.describe('ranges on the geometry fields', () => { /* [link, the line under the field, what it has to say]. The magnet and screw maxima are the standard 42 mm pitch's, from mountLimits; the pitch cases show the same - limit moving with the cell, down to no room at all. */ + limit moving with the cell, down to no room at all. Those take no joint (cn=none): + the default dovetail's notches stop a magnet from beneath first, at 12.3 mm, and + the joint cases at the end of the list say so. */ + const BOWTIE_42 = '#pi=42&w=168&d=84&mm=custom&ml=0&mr=0&mf=0&mb=0&bw=100&bd=400&cn=bowtie&km=floor&ki=bottom'; const CASES = [ ['#tc=0', 'errFloor', /Rim cutoff must be at least 0\.1 mm/], ['#tc=5', 'errFloor', /Rim cutoff must be 1 mm or less — past that a spec bin rides on the rim/], @@ -87,9 +90,9 @@ test.describe('ranges on the geometry fields', () => { ['#mg=1&md=0', 'errMagnet', /Magnet Ø must be at least 1 mm/], ['#mg=1&mh=0', 'errMagnet', /Magnet depth must be at least 0\.5 mm/], ['#mg=1&ms=top&mh=-5', 'errMagnet', /Magnet depth must be at least 0\.5 mm/], - ['#mg=1&md=20', 'errMagnet', /Magnet Ø must be 13\.6 mm or less at a 42 mm pitch/], + ['#cn=none&mg=1&md=20', 'errMagnet', /Magnet Ø must be 13\.6 mm or less at a 42 mm pitch/], ['#mg=1&ms=top&md=10', 'errMagnet', /Magnet Ø must be 8 mm or less at a 42 mm pitch/], - ['#mg=1&pi=30', 'errMagnet', /Magnet Ø must be 1\.8 mm or less at a 30 mm pitch/], + ['#cn=none&mg=1&pi=30', 'errMagnet', /Magnet Ø must be 1\.8 mm or less at a 30 mm pitch/], // past about 50 mm it is the hole beside a pocket that stops it: a 1-inch magnet met it ['#pi=55&w=110&d=110&mm=custom&ml=0&mr=0&mf=0&mb=0&bw=400&bd=400&mg=1&md=25.4', 'errMagnet', /Magnet Ø must be 24\.3 mm or less at a 55 mm pitch — mounting holes sit 13 mm from each cell centre, where the Gridfinity spec puts them, and a cell's four holes have to stay clear of each other/], @@ -97,12 +100,23 @@ test.describe('ranges on the geometry fields', () => { /Screw head Ø must be 25 mm or less at a 60 mm pitch — .* a cell's four holes have to stay clear of each other/], ['#mg=1&bm=bosses&mh=3', 'errMagnet', /Magnet depth must be 2\.4 mm or less with corner pockets/], ['#sc=1&sh=20', 'errScrew', /Screw hole Ø must be 8\.3 mm or less/], - ['#sc=1&sd=30', 'errScrew', /Screw head Ø must be 14 mm or less/], + ['#cn=none&sc=1&sd=30', 'errScrew', /Screw head Ø must be 14 mm or less/], ['#sc=1&se=50', 'errScrew', /Screw head depth must be 10 mm or less/], ['#cl=1', 'errConnClr', /Fit clearance must be 0\.3 mm or less — any looser and a dovetail pocket/], ['#cn=bowtie&cl=5', 'errConnClr', /Fit clearance must be 1 mm or less — check the figure is in millimetres/], ['#cl=-1', 'errConnClr', /Fit clearance must be at least 0 mm/], ['#pi=10', 'errPitch', /Grid pitch must be at least 13\.5 mm/], + /* #64: a hole has to stay out of a joint's cut in the floor. A 10 mm magnet from + beneath reached a bowtie's recess at 42 mm, and the plate built with 19 bad edges a + piece and Download on; from above, an 8 mm one stood over the key. */ + [`${BOWTIE_42}&mg=1&md=10`, 'errMagnet', + /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — mounting holes sit 13 mm from each cell centre, where the Gridfinity spec puts them, and a hole has to stay out of the recesses the bowtie keys fit into/], + [`${BOWTIE_42}&mg=1&ms=top&md=8`, 'errMagnet', + /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — .* the recesses the bowtie keys fit into/], + [`${BOWTIE_42.replace('cn=bowtie', 'cn=snap')}&sc=1&sd=10`, 'errScrew', + /Screw head Ø must be 7\.8 mm or less at a 42 mm pitch — .* the recesses the snap clips fit into/], + ['#mg=1&md=20', 'errMagnet', + /Magnet Ø must be 12\.3 mm or less at a 42 mm pitch — .* the notches the dovetail tabs fit into/], ]; for (const [hash, errId, msg] of CASES) { test(`${hash} is refused at the field`, async ({ page }) => { @@ -118,6 +132,32 @@ test.describe('ranges on the geometry fields', () => { }); } + /* The range moves with the joint. With a bowtie in the floor at 42 mm a magnet from + beneath goes up to 7.6 mm, where the cell alone takes 13.6: at 7.6 it builds with + Download on, a tenth past is refused with Download off, and with no joint the field + takes the cell's size again. */ + test('a magnet pocket is held out of a joint\'s recess, and the field says how far', + async ({ page }) => { + const errors = await openAt(page, `${BOWTIE_42}&mg=1&md=7.6`); + const max = () => page.evaluate(() => document.getElementById('magnetD').max); + expect(await max()).toBe('7.6'); + expect(await shown(page, 'errMagnet')).toBe(false); + expect(await text(page, 'pieceTail')).toMatch(/ready/); + expect(await exportOff(page)).toBe(false); + await H.setField(page, 'magnetD', '7.7'); + expect(await text(page, 'errMagnet')) + .toMatch(/Magnet Ø must be 7\.6 mm or less .* the recesses the bowtie keys fit into/); + expect(await text(page, 'pieceTail')).toMatch(/not building/); + expect(await exportOff(page)).toBe(true); + await page.selectOption('#connector', 'none'); + await page.waitForFunction(() => /ready/.test(document.getElementById('pieceTail').textContent), + null, { timeout: 30000 }); + expect(await max()).toBe('13.6'); + expect(await shown(page, 'errMagnet')).toBe(false); + expect(await exportOff(page)).toBe(false); + expect(errors).toEqual([]); + }); + test('a typed value is held to the same range, and a good one clears it', async ({ page }) => { await H.openPlates(page); await H.setField(page, 'topCutoff', '0'); @@ -345,11 +385,16 @@ test.describe('limits no tighter than the geometry', () => { expect(s.built).toBeCloseTo(7.05, 9); }); + /* The 34 mm case takes no joint: the default dovetail's notches hold its 6 mm screw head + to 3.8 mm there, which is a field error of its own. The puzzle tabs' are what leave + a magnet no room at 36 mm, where the cell alone would take 7.7. */ for (const [hash, id, errId, carried, msg] of [ - ['#sc=1&pi=34', 'screwHoleD', 'errScrew', 3, + ['#cn=none&sc=1&pi=34', 'screwHoleD', 'errScrew', 3, /Screw hole Ø: there is no room for one at a 34 mm pitch.*Use a larger pitch, or turn off screw holes\./], ['#mg=1&pi=20', 'magnetD', 'errMagnet', 6, - /Magnet Ø: there is no room for one at a 20 mm pitch.*Use a larger pitch, or turn off magnet pockets\./]]) + /Magnet Ø: there is no room for one at a 20 mm pitch.*Use a larger pitch, or turn off magnet pockets\./], + ['#cn=puzzle&mg=1&pi=36', 'magnetD', 'errMagnet', 6, + /Magnet Ø: there is no room for one at a 36 mm pitch — .* the notches the puzzle tabs fit into\. Use a larger pitch, or turn off magnet pockets\./]]) test(`${hash}: no room at all is a check on the design, not a field nothing satisfies`, async ({ page }) => { const errors = await openAt(page, hash); From 8eb7210d478ad6b7353cba4ea6c4e475fc6a3112 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 07:57:43 +0000 Subject: [PATCH 03/15] Rebuild the pages Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- bins/index.html | 213 +++++++++++++++++++++++++++++++++++------ index.html | 245 ++++++++++++++++++++++++++++++++++++++++++------ sw.js | 2 +- 3 files changed, 400 insertions(+), 60 deletions(-) diff --git a/bins/index.html b/bins/index.html index 33311a4..d6a0e6a 100644 --- a/bins/index.html +++ b/bins/index.html @@ -2957,6 +2957,30 @@

Your drawers

return [s + lt, e + g * dp]; }); } +/* The notch a tab fits into, cut up into the floor of the piece across the seam from it + (pieceConnectors' `notches` or `pnotches`), as one closed solid. buildPiece cuts it, and + mountLimits keeps the mounting sites out of it; one shape, so the two cannot drift. */ +function tabNotch(cfg, nb, pad) { + if (cfg.connector === 'puzzle') + return extrudePoly(puzzleShape(nb.edge, nb.e, nb.s, cfg.puzzle, cfg.puzzle.clr, true), + -0.5, pad - 0.4); + const t = cfg.tab, H = pad + cfg.plateHeight; + const nWr = t.wr + 2*t.clr, nWt = t.wt + 2*t.clr, nDp = t.dp + t.clr; + // 4-pt taper: no vertex sits exactly on the region side plane; jitter breaks + // residual coincidences with ring geometry + const J = 0.0017, BK = 1.0, e = nb.e, s = nb.s + J; + let pts; + if (nb.edge === '+x' || nb.edge === '-x') { + const g = nb.edge === '-x' ? 1 : -1; // cut extends INTO the piece + pts = [[e - g*BK, s - nWr/2], [e + g*nDp, s - nWt/2], + [e + g*nDp, s + nWt/2], [e - g*BK, s + nWr/2]]; + } else { + const g = nb.edge === '-y' ? 1 : -1; + pts = [[s - nWr/2, e - g*BK], [s - nWt/2, e + g*nDp], + [s + nWt/2, e + g*nDp], [s + nWr/2, e - g*BK]]; + } + return extrudePoly(pts, -0.503, Math.min(t.h + 0.2, H - 0.8)); +} // generic underside key halves (recess cut into one piece's edge region) function keyHalf(type, edge, e, s, prm, grow) { // returns polygon extending prm depth into the piece, 0.5 past the seam @@ -3918,11 +3942,15 @@

Your drawers

* - in a corner boss: it must stay in the boss, which is shorter than the solid floor * and does not grow with the pocket, so it also caps the depth. * + * And whichever way it opens, it must stay out of a joint's cut in the floor beside it: + * a key's recess, or the notch a tab fits into. That one needs `layout`, which says + * where the seams are; without it no joint is counted. + * * These are measurements, not field ranges, and can come out below the field's minimum * or negative — a screw shank at a 34 mm pitch has −0.1 mm. That means no cut of any size * fits there; the page turns it into a check on the design rather than a range for the * field (src/ui.js readNumber), since no number typed into the field could fix it. */ -function mountLimits(cfg) { +function mountLimits(cfg, layout) { const half = cfg.pitch / 2, off = cfg.holeOffset; const tol = cfg.tolerance === 'tight' ? +0.1 : cfg.tolerance === 'loose' ? -0.1 : 0; // distance from a point at (s, s) to the edge of a rounded square of half-size h, @@ -3948,18 +3976,129 @@

Your drawers

stop at 12.5 mm and the wall between two pockets is at least MOUNT_WALL, 1 mm. */ const beside = off - MOUNT_WALL / 2; const fit = (r) => Math.min(r, beside); - const room = fit(cfg.magnetSide === 'top' ? top : under); + /* A joint cut up into the solid floor beside the sites: the recess a key or an H-clip + is put into from beneath (keyPlan's 'recess', in the floor or in the wall), or the + notch a dovetail or puzzle tab fits into (tabNotch). Each starts under the plate, as + a magnet pocket from beneath, a counterbore and a shank do, so any of those that + reaches one in plan has broken into it. A magnet from above meets it unless the + pocket's floor stands at least MOUNT_SKIN over the cut's ceiling. The housings a key + is dropped into from above (keySiteOps' 'cup' and 'snaptop') start 1.3 mm or more + over the socket floor: a pocket from above stops under them, and a shank, which + stays on the socket floor, is in the socket's open air up there. + + Measured off the solids buildPiece cuts, at the sites it cuts pockets at: whole cells + only, so a housing beside a half cell or a margin is measured from the whole cell on + the other side of it, which is the only one with pockets. A corner boss is left out: + its pocket is cut in the boss, a shell of its own that no joint is cut from. + + Issue #64: a bowtie in the floor at 42 mm, with magnets from beneath, built 12 bad + edges at 7.9 mm and 19 at 10, with Download on; puzzle tabs at 36 to 40 mm built 26 + to 86 with the spec's 6.5 × 2.4 magnet. The pocket had run into the cut with its + ceiling level with the cut's: a 2 mm magnet or the default counterbore with a key's + 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face + that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a + key's recess, the 96 level with it went bad 74 times and the 672 at seven other + depths never, as near as 0.01 mm either side. So it is the pocket breaking in that + is refused here, not the depth that shows it: the magnet and the key, or the shank + and the other piece's tab, would want the same place. + + No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that + was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five + cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first + went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath + with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ + const jointCuts = []; // { room, top }: the nearest a site comes to one cut, its ceiling + /* Room past the most the cell or the floor leaves cannot stop a size, so nothing + further off than that is measured, and nothing at all where neither leaves any. A + plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this + is a few milliseconds, on every redraw. */ + const reach = Math.max(fit(top), fit(under)); + if (layout && !bosses && cfg.connector !== 'none' && reach > 0) { + const plan = keyPlan(cfg), pad = platePad(cfg), H = pad + cfg.plateHeight; + /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, + for each seam it can be cut from. Every cut from one seam is the same solid moved + along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once + and each site is moved the other way instead. */ + const shapes = {}; + const shapeOf = (edge) => { + if (shapes[edge]) return shapes[edge]; + const at = { edge, e: 0, s: 0 }; + const solid = plan.kind === 'recess' + ? keySiteOps(plan.kind, plan.shape, plan.prm, plan.clr, edge, 0, 0, H).cut + : tabNotch(cfg, at, pad); + const segs = [], bb = [Infinity, Infinity, -Infinity, -Infinity]; + let ceiling = -Infinity; + for (const p of solid) { + for (const v of p.verts) { + ceiling = Math.max(ceiling, v[2]); + bb[0] = Math.min(bb[0], v[0]); bb[1] = Math.min(bb[1], v[1]); + bb[2] = Math.max(bb[2], v[0]); bb[3] = Math.max(bb[3], v[1]); + } + if (Math.abs(p.plane.n[2]) > 1e-9) continue; + const a = p.verts[0], b = p.verts.find((v) => Math.hypot(v[0] - a[0], v[1] - a[1]) > 1e-9); + if (b) segs.push([a, b]); + } + return (shapes[edge] = { segs, bb, ceiling }); + }; + // how far a point is from the footprint, less than none inside it + const from = (segs, x, y) => { + let d = Infinity, inside = false; + for (const [a, b] of segs) { + const dx = b[0] - a[0], dy = b[1] - a[1]; + const t = Math.max(0, Math.min(1, ((x - a[0])*dx + (y - a[1])*dy) / (dx*dx + dy*dy))); + d = Math.min(d, Math.hypot(a[0] + t*dx - x, a[1] + t*dy - y)); + if ((a[1] > y) !== (b[1] > y) && x < a[0] + (y - a[1]) * dx / dy) inside = !inside; + } + return inside ? -d : d; + }; + for (const piece of layout.pieces) { + const conn = pieceConnectors(cfg, layout, piece); + // the cuts buildPiece makes in this piece: notches for tabs, recesses for keys + const cuts = [...conn.notches, ...conn.pnotches, ...(plan.kind !== 'recess' ? [] + : conn.keyed.filter((bo) => !(plan.junction && offJunction(bo, cfg.pitch, piece))))]; + for (const bo of cuts) { + const { segs, bb, ceiling } = shapeOf(bo.edge); + const across = bo.edge === '+x' || bo.edge === '-x'; + const ox = across ? bo.e : bo.s, oy = across ? bo.s : bo.e; + // the whole cells with a site in reach of it (a half cell has none; see buildPiece) + const cells = (lo, hi, m, n) => [Math.max(0, Math.floor((lo - reach - off - half - m) / cfg.pitch)), + Math.min(n - 1, Math.ceil((hi + reach + off - half - m) / cfg.pitch))]; + const [i0, i1] = cells(bb[0] + ox, bb[2] + ox, piece.mL, piece.nx); + const [j0, j1] = cells(bb[1] + oy, bb[3] + oy, piece.mF, piece.ny); + let room = Infinity; + for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) + for (const sx of [-1, 1]) for (const sy of [-1, 1]) { + const x = piece.mL + i*cfg.pitch + half + sx*off - ox; + const y = piece.mF + j*cfg.pitch + half + sy*off - oy; + if (x < bb[0] - reach || x > bb[2] + reach || y < bb[1] - reach || y > bb[3] + reach) continue; + room = Math.min(room, from(segs, x, y)); + } + jointCuts.push({ room, top: ceiling }); + } + } + } + // the nearest the cuts come that a pocket with its floor at z meets + const jointRoom = (z) => jointCuts.reduce((m, c) => + c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); + const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank + const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length + ? jointRoom(platePad(cfg) - cfg.magnetH) : below; + const own = fit(cfg.magnetSide === 'top' ? top : under); + const room = Math.min(own, magnetJoint); return { // a magnet pocket's corners are 0.1 mm over the magnet's radius, or out to where its // flats stand on that radius if that is further (fastenerCutter) magnetD: r10(2 * Math.min(room - 0.1, room * Math.cos(Math.PI / 14))), // a screw's bores have their corners on its size - screwHoleD: r10(2 * fit(top)), - screwHeadD: r10(2 * fit(under)), + screwHoleD: r10(2 * Math.min(fit(top), below)), + screwHeadD: r10(2 * Math.min(fit(under), below)), // in the solid floor the pad grows to suit, so only a boss caps the depth depth: bosses ? r10(BOSS_H - MOUNT_SKIN) : Infinity, // which of the sizes the cut beside it stops, rather than the floor, cell or boss - beside: { magnetD: room === beside, screwHoleD: top >= beside, screwHeadD: under >= beside }, + beside: { magnetD: room === beside, screwHoleD: top >= beside && below >= beside, + screwHeadD: under >= beside && below >= beside }, + // and which a joint's cut stops, before any of those + joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, }; } @@ -4177,7 +4316,38 @@

Your drawers

} return out; }; - const fastenerFoot = wallsAt(0), fastenerTop = pad > 0.01 ? wallsAt(pad) : []; + /* The same, its corners only. Where the walls of two bores were unioned (a counterbore, + its screw's shank), the BSP split each wall along the other's planes, and wallsAt + hands back those split points as well: two on every flat of the shank, 24 points on + the socket floor that are no corner of anything. A 2.4 mm shank under a 4.8 mm head + at 44.08 mm, with loose tolerance, had a spoke within FAN_CLEAR of one of them from + every point fanCentre tries, so the socket floor's fan never moved and the cell + shipped with six open edges. A corner is where two walls that are not in line meet; + a split point is where one wall was cut in two. From the corners alone the fan moves + 0.2 mm and the floor closes. Only the socket floor's list, which only an open cell's + refan reads (buildPiece), so every cell that came out closed is built as before. */ + const cornersAt = (z) => { + const ends = new Map(); // a wall end, to the directions of the walls that end there + for (const p of cellFastener || []) { + const zs = p.verts.map((v) => v[2]); + if (!(Math.min(...zs) < z && Math.max(...zs) > z) || Math.abs(p.plane.n[2]) > 1e-9) continue; + const d = [-p.plane.n[1], p.plane.n[0]]; // along the wall + let lo = null, hi = null; + for (const v of p.verts) { + const t = v[0]*d[0] + v[1]*d[1]; + if (!lo || t < lo[0]) lo = [t, v]; + if (!hi || t > hi[0]) hi = [t, v]; + } + for (const [, v] of [lo, hi]) { + const k = `${v[0].toFixed(6)} ${v[1].toFixed(6)}`; + if (!ends.has(k)) ends.set(k, { at: [v[0], v[1]], dirs: [] }); + ends.get(k).dirs.push(d); + } + } + return [...ends.values()].filter(({ dirs }) => + dirs.some((a) => dirs.some((b) => Math.abs(a[0]*b[1] - a[1]*b[0]) > 1e-6))).map((e) => e.at); + }; + const fastenerFoot = wallsAt(0), fastenerTop = pad > 0.01 ? cornersAt(pad) : []; // ---- connectors ---- const conn = pieceConnectors(cfg, layout, piece); @@ -4571,7 +4741,9 @@

Your drawers

* And once every cell is built, the shells settle cut again are checked as a whole, with * those beside them: if they have more bad edges (checkManifold) than they had before, * or more open or turned over (healCsgSeams), every one goes back to its first cut. So - * settle never leaves a piece worse than it found it, whatever order the cells come in. + * settle never leaves those shells worse than it found them, whatever order the cells + * come in. What is made after the check is not judged by it: the dovetail and puzzle + * tabs, and what the top-insert pass cuts again (see the check below). * `alt` and `pocket` are the cuts a cell was last taken with, so a cell cut again for * one reason keeps what it was cut again for the other. */ const POCKET_TRIES = 7; @@ -4744,22 +4916,7 @@

Your drawers

(nb.edge === '+x' ? Math.abs(x1 - W) : Math.abs(x0)) < nDp + 0.2) : (nb.s > x0 - nWt && nb.s < x1 + nWt && (nb.edge === '+y' ? Math.abs(y1 - D) : Math.abs(y0)) < nDp + 0.2); - if (near) { - // 4-pt taper: no vertex sits exactly on the region side plane; jitter breaks - // residual coincidences with ring geometry - const J = 0.0017, BK = 1.0, e = nb.e, s = nb.s + J; - let pts; - if (nb.edge === '+x' || nb.edge === '-x') { - const g = nb.edge === '-x' ? 1 : -1; // cut extends INTO the piece - pts = [[e - g*BK, s - nWr/2], [e + g*nDp, s - nWt/2], - [e + g*nDp, s + nWt/2], [e - g*BK, s + nWr/2]]; - } else { - const g = nb.edge === '-y' ? 1 : -1; - pts = [[s - nWr/2, e - g*BK], [s - nWt/2, e + g*nDp], - [s + nWt/2, e + g*nDp], [s + nWr/2, e - g*BK]]; - } - cuts.notch.push(...extrudePoly(pts, -0.503, Math.min(t.h + 0.2, H - 0.8))); - } + if (near) cuts.notch.push(...tabNotch(cfg, nb, pad)); } for (const bo of keyed) { if (plan.junction && offJunction(bo, pitch, piece)) @@ -4789,9 +4946,7 @@

Your drawers

(pn.edge === '+x' ? Math.abs(x1 - W) : Math.abs(x0)) < reach) : (pn.s > x0 - cfg.puzzle.lobeR*2 && pn.s < x1 + cfg.puzzle.lobeR*2 && (pn.edge === '+y' ? Math.abs(y1 - D) : Math.abs(y0)) < reach); - if (near) cuts.puzzle.push( - ...extrudePoly(puzzleShape(pn.edge, pn.e, pn.s, cfg.puzzle, cfg.puzzle.clr, true), - -0.5, pad - 0.4)); + if (near) cuts.puzzle.push(...tabNotch(cfg, pn, pad)); } /* None in a half cell. A half-size bin's quarter feet carry no holes (feetHolesOff in bins/bin.js), and where a half socket's would go is not settled: a whole @@ -4915,8 +5070,10 @@

Your drawers

Only here, not on every cell: a 6 mm magnet from above at 42 mm has a spoke 2.3 microns from a corner in every cell and comes out closed, as most do. And only where the fan moves and the cell is open at the floor's height: a cell open - somewhere else, as a pocket that meets a joint's housing is, or one whose spokes - are already clear, would be cut again for the same result. A bowtie plate at + somewhere else, as a pocket that meets a joint's housing is, would be cut again + for the same result, and so would one whose fan stays where it was, either because + its spokes are already clear or because fanCentre finds no point clear of every + corner and keeps the centre. A bowtie plate at 45.57 mm with screws, open in every piece on main as well, took twice as long with every open cell cut again. */ if (region.open && floorAvoid.length && openAt(region, pad)) { diff --git a/index.html b/index.html index 8fb1296..5a940b7 100644 --- a/index.html +++ b/index.html @@ -2744,6 +2744,30 @@

Your drawers

return [s + lt, e + g * dp]; }); } +/* The notch a tab fits into, cut up into the floor of the piece across the seam from it + (pieceConnectors' `notches` or `pnotches`), as one closed solid. buildPiece cuts it, and + mountLimits keeps the mounting sites out of it; one shape, so the two cannot drift. */ +function tabNotch(cfg, nb, pad) { + if (cfg.connector === 'puzzle') + return extrudePoly(puzzleShape(nb.edge, nb.e, nb.s, cfg.puzzle, cfg.puzzle.clr, true), + -0.5, pad - 0.4); + const t = cfg.tab, H = pad + cfg.plateHeight; + const nWr = t.wr + 2*t.clr, nWt = t.wt + 2*t.clr, nDp = t.dp + t.clr; + // 4-pt taper: no vertex sits exactly on the region side plane; jitter breaks + // residual coincidences with ring geometry + const J = 0.0017, BK = 1.0, e = nb.e, s = nb.s + J; + let pts; + if (nb.edge === '+x' || nb.edge === '-x') { + const g = nb.edge === '-x' ? 1 : -1; // cut extends INTO the piece + pts = [[e - g*BK, s - nWr/2], [e + g*nDp, s - nWt/2], + [e + g*nDp, s + nWt/2], [e - g*BK, s + nWr/2]]; + } else { + const g = nb.edge === '-y' ? 1 : -1; + pts = [[s - nWr/2, e - g*BK], [s - nWt/2, e + g*nDp], + [s + nWt/2, e + g*nDp], [s + nWr/2, e - g*BK]]; + } + return extrudePoly(pts, -0.503, Math.min(t.h + 0.2, H - 0.8)); +} // generic underside key halves (recess cut into one piece's edge region) function keyHalf(type, edge, e, s, prm, grow) { // returns polygon extending prm depth into the piece, 0.5 past the seam @@ -3705,11 +3729,15 @@

Your drawers

* - in a corner boss: it must stay in the boss, which is shorter than the solid floor * and does not grow with the pocket, so it also caps the depth. * + * And whichever way it opens, it must stay out of a joint's cut in the floor beside it: + * a key's recess, or the notch a tab fits into. That one needs `layout`, which says + * where the seams are; without it no joint is counted. + * * These are measurements, not field ranges, and can come out below the field's minimum * or negative — a screw shank at a 34 mm pitch has −0.1 mm. That means no cut of any size * fits there; the page turns it into a check on the design rather than a range for the * field (src/ui.js readNumber), since no number typed into the field could fix it. */ -function mountLimits(cfg) { +function mountLimits(cfg, layout) { const half = cfg.pitch / 2, off = cfg.holeOffset; const tol = cfg.tolerance === 'tight' ? +0.1 : cfg.tolerance === 'loose' ? -0.1 : 0; // distance from a point at (s, s) to the edge of a rounded square of half-size h, @@ -3735,18 +3763,129 @@

Your drawers

stop at 12.5 mm and the wall between two pockets is at least MOUNT_WALL, 1 mm. */ const beside = off - MOUNT_WALL / 2; const fit = (r) => Math.min(r, beside); - const room = fit(cfg.magnetSide === 'top' ? top : under); + /* A joint cut up into the solid floor beside the sites: the recess a key or an H-clip + is put into from beneath (keyPlan's 'recess', in the floor or in the wall), or the + notch a dovetail or puzzle tab fits into (tabNotch). Each starts under the plate, as + a magnet pocket from beneath, a counterbore and a shank do, so any of those that + reaches one in plan has broken into it. A magnet from above meets it unless the + pocket's floor stands at least MOUNT_SKIN over the cut's ceiling. The housings a key + is dropped into from above (keySiteOps' 'cup' and 'snaptop') start 1.3 mm or more + over the socket floor: a pocket from above stops under them, and a shank, which + stays on the socket floor, is in the socket's open air up there. + + Measured off the solids buildPiece cuts, at the sites it cuts pockets at: whole cells + only, so a housing beside a half cell or a margin is measured from the whole cell on + the other side of it, which is the only one with pockets. A corner boss is left out: + its pocket is cut in the boss, a shell of its own that no joint is cut from. + + Issue #64: a bowtie in the floor at 42 mm, with magnets from beneath, built 12 bad + edges at 7.9 mm and 19 at 10, with Download on; puzzle tabs at 36 to 40 mm built 26 + to 86 with the spec's 6.5 × 2.4 magnet. The pocket had run into the cut with its + ceiling level with the cut's: a 2 mm magnet or the default counterbore with a key's + 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face + that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a + key's recess, the 96 level with it went bad 74 times and the 672 at seven other + depths never, as near as 0.01 mm either side. So it is the pocket breaking in that + is refused here, not the depth that shows it: the magnet and the key, or the shank + and the other piece's tab, would want the same place. + + No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that + was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five + cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first + went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath + with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ + const jointCuts = []; // { room, top }: the nearest a site comes to one cut, its ceiling + /* Room past the most the cell or the floor leaves cannot stop a size, so nothing + further off than that is measured, and nothing at all where neither leaves any. A + plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this + is a few milliseconds, on every redraw. */ + const reach = Math.max(fit(top), fit(under)); + if (layout && !bosses && cfg.connector !== 'none' && reach > 0) { + const plan = keyPlan(cfg), pad = platePad(cfg), H = pad + cfg.plateHeight; + /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, + for each seam it can be cut from. Every cut from one seam is the same solid moved + along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once + and each site is moved the other way instead. */ + const shapes = {}; + const shapeOf = (edge) => { + if (shapes[edge]) return shapes[edge]; + const at = { edge, e: 0, s: 0 }; + const solid = plan.kind === 'recess' + ? keySiteOps(plan.kind, plan.shape, plan.prm, plan.clr, edge, 0, 0, H).cut + : tabNotch(cfg, at, pad); + const segs = [], bb = [Infinity, Infinity, -Infinity, -Infinity]; + let ceiling = -Infinity; + for (const p of solid) { + for (const v of p.verts) { + ceiling = Math.max(ceiling, v[2]); + bb[0] = Math.min(bb[0], v[0]); bb[1] = Math.min(bb[1], v[1]); + bb[2] = Math.max(bb[2], v[0]); bb[3] = Math.max(bb[3], v[1]); + } + if (Math.abs(p.plane.n[2]) > 1e-9) continue; + const a = p.verts[0], b = p.verts.find((v) => Math.hypot(v[0] - a[0], v[1] - a[1]) > 1e-9); + if (b) segs.push([a, b]); + } + return (shapes[edge] = { segs, bb, ceiling }); + }; + // how far a point is from the footprint, less than none inside it + const from = (segs, x, y) => { + let d = Infinity, inside = false; + for (const [a, b] of segs) { + const dx = b[0] - a[0], dy = b[1] - a[1]; + const t = Math.max(0, Math.min(1, ((x - a[0])*dx + (y - a[1])*dy) / (dx*dx + dy*dy))); + d = Math.min(d, Math.hypot(a[0] + t*dx - x, a[1] + t*dy - y)); + if ((a[1] > y) !== (b[1] > y) && x < a[0] + (y - a[1]) * dx / dy) inside = !inside; + } + return inside ? -d : d; + }; + for (const piece of layout.pieces) { + const conn = pieceConnectors(cfg, layout, piece); + // the cuts buildPiece makes in this piece: notches for tabs, recesses for keys + const cuts = [...conn.notches, ...conn.pnotches, ...(plan.kind !== 'recess' ? [] + : conn.keyed.filter((bo) => !(plan.junction && offJunction(bo, cfg.pitch, piece))))]; + for (const bo of cuts) { + const { segs, bb, ceiling } = shapeOf(bo.edge); + const across = bo.edge === '+x' || bo.edge === '-x'; + const ox = across ? bo.e : bo.s, oy = across ? bo.s : bo.e; + // the whole cells with a site in reach of it (a half cell has none; see buildPiece) + const cells = (lo, hi, m, n) => [Math.max(0, Math.floor((lo - reach - off - half - m) / cfg.pitch)), + Math.min(n - 1, Math.ceil((hi + reach + off - half - m) / cfg.pitch))]; + const [i0, i1] = cells(bb[0] + ox, bb[2] + ox, piece.mL, piece.nx); + const [j0, j1] = cells(bb[1] + oy, bb[3] + oy, piece.mF, piece.ny); + let room = Infinity; + for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) + for (const sx of [-1, 1]) for (const sy of [-1, 1]) { + const x = piece.mL + i*cfg.pitch + half + sx*off - ox; + const y = piece.mF + j*cfg.pitch + half + sy*off - oy; + if (x < bb[0] - reach || x > bb[2] + reach || y < bb[1] - reach || y > bb[3] + reach) continue; + room = Math.min(room, from(segs, x, y)); + } + jointCuts.push({ room, top: ceiling }); + } + } + } + // the nearest the cuts come that a pocket with its floor at z meets + const jointRoom = (z) => jointCuts.reduce((m, c) => + c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); + const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank + const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length + ? jointRoom(platePad(cfg) - cfg.magnetH) : below; + const own = fit(cfg.magnetSide === 'top' ? top : under); + const room = Math.min(own, magnetJoint); return { // a magnet pocket's corners are 0.1 mm over the magnet's radius, or out to where its // flats stand on that radius if that is further (fastenerCutter) magnetD: r10(2 * Math.min(room - 0.1, room * Math.cos(Math.PI / 14))), // a screw's bores have their corners on its size - screwHoleD: r10(2 * fit(top)), - screwHeadD: r10(2 * fit(under)), + screwHoleD: r10(2 * Math.min(fit(top), below)), + screwHeadD: r10(2 * Math.min(fit(under), below)), // in the solid floor the pad grows to suit, so only a boss caps the depth depth: bosses ? r10(BOSS_H - MOUNT_SKIN) : Infinity, // which of the sizes the cut beside it stops, rather than the floor, cell or boss - beside: { magnetD: room === beside, screwHoleD: top >= beside, screwHeadD: under >= beside }, + beside: { magnetD: room === beside, screwHoleD: top >= beside && below >= beside, + screwHeadD: under >= beside && below >= beside }, + // and which a joint's cut stops, before any of those + joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, }; } @@ -3964,7 +4103,38 @@

Your drawers

} return out; }; - const fastenerFoot = wallsAt(0), fastenerTop = pad > 0.01 ? wallsAt(pad) : []; + /* The same, its corners only. Where the walls of two bores were unioned (a counterbore, + its screw's shank), the BSP split each wall along the other's planes, and wallsAt + hands back those split points as well: two on every flat of the shank, 24 points on + the socket floor that are no corner of anything. A 2.4 mm shank under a 4.8 mm head + at 44.08 mm, with loose tolerance, had a spoke within FAN_CLEAR of one of them from + every point fanCentre tries, so the socket floor's fan never moved and the cell + shipped with six open edges. A corner is where two walls that are not in line meet; + a split point is where one wall was cut in two. From the corners alone the fan moves + 0.2 mm and the floor closes. Only the socket floor's list, which only an open cell's + refan reads (buildPiece), so every cell that came out closed is built as before. */ + const cornersAt = (z) => { + const ends = new Map(); // a wall end, to the directions of the walls that end there + for (const p of cellFastener || []) { + const zs = p.verts.map((v) => v[2]); + if (!(Math.min(...zs) < z && Math.max(...zs) > z) || Math.abs(p.plane.n[2]) > 1e-9) continue; + const d = [-p.plane.n[1], p.plane.n[0]]; // along the wall + let lo = null, hi = null; + for (const v of p.verts) { + const t = v[0]*d[0] + v[1]*d[1]; + if (!lo || t < lo[0]) lo = [t, v]; + if (!hi || t > hi[0]) hi = [t, v]; + } + for (const [, v] of [lo, hi]) { + const k = `${v[0].toFixed(6)} ${v[1].toFixed(6)}`; + if (!ends.has(k)) ends.set(k, { at: [v[0], v[1]], dirs: [] }); + ends.get(k).dirs.push(d); + } + } + return [...ends.values()].filter(({ dirs }) => + dirs.some((a) => dirs.some((b) => Math.abs(a[0]*b[1] - a[1]*b[0]) > 1e-6))).map((e) => e.at); + }; + const fastenerFoot = wallsAt(0), fastenerTop = pad > 0.01 ? cornersAt(pad) : []; // ---- connectors ---- const conn = pieceConnectors(cfg, layout, piece); @@ -4358,7 +4528,9 @@

Your drawers

* And once every cell is built, the shells settle cut again are checked as a whole, with * those beside them: if they have more bad edges (checkManifold) than they had before, * or more open or turned over (healCsgSeams), every one goes back to its first cut. So - * settle never leaves a piece worse than it found it, whatever order the cells come in. + * settle never leaves those shells worse than it found them, whatever order the cells + * come in. What is made after the check is not judged by it: the dovetail and puzzle + * tabs, and what the top-insert pass cuts again (see the check below). * `alt` and `pocket` are the cuts a cell was last taken with, so a cell cut again for * one reason keeps what it was cut again for the other. */ const POCKET_TRIES = 7; @@ -4531,22 +4703,7 @@

Your drawers

(nb.edge === '+x' ? Math.abs(x1 - W) : Math.abs(x0)) < nDp + 0.2) : (nb.s > x0 - nWt && nb.s < x1 + nWt && (nb.edge === '+y' ? Math.abs(y1 - D) : Math.abs(y0)) < nDp + 0.2); - if (near) { - // 4-pt taper: no vertex sits exactly on the region side plane; jitter breaks - // residual coincidences with ring geometry - const J = 0.0017, BK = 1.0, e = nb.e, s = nb.s + J; - let pts; - if (nb.edge === '+x' || nb.edge === '-x') { - const g = nb.edge === '-x' ? 1 : -1; // cut extends INTO the piece - pts = [[e - g*BK, s - nWr/2], [e + g*nDp, s - nWt/2], - [e + g*nDp, s + nWt/2], [e - g*BK, s + nWr/2]]; - } else { - const g = nb.edge === '-y' ? 1 : -1; - pts = [[s - nWr/2, e - g*BK], [s - nWt/2, e + g*nDp], - [s + nWt/2, e + g*nDp], [s + nWr/2, e - g*BK]]; - } - cuts.notch.push(...extrudePoly(pts, -0.503, Math.min(t.h + 0.2, H - 0.8))); - } + if (near) cuts.notch.push(...tabNotch(cfg, nb, pad)); } for (const bo of keyed) { if (plan.junction && offJunction(bo, pitch, piece)) @@ -4576,9 +4733,7 @@

Your drawers

(pn.edge === '+x' ? Math.abs(x1 - W) : Math.abs(x0)) < reach) : (pn.s > x0 - cfg.puzzle.lobeR*2 && pn.s < x1 + cfg.puzzle.lobeR*2 && (pn.edge === '+y' ? Math.abs(y1 - D) : Math.abs(y0)) < reach); - if (near) cuts.puzzle.push( - ...extrudePoly(puzzleShape(pn.edge, pn.e, pn.s, cfg.puzzle, cfg.puzzle.clr, true), - -0.5, pad - 0.4)); + if (near) cuts.puzzle.push(...tabNotch(cfg, pn, pad)); } /* None in a half cell. A half-size bin's quarter feet carry no holes (feetHolesOff in bins/bin.js), and where a half socket's would go is not settled: a whole @@ -4702,8 +4857,10 @@

Your drawers

Only here, not on every cell: a 6 mm magnet from above at 42 mm has a spoke 2.3 microns from a corner in every cell and comes out closed, as most do. And only where the fan moves and the cell is open at the floor's height: a cell open - somewhere else, as a pocket that meets a joint's housing is, or one whose spokes - are already clear, would be cut again for the same result. A bowtie plate at + somewhere else, as a pocket that meets a joint's housing is, would be cut again + for the same result, and so would one whose fan stays where it was, either because + its spokes are already clear or because fanCentre finds no point clear of every + corner and keeps the centre. A bowtie plate at 45.57 mm with screws, open in every piece on main as well, took twice as long with every open cell cut again. */ if (region.open && floorAvoid.length && openAt(region, pad)) { @@ -7211,6 +7368,8 @@

Your drawers

const numIds = ['drawerW','drawerD','bedW','bedD','bedH','mLeft','mRight','mFront','mBack', 'pitch','outerRadius','bottomPad','topCutoff','magnetD','magnetH', 'screwHoleD','screwHeadD','screwHeadDepth','infill']; +// the ones readControls reads after the rest, in this order (see there) +const MOUNT_LAST = ['magnetH', 'screwHeadDepth', 'screwHoleD', 'screwHeadD', 'magnetD']; /* The fields that carry a real-world size, and the range one can be. * @@ -7244,13 +7403,22 @@

Your drawers

* the pitch has no room for. */ const RANGES = PLATE_RANGES; const customMargins = () => state.marginMode === 'custom' && !state.noMargin; -const mount = () => mountLimits(state); +/* The sizes a joint's cut in the floor leaves room for depend on where the seams are and + on the clearance, so mountLimits takes the layout, and readControls reads the mounting + sizes after everything that moves either. One answer per size it reads, kept here + meanwhile: the layout and the cuts are measured once, not once for the range and + again for the reason. */ +let mountNow = null; +const mount = () => mountNow || (mountNow = mountLimits(state, computeLayout(state))); // "an 18 mm pitch", "an 80 mm pitch": the article goes by how the number is said const atPitch = () => `at ${/^(8|1[18](\.|$))/.test(String(state.pitch)) ? 'an' : 'a'} ` + `${state.pitch} mm pitch`; const mountWhy = (opens, field) => `${atPitch()} — mounting holes sit ` + `${state.holeOffset} mm from each cell centre, where the Gridfinity spec puts them, and ` + - (mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' + (mount().joint[field] ? `a hole has to stay out of the ` + + `${['dovetail', 'puzzle'].includes(state.connector) ? 'notches' : 'recesses'} the ` + + `${CONNECTOR_NAMES[state.connector]} fit into` + : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' : opens ? 'a cut open to the socket has to stay on the socket floor' : 'a pocket under the floor has to stay inside its cell'); @@ -7437,7 +7605,7 @@

Your drawers

state.magnets = $('magnets').checked; state.screws = $('screws').checked; state.magnetSide = $('magnetSide').value; - for (const id of numIds) state[id] = readNumber(id); + for (const id of numIds) if (!MOUNT_LAST.includes(id)) state[id] = readNumber(id); if (state.noMargin) { state.marginMode = 'custom'; state.mLeft = state.mRight = state.mFront = state.mBack = 0; } // the per-corner radii need no range here: buildPiece caps each one at the socket's rim if ($('perCorner').checked) { @@ -7457,6 +7625,21 @@

Your drawers

state.key = Object.assign({}, DEFAULTS.key, { clr: fit.key }); state.hclip = Object.assign({}, DEFAULTS.hclip, { clr: fit.hclip }); state.puzzle = Object.assign({}, DEFAULTS.puzzle, { clr: fit.puzzle }); + /* The mounting sizes last, since a joint's cut beside the sites moves with the margins, + the split and the clearance (see mount). The magnet's is the very last, and measured + again: a pocket from above meets a cut by how thick the floor is, which the screws + and the magnet's own depth set. */ + mountNow = null; + for (const id of MOUNT_LAST) { + if (id === 'magnetD') mountNow = null; + state[id] = readNumber(id); + } + // and Checks says what is wrong in the panel's order, not the order it was read in + for (const m of [fieldErrors, noRoom]) { + const read = new Map(m); + m.clear(); + for (const id of [...numIds, 'connClr']) if (read.has(id)) m.set(id, read.get(id)); + } // half cells keep the alignment: it places what is left after them $('alignRow').style.display = mm === 'auto' || mm === 'half' ? '' : 'none'; $('halfHint').style.display = mm === 'half' ? '' : 'none'; diff --git a/sw.js b/sw.js index b7bd8ec..7ed15ee 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "922acce9ef1e"; +const VERSION = "c1f1e2643be6"; const FILES = [ "./", "bins/", From 8a58aba9d1d87510c39e4bebf770c710b027f864 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 11:10:09 +0000 Subject: [PATCH 04/15] Work out the layout once a keystroke with mounting holes on With magnets or screws on, a keystroke worked out the layout three times: the depth fields' range asked mountLimits with the layout though the depth needs none, the magnet's size was read again from scratch, and recomputeLayout worked it out once more. In Fewest plates mode each one is a search of about 100 ms, so typing took 230 to 310 ms a key against 110 on main. - The depth's range is read without the layout: only a corner boss caps it. - readControls works out the layout the first time a size needs it, and recomputeLayout keeps that one: no mounting size moves it. - mountLimits hands back the joint's cuts it measured, and takes them again (`known`) for the magnet's second read, measuring again only if the floor has moved. One layout a keystroke now, as on main, and the same time to within the noise on the review's links. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- src/core.js | 21 +++++++++++++++------ src/ui.js | 28 +++++++++++++++++----------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/core.js b/src/core.js index 36e5684..b67b9a2 100644 --- a/src/core.js +++ b/src/core.js @@ -2343,8 +2343,13 @@ const MOUNT_WALL = 1.0; * These are measurements, not field ranges, and can come out below the field's minimum * or negative — a screw shank at a 34 mm pitch has −0.1 mm. That means no cut of any size * fits there; the page turns it into a check on the design rather than a range for the - * field (src/ui.js readNumber), since no number typed into the field could fix it. */ -function mountLimits(cfg, layout) { + * field (src/ui.js readNumber), since no number typed into the field could fix it. + * + * `known` is the `cuts` of an earlier answer for the same design on the same layout, + * with only the mounting sizes changed since: the joint's cuts are not measured again + * unless the floor has moved, which moves their ceilings. The page reads the magnet's + * size last and asks again for it, after the screws' sizes have settled the floor. */ +function mountLimits(cfg, layout, known) { const half = cfg.pitch / 2, off = cfg.holeOffset; const tol = cfg.tolerance === 'tight' ? +0.1 : cfg.tolerance === 'loose' ? -0.1 : 0; // distance from a point at (s, s) to the edge of a rounded square of half-size h, @@ -2401,14 +2406,16 @@ function mountLimits(cfg, layout) { cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ - const jointCuts = []; // { room, top }: the nearest a site comes to one cut, its ceiling + const pad = platePad(cfg), again = !!known && known.pad === pad; + // { room, top }: the nearest a site comes to one cut, its ceiling + const jointCuts = again ? known.list : []; /* Room past the most the cell or the floor leaves cannot stop a size, so nothing further off than that is measured, and nothing at all where neither leaves any. A plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this is a few milliseconds, on every redraw. */ const reach = Math.max(fit(top), fit(under)); - if (layout && !bosses && cfg.connector !== 'none' && reach > 0) { - const plan = keyPlan(cfg), pad = platePad(cfg), H = pad + cfg.plateHeight; + if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { + const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, for each seam it can be cut from. Every cut from one seam is the same solid moved along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once @@ -2476,7 +2483,7 @@ function mountLimits(cfg, layout) { c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length - ? jointRoom(platePad(cfg) - cfg.magnetH) : below; + ? jointRoom(pad - cfg.magnetH) : below; const own = fit(cfg.magnetSide === 'top' ? top : under); const room = Math.min(own, magnetJoint); return { @@ -2493,6 +2500,8 @@ function mountLimits(cfg, layout) { screwHeadD: under >= beside && below >= beside }, // and which a joint's cut stops, before any of those joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, + // what was measured of the joint's cuts, for `known` + cuts: { pad, list: jointCuts }, }; } diff --git a/src/ui.js b/src/ui.js index d35fe29..9b91c65 100644 --- a/src/ui.js +++ b/src/ui.js @@ -81,11 +81,16 @@ const RANGES = PLATE_RANGES; const customMargins = () => state.marginMode === 'custom' && !state.noMargin; /* The sizes a joint's cut in the floor leaves room for depend on where the seams are and on the clearance, so mountLimits takes the layout, and readControls reads the mounting - sizes after everything that moves either. One answer per size it reads, kept here - meanwhile: the layout and the cuts are measured once, not once for the range and - again for the reason. */ -let mountNow = null; -const mount = () => mountNow || (mountNow = mountLimits(state, computeLayout(state))); + sizes after everything that moves either. The layout is worked out once for a read, the + first time a size needs it, and recomputeLayout keeps that one rather than working it + out again: none of the mounting sizes moves it. In Fewest plates mode one is a search, + about 100 ms, and with magnets on a keystroke ran three. The answer is kept meanwhile, + for the range and the reason alike. */ +let mountNow = null, mountLayout = null; +const mount = () => mountNow || + (mountNow = mountLimits(state, mountLayout || (mountLayout = computeLayout(state)))); +// how deep a pocket goes: only a corner boss caps it, which needs no layout +const mountDepth = () => mountLimits(state).depth; // "an 18 mm pitch", "an 80 mm pitch": the article goes by how the number is said const atPitch = () => `at ${/^(8|1[18](\.|$))/.test(String(state.pitch)) ? 'an' : 'a'} ` + `${state.pitch} mm pitch`; @@ -125,13 +130,13 @@ const LIMITS = { why: () => '— past that a spec bin rides on the rim instead of seating in its socket' }, magnetD: { ...RANGES.magnetD, max: () => mount().magnetD, label: 'Magnet Ø', when: () => state.magnets, why: () => mountWhy(state.magnetSide === 'top', 'magnetD'), off: 'magnet pockets' }, - magnetH: { ...RANGES.magnetH, max: () => Math.min(RANGES.magnetH.max, mount().depth), label: 'Magnet depth', + magnetH: { ...RANGES.magnetH, max: () => Math.min(RANGES.magnetH.max, mountDepth()), label: 'Magnet depth', when: () => state.magnets, why: bossDepth }, screwHoleD: { ...RANGES.screwHoleD, max: () => mount().screwHoleD, label: 'Screw hole Ø', when: () => state.screws, why: () => mountWhy(true, 'screwHoleD'), off: 'screw holes' }, screwHeadD: { ...RANGES.screwHeadD, max: () => mount().screwHeadD, label: 'Screw head Ø', when: () => state.screws, why: () => mountWhy(false, 'screwHeadD'), off: 'screw holes' }, - screwHeadDepth: { ...RANGES.screwHeadDepth, max: () => Math.min(RANGES.screwHeadDepth.max, mount().depth), + screwHeadDepth: { ...RANGES.screwHeadDepth, max: () => Math.min(RANGES.screwHeadDepth.max, mountDepth()), label: 'Screw head depth', when: () => state.screws, why: bossDepth }, // each joint's ceiling is its own, so none is held to another's reason; see clrWhy connClr: { min: RANGES.connClr.min, max: () => connClrCeiling(state).max, label: 'Fit clearance', @@ -304,10 +309,11 @@ function readControls() { /* The mounting sizes last, since a joint's cut beside the sites moves with the margins, the split and the clearance (see mount). The magnet's is the very last, and measured again: a pocket from above meets a cut by how thick the floor is, which the screws - and the magnet's own depth set. */ - mountNow = null; + and the magnet's own depth set. Only that step is taken again, on the same layout + and the cuts already measured, unless the floor has moved (mountLimits' `known`). */ + mountNow = mountLayout = null; for (const id of MOUNT_LAST) { - if (id === 'magnetD') mountNow = null; + if (id === 'magnetD' && mountNow) mountNow = mountLimits(state, mountLayout, mountNow.cuts); state[id] = readNumber(id); } // and Checks says what is wrong in the panel's order, not the order it was read in @@ -382,7 +388,7 @@ function plateStyleHint() { nothing, and each of those is a discrete edit. */ function recomputeLayout(ev) { readControls(); - layout = computeLayout(state); + layout = mountLayout || computeLayout(state); // the one the sizes were read against, if any // clamp stored manual cuts to the current grid if (state.splitMode === 'manual') { state.rowCuts = layout.rowCuts.slice(); From 33e1a04aa6289f8a3f1e8a0eae602563277b28bf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 11:10:13 +0000 Subject: [PATCH 05/15] Say what keeping a pocket out of a joint's cut does and does not show The comments and ENGINE.md overstated it. A pocket that breaks into a cut does not mean the magnet or screw in it reaches the key or the tab: the pocket is measured by the circle through its corners, and the part stands the fit clearance inside the cut (a 12.7 mm magnet at 42 mm is about 0.24 mm clear of a dovetail's tab). Only level ceilings went bad in the 768-pocket sample, but a sliver into a cut has gone bad at other depths too. And stopping short of a cut is a sample, not a promise: a counterbore 0.05 mm clear of a dovetail's notch at 43.17 mm turns a face over, byte for byte as main does, the joint cut's own lottery. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 23 ++++++++++++++++------- src/core.js | 20 +++++++++++++++----- test/plate-audit.js | 15 ++++++++------- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index 0b03935..355682f 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -754,21 +754,30 @@ currently installed): - **A pocket that reaches a joint's cut goes bad where the two ceilings are level.** A key's recess, an H-clip's and a tab's notch are all cut up from under the plate, as a magnet pocket from beneath and a counterbore are. Run into one, the pocket comes out - closed at any depth but one: the recess's 2 mm (a 2 mm magnet, the default counterbore) + closed at nearly any depth but one: the recess's 2 mm (a 2 mm magnet, the default counterbore) or the notch's 2.4 (the spec's 6.5 × 2.4 magnet), where the two ceilings share a face that two subtractions each split their own way. A bowtie in the floor at 42 mm left 12 edges open at 7.9 mm and 19 at 10; puzzle tabs at 36 to 40 mm left 26 to 86 with the spec's magnet. Over 768 such pockets 0.1 to 1.25 mm into a key's recess, magnets from beneath and screw heads, four keys at four pitches, the 96 level with it went bad 74 - times, and the 672 at seven other depths, as near as 0.01 mm either side, never. It is - not mended, it is refused: the pocket has broken into the space the key or the other - piece's tab fills, and a magnet there would sit against it. + times, and the 672 at seven other depths, as near as 0.01 mm either side, never. Not + never anywhere: a pocket only a sliver into a cut can go bad at another depth, as one + 0.019 mm into a snap key's recess at 36.52 mm did on main at four depths. It is not + mended, it is refused, any pocket that breaks into the cut at all. That is safe rather + than exact. The pocket is measured by the circle through its corners, and the key or + the other piece's tab stands the fit clearance inside the cut, so a pocket can break in + with the magnet or screw in it still clear of the part: a 12.7 mm magnet at 42 mm is + about 0.24 mm clear of a dovetail's tab, its pocket 0.09 mm into the notch. `mountLimits` measures every mounting site of a whole cell against each cut on the layout and holds every size to the room, with no wall: of 10,882 designs over seven keyed joints, 71 pitches and five cuts, none that stopped short of the cut built a bad edge, - and the first went bad 0.035 mm into it. A pocket from above meets a cut unless its - floor stands a layer over the cut's ceiling. The housings a key is dropped into from - above start 1.3 mm over the socket floor and nothing reaches them, and a pocket in a + and the first went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm + counterbore 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, turns + a face over at the notch's corner, byte for byte as main does, and builds clean at + 43.16 and 43.18 mm; that is the joint cut's own lottery (the next item), not the + pocket's. A pocket from above meets a cut unless its floor stands a layer over the + cut's ceiling. The housings a key is dropped into from above start 1.3 mm over the + socket floor and nothing reaches them, and a pocket in a corner boss is left out: the boss is a shell of its own, and no joint is cut from it. - **A joint's cut is the same lottery, and below 16 mm it comes up often.** The socket's straight walls run only 2.5 mm either side of a cell's middle at 13.5 mm, so every diff --git a/src/core.js b/src/core.js index b67b9a2..9b80cc8 100644 --- a/src/core.js +++ b/src/core.js @@ -2397,15 +2397,25 @@ function mountLimits(cfg, layout, known) { 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a key's recess, the 96 level with it went bad 74 times and the 672 at seven other - depths never, as near as 0.01 mm either side. So it is the pocket breaking in that - is refused here, not the depth that shows it: the magnet and the key, or the shank - and the other piece's tab, would want the same place. + depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver + into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap + key's recess at 36.52 mm, bad at four depths on main). So any pocket breaking in is + refused here, not only the depth that shows it. That is safe, and more than the + parts need: the pocket is measured by the circle through its corners, and it can + break into the cut with the magnet or screw in it still clear of the key or the tab, + which stand the fit clearance inside the cut. A 12.7 mm magnet at 42 mm is clear of + a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the notch. No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first - went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath - with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ + went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore + 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, folds a face + over at the notch's corner and uses an edge four times, on main as here, byte for + byte, and not at 43.16 or 43.18 mm, 14 mm across or 2.35 deep. That is the joint + cut's own lottery (see cutAgain in buildPiece), not the pocket's. A wall of 1 mm + would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm + to spare and always built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; // { room, top }: the nearest a site comes to one cut, its ceiling const jointCuts = again ? known.list : []; diff --git a/test/plate-audit.js b/test/plate-audit.js index 18eb9bb..06dc266 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -2006,13 +2006,14 @@ console.log('\nthe other limits, built at their ends:'); has to come out watertight, and the first tenth past it, and a size main took that reaches the cut (the first that leaked, where one did), have to be refused. Two pieces side by side, so the seam between them is cut. The bands are #61's, where its - wider pocket brought the leak 0.1 to 0.4 mm lower. From above, an 8 mm magnet meets - the recess under it without a bad edge, and would sit on the key; in the wall, main's - widest leaked. The 38.13 mm link is the one #61 left for later: its - 6.5 mm counterbore stood 0.7 mm into a puzzle key's recess. The last two are the - spec's 6.5 × 2.4 magnet beside a tab, whose notch stops 2.4 mm up as well. And the - same bowtie in four pieces with strips of half cells and margins round them, whose - whole cells are the ones measured. */ + wider pocket brought the leak 0.1 to 0.4 mm lower. From above, an 8 mm magnet's + pocket breaks into the recess under it without a bad edge, the magnet itself about + 0.13 mm clear of the key: refused all the same, as every pocket that breaks into a + cut is (see mountLimits). In the wall, main's widest leaked. The 38.13 mm link is + the one #61 left for later: its 6.5 mm counterbore stood 0.7 mm into a puzzle key's + recess. The last two are the spec's 6.5 × 2.4 magnet beside a tab, whose notch stops + 2.4 mm up as well. And the same bowtie in four pieces with strips of half cells and + margins round them, whose whole cells are the ones measured. */ const pair = (p, o) => ({ pitch: p, drawerW: 4 * p, drawerD: 2 * p, bedW: 2 * p + 16, bedD: 400, ...o }); const JOINTED = [ // [what, design, field, a size main took into the cut] ['bowtie, magnet below, 42', pair(42, { connector: 'bowtie', magnets: true }), 'magnetD', 7.9], From df717e16ad599498de4fe8ec24e8e3e6802d34ab Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 11:10:23 +0000 Subject: [PATCH 06/15] Rebuild the pages Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- bins/index.html | 41 +++++++++++++++++++++-------- index.html | 69 +++++++++++++++++++++++++++++++++---------------- sw.js | 2 +- 3 files changed, 78 insertions(+), 34 deletions(-) diff --git a/bins/index.html b/bins/index.html index bd1f1ec..c7eec00 100644 --- a/bins/index.html +++ b/bins/index.html @@ -3949,8 +3949,13 @@

Your drawers

* These are measurements, not field ranges, and can come out below the field's minimum * or negative — a screw shank at a 34 mm pitch has −0.1 mm. That means no cut of any size * fits there; the page turns it into a check on the design rather than a range for the - * field (src/ui.js readNumber), since no number typed into the field could fix it. */ -function mountLimits(cfg, layout) { + * field (src/ui.js readNumber), since no number typed into the field could fix it. + * + * `known` is the `cuts` of an earlier answer for the same design on the same layout, + * with only the mounting sizes changed since: the joint's cuts are not measured again + * unless the floor has moved, which moves their ceilings. The page reads the magnet's + * size last and asks again for it, after the screws' sizes have settled the floor. */ +function mountLimits(cfg, layout, known) { const half = cfg.pitch / 2, off = cfg.holeOffset; const tol = cfg.tolerance === 'tight' ? +0.1 : cfg.tolerance === 'loose' ? -0.1 : 0; // distance from a point at (s, s) to the edge of a rounded square of half-size h, @@ -3998,23 +4003,35 @@

Your drawers

2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a key's recess, the 96 level with it went bad 74 times and the 672 at seven other - depths never, as near as 0.01 mm either side. So it is the pocket breaking in that - is refused here, not the depth that shows it: the magnet and the key, or the shank - and the other piece's tab, would want the same place. + depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver + into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap + key's recess at 36.52 mm, bad at four depths on main). So any pocket breaking in is + refused here, not only the depth that shows it. That is safe, and more than the + parts need: the pocket is measured by the circle through its corners, and it can + break into the cut with the magnet or screw in it still clear of the key or the tab, + which stand the fit clearance inside the cut. A 12.7 mm magnet at 42 mm is clear of + a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the notch. No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first - went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath - with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ - const jointCuts = []; // { room, top }: the nearest a site comes to one cut, its ceiling + went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore + 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, folds a face + over at the notch's corner and uses an edge four times, on main as here, byte for + byte, and not at 43.16 or 43.18 mm, 14 mm across or 2.35 deep. That is the joint + cut's own lottery (see cutAgain in buildPiece), not the pocket's. A wall of 1 mm + would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm + to spare and always built clean. */ + const pad = platePad(cfg), again = !!known && known.pad === pad; + // { room, top }: the nearest a site comes to one cut, its ceiling + const jointCuts = again ? known.list : []; /* Room past the most the cell or the floor leaves cannot stop a size, so nothing further off than that is measured, and nothing at all where neither leaves any. A plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this is a few milliseconds, on every redraw. */ const reach = Math.max(fit(top), fit(under)); - if (layout && !bosses && cfg.connector !== 'none' && reach > 0) { - const plan = keyPlan(cfg), pad = platePad(cfg), H = pad + cfg.plateHeight; + if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { + const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, for each seam it can be cut from. Every cut from one seam is the same solid moved along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once @@ -4082,7 +4099,7 @@

Your drawers

c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length - ? jointRoom(platePad(cfg) - cfg.magnetH) : below; + ? jointRoom(pad - cfg.magnetH) : below; const own = fit(cfg.magnetSide === 'top' ? top : under); const room = Math.min(own, magnetJoint); return { @@ -4099,6 +4116,8 @@

Your drawers

screwHeadD: under >= beside && below >= beside }, // and which a joint's cut stops, before any of those joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, + // what was measured of the joint's cuts, for `known` + cuts: { pad, list: jointCuts }, }; } diff --git a/index.html b/index.html index 5a940b7..de00ebe 100644 --- a/index.html +++ b/index.html @@ -3736,8 +3736,13 @@

Your drawers

* These are measurements, not field ranges, and can come out below the field's minimum * or negative — a screw shank at a 34 mm pitch has −0.1 mm. That means no cut of any size * fits there; the page turns it into a check on the design rather than a range for the - * field (src/ui.js readNumber), since no number typed into the field could fix it. */ -function mountLimits(cfg, layout) { + * field (src/ui.js readNumber), since no number typed into the field could fix it. + * + * `known` is the `cuts` of an earlier answer for the same design on the same layout, + * with only the mounting sizes changed since: the joint's cuts are not measured again + * unless the floor has moved, which moves their ceilings. The page reads the magnet's + * size last and asks again for it, after the screws' sizes have settled the floor. */ +function mountLimits(cfg, layout, known) { const half = cfg.pitch / 2, off = cfg.holeOffset; const tol = cfg.tolerance === 'tight' ? +0.1 : cfg.tolerance === 'loose' ? -0.1 : 0; // distance from a point at (s, s) to the edge of a rounded square of half-size h, @@ -3785,23 +3790,35 @@

Your drawers

2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a key's recess, the 96 level with it went bad 74 times and the 672 at seven other - depths never, as near as 0.01 mm either side. So it is the pocket breaking in that - is refused here, not the depth that shows it: the magnet and the key, or the shank - and the other piece's tab, would want the same place. + depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver + into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap + key's recess at 36.52 mm, bad at four depths on main). So any pocket breaking in is + refused here, not only the depth that shows it. That is safe, and more than the + parts need: the pocket is measured by the circle through its corners, and it can + break into the cut with the magnet or screw in it still clear of the key or the tab, + which stand the fit clearance inside the cut. A 12.7 mm magnet at 42 mm is clear of + a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the notch. No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first - went bad 0.035 mm into it. A wall of 1 mm would refuse the 6 mm magnet from beneath - with a bowtie at 42 mm, which has 0.84 mm to spare and always built clean. */ - const jointCuts = []; // { room, top }: the nearest a site comes to one cut, its ceiling + went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore + 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, folds a face + over at the notch's corner and uses an edge four times, on main as here, byte for + byte, and not at 43.16 or 43.18 mm, 14 mm across or 2.35 deep. That is the joint + cut's own lottery (see cutAgain in buildPiece), not the pocket's. A wall of 1 mm + would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm + to spare and always built clean. */ + const pad = platePad(cfg), again = !!known && known.pad === pad; + // { room, top }: the nearest a site comes to one cut, its ceiling + const jointCuts = again ? known.list : []; /* Room past the most the cell or the floor leaves cannot stop a size, so nothing further off than that is measured, and nothing at all where neither leaves any. A plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this is a few milliseconds, on every redraw. */ const reach = Math.max(fit(top), fit(under)); - if (layout && !bosses && cfg.connector !== 'none' && reach > 0) { - const plan = keyPlan(cfg), pad = platePad(cfg), H = pad + cfg.plateHeight; + if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { + const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, for each seam it can be cut from. Every cut from one seam is the same solid moved along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once @@ -3869,7 +3886,7 @@

Your drawers

c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length - ? jointRoom(platePad(cfg) - cfg.magnetH) : below; + ? jointRoom(pad - cfg.magnetH) : below; const own = fit(cfg.magnetSide === 'top' ? top : under); const room = Math.min(own, magnetJoint); return { @@ -3886,6 +3903,8 @@

Your drawers

screwHeadD: under >= beside && below >= beside }, // and which a joint's cut stops, before any of those joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, + // what was measured of the joint's cuts, for `known` + cuts: { pad, list: jointCuts }, }; } @@ -7405,11 +7424,16 @@

Your drawers

const customMargins = () => state.marginMode === 'custom' && !state.noMargin; /* The sizes a joint's cut in the floor leaves room for depend on where the seams are and on the clearance, so mountLimits takes the layout, and readControls reads the mounting - sizes after everything that moves either. One answer per size it reads, kept here - meanwhile: the layout and the cuts are measured once, not once for the range and - again for the reason. */ -let mountNow = null; -const mount = () => mountNow || (mountNow = mountLimits(state, computeLayout(state))); + sizes after everything that moves either. The layout is worked out once for a read, the + first time a size needs it, and recomputeLayout keeps that one rather than working it + out again: none of the mounting sizes moves it. In Fewest plates mode one is a search, + about 100 ms, and with magnets on a keystroke ran three. The answer is kept meanwhile, + for the range and the reason alike. */ +let mountNow = null, mountLayout = null; +const mount = () => mountNow || + (mountNow = mountLimits(state, mountLayout || (mountLayout = computeLayout(state)))); +// how deep a pocket goes: only a corner boss caps it, which needs no layout +const mountDepth = () => mountLimits(state).depth; // "an 18 mm pitch", "an 80 mm pitch": the article goes by how the number is said const atPitch = () => `at ${/^(8|1[18](\.|$))/.test(String(state.pitch)) ? 'an' : 'a'} ` + `${state.pitch} mm pitch`; @@ -7449,13 +7473,13 @@

Your drawers

why: () => '— past that a spec bin rides on the rim instead of seating in its socket' }, magnetD: { ...RANGES.magnetD, max: () => mount().magnetD, label: 'Magnet Ø', when: () => state.magnets, why: () => mountWhy(state.magnetSide === 'top', 'magnetD'), off: 'magnet pockets' }, - magnetH: { ...RANGES.magnetH, max: () => Math.min(RANGES.magnetH.max, mount().depth), label: 'Magnet depth', + magnetH: { ...RANGES.magnetH, max: () => Math.min(RANGES.magnetH.max, mountDepth()), label: 'Magnet depth', when: () => state.magnets, why: bossDepth }, screwHoleD: { ...RANGES.screwHoleD, max: () => mount().screwHoleD, label: 'Screw hole Ø', when: () => state.screws, why: () => mountWhy(true, 'screwHoleD'), off: 'screw holes' }, screwHeadD: { ...RANGES.screwHeadD, max: () => mount().screwHeadD, label: 'Screw head Ø', when: () => state.screws, why: () => mountWhy(false, 'screwHeadD'), off: 'screw holes' }, - screwHeadDepth: { ...RANGES.screwHeadDepth, max: () => Math.min(RANGES.screwHeadDepth.max, mount().depth), + screwHeadDepth: { ...RANGES.screwHeadDepth, max: () => Math.min(RANGES.screwHeadDepth.max, mountDepth()), label: 'Screw head depth', when: () => state.screws, why: bossDepth }, // each joint's ceiling is its own, so none is held to another's reason; see clrWhy connClr: { min: RANGES.connClr.min, max: () => connClrCeiling(state).max, label: 'Fit clearance', @@ -7628,10 +7652,11 @@

Your drawers

/* The mounting sizes last, since a joint's cut beside the sites moves with the margins, the split and the clearance (see mount). The magnet's is the very last, and measured again: a pocket from above meets a cut by how thick the floor is, which the screws - and the magnet's own depth set. */ - mountNow = null; + and the magnet's own depth set. Only that step is taken again, on the same layout + and the cuts already measured, unless the floor has moved (mountLimits' `known`). */ + mountNow = mountLayout = null; for (const id of MOUNT_LAST) { - if (id === 'magnetD') mountNow = null; + if (id === 'magnetD' && mountNow) mountNow = mountLimits(state, mountLayout, mountNow.cuts); state[id] = readNumber(id); } // and Checks says what is wrong in the panel's order, not the order it was read in @@ -7706,7 +7731,7 @@

Your drawers

nothing, and each of those is a discrete edit. */ function recomputeLayout(ev) { readControls(); - layout = computeLayout(state); + layout = mountLayout || computeLayout(state); // the one the sizes were read against, if any // clamp stored manual cuts to the current grid if (state.splitMode === 'manual') { state.rowCuts = layout.rowCuts.slice(); diff --git a/sw.js b/sw.js index f8de4e4..7760232 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "b5c5d0581967"; +const VERSION = "ba36e330ceb8"; const FILES = [ "./", "bins/", From a54982f4d54d6d4e7e5997c15a9cb46729c258f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 12:33:14 +0000 Subject: [PATCH 07/15] Say the 43.17 mm counterbore's folded edge needs the pocket and the notch together It is bad from 2.4 to 3 mm deep and clean at 2.35, 14 mm across and with no counterbore, so it is not the joint cut's lottery alone. The snap sliver is cited with the 0.5 mm fit clearance it needs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 28 +++++++++++++++------------- src/core.js | 25 +++++++++++++------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index 355682f..e9c1fb8 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -762,23 +762,25 @@ currently installed): beneath and screw heads, four keys at four pitches, the 96 level with it went bad 74 times, and the 672 at seven other depths, as near as 0.01 mm either side, never. Not never anywhere: a pocket only a sliver into a cut can go bad at another depth, as one - 0.019 mm into a snap key's recess at 36.52 mm did on main at four depths. It is not - mended, it is refused, any pocket that breaks into the cut at all. That is safe rather - than exact. The pocket is measured by the circle through its corners, and the key or - the other piece's tab stands the fit clearance inside the cut, so a pocket can break in - with the magnet or screw in it still clear of the part: a 12.7 mm magnet at 42 mm is - about 0.24 mm clear of a dovetail's tab, its pocket 0.09 mm into the notch. + 0.019 mm into a snap key's recess at 36.52 mm, with a 0.5 mm fit clearance, did on main + at four depths. It is not mended, it is refused, any pocket that breaks into the cut at + all. That is safe rather than exact. The pocket is measured by the circle through its + corners, and the key or the other piece's tab stands the fit clearance inside the cut, + so a pocket can break in with the magnet or screw in it still clear of the part: a + 12.7 mm magnet at 42 mm is about 0.24 mm clear of a dovetail's tab, its pocket 0.09 mm + into the notch. `mountLimits` measures every mounting site of a whole cell against each cut on the layout and holds every size to the room, with no wall: of 10,882 designs over seven keyed joints, 71 pitches and five cuts, none that stopped short of the cut built a bad edge, and the first went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm - counterbore 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, turns - a face over at the notch's corner, byte for byte as main does, and builds clean at - 43.16 and 43.18 mm; that is the joint cut's own lottery (the next item), not the - pocket's. A pocket from above meets a cut unless its floor stands a layer over the - cut's ceiling. The housings a key is dropped into from above start 1.3 mm over the - socket floor and nothing reaches them, and a pocket in a - corner boss is left out: the boss is a shell of its own, and no joint is cut from it. + counterbore 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, + folds an edge at the notch's corner, byte for byte as main does, and builds clean at + 2.35 mm deep, 14 mm across and with no counterbore: the pocket and the notch together, + a lottery the room measured here does not see. A pocket from above meets a cut unless + its floor stands a layer over the cut's ceiling. The housings a key is dropped into + from above start 1.3 mm over the socket floor and nothing reaches them, and a pocket + in a corner boss is left out: the boss is a shell of its own, and no joint is cut from + it. - **A joint's cut is the same lottery, and below 16 mm it comes up often.** The socket's straight walls run only 2.5 mm either side of a cell's middle at 13.5 mm, so every housing, notch and clip pocket crosses its corner arcs and cones, at points that move diff --git a/src/core.js b/src/core.js index 9b80cc8..76aea83 100644 --- a/src/core.js +++ b/src/core.js @@ -2399,23 +2399,24 @@ function mountLimits(cfg, layout, known) { key's recess, the 96 level with it went bad 74 times and the 672 at seven other depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap - key's recess at 36.52 mm, bad at four depths on main). So any pocket breaking in is - refused here, not only the depth that shows it. That is safe, and more than the - parts need: the pocket is measured by the circle through its corners, and it can - break into the cut with the magnet or screw in it still clear of the key or the tab, - which stand the fit clearance inside the cut. A 12.7 mm magnet at 42 mm is clear of - a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the notch. + key's recess at 36.52 mm with a 0.5 mm fit clearance, bad at four depths on main). So + any pocket breaking in is refused here, not only the depth that shows it. That is + safe, and more than the parts need: the pocket is measured by the circle through its + corners, and it can break into the cut with the magnet or screw in it still clear of + the key or the tab, which stand the fit clearance inside the cut. A 12.7 mm magnet at + 42 mm is clear of a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the + notch. No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore - 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, folds a face - over at the notch's corner and uses an edge four times, on main as here, byte for - byte, and not at 43.16 or 43.18 mm, 14 mm across or 2.35 deep. That is the joint - cut's own lottery (see cutAgain in buildPiece), not the pocket's. A wall of 1 mm - would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm - to spare and always built clean. */ + 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, folds an + edge at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, + 14 mm across and with no counterbore. That is the pocket and the notch together, a + lottery the room measured here does not see. A wall of 1 mm would refuse the 6 mm + magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always + built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; // { room, top }: the nearest a site comes to one cut, its ceiling const jointCuts = again ? known.list : []; From b53ce5c1f0f2868b3fed6878b376b7eb771e0e66 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 12:33:14 +0000 Subject: [PATCH 08/15] Rebuild the pages Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- bins/index.html | 25 +++++++++++++------------ index.html | 25 +++++++++++++------------ sw.js | 2 +- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/bins/index.html b/bins/index.html index c7eec00..28162cc 100644 --- a/bins/index.html +++ b/bins/index.html @@ -4005,23 +4005,24 @@

Your drawers

key's recess, the 96 level with it went bad 74 times and the 672 at seven other depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap - key's recess at 36.52 mm, bad at four depths on main). So any pocket breaking in is - refused here, not only the depth that shows it. That is safe, and more than the - parts need: the pocket is measured by the circle through its corners, and it can - break into the cut with the magnet or screw in it still clear of the key or the tab, - which stand the fit clearance inside the cut. A 12.7 mm magnet at 42 mm is clear of - a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the notch. + key's recess at 36.52 mm with a 0.5 mm fit clearance, bad at four depths on main). So + any pocket breaking in is refused here, not only the depth that shows it. That is + safe, and more than the parts need: the pocket is measured by the circle through its + corners, and it can break into the cut with the magnet or screw in it still clear of + the key or the tab, which stand the fit clearance inside the cut. A 12.7 mm magnet at + 42 mm is clear of a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the + notch. No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore - 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, folds a face - over at the notch's corner and uses an edge four times, on main as here, byte for - byte, and not at 43.16 or 43.18 mm, 14 mm across or 2.35 deep. That is the joint - cut's own lottery (see cutAgain in buildPiece), not the pocket's. A wall of 1 mm - would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm - to spare and always built clean. */ + 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, folds an + edge at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, + 14 mm across and with no counterbore. That is the pocket and the notch together, a + lottery the room measured here does not see. A wall of 1 mm would refuse the 6 mm + magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always + built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; // { room, top }: the nearest a site comes to one cut, its ceiling const jointCuts = again ? known.list : []; diff --git a/index.html b/index.html index de00ebe..99891aa 100644 --- a/index.html +++ b/index.html @@ -3792,23 +3792,24 @@

Your drawers

key's recess, the 96 level with it went bad 74 times and the 672 at seven other depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap - key's recess at 36.52 mm, bad at four depths on main). So any pocket breaking in is - refused here, not only the depth that shows it. That is safe, and more than the - parts need: the pocket is measured by the circle through its corners, and it can - break into the cut with the magnet or screw in it still clear of the key or the tab, - which stand the fit clearance inside the cut. A 12.7 mm magnet at 42 mm is clear of - a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the notch. + key's recess at 36.52 mm with a 0.5 mm fit clearance, bad at four depths on main). So + any pocket breaking in is refused here, not only the depth that shows it. That is + safe, and more than the parts need: the pocket is measured by the circle through its + corners, and it can break into the cut with the magnet or screw in it still clear of + the key or the tab, which stand the fit clearance inside the cut. A 12.7 mm magnet at + 42 mm is clear of a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the + notch. No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore - 2.4 mm deep, 0.05 mm clear of a dovetail's notch at 43.17 mm, loose, folds a face - over at the notch's corner and uses an edge four times, on main as here, byte for - byte, and not at 43.16 or 43.18 mm, 14 mm across or 2.35 deep. That is the joint - cut's own lottery (see cutAgain in buildPiece), not the pocket's. A wall of 1 mm - would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm - to spare and always built clean. */ + 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, folds an + edge at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, + 14 mm across and with no counterbore. That is the pocket and the notch together, a + lottery the room measured here does not see. A wall of 1 mm would refuse the 6 mm + magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always + built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; // { room, top }: the nearest a site comes to one cut, its ceiling const jointCuts = again ? known.list : []; diff --git a/sw.js b/sw.js index 7760232..5b5794f 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "ba36e330ceb8"; +const VERSION = "1fc8f295e0d4"; const FILES = [ "./", "bins/", From 56dabea2e1c3eaa500dc396e6721daa9f5c8dc05 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 13:08:46 +0000 Subject: [PATCH 09/15] Let a pocket into a dovetail's notch while the magnet clears the tab The review's option (c), measured before it was built. A dovetail's notch now takes a magnet pocket or counterbore from beneath that breaks into it, unless the pocket is as deep as the notch (within 0.05 mm, where every level pocket tried went bad) or the magnet or screw itself would reach the other piece's tab. So the half-inch magnet on the default dovetail at 42 mm is taken 2 and 3 mm thick (cap 13.1, was 12.3), and refused 2.4 mm thick, level with the notch, where it builds 96 bad edges. Keys, H-clips and puzzle tabs keep refusing any pocket that breaks in. The same middle rule let 7 of 2,519 such pockets at the default fit or tighter go bad (0.02 to 0.14 mm in) and 8 of 1,151 at looser fits; none of 3,699 dovetail designs into the notch did. Every cut is now measured by the pocket's own polygon (boreReach), not the circle through its corners, and a pocket that stops short of a cut stops 0.01 mm short (MOUNT_SEAM): within the weld's reach a thin wall is welded through, and 4 of 715 pockets less than 0.005 mm short went bad, none of 1,941 from 0.005 to 0.03. Under a dovetail's notch that leaves a few hundredths of refused sizes below the cap (`gaps`); the field says so. Checks says which refusal it is: as deep as the notch, the magnet touching the tabs, too near the notch's edge, or a hole in a key's recess, where it adds that keys put in from above leave the floor clear. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 55 +++++++------ src/core.js | 219 ++++++++++++++++++++++++++++++++++++++----------- src/ui.js | 56 ++++++++++--- 3 files changed, 245 insertions(+), 85 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index e9c1fb8..0617c38 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -758,29 +758,38 @@ currently installed): or the notch's 2.4 (the spec's 6.5 × 2.4 magnet), where the two ceilings share a face that two subtractions each split their own way. A bowtie in the floor at 42 mm left 12 edges open at 7.9 mm and 19 at 10; puzzle tabs at 36 to 40 mm left 26 to 86 with the - spec's magnet. Over 768 such pockets 0.1 to 1.25 mm into a key's recess, magnets from - beneath and screw heads, four keys at four pitches, the 96 level with it went bad 74 - times, and the 672 at seven other depths, as near as 0.01 mm either side, never. Not - never anywhere: a pocket only a sliver into a cut can go bad at another depth, as one - 0.019 mm into a snap key's recess at 36.52 mm, with a 0.5 mm fit clearance, did on main - at four depths. It is not mended, it is refused, any pocket that breaks into the cut at - all. That is safe rather than exact. The pocket is measured by the circle through its - corners, and the key or the other piece's tab stands the fit clearance inside the cut, - so a pocket can break in with the magnet or screw in it still clear of the part: a - 12.7 mm magnet at 42 mm is about 0.24 mm clear of a dovetail's tab, its pocket 0.09 mm - into the notch. - `mountLimits` measures every mounting site of a whole cell against each cut on the - layout and holds every size to the room, with no wall: of 10,882 designs over seven keyed - joints, 71 pitches and five cuts, none that stopped short of the cut built a bad edge, - and the first went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm - counterbore 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, - folds an edge at the notch's corner, byte for byte as main does, and builds clean at - 2.35 mm deep, 14 mm across and with no counterbore: the pocket and the notch together, - a lottery the room measured here does not see. A pocket from above meets a cut unless - its floor stands a layer over the cut's ceiling. The housings a key is dropped into - from above start 1.3 mm over the socket floor and nothing reaches them, and a pocket - in a corner boss is left out: the boss is a shell of its own, and no joint is cut from - it. + spec's magnet. All 86 pockets tried level with a cut went bad; 0.001 mm off it, 3 did, + and 0.003 mm or more off it, none. Off the level it depends on the cut, and `mountLimits` + measures every mounting site of a whole cell against each cut on the layout, by the + pocket's own polygon (`boreReach`), not the circle through its corners: + - **A key's recess, an H-clip's or a puzzle tab's notch takes no pocket.** A sliver in + can go bad off the level too: 0.019 mm into a snap key's recess at 36.52 mm, with a + 0.5 mm fit clearance, on main at four depths. Let in wherever the magnet or screw stays + clear of the key or tab, 7 of 2,519 such pockets at the default fit or tighter went bad + (0.02 to 0.14 mm in), and 8 of 1,151 at looser fits (0.2 to 0.65 mm in). + - **A dovetail's notch takes a pocket from beneath**, a sliver or deep, unless it is + level with the notch or the magnet or screw in it would reach the other piece's tab, + which stands the fit clearance inside the notch. None of 3,699 such designs went bad, + 1,086 of them on the page's design at 40.5 to 44.5 mm. A 12.7 mm magnet at 42 mm, 2 or + 3 mm thick, is taken: its pocket is 0.04 to 0.09 mm into the notch and the magnet + 0.24 mm clear of the tab. 2.4 mm thick it is level, built 96 bad edges, and is refused. + - **A pocket from above** meets any of them unless its floor stands a layer over the + cut's ceiling. The housings a key is dropped into from above start 1.3 mm over the + socket floor and nothing reaches them, and a pocket in a corner boss is left out: the + boss is a shell of its own, and no joint is cut from it. + + A pocket that stops short of a cut stops 0.01 mm short (`MOUNT_SEAM`): the weld in + `healCsgSeams` takes points `VTOL` apart for one, and a thinner wall can come out welded + through. 4 of 715 pockets less than 0.005 mm short went bad, and none of 1,941 from 0.005 + to 0.03 mm. Under a dovetail's notch that leaves a few hundredths of a millimetre of + refused sizes below the largest, between the pocket that stops 0.01 mm short and the one + that breaks in; the page says so at the field. Past the weld's reach there is still the + lottery the room cannot see, about one design in a thousand, single sizes with clean + ones on either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch + at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as main does, and + is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there into + the notch, and with no counterbore. A guard out that far would refuse sizes that build + clean on both sides of it and still miss the next, 0.1 mm off. - **A joint's cut is the same lottery, and below 16 mm it comes up often.** The socket's straight walls run only 2.5 mm either side of a cell's middle at 13.5 mm, so every housing, notch and clip pocket crosses its corner arcs and cones, at points that move diff --git a/src/core.js b/src/core.js index 76aea83..ff4c2c1 100644 --- a/src/core.js +++ b/src/core.js @@ -2322,6 +2322,43 @@ function platePad(cfg) { facets graze the floor's own triangulation — screws at a 36 mm pitch leaked 192 edges with 0.65 mm to spare. */ const MOUNT_WALL = 1.0; +/* How near a pocket's ceiling may come to a dovetail notch's before the two count as + level, and how near its walls may come to any joint's cut without breaking into it. + See mountLimits. */ +const MOUNT_LEVEL = 0.05, MOUNT_SEAM = 0.01; +/* How far a mounting bore about (x, y) can grow before it meets any of `segs`, as the + radius of the circle through its corners: the polygon cylinder() cuts, `sides` flats + with a corner at every 2πk/sides from +x. A point is in that polygon when it stands no + further out along any flat's normal than R cos(π/sides), so along one segment the + least R that takes a point of it in is at an end, or where the segment crosses the + line out through a corner, on which a point's R is its distance. */ +function boreReach(sides, segs, x, y) { + const step = 2 * Math.PI / sides, h = Math.cos(step / 2); + const cx = [], cy = [], nx = [], ny = []; + for (let k = 0; k < sides; k++) { + cx.push(Math.cos(k * step)); cy.push(Math.sin(k * step)); + nx.push(Math.cos((k + 0.5) * step)); ny.push(Math.sin((k + 0.5) * step)); + } + const at = (dx, dy) => { + let m = -Infinity; + for (let k = 0; k < sides; k++) m = Math.max(m, dx * nx[k] + dy * ny[k]); + return m / h; + }; + let r = Infinity; + for (const [a, b] of segs) { + const ax = a[0] - x, ay = a[1] - y, ex = b[0] - a[0], ey = b[1] - a[1]; + r = Math.min(r, at(ax, ay), at(ax + ex, ay + ey)); + for (let k = 0; k < sides; k++) { + const den = ex * cy[k] - ey * cx[k]; + if (Math.abs(den) < 1e-12) continue; + const t = (ay * cx[k] - ax * cy[k]) / den; + if (t < 0 || t > 1) continue; + const s = (ax + t * ex) * cx[k] + (ay + t * ey) * cy[k]; + if (s >= 0) r = Math.min(r, s); + } + } + return r; +} /* The largest mounting cuts this configuration has room for, as diameters and depths in the units the page's fields use. Magnets and screws sit holeOffset (13 mm, the spec's) from each cell centre at ANY pitch, so the room round them shrinks with the pitch: @@ -2337,7 +2374,8 @@ const MOUNT_WALL = 1.0; * and does not grow with the pocket, so it also caps the depth. * * And whichever way it opens, it must stay out of a joint's cut in the floor beside it: - * a key's recess, or the notch a tab fits into. That one needs `layout`, which says + * a key's recess, or the notch a tab fits into, where a dovetail's lets a pocket from + * beneath in only so far as its tab leaves room. That one needs `layout`, which says * where the seams are; without it no joint is counted. * * These are measurements, not field ranges, and can come out below the field's minimum @@ -2395,30 +2433,49 @@ function mountLimits(cfg, layout, known) { to 86 with the spec's 6.5 × 2.4 magnet. The pocket had run into the cut with its ceiling level with the cut's: a 2 mm magnet or the default counterbore with a key's 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face - that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a - key's recess, the 96 level with it went bad 74 times and the 672 at seven other - depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver - into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap - key's recess at 36.52 mm with a 0.5 mm fit clearance, bad at four depths on main). So - any pocket breaking in is refused here, not only the depth that shows it. That is - safe, and more than the parts need: the pocket is measured by the circle through its - corners, and it can break into the cut with the magnet or screw in it still clear of - the key or the tab, which stand the fit clearance inside the cut. A 12.7 mm magnet at - 42 mm is clear of a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the - notch. + that two subtractions split their own ways. All 86 pockets tried level with a cut + went bad; moved 0.001 mm up or down, 3 of them did, and 0.003 mm or more, none. + MOUNT_LEVEL counts 0.05 mm as level. + + Off the level, what a pocket may do depends on the cut, measured on random designs + past where a pocket first meets one: keys and tabs, magnets from both sides, screw + heads and shanks, halves and margins, pitches that are not round numbers. + - A key's recess, an H-clip's or a puzzle tab's notch takes no pocket at all ('cut'). + One a sliver in has gone bad off the level: 0.019 mm into a snap key's recess at + 36.52 mm, with a 0.5 mm fit clearance, at four depths on main. Let in wherever + the magnet or screw stayed clear of the key or tab, 7 of 2,519 such pockets at + the default fit or tighter went bad, 0.02 to 0.14 mm in, and 8 of 1,151 at + looser fits, 0.2 to 0.65 mm in. + - A dovetail's notch takes a pocket from beneath, a sliver or deep, unless it is + level with the notch ('level') or the magnet or screw in it would reach the other + piece's tab, which stands the fit clearance inside the notch ('part'). None of + 3,699 such designs went bad, 1,086 of them on the page's design at 40.5 to + 44.5 mm. So a 12.7 mm magnet at 42 mm, 2 or 3 mm thick, is taken: its pocket is + 0.04 to 0.09 mm into the notch and the magnet 0.24 mm clear of the tab. + - A pocket from above meets any of them unless its floor stands a layer over the + cut's ceiling ('floor'). + The pocket is measured as fastenerCutter cuts it, as a polygon (boreReach), not by the + circle through its corners, which kept sizes out that came a flat's width short. - No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that - was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five - cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first - went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore - 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, folds an - edge at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, - 14 mm across and with no counterbore. That is the pocket and the notch together, a - lottery the room measured here does not see. A wall of 1 mm would refuse the 6 mm - magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always - built clean. */ + A pocket that stops short of a cut stops MOUNT_SEAM short. The weld in healCsgSeams + takes points VTOL apart for one, and a thinner wall than a few of those can come out + welded through: 4 of 715 pockets less than 0.005 mm short went bad, and none of 1,941 + from 0.005 to 0.03 mm. Under a dovetail's notch that leaves a gap of refused sizes + below the largest (`gaps`), between the one that stops MOUNT_SEAM short and the one + that breaks in. Past the weld's reach there is still the lottery the room measured + here does not see, about one design in a thousand, single sizes with clean ones on + either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch + at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as on main, + and is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there + into the notch, and with no counterbore. A guard out that far would refuse sizes that + build clean on both sides of it and still miss the next, 0.1 mm off. A wall of 1 mm + would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm + to spare and always built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; - // { room, top }: the nearest a site comes to one cut, its ceiling + /* Each cut as { top, sites }: its ceiling, and each site in reach of it as how far a + bore's corner circle (`room`) and the bores themselves (`bore`, by their sides) can + grow before they meet the cut, and a magnet or screw (`body`) before it meets the + part in it. */ const jointCuts = again ? known.list : []; /* Room past the most the cell or the floor leaves cannot stop a size, so nothing further off than that is measured, and nothing at all where neither leaves any. A @@ -2428,10 +2485,13 @@ function mountLimits(cfg, layout, known) { if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, - for each seam it can be cut from. Every cut from one seam is the same solid moved - along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once - and each site is moved the other way instead. */ + for each seam it can be cut from, and the part's that goes in it: the key's half, + or the tab of the piece across the seam, as buildPiece stands it there, the fit + clearance inside the cut. Every cut from one seam is the same solid moved along it + (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once and each + site is moved the other way instead. */ const shapes = {}; + const ring = (pts) => pts.map((p, i) => [p, pts[(i + 1) % pts.length]]); const shapeOf = (edge) => { if (shapes[edge]) return shapes[edge]; const at = { edge, e: 0, s: 0 }; @@ -2450,7 +2510,10 @@ function mountLimits(cfg, layout, known) { const a = p.verts[0], b = p.verts.find((v) => Math.hypot(v[0] - a[0], v[1] - a[1]) > 1e-9); if (b) segs.push([a, b]); } - return (shapes[edge] = { segs, bb, ceiling }); + const part = plan.kind === 'recess' ? keyHalf(plan.shape, edge, 0, 0, plan.prm, 0) + : cfg.connector === 'puzzle' ? puzzleShape(OPP[edge], 0, 0, cfg.puzzle, 0, false) + : tabFootprint(OPP[edge], 0, 0, cfg.tab.wr, cfg.tab.wt, cfg.tab.dp, 0.8); + return (shapes[edge] = { segs, bb, ceiling, part: ring(part) }); }; // how far a point is from the footprint, less than none inside it const from = (segs, x, y) => { @@ -2469,7 +2532,7 @@ function mountLimits(cfg, layout, known) { const cuts = [...conn.notches, ...conn.pnotches, ...(plan.kind !== 'recess' ? [] : conn.keyed.filter((bo) => !(plan.junction && offJunction(bo, cfg.pitch, piece))))]; for (const bo of cuts) { - const { segs, bb, ceiling } = shapeOf(bo.edge); + const { segs, bb, ceiling, part } = shapeOf(bo.edge); const across = bo.edge === '+x' || bo.edge === '-x'; const ox = across ? bo.e : bo.s, oy = across ? bo.s : bo.e; // the whole cells with a site in reach of it (a half cell has none; see buildPiece) @@ -2477,40 +2540,98 @@ function mountLimits(cfg, layout, known) { Math.min(n - 1, Math.ceil((hi + reach + off - half - m) / cfg.pitch))]; const [i0, i1] = cells(bb[0] + ox, bb[2] + ox, piece.mL, piece.nx); const [j0, j1] = cells(bb[1] + oy, bb[3] + oy, piece.mF, piece.ny); - let room = Infinity; + const sites = []; for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) for (const sx of [-1, 1]) for (const sy of [-1, 1]) { const x = piece.mL + i*cfg.pitch + half + sx*off - ox; const y = piece.mF + j*cfg.pitch + half + sy*off - oy; if (x < bb[0] - reach || x > bb[2] + reach || y < bb[1] - reach || y > bb[3] + reach) continue; - room = Math.min(room, from(segs, x, y)); + // the bores and the part stand further off than the corner circle, or as far + const room = from(segs, x, y); + if (room >= reach) continue; + const bore = (n) => room > 0 ? boreReach(n, segs, x, y) : room; + sites.push({ room, body: from(part, x, y), bore: { 12: bore(12), 14: bore(14) } }); } - jointCuts.push({ room, top: ceiling }); + if (sites.length) jointCuts.push({ top: ceiling, sites }); + } + } + } + /* The bores as fastenerCutter cuts them, in one place: how many sides, and the largest + size whose corners stay inside a radius. A magnet's corners are 0.1 mm over its + radius, or out to where its flats stand on that radius if that is further; a screw's + bores have their corners on its size. */ + const BORE = { + magnetD: { sides: 14, fits: (r) => 2 * Math.min(r - 0.1, r * Math.cos(Math.PI / 14)) }, + screwHeadD: { sides: 14, fits: (r) => 2 * r }, + screwHoleD: { sides: 12, fits: (r) => 2 * r }, + }; + // the room the cell, the floor or a boss leaves, and the hole beside + const own = { magnetD: fit(cfg.magnetSide === 'top' ? top : under), screwHoleD: fit(top), screwHeadD: fit(under) }; + // a dovetail's notch takes a pocket from beneath that breaks into it; every other cut does not + const notch = cfg.connector === 'dovetail'; + /* What the joint's cuts leave one size, as { cap, why, near }: the largest size, and what + stops it: 'cut', a pocket that would break into a key's recess or a puzzle tab's notch; + 'floor', one from above that leaves no layer of floor over a cut; 'level', one from + beneath as deep as a dovetail's notch; 'part', a magnet or screw that would reach the + tab in one. Each stops MOUNT_SEAM short of the cut. `near` is where that leaves sizes + under the cap refused, as [from, to]: a dovetail's notch, which a pocket may break + into, but not stop just short of. */ + const jointFor = (f) => { + const { sides, fits } = BORE[f]; + const above = f === 'magnetD' && cfg.magnetSide === 'top'; + // how high a pocket from beneath goes; a shank goes through + const ceiling = f === 'magnetD' ? cfg.magnetH : f === 'screwHeadD' ? cfg.screwHeadDepth : Infinity; + let cap = Infinity, why = false; + const near = []; + for (const c of jointCuts) { + // a pocket from above clears a cut whose ceiling it leaves a layer of floor over + if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; + const stop = above ? 'floor' : !notch ? 'cut' : Math.abs(ceiling - c.top) < MOUNT_LEVEL ? 'level' : 'part'; + for (const s of c.sites) { + const short = fits(s.bore[sides] - MOUNT_SEAM); + const size = stop === 'part' ? 2 * s.body : short; + if (size < cap) { cap = size; why = stop; } + if (stop === 'part') near.push([short, fits(s.bore[sides])]); } } + return { cap, why, near }; + }; + const sizes = {}, joint = {}, gaps = {}; + for (const f of ['magnetD', 'screwHoleD', 'screwHeadD']) { + const cell = BORE[f].fits(own[f]), J = jointFor(f); + let size = r10(Math.min(cell, J.cap)); + joint[f] = J.cap < cell && J.why; + /* The sizes `near` refuses, out to the tenths either side, as the cap is: each gap is + [from, to], both taken. One that reaches the cap brings it down to where it starts. */ + const out = []; + for (const [a, b] of J.near.sort((x, y) => x[0] - y[0])) { + const from = r10(a), to = (Math.floor(b * 10 + 1e-9) + 1) / 10; + if (to <= 0) continue; + if (out.length && from < out[out.length - 1][1]) out[out.length - 1][1] = Math.max(out[out.length - 1][1], to); + else out.push([from, to]); + } + gaps[f] = []; + for (const [from, to] of out) { + if (from >= size) break; + if (to > size) { size = from; joint[f] = 'near'; break; } + gaps[f].push([from, to]); + } + sizes[f] = size; } - // the nearest the cuts come that a pocket with its floor at z meets - const jointRoom = (z) => jointCuts.reduce((m, c) => - c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); - const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank - const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length - ? jointRoom(pad - cfg.magnetH) : below; - const own = fit(cfg.magnetSide === 'top' ? top : under); - const room = Math.min(own, magnetJoint); return { - // a magnet pocket's corners are 0.1 mm over the magnet's radius, or out to where its - // flats stand on that radius if that is further (fastenerCutter) - magnetD: r10(2 * Math.min(room - 0.1, room * Math.cos(Math.PI / 14))), - // a screw's bores have their corners on its size - screwHoleD: r10(2 * Math.min(fit(top), below)), - screwHeadD: r10(2 * Math.min(fit(under), below)), + magnetD: sizes.magnetD, + screwHoleD: sizes.screwHoleD, + screwHeadD: sizes.screwHeadD, // in the solid floor the pad grows to suit, so only a boss caps the depth depth: bosses ? r10(BOSS_H - MOUNT_SKIN) : Infinity, // which of the sizes the cut beside it stops, rather than the floor, cell or boss - beside: { magnetD: room === beside, screwHoleD: top >= beside && below >= beside, - screwHeadD: under >= beside && below >= beside }, - // and which a joint's cut stops, before any of those - joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, + beside: { magnetD: own.magnetD === beside && !joint.magnetD, + screwHoleD: own.screwHoleD === beside && !joint.screwHoleD, + screwHeadD: own.screwHeadD === beside && !joint.screwHeadD }, + // and which a joint's cut stops, before any of those, and how (jointFor) + joint, + // sizes under the largest refused all the same, as [from, to] with both ends taken + gaps, // what was measured of the joint's cuts, for `known` cuts: { pad, list: jointCuts }, }; diff --git a/src/ui.js b/src/ui.js index 9b91c65..9b27609 100644 --- a/src/ui.js +++ b/src/ui.js @@ -76,7 +76,8 @@ const MOUNT_LAST = ['magnetH', 'screwHeadDepth', 'screwHoleD', 'screwHeadD', 'ma * off, nor margins outside Custom, because a complaint about a field you cannot see is * one you cannot act on. `why` finishes the too-big message where "check the figure is * in millimetres" would be the wrong advice, and `off` names the switch that drops a cut - * the pitch has no room for. */ + * the pitch has no room for. `gaps` are sizes under `max` refused all the same, as + * [from, to] with both ends taken. */ const RANGES = PLATE_RANGES; const customMargins = () => state.marginMode === 'custom' && !state.noMargin; /* The sizes a joint's cut in the floor leaves room for depend on where the seams are and @@ -94,15 +95,33 @@ const mountDepth = () => mountLimits(state).depth; // "an 18 mm pitch", "an 80 mm pitch": the article goes by how the number is said const atPitch = () => `at ${/^(8|1[18](\.|$))/.test(String(state.pitch)) ? 'an' : 'a'} ` + `${state.pitch} mm pitch`; -const mountWhy = (opens, field) => `${atPitch()} — mounting holes sit ` + - `${state.holeOffset} mm from each cell centre, where the Gridfinity spec puts them, and ` + - (mount().joint[field] ? `a hole has to stay out of the ` + - `${['dovetail', 'puzzle'].includes(state.connector) ? 'notches' : 'recesses'} the ` + - `${CONNECTOR_NAMES[state.connector]} fit into` - : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' - : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' - : opens ? 'a cut open to the socket has to stay on the socket floor' - : 'a pocket under the floor has to stay inside its cell'); +// a joint's cut in the floor, as the messages name it: "the notches the dovetail tabs fit into" +const cutsNamed = () => `${['dovetail', 'puzzle'].includes(state.connector) ? 'notches' : 'recesses'} the ` + + `${CONNECTOR_NAMES[state.connector]} fit into`; +/* Why `field` stops where it does. A joint's cut stops it in one of the ways mountLimits' + `joint` names: a pocket from beneath as deep as a dovetail's notch, a magnet or screw + that would reach the tab in one, a pocket any wider coming too near the notch's edge, + or any other hole breaking into the cut. */ +const mountWhy = (opens, field) => { + const joint = mount().joint[field]; + const cuts = cutsNamed(); + return `${atPitch()} — mounting holes sit ` + + `${state.holeOffset} mm from each cell centre, where the Gridfinity spec puts them, and ` + + (joint === 'level' ? `a pocket ${field === 'magnetD' ? state.magnetH : state.screwHeadDepth} mm deep, ` + + `as deep as the ${cuts}, has to stay out of them` + : joint === 'part' ? `${{ magnetD: 'a magnet', screwHeadD: 'a screw head', screwHoleD: 'a screw' }[field]} ` + + `has to stay clear of the ${CONNECTOR_NAMES[state.connector]} in the notches beside it` + : joint === 'near' ? `a pocket any wider would come too near the edge of the ${cuts} to cut cleanly` + : joint ? `a hole has to stay out of the ${cuts}` + : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' + : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' + : opens ? 'a cut open to the socket has to stay on the socket floor' + : 'a pocket under the floor has to stay inside its cell') + + (joint && KEYED.includes(state.connector) && !keyFromTop() + ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above leave the floor clear` : ''); +}; +// why a size under the largest is refused (mountLimits' `gaps`) +const nearWhy = () => `${atPitch()} — its pocket would come too near the edge of the ${cutsNamed()} to cut cleanly`; const bossDepth = () => state.baseMode === 'bosses' ? 'with corner pockets — a boss is 2.6 mm tall, while the solid floor grows to suit' : ''; const LIMITS = { @@ -129,13 +148,16 @@ const LIMITS = { tooSmall: 'at 0 the rim between sockets is a face with no width, and the plate comes out open', why: () => '— past that a spec bin rides on the rim instead of seating in its socket' }, magnetD: { ...RANGES.magnetD, max: () => mount().magnetD, label: 'Magnet Ø', when: () => state.magnets, - why: () => mountWhy(state.magnetSide === 'top', 'magnetD'), off: 'magnet pockets' }, + why: () => mountWhy(state.magnetSide === 'top', 'magnetD'), off: 'magnet pockets', + gaps: () => mount().gaps.magnetD }, magnetH: { ...RANGES.magnetH, max: () => Math.min(RANGES.magnetH.max, mountDepth()), label: 'Magnet depth', when: () => state.magnets, why: bossDepth }, screwHoleD: { ...RANGES.screwHoleD, max: () => mount().screwHoleD, label: 'Screw hole Ø', - when: () => state.screws, why: () => mountWhy(true, 'screwHoleD'), off: 'screw holes' }, + when: () => state.screws, why: () => mountWhy(true, 'screwHoleD'), off: 'screw holes', + gaps: () => mount().gaps.screwHoleD }, screwHeadD: { ...RANGES.screwHeadD, max: () => mount().screwHeadD, label: 'Screw head Ø', - when: () => state.screws, why: () => mountWhy(false, 'screwHeadD'), off: 'screw holes' }, + when: () => state.screws, why: () => mountWhy(false, 'screwHeadD'), off: 'screw holes', + gaps: () => mount().gaps.screwHeadD }, screwHeadDepth: { ...RANGES.screwHeadDepth, max: () => Math.min(RANGES.screwHeadDepth.max, mountDepth()), label: 'Screw head depth', when: () => state.screws, why: bossDepth }, // each joint's ceiling is its own, so none is held to another's reason; see clrWhy @@ -242,6 +264,14 @@ function readNumber(id) { (why ? `${why}.` : `— check the figure is in ${unitName}.`)); return hi; } + /* A size under the largest can be refused as well, where its pocket would come too near + the edge of a dovetail's notch (mountLimits' `gaps`); the sizes either side are taken. */ + const gap = inPlay && lim.gaps && lim.gaps().find(([a, b]) => v > a && v < b); + if (gap) { + say(`${lim.label} of ${both(v)} is refused ${nearWhy()}. Use ${both(gap[0])} or less, ` + + `or ${both(gap[1])} or more.`); + return gap[0]; + } return v; } /* The invalid state is set on the element rather than through a class, because the From 681c939736565dd8b5c9e5af3d950fda1ce43883 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 13:08:55 +0000 Subject: [PATCH 10/15] Hold the dovetail's middle rule to the half-inch magnet and the snap sliver Seven plate-audit rows, each with the reason mountLimits has to give: 12.7 x 2 and 12.7 x 3 on the page's design at 42 mm taken and watertight; 12.7 x 2.4 refused as level (96 bad edges if built); 13.2 x 2 refused only because the magnet would touch the tab (builds clean); at 36 mm 5.6 x 2 refused as too near the notch's edge and 5.7 taken; and the review's snap sliver at 36.52 mm, 0.019 mm into the recess, refused (6 bad edges if built). plates-robustness: the default dovetail's cap is 13.1 with the tab named, 12.5 at 2.4 mm deep with the level named, the 5.6 mm gap at 36 mm, the bowtie's message with the keys-from-above way out, and the half-inch magnet taken with Download on. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- test/plate-audit.js | 36 ++++++++++++++++++++++++++++++- test/ui/plates-robustness.spec.js | 31 ++++++++++++++++++++------ 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/test/plate-audit.js b/test/plate-audit.js index 06dc266..4087fa4 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -2009,7 +2009,7 @@ console.log('\nthe other limits, built at their ends:'); wider pocket brought the leak 0.1 to 0.4 mm lower. From above, an 8 mm magnet's pocket breaks into the recess under it without a bad edge, the magnet itself about 0.13 mm clear of the key: refused all the same, as every pocket that breaks into a - cut is (see mountLimits). In the wall, main's widest leaked. The 38.13 mm link is + key's recess is (see mountLimits). In the wall, main's widest leaked. The 38.13 mm link is the one #61 left for later: its 6.5 mm counterbore stood 0.7 mm into a puzzle key's recess. The last two are the spec's 6.5 × 2.4 magnet beside a tab, whose notch stops 2.4 mm up as well. And the same bowtie in four pieces with strips of half cells and @@ -2044,6 +2044,40 @@ console.log('\nthe other limits, built at their ends:'); if (widest.bad) bad++; bad += taken.length; } + /* What a pocket may and may not do in a joint's cut, by size, each with the reason + mountLimits gives (false where it takes the size). A dovetail's notch takes a pocket + from beneath that breaks into it, unless the two ceilings are level or the magnet + reaches the tab: the half-inch magnet on the page's default design at 42 mm, 2 and + 3 mm thick, has to be taken and come out watertight; 2.4 thick, level with the + notch, it built 96 bad edges and has to be refused; and 13.2 mm, 2 thick, builds + clean but would touch the tab. At 36 mm a 5.6 mm magnet's pocket would stand right + on the notch's wall, under MOUNT_SEAM from it, so it is refused there (a gap) and + 5.7, which breaks in, is taken. Any other cut takes none: the snap clip at 36.52 mm + is the review's, a 1.5 mm magnet at a fit clearance of 0.5 whose pocket is only + 0.019 mm into the recess, and main built it with 6 bad edges at 2.5 mm deep (and at + 1.9, 2.1 and 2.4). The refused ones are built too, to show what main would have, but + only the reason is held to. */ + const PAGE = { marginMode: 'auto', connector: 'dovetail', magnets: true }; + const SNAP = { pitch: 36.52, drawerW: 73.04, drawerD: 73.04, bedW: 52.52, bedD: 400, splitMode: 'balanced', + connector: 'snap', keyMount: 'floor', keyInsert: 'bottom', tolerance: 'tight', clr: 0.5, + magnets: true, magnetH: 2.5, screws: true, screwHoleD: 1.6, screwHeadD: 1.6, screwHeadDepth: 2 }; + for (const [nm, o, f, d, why] of [ + ['dovetail, 12.7 x 2, page', { ...PAGE, magnetH: 2 }, 'magnetD', 12.7, false], + ['dovetail, 12.7 x 3, page', { ...PAGE, magnetH: 3 }, 'magnetD', 12.7, false], + ['dovetail, 12.7 x 2.4, page', { ...PAGE, magnetH: 2.4 }, 'magnetD', 12.7, 'level'], + ['dovetail, 13.2 x 2, page', { ...PAGE, magnetH: 2 }, 'magnetD', 13.2, 'part'], + ['dovetail, 5.6 x 2, page, 36', { ...PAGE, pitch: 36, magnetH: 2 }, 'magnetD', 5.6, 'gap'], + ['dovetail, 5.7 x 2, page, 36', { ...PAGE, pitch: 36, magnetH: 2 }, 'magnetD', 5.7, false], + ['snap, 1.5 x 2.5, 36.52', SNAP, 'magnetD', 1.5, 'cut']]) { + const cfg = designCfg(sized(o, f, d)); + const lims = G.mountLimits(cfg, G.computeLayout(cfg)); + const r = buildAll(sized(o, f, d)); + const refused = d > lims[f] ? lims.joint[f] : lims.gaps[f].some(([a, b]) => d > a && d < b) && 'gap'; + const holds = why ? refused === why : !refused && !r.bad; + console.log(` ${nm.padEnd(28)} ${refused ? `refused (${refused}), would build` : 'taken,'} ` + + `${leakText(r)}${holds ? '' : ` FAIL: ${why ? `has to be refused as ${why}` : 'has to be taken watertight'}`}`); + if (!holds) bad++; + } /* A counterbore's floor fan (#61's round 4). Where a 4.8 mm head was unioned with its 2.4 mm shank, the shank's flats came back split at the head's planes, and the socket floor's fan was held clear of those split points as well as the corners: no point diff --git a/test/ui/plates-robustness.spec.js b/test/ui/plates-robustness.spec.js index db5c058..4f7adde 100644 --- a/test/ui/plates-robustness.spec.js +++ b/test/ui/plates-robustness.spec.js @@ -77,8 +77,8 @@ test.describe('ranges on the geometry fields', () => { /* [link, the line under the field, what it has to say]. The magnet and screw maxima are the standard 42 mm pitch's, from mountLimits; the pitch cases show the same limit moving with the cell, down to no room at all. Those take no joint (cn=none): - the default dovetail's notches stop a magnet from beneath first, at 12.3 mm, and - the joint cases at the end of the list say so. */ + the default dovetail's tabs stop a magnet from beneath first, at 13.1 mm, and the + joint cases at the end of the list say so. */ const BOWTIE_42 = '#pi=42&w=168&d=84&mm=custom&ml=0&mr=0&mf=0&mb=0&bw=100&bd=400&cn=bowtie&km=floor&ki=bottom'; const CASES = [ ['#tc=0', 'errFloor', /Rim cutoff must be at least 0\.1 mm/], @@ -110,13 +110,20 @@ test.describe('ranges on the geometry fields', () => { beneath reached a bowtie's recess at 42 mm, and the plate built with 19 bad edges a piece and Download on; from above, an 8 mm one stood over the key. */ [`${BOWTIE_42}&mg=1&md=10`, 'errMagnet', - /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — mounting holes sit 13 mm from each cell centre, where the Gridfinity spec puts them, and a hole has to stay out of the recesses the bowtie keys fit into/], + /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — mounting holes sit 13 mm from each cell centre, where the Gridfinity spec puts them, and a hole has to stay out of the recesses the bowtie keys fit into; keys housed inside the walls and put in from above leave the floor clear\./], [`${BOWTIE_42}&mg=1&ms=top&md=8`, 'errMagnet', /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — .* the recesses the bowtie keys fit into/], [`${BOWTIE_42.replace('cn=bowtie', 'cn=snap')}&sc=1&sd=10`, 'errScrew', /Screw head Ø must be 7\.8 mm or less at a 42 mm pitch — .* the recesses the snap clips fit into/], + /* A dovetail's notch lets a pocket from beneath in (#69's review, option c), so long + as the magnet stays clear of the tab and the pocket is not as deep as the notch, + and does not stop just short of its edge; each refusal says which it is. */ ['#mg=1&md=20', 'errMagnet', - /Magnet Ø must be 12\.3 mm or less at a 42 mm pitch — .* the notches the dovetail tabs fit into/], + /Magnet Ø must be 13\.1 mm or less at a 42 mm pitch — .* a magnet has to stay clear of the dovetail tabs in the notches beside it\./], + ['#mg=1&mh=2.4&md=13', 'errMagnet', + /Magnet Ø must be 12\.5 mm or less at a 42 mm pitch — .* a pocket 2\.4 mm deep, as deep as the notches the dovetail tabs fit into, has to stay out of them\./], + ['#pi=36&mg=1&md=5.6', 'errMagnet', + /Magnet Ø of 5\.6 mm is refused at a 36 mm pitch — its pocket would come too near the edge of the notches the dovetail tabs fit into to cut cleanly\. Use 5\.5 mm or less, or 5\.7 mm or more\./], ]; for (const [hash, errId, msg] of CASES) { test(`${hash} is refused at the field`, async ({ page }) => { @@ -158,6 +165,18 @@ test.describe('ranges on the geometry fields', () => { expect(errors).toEqual([]); }); + /* The half-inch magnet on the default dovetail at 42 mm: its pocket breaks 0.04 to + 0.09 mm into the notches, the magnet 0.24 mm clear of the tabs, and it builds clean, + so the field takes it; 2.4 mm deep, level with the notch, it would not. */ + test('a half-inch magnet beside the default dovetail is taken', async ({ page }) => { + const errors = await openAt(page, '#mg=1&md=12.7&mh=2'); + expect(await page.evaluate(() => document.getElementById('magnetD').max)).toBe('13.1'); + expect(await shown(page, 'errMagnet')).toBe(false); + expect(await text(page, 'pieceTail')).toMatch(/ready/); + expect(await exportOff(page)).toBe(false); + expect(errors).toEqual([]); + }); + test('a typed value is held to the same range, and a good one clears it', async ({ page }) => { await H.openPlates(page); await H.setField(page, 'topCutoff', '0'); @@ -385,8 +404,8 @@ test.describe('limits no tighter than the geometry', () => { expect(s.built).toBeCloseTo(7.05, 9); }); - /* The 34 mm case takes no joint: the default dovetail's notches hold its 6 mm screw head - to 3.8 mm there, which is a field error of its own. The puzzle tabs' are what leave + /* The 34 mm case takes no joint: the default dovetail's tabs hold its 6 mm screw head + to 4.2 mm there, which is a field error of its own. The puzzle tabs' are what leave a magnet no room at 36 mm, where the cell alone would take 7.7. */ for (const [hash, id, errId, carried, msg] of [ ['#cn=none&sc=1&pi=34', 'screwHoleD', 'errScrew', 3, From fa147661cf5c4d990237951990a024a222e64423 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 13:09:03 +0000 Subject: [PATCH 11/15] Rebuild the pages Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- bins/index.html | 221 +++++++++++++++++++++++++++++--------- index.html | 277 +++++++++++++++++++++++++++++++++++++----------- sw.js | 2 +- 3 files changed, 386 insertions(+), 114 deletions(-) diff --git a/bins/index.html b/bins/index.html index 28162cc..1d1af58 100644 --- a/bins/index.html +++ b/bins/index.html @@ -3928,6 +3928,43 @@

Your drawers

facets graze the floor's own triangulation — screws at a 36 mm pitch leaked 192 edges with 0.65 mm to spare. */ const MOUNT_WALL = 1.0; +/* How near a pocket's ceiling may come to a dovetail notch's before the two count as + level, and how near its walls may come to any joint's cut without breaking into it. + See mountLimits. */ +const MOUNT_LEVEL = 0.05, MOUNT_SEAM = 0.01; +/* How far a mounting bore about (x, y) can grow before it meets any of `segs`, as the + radius of the circle through its corners: the polygon cylinder() cuts, `sides` flats + with a corner at every 2πk/sides from +x. A point is in that polygon when it stands no + further out along any flat's normal than R cos(π/sides), so along one segment the + least R that takes a point of it in is at an end, or where the segment crosses the + line out through a corner, on which a point's R is its distance. */ +function boreReach(sides, segs, x, y) { + const step = 2 * Math.PI / sides, h = Math.cos(step / 2); + const cx = [], cy = [], nx = [], ny = []; + for (let k = 0; k < sides; k++) { + cx.push(Math.cos(k * step)); cy.push(Math.sin(k * step)); + nx.push(Math.cos((k + 0.5) * step)); ny.push(Math.sin((k + 0.5) * step)); + } + const at = (dx, dy) => { + let m = -Infinity; + for (let k = 0; k < sides; k++) m = Math.max(m, dx * nx[k] + dy * ny[k]); + return m / h; + }; + let r = Infinity; + for (const [a, b] of segs) { + const ax = a[0] - x, ay = a[1] - y, ex = b[0] - a[0], ey = b[1] - a[1]; + r = Math.min(r, at(ax, ay), at(ax + ex, ay + ey)); + for (let k = 0; k < sides; k++) { + const den = ex * cy[k] - ey * cx[k]; + if (Math.abs(den) < 1e-12) continue; + const t = (ay * cx[k] - ax * cy[k]) / den; + if (t < 0 || t > 1) continue; + const s = (ax + t * ex) * cx[k] + (ay + t * ey) * cy[k]; + if (s >= 0) r = Math.min(r, s); + } + } + return r; +} /* The largest mounting cuts this configuration has room for, as diameters and depths in the units the page's fields use. Magnets and screws sit holeOffset (13 mm, the spec's) from each cell centre at ANY pitch, so the room round them shrinks with the pitch: @@ -3943,7 +3980,8 @@

Your drawers

* and does not grow with the pocket, so it also caps the depth. * * And whichever way it opens, it must stay out of a joint's cut in the floor beside it: - * a key's recess, or the notch a tab fits into. That one needs `layout`, which says + * a key's recess, or the notch a tab fits into, where a dovetail's lets a pocket from + * beneath in only so far as its tab leaves room. That one needs `layout`, which says * where the seams are; without it no joint is counted. * * These are measurements, not field ranges, and can come out below the field's minimum @@ -4001,30 +4039,49 @@

Your drawers

to 86 with the spec's 6.5 × 2.4 magnet. The pocket had run into the cut with its ceiling level with the cut's: a 2 mm magnet or the default counterbore with a key's 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face - that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a - key's recess, the 96 level with it went bad 74 times and the 672 at seven other - depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver - into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap - key's recess at 36.52 mm with a 0.5 mm fit clearance, bad at four depths on main). So - any pocket breaking in is refused here, not only the depth that shows it. That is - safe, and more than the parts need: the pocket is measured by the circle through its - corners, and it can break into the cut with the magnet or screw in it still clear of - the key or the tab, which stand the fit clearance inside the cut. A 12.7 mm magnet at - 42 mm is clear of a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the - notch. - - No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that - was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five - cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first - went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore - 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, folds an - edge at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, - 14 mm across and with no counterbore. That is the pocket and the notch together, a - lottery the room measured here does not see. A wall of 1 mm would refuse the 6 mm - magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always - built clean. */ + that two subtractions split their own ways. All 86 pockets tried level with a cut + went bad; moved 0.001 mm up or down, 3 of them did, and 0.003 mm or more, none. + MOUNT_LEVEL counts 0.05 mm as level. + + Off the level, what a pocket may do depends on the cut, measured on random designs + past where a pocket first meets one: keys and tabs, magnets from both sides, screw + heads and shanks, halves and margins, pitches that are not round numbers. + - A key's recess, an H-clip's or a puzzle tab's notch takes no pocket at all ('cut'). + One a sliver in has gone bad off the level: 0.019 mm into a snap key's recess at + 36.52 mm, with a 0.5 mm fit clearance, at four depths on main. Let in wherever + the magnet or screw stayed clear of the key or tab, 7 of 2,519 such pockets at + the default fit or tighter went bad, 0.02 to 0.14 mm in, and 8 of 1,151 at + looser fits, 0.2 to 0.65 mm in. + - A dovetail's notch takes a pocket from beneath, a sliver or deep, unless it is + level with the notch ('level') or the magnet or screw in it would reach the other + piece's tab, which stands the fit clearance inside the notch ('part'). None of + 3,699 such designs went bad, 1,086 of them on the page's design at 40.5 to + 44.5 mm. So a 12.7 mm magnet at 42 mm, 2 or 3 mm thick, is taken: its pocket is + 0.04 to 0.09 mm into the notch and the magnet 0.24 mm clear of the tab. + - A pocket from above meets any of them unless its floor stands a layer over the + cut's ceiling ('floor'). + The pocket is measured as fastenerCutter cuts it, as a polygon (boreReach), not by the + circle through its corners, which kept sizes out that came a flat's width short. + + A pocket that stops short of a cut stops MOUNT_SEAM short. The weld in healCsgSeams + takes points VTOL apart for one, and a thinner wall than a few of those can come out + welded through: 4 of 715 pockets less than 0.005 mm short went bad, and none of 1,941 + from 0.005 to 0.03 mm. Under a dovetail's notch that leaves a gap of refused sizes + below the largest (`gaps`), between the one that stops MOUNT_SEAM short and the one + that breaks in. Past the weld's reach there is still the lottery the room measured + here does not see, about one design in a thousand, single sizes with clean ones on + either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch + at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as on main, + and is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there + into the notch, and with no counterbore. A guard out that far would refuse sizes that + build clean on both sides of it and still miss the next, 0.1 mm off. A wall of 1 mm + would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm + to spare and always built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; - // { room, top }: the nearest a site comes to one cut, its ceiling + /* Each cut as { top, sites }: its ceiling, and each site in reach of it as how far a + bore's corner circle (`room`) and the bores themselves (`bore`, by their sides) can + grow before they meet the cut, and a magnet or screw (`body`) before it meets the + part in it. */ const jointCuts = again ? known.list : []; /* Room past the most the cell or the floor leaves cannot stop a size, so nothing further off than that is measured, and nothing at all where neither leaves any. A @@ -4034,10 +4091,13 @@

Your drawers

if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, - for each seam it can be cut from. Every cut from one seam is the same solid moved - along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once - and each site is moved the other way instead. */ + for each seam it can be cut from, and the part's that goes in it: the key's half, + or the tab of the piece across the seam, as buildPiece stands it there, the fit + clearance inside the cut. Every cut from one seam is the same solid moved along it + (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once and each + site is moved the other way instead. */ const shapes = {}; + const ring = (pts) => pts.map((p, i) => [p, pts[(i + 1) % pts.length]]); const shapeOf = (edge) => { if (shapes[edge]) return shapes[edge]; const at = { edge, e: 0, s: 0 }; @@ -4056,7 +4116,10 @@

Your drawers

const a = p.verts[0], b = p.verts.find((v) => Math.hypot(v[0] - a[0], v[1] - a[1]) > 1e-9); if (b) segs.push([a, b]); } - return (shapes[edge] = { segs, bb, ceiling }); + const part = plan.kind === 'recess' ? keyHalf(plan.shape, edge, 0, 0, plan.prm, 0) + : cfg.connector === 'puzzle' ? puzzleShape(OPP[edge], 0, 0, cfg.puzzle, 0, false) + : tabFootprint(OPP[edge], 0, 0, cfg.tab.wr, cfg.tab.wt, cfg.tab.dp, 0.8); + return (shapes[edge] = { segs, bb, ceiling, part: ring(part) }); }; // how far a point is from the footprint, less than none inside it const from = (segs, x, y) => { @@ -4075,7 +4138,7 @@

Your drawers

const cuts = [...conn.notches, ...conn.pnotches, ...(plan.kind !== 'recess' ? [] : conn.keyed.filter((bo) => !(plan.junction && offJunction(bo, cfg.pitch, piece))))]; for (const bo of cuts) { - const { segs, bb, ceiling } = shapeOf(bo.edge); + const { segs, bb, ceiling, part } = shapeOf(bo.edge); const across = bo.edge === '+x' || bo.edge === '-x'; const ox = across ? bo.e : bo.s, oy = across ? bo.s : bo.e; // the whole cells with a site in reach of it (a half cell has none; see buildPiece) @@ -4083,40 +4146,98 @@

Your drawers

Math.min(n - 1, Math.ceil((hi + reach + off - half - m) / cfg.pitch))]; const [i0, i1] = cells(bb[0] + ox, bb[2] + ox, piece.mL, piece.nx); const [j0, j1] = cells(bb[1] + oy, bb[3] + oy, piece.mF, piece.ny); - let room = Infinity; + const sites = []; for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) for (const sx of [-1, 1]) for (const sy of [-1, 1]) { const x = piece.mL + i*cfg.pitch + half + sx*off - ox; const y = piece.mF + j*cfg.pitch + half + sy*off - oy; if (x < bb[0] - reach || x > bb[2] + reach || y < bb[1] - reach || y > bb[3] + reach) continue; - room = Math.min(room, from(segs, x, y)); + // the bores and the part stand further off than the corner circle, or as far + const room = from(segs, x, y); + if (room >= reach) continue; + const bore = (n) => room > 0 ? boreReach(n, segs, x, y) : room; + sites.push({ room, body: from(part, x, y), bore: { 12: bore(12), 14: bore(14) } }); } - jointCuts.push({ room, top: ceiling }); + if (sites.length) jointCuts.push({ top: ceiling, sites }); } } } - // the nearest the cuts come that a pocket with its floor at z meets - const jointRoom = (z) => jointCuts.reduce((m, c) => - c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); - const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank - const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length - ? jointRoom(pad - cfg.magnetH) : below; - const own = fit(cfg.magnetSide === 'top' ? top : under); - const room = Math.min(own, magnetJoint); + /* The bores as fastenerCutter cuts them, in one place: how many sides, and the largest + size whose corners stay inside a radius. A magnet's corners are 0.1 mm over its + radius, or out to where its flats stand on that radius if that is further; a screw's + bores have their corners on its size. */ + const BORE = { + magnetD: { sides: 14, fits: (r) => 2 * Math.min(r - 0.1, r * Math.cos(Math.PI / 14)) }, + screwHeadD: { sides: 14, fits: (r) => 2 * r }, + screwHoleD: { sides: 12, fits: (r) => 2 * r }, + }; + // the room the cell, the floor or a boss leaves, and the hole beside + const own = { magnetD: fit(cfg.magnetSide === 'top' ? top : under), screwHoleD: fit(top), screwHeadD: fit(under) }; + // a dovetail's notch takes a pocket from beneath that breaks into it; every other cut does not + const notch = cfg.connector === 'dovetail'; + /* What the joint's cuts leave one size, as { cap, why, near }: the largest size, and what + stops it: 'cut', a pocket that would break into a key's recess or a puzzle tab's notch; + 'floor', one from above that leaves no layer of floor over a cut; 'level', one from + beneath as deep as a dovetail's notch; 'part', a magnet or screw that would reach the + tab in one. Each stops MOUNT_SEAM short of the cut. `near` is where that leaves sizes + under the cap refused, as [from, to]: a dovetail's notch, which a pocket may break + into, but not stop just short of. */ + const jointFor = (f) => { + const { sides, fits } = BORE[f]; + const above = f === 'magnetD' && cfg.magnetSide === 'top'; + // how high a pocket from beneath goes; a shank goes through + const ceiling = f === 'magnetD' ? cfg.magnetH : f === 'screwHeadD' ? cfg.screwHeadDepth : Infinity; + let cap = Infinity, why = false; + const near = []; + for (const c of jointCuts) { + // a pocket from above clears a cut whose ceiling it leaves a layer of floor over + if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; + const stop = above ? 'floor' : !notch ? 'cut' : Math.abs(ceiling - c.top) < MOUNT_LEVEL ? 'level' : 'part'; + for (const s of c.sites) { + const short = fits(s.bore[sides] - MOUNT_SEAM); + const size = stop === 'part' ? 2 * s.body : short; + if (size < cap) { cap = size; why = stop; } + if (stop === 'part') near.push([short, fits(s.bore[sides])]); + } + } + return { cap, why, near }; + }; + const sizes = {}, joint = {}, gaps = {}; + for (const f of ['magnetD', 'screwHoleD', 'screwHeadD']) { + const cell = BORE[f].fits(own[f]), J = jointFor(f); + let size = r10(Math.min(cell, J.cap)); + joint[f] = J.cap < cell && J.why; + /* The sizes `near` refuses, out to the tenths either side, as the cap is: each gap is + [from, to], both taken. One that reaches the cap brings it down to where it starts. */ + const out = []; + for (const [a, b] of J.near.sort((x, y) => x[0] - y[0])) { + const from = r10(a), to = (Math.floor(b * 10 + 1e-9) + 1) / 10; + if (to <= 0) continue; + if (out.length && from < out[out.length - 1][1]) out[out.length - 1][1] = Math.max(out[out.length - 1][1], to); + else out.push([from, to]); + } + gaps[f] = []; + for (const [from, to] of out) { + if (from >= size) break; + if (to > size) { size = from; joint[f] = 'near'; break; } + gaps[f].push([from, to]); + } + sizes[f] = size; + } return { - // a magnet pocket's corners are 0.1 mm over the magnet's radius, or out to where its - // flats stand on that radius if that is further (fastenerCutter) - magnetD: r10(2 * Math.min(room - 0.1, room * Math.cos(Math.PI / 14))), - // a screw's bores have their corners on its size - screwHoleD: r10(2 * Math.min(fit(top), below)), - screwHeadD: r10(2 * Math.min(fit(under), below)), + magnetD: sizes.magnetD, + screwHoleD: sizes.screwHoleD, + screwHeadD: sizes.screwHeadD, // in the solid floor the pad grows to suit, so only a boss caps the depth depth: bosses ? r10(BOSS_H - MOUNT_SKIN) : Infinity, // which of the sizes the cut beside it stops, rather than the floor, cell or boss - beside: { magnetD: room === beside, screwHoleD: top >= beside && below >= beside, - screwHeadD: under >= beside && below >= beside }, - // and which a joint's cut stops, before any of those - joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, + beside: { magnetD: own.magnetD === beside && !joint.magnetD, + screwHoleD: own.screwHoleD === beside && !joint.screwHoleD, + screwHeadD: own.screwHeadD === beside && !joint.screwHeadD }, + // and which a joint's cut stops, before any of those, and how (jointFor) + joint, + // sizes under the largest refused all the same, as [from, to] with both ends taken + gaps, // what was measured of the joint's cuts, for `known` cuts: { pad, list: jointCuts }, }; diff --git a/index.html b/index.html index 99891aa..9b379f0 100644 --- a/index.html +++ b/index.html @@ -3715,6 +3715,43 @@

Your drawers

facets graze the floor's own triangulation — screws at a 36 mm pitch leaked 192 edges with 0.65 mm to spare. */ const MOUNT_WALL = 1.0; +/* How near a pocket's ceiling may come to a dovetail notch's before the two count as + level, and how near its walls may come to any joint's cut without breaking into it. + See mountLimits. */ +const MOUNT_LEVEL = 0.05, MOUNT_SEAM = 0.01; +/* How far a mounting bore about (x, y) can grow before it meets any of `segs`, as the + radius of the circle through its corners: the polygon cylinder() cuts, `sides` flats + with a corner at every 2πk/sides from +x. A point is in that polygon when it stands no + further out along any flat's normal than R cos(π/sides), so along one segment the + least R that takes a point of it in is at an end, or where the segment crosses the + line out through a corner, on which a point's R is its distance. */ +function boreReach(sides, segs, x, y) { + const step = 2 * Math.PI / sides, h = Math.cos(step / 2); + const cx = [], cy = [], nx = [], ny = []; + for (let k = 0; k < sides; k++) { + cx.push(Math.cos(k * step)); cy.push(Math.sin(k * step)); + nx.push(Math.cos((k + 0.5) * step)); ny.push(Math.sin((k + 0.5) * step)); + } + const at = (dx, dy) => { + let m = -Infinity; + for (let k = 0; k < sides; k++) m = Math.max(m, dx * nx[k] + dy * ny[k]); + return m / h; + }; + let r = Infinity; + for (const [a, b] of segs) { + const ax = a[0] - x, ay = a[1] - y, ex = b[0] - a[0], ey = b[1] - a[1]; + r = Math.min(r, at(ax, ay), at(ax + ex, ay + ey)); + for (let k = 0; k < sides; k++) { + const den = ex * cy[k] - ey * cx[k]; + if (Math.abs(den) < 1e-12) continue; + const t = (ay * cx[k] - ax * cy[k]) / den; + if (t < 0 || t > 1) continue; + const s = (ax + t * ex) * cx[k] + (ay + t * ey) * cy[k]; + if (s >= 0) r = Math.min(r, s); + } + } + return r; +} /* The largest mounting cuts this configuration has room for, as diameters and depths in the units the page's fields use. Magnets and screws sit holeOffset (13 mm, the spec's) from each cell centre at ANY pitch, so the room round them shrinks with the pitch: @@ -3730,7 +3767,8 @@

Your drawers

* and does not grow with the pocket, so it also caps the depth. * * And whichever way it opens, it must stay out of a joint's cut in the floor beside it: - * a key's recess, or the notch a tab fits into. That one needs `layout`, which says + * a key's recess, or the notch a tab fits into, where a dovetail's lets a pocket from + * beneath in only so far as its tab leaves room. That one needs `layout`, which says * where the seams are; without it no joint is counted. * * These are measurements, not field ranges, and can come out below the field's minimum @@ -3788,30 +3826,49 @@

Your drawers

to 86 with the spec's 6.5 × 2.4 magnet. The pocket had run into the cut with its ceiling level with the cut's: a 2 mm magnet or the default counterbore with a key's 2 mm recess, a 2.4 mm magnet with a tab's notch. The two ceilings then share a face - that two subtractions split their own ways. Of 768 pockets 0.1 to 1.25 mm into a - key's recess, the 96 level with it went bad 74 times and the 672 at seven other - depths never, as near as 0.01 mm either side. Never there; a pocket only a sliver - into a cut has gone bad at other depths too (a review found one 0.019 mm into a snap - key's recess at 36.52 mm with a 0.5 mm fit clearance, bad at four depths on main). So - any pocket breaking in is refused here, not only the depth that shows it. That is - safe, and more than the parts need: the pocket is measured by the circle through its - corners, and it can break into the cut with the magnet or screw in it still clear of - the key or the tab, which stand the fit clearance inside the cut. A 12.7 mm magnet at - 42 mm is clear of a dovetail's tab by about 0.24 mm, with its pocket 0.09 mm into the - notch. - - No wall is left between them, where MOUNT_WALL leaves 1 mm everywhere else, and that - was measured too: of 10,882 designs across seven keyed joints, 71 pitches and five - cuts, none of the 7,823 that stopped short of the cut built a bad edge, and the first - went bad 0.035 mm into it. That is a sample, not a promise: a 14.1 mm counterbore - 2.4 to 3 mm deep, 0.05 mm short of a dovetail's notch at 43.17 mm, loose, folds an - edge at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, - 14 mm across and with no counterbore. That is the pocket and the notch together, a - lottery the room measured here does not see. A wall of 1 mm would refuse the 6 mm - magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always - built clean. */ + that two subtractions split their own ways. All 86 pockets tried level with a cut + went bad; moved 0.001 mm up or down, 3 of them did, and 0.003 mm or more, none. + MOUNT_LEVEL counts 0.05 mm as level. + + Off the level, what a pocket may do depends on the cut, measured on random designs + past where a pocket first meets one: keys and tabs, magnets from both sides, screw + heads and shanks, halves and margins, pitches that are not round numbers. + - A key's recess, an H-clip's or a puzzle tab's notch takes no pocket at all ('cut'). + One a sliver in has gone bad off the level: 0.019 mm into a snap key's recess at + 36.52 mm, with a 0.5 mm fit clearance, at four depths on main. Let in wherever + the magnet or screw stayed clear of the key or tab, 7 of 2,519 such pockets at + the default fit or tighter went bad, 0.02 to 0.14 mm in, and 8 of 1,151 at + looser fits, 0.2 to 0.65 mm in. + - A dovetail's notch takes a pocket from beneath, a sliver or deep, unless it is + level with the notch ('level') or the magnet or screw in it would reach the other + piece's tab, which stands the fit clearance inside the notch ('part'). None of + 3,699 such designs went bad, 1,086 of them on the page's design at 40.5 to + 44.5 mm. So a 12.7 mm magnet at 42 mm, 2 or 3 mm thick, is taken: its pocket is + 0.04 to 0.09 mm into the notch and the magnet 0.24 mm clear of the tab. + - A pocket from above meets any of them unless its floor stands a layer over the + cut's ceiling ('floor'). + The pocket is measured as fastenerCutter cuts it, as a polygon (boreReach), not by the + circle through its corners, which kept sizes out that came a flat's width short. + + A pocket that stops short of a cut stops MOUNT_SEAM short. The weld in healCsgSeams + takes points VTOL apart for one, and a thinner wall than a few of those can come out + welded through: 4 of 715 pockets less than 0.005 mm short went bad, and none of 1,941 + from 0.005 to 0.03 mm. Under a dovetail's notch that leaves a gap of refused sizes + below the largest (`gaps`), between the one that stops MOUNT_SEAM short and the one + that breaks in. Past the weld's reach there is still the lottery the room measured + here does not see, about one design in a thousand, single sizes with clean ones on + either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch + at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as on main, + and is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there + into the notch, and with no counterbore. A guard out that far would refuse sizes that + build clean on both sides of it and still miss the next, 0.1 mm off. A wall of 1 mm + would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm + to spare and always built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; - // { room, top }: the nearest a site comes to one cut, its ceiling + /* Each cut as { top, sites }: its ceiling, and each site in reach of it as how far a + bore's corner circle (`room`) and the bores themselves (`bore`, by their sides) can + grow before they meet the cut, and a magnet or screw (`body`) before it meets the + part in it. */ const jointCuts = again ? known.list : []; /* Room past the most the cell or the floor leaves cannot stop a size, so nothing further off than that is measured, and nothing at all where neither leaves any. A @@ -3821,10 +3878,13 @@

Your drawers

if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, - for each seam it can be cut from. Every cut from one seam is the same solid moved - along it (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once - and each site is moved the other way instead. */ + for each seam it can be cut from, and the part's that goes in it: the key's half, + or the tab of the piece across the seam, as buildPiece stands it there, the fit + clearance inside the cut. Every cut from one seam is the same solid moved along it + (keyHalf, puzzleShape, tabNotch), so it is worked out at the origin once and each + site is moved the other way instead. */ const shapes = {}; + const ring = (pts) => pts.map((p, i) => [p, pts[(i + 1) % pts.length]]); const shapeOf = (edge) => { if (shapes[edge]) return shapes[edge]; const at = { edge, e: 0, s: 0 }; @@ -3843,7 +3903,10 @@

Your drawers

const a = p.verts[0], b = p.verts.find((v) => Math.hypot(v[0] - a[0], v[1] - a[1]) > 1e-9); if (b) segs.push([a, b]); } - return (shapes[edge] = { segs, bb, ceiling }); + const part = plan.kind === 'recess' ? keyHalf(plan.shape, edge, 0, 0, plan.prm, 0) + : cfg.connector === 'puzzle' ? puzzleShape(OPP[edge], 0, 0, cfg.puzzle, 0, false) + : tabFootprint(OPP[edge], 0, 0, cfg.tab.wr, cfg.tab.wt, cfg.tab.dp, 0.8); + return (shapes[edge] = { segs, bb, ceiling, part: ring(part) }); }; // how far a point is from the footprint, less than none inside it const from = (segs, x, y) => { @@ -3862,7 +3925,7 @@

Your drawers

const cuts = [...conn.notches, ...conn.pnotches, ...(plan.kind !== 'recess' ? [] : conn.keyed.filter((bo) => !(plan.junction && offJunction(bo, cfg.pitch, piece))))]; for (const bo of cuts) { - const { segs, bb, ceiling } = shapeOf(bo.edge); + const { segs, bb, ceiling, part } = shapeOf(bo.edge); const across = bo.edge === '+x' || bo.edge === '-x'; const ox = across ? bo.e : bo.s, oy = across ? bo.s : bo.e; // the whole cells with a site in reach of it (a half cell has none; see buildPiece) @@ -3870,40 +3933,98 @@

Your drawers

Math.min(n - 1, Math.ceil((hi + reach + off - half - m) / cfg.pitch))]; const [i0, i1] = cells(bb[0] + ox, bb[2] + ox, piece.mL, piece.nx); const [j0, j1] = cells(bb[1] + oy, bb[3] + oy, piece.mF, piece.ny); - let room = Infinity; + const sites = []; for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) for (const sx of [-1, 1]) for (const sy of [-1, 1]) { const x = piece.mL + i*cfg.pitch + half + sx*off - ox; const y = piece.mF + j*cfg.pitch + half + sy*off - oy; if (x < bb[0] - reach || x > bb[2] + reach || y < bb[1] - reach || y > bb[3] + reach) continue; - room = Math.min(room, from(segs, x, y)); + // the bores and the part stand further off than the corner circle, or as far + const room = from(segs, x, y); + if (room >= reach) continue; + const bore = (n) => room > 0 ? boreReach(n, segs, x, y) : room; + sites.push({ room, body: from(part, x, y), bore: { 12: bore(12), 14: bore(14) } }); } - jointCuts.push({ room, top: ceiling }); + if (sites.length) jointCuts.push({ top: ceiling, sites }); + } + } + } + /* The bores as fastenerCutter cuts them, in one place: how many sides, and the largest + size whose corners stay inside a radius. A magnet's corners are 0.1 mm over its + radius, or out to where its flats stand on that radius if that is further; a screw's + bores have their corners on its size. */ + const BORE = { + magnetD: { sides: 14, fits: (r) => 2 * Math.min(r - 0.1, r * Math.cos(Math.PI / 14)) }, + screwHeadD: { sides: 14, fits: (r) => 2 * r }, + screwHoleD: { sides: 12, fits: (r) => 2 * r }, + }; + // the room the cell, the floor or a boss leaves, and the hole beside + const own = { magnetD: fit(cfg.magnetSide === 'top' ? top : under), screwHoleD: fit(top), screwHeadD: fit(under) }; + // a dovetail's notch takes a pocket from beneath that breaks into it; every other cut does not + const notch = cfg.connector === 'dovetail'; + /* What the joint's cuts leave one size, as { cap, why, near }: the largest size, and what + stops it: 'cut', a pocket that would break into a key's recess or a puzzle tab's notch; + 'floor', one from above that leaves no layer of floor over a cut; 'level', one from + beneath as deep as a dovetail's notch; 'part', a magnet or screw that would reach the + tab in one. Each stops MOUNT_SEAM short of the cut. `near` is where that leaves sizes + under the cap refused, as [from, to]: a dovetail's notch, which a pocket may break + into, but not stop just short of. */ + const jointFor = (f) => { + const { sides, fits } = BORE[f]; + const above = f === 'magnetD' && cfg.magnetSide === 'top'; + // how high a pocket from beneath goes; a shank goes through + const ceiling = f === 'magnetD' ? cfg.magnetH : f === 'screwHeadD' ? cfg.screwHeadDepth : Infinity; + let cap = Infinity, why = false; + const near = []; + for (const c of jointCuts) { + // a pocket from above clears a cut whose ceiling it leaves a layer of floor over + if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; + const stop = above ? 'floor' : !notch ? 'cut' : Math.abs(ceiling - c.top) < MOUNT_LEVEL ? 'level' : 'part'; + for (const s of c.sites) { + const short = fits(s.bore[sides] - MOUNT_SEAM); + const size = stop === 'part' ? 2 * s.body : short; + if (size < cap) { cap = size; why = stop; } + if (stop === 'part') near.push([short, fits(s.bore[sides])]); } } + return { cap, why, near }; + }; + const sizes = {}, joint = {}, gaps = {}; + for (const f of ['magnetD', 'screwHoleD', 'screwHeadD']) { + const cell = BORE[f].fits(own[f]), J = jointFor(f); + let size = r10(Math.min(cell, J.cap)); + joint[f] = J.cap < cell && J.why; + /* The sizes `near` refuses, out to the tenths either side, as the cap is: each gap is + [from, to], both taken. One that reaches the cap brings it down to where it starts. */ + const out = []; + for (const [a, b] of J.near.sort((x, y) => x[0] - y[0])) { + const from = r10(a), to = (Math.floor(b * 10 + 1e-9) + 1) / 10; + if (to <= 0) continue; + if (out.length && from < out[out.length - 1][1]) out[out.length - 1][1] = Math.max(out[out.length - 1][1], to); + else out.push([from, to]); + } + gaps[f] = []; + for (const [from, to] of out) { + if (from >= size) break; + if (to > size) { size = from; joint[f] = 'near'; break; } + gaps[f].push([from, to]); + } + sizes[f] = size; } - // the nearest the cuts come that a pocket with its floor at z meets - const jointRoom = (z) => jointCuts.reduce((m, c) => - c.top + MOUNT_SKIN > z + 1e-6 ? Math.min(m, c.room) : m, Infinity); - const below = jointRoom(-Infinity); // a magnet from beneath, a counterbore, a shank - const magnetJoint = cfg.magnetSide === 'top' && jointCuts.length - ? jointRoom(pad - cfg.magnetH) : below; - const own = fit(cfg.magnetSide === 'top' ? top : under); - const room = Math.min(own, magnetJoint); return { - // a magnet pocket's corners are 0.1 mm over the magnet's radius, or out to where its - // flats stand on that radius if that is further (fastenerCutter) - magnetD: r10(2 * Math.min(room - 0.1, room * Math.cos(Math.PI / 14))), - // a screw's bores have their corners on its size - screwHoleD: r10(2 * Math.min(fit(top), below)), - screwHeadD: r10(2 * Math.min(fit(under), below)), + magnetD: sizes.magnetD, + screwHoleD: sizes.screwHoleD, + screwHeadD: sizes.screwHeadD, // in the solid floor the pad grows to suit, so only a boss caps the depth depth: bosses ? r10(BOSS_H - MOUNT_SKIN) : Infinity, // which of the sizes the cut beside it stops, rather than the floor, cell or boss - beside: { magnetD: room === beside, screwHoleD: top >= beside && below >= beside, - screwHeadD: under >= beside && below >= beside }, - // and which a joint's cut stops, before any of those - joint: { magnetD: magnetJoint < own, screwHoleD: below < fit(top), screwHeadD: below < fit(under) }, + beside: { magnetD: own.magnetD === beside && !joint.magnetD, + screwHoleD: own.screwHoleD === beside && !joint.screwHoleD, + screwHeadD: own.screwHeadD === beside && !joint.screwHeadD }, + // and which a joint's cut stops, before any of those, and how (jointFor) + joint, + // sizes under the largest refused all the same, as [from, to] with both ends taken + gaps, // what was measured of the joint's cuts, for `known` cuts: { pad, list: jointCuts }, }; @@ -7420,7 +7541,8 @@

Your drawers

* off, nor margins outside Custom, because a complaint about a field you cannot see is * one you cannot act on. `why` finishes the too-big message where "check the figure is * in millimetres" would be the wrong advice, and `off` names the switch that drops a cut - * the pitch has no room for. */ + * the pitch has no room for. `gaps` are sizes under `max` refused all the same, as + * [from, to] with both ends taken. */ const RANGES = PLATE_RANGES; const customMargins = () => state.marginMode === 'custom' && !state.noMargin; /* The sizes a joint's cut in the floor leaves room for depend on where the seams are and @@ -7438,15 +7560,33 @@

Your drawers

// "an 18 mm pitch", "an 80 mm pitch": the article goes by how the number is said const atPitch = () => `at ${/^(8|1[18](\.|$))/.test(String(state.pitch)) ? 'an' : 'a'} ` + `${state.pitch} mm pitch`; -const mountWhy = (opens, field) => `${atPitch()} — mounting holes sit ` + - `${state.holeOffset} mm from each cell centre, where the Gridfinity spec puts them, and ` + - (mount().joint[field] ? `a hole has to stay out of the ` + - `${['dovetail', 'puzzle'].includes(state.connector) ? 'notches' : 'recesses'} the ` + - `${CONNECTOR_NAMES[state.connector]} fit into` - : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' - : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' - : opens ? 'a cut open to the socket has to stay on the socket floor' - : 'a pocket under the floor has to stay inside its cell'); +// a joint's cut in the floor, as the messages name it: "the notches the dovetail tabs fit into" +const cutsNamed = () => `${['dovetail', 'puzzle'].includes(state.connector) ? 'notches' : 'recesses'} the ` + + `${CONNECTOR_NAMES[state.connector]} fit into`; +/* Why `field` stops where it does. A joint's cut stops it in one of the ways mountLimits' + `joint` names: a pocket from beneath as deep as a dovetail's notch, a magnet or screw + that would reach the tab in one, a pocket any wider coming too near the notch's edge, + or any other hole breaking into the cut. */ +const mountWhy = (opens, field) => { + const joint = mount().joint[field]; + const cuts = cutsNamed(); + return `${atPitch()} — mounting holes sit ` + + `${state.holeOffset} mm from each cell centre, where the Gridfinity spec puts them, and ` + + (joint === 'level' ? `a pocket ${field === 'magnetD' ? state.magnetH : state.screwHeadDepth} mm deep, ` + + `as deep as the ${cuts}, has to stay out of them` + : joint === 'part' ? `${{ magnetD: 'a magnet', screwHeadD: 'a screw head', screwHoleD: 'a screw' }[field]} ` + + `has to stay clear of the ${CONNECTOR_NAMES[state.connector]} in the notches beside it` + : joint === 'near' ? `a pocket any wider would come too near the edge of the ${cuts} to cut cleanly` + : joint ? `a hole has to stay out of the ${cuts}` + : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' + : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' + : opens ? 'a cut open to the socket has to stay on the socket floor' + : 'a pocket under the floor has to stay inside its cell') + + (joint && KEYED.includes(state.connector) && !keyFromTop() + ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above leave the floor clear` : ''); +}; +// why a size under the largest is refused (mountLimits' `gaps`) +const nearWhy = () => `${atPitch()} — its pocket would come too near the edge of the ${cutsNamed()} to cut cleanly`; const bossDepth = () => state.baseMode === 'bosses' ? 'with corner pockets — a boss is 2.6 mm tall, while the solid floor grows to suit' : ''; const LIMITS = { @@ -7473,13 +7613,16 @@

Your drawers

tooSmall: 'at 0 the rim between sockets is a face with no width, and the plate comes out open', why: () => '— past that a spec bin rides on the rim instead of seating in its socket' }, magnetD: { ...RANGES.magnetD, max: () => mount().magnetD, label: 'Magnet Ø', when: () => state.magnets, - why: () => mountWhy(state.magnetSide === 'top', 'magnetD'), off: 'magnet pockets' }, + why: () => mountWhy(state.magnetSide === 'top', 'magnetD'), off: 'magnet pockets', + gaps: () => mount().gaps.magnetD }, magnetH: { ...RANGES.magnetH, max: () => Math.min(RANGES.magnetH.max, mountDepth()), label: 'Magnet depth', when: () => state.magnets, why: bossDepth }, screwHoleD: { ...RANGES.screwHoleD, max: () => mount().screwHoleD, label: 'Screw hole Ø', - when: () => state.screws, why: () => mountWhy(true, 'screwHoleD'), off: 'screw holes' }, + when: () => state.screws, why: () => mountWhy(true, 'screwHoleD'), off: 'screw holes', + gaps: () => mount().gaps.screwHoleD }, screwHeadD: { ...RANGES.screwHeadD, max: () => mount().screwHeadD, label: 'Screw head Ø', - when: () => state.screws, why: () => mountWhy(false, 'screwHeadD'), off: 'screw holes' }, + when: () => state.screws, why: () => mountWhy(false, 'screwHeadD'), off: 'screw holes', + gaps: () => mount().gaps.screwHeadD }, screwHeadDepth: { ...RANGES.screwHeadDepth, max: () => Math.min(RANGES.screwHeadDepth.max, mountDepth()), label: 'Screw head depth', when: () => state.screws, why: bossDepth }, // each joint's ceiling is its own, so none is held to another's reason; see clrWhy @@ -7586,6 +7729,14 @@

Your drawers

(why ? `${why}.` : `— check the figure is in ${unitName}.`)); return hi; } + /* A size under the largest can be refused as well, where its pocket would come too near + the edge of a dovetail's notch (mountLimits' `gaps`); the sizes either side are taken. */ + const gap = inPlay && lim.gaps && lim.gaps().find(([a, b]) => v > a && v < b); + if (gap) { + say(`${lim.label} of ${both(v)} is refused ${nearWhy()}. Use ${both(gap[0])} or less, ` + + `or ${both(gap[1])} or more.`); + return gap[0]; + } return v; } /* The invalid state is set on the element rather than through a class, because the diff --git a/sw.js b/sw.js index 5b5794f..cbbadc1 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "1fc8f295e0d4"; +const VERSION = "606285c4d6be"; const FILES = [ "./", "bins/", From b5d13a5cb712d0e3b709a92275d0ce7de887ef2c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 13:14:10 +0000 Subject: [PATCH 12/15] Wrap the P4 sentence to the comment's width Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 11 ++++++----- src/core.js | 15 ++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index 0617c38..6d80ab6 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -785,11 +785,12 @@ currently installed): refused sizes below the largest, between the pocket that stops 0.01 mm short and the one that breaks in; the page says so at the field. Past the weld's reach there is still the lottery the room cannot see, about one design in a thousand, single sizes with clean - ones on either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch - at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as main does, and - is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there into - the notch, and with no counterbore. A guard out that far would refuse sizes that build - clean on both sides of it and still miss the next, 0.1 mm off. + ones on either side, and it needs the pocket and the cut together: a 14.1 mm + counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch at 43.17 mm, loose, + folds an edge at the notch's corner, byte for byte as main does, and is clean at 2.35 mm + deep, at 14.075 and 14.125 mm across, at every size from there into the notch, and with + no counterbore. A guard out that far would refuse sizes that build clean on both sides + of it and still miss the next, 0.1 mm off. - **A joint's cut is the same lottery, and below 16 mm it comes up often.** The socket's straight walls run only 2.5 mm either side of a cell's middle at 13.5 mm, so every housing, notch and clip pocket crosses its corner arcs and cones, at points that move diff --git a/src/core.js b/src/core.js index ff4c2c1..b60cd2b 100644 --- a/src/core.js +++ b/src/core.js @@ -2464,13 +2464,14 @@ function mountLimits(cfg, layout, known) { below the largest (`gaps`), between the one that stops MOUNT_SEAM short and the one that breaks in. Past the weld's reach there is still the lottery the room measured here does not see, about one design in a thousand, single sizes with clean ones on - either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch - at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as on main, - and is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there - into the notch, and with no counterbore. A guard out that far would refuse sizes that - build clean on both sides of it and still miss the next, 0.1 mm off. A wall of 1 mm - would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm - to spare and always built clean. */ + either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 + to 3 mm deep, 0.09 mm short of a dovetail's notch at 43.17 mm, loose, folds an edge + at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, at + 14.075 and 14.125 mm across, at every size from there into the notch, and with no + counterbore. A guard out that far would refuse sizes that build clean on both sides + of it and still miss the next, 0.1 mm off. A wall of 1 mm would refuse the 6 mm + magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always + built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; /* Each cut as { top, sites }: its ceiling, and each site in reach of it as how far a bore's corner circle (`room`) and the bores themselves (`bore`, by their sides) can From 7657e76d82b76b08f70c92e01f9f519ead704add Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 13:14:10 +0000 Subject: [PATCH 13/15] Rebuild the pages Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- bins/index.html | 15 ++++++++------- index.html | 15 ++++++++------- sw.js | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bins/index.html b/bins/index.html index 1d1af58..695041b 100644 --- a/bins/index.html +++ b/bins/index.html @@ -4070,13 +4070,14 @@

Your drawers

below the largest (`gaps`), between the one that stops MOUNT_SEAM short and the one that breaks in. Past the weld's reach there is still the lottery the room measured here does not see, about one design in a thousand, single sizes with clean ones on - either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch - at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as on main, - and is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there - into the notch, and with no counterbore. A guard out that far would refuse sizes that - build clean on both sides of it and still miss the next, 0.1 mm off. A wall of 1 mm - would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm - to spare and always built clean. */ + either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 + to 3 mm deep, 0.09 mm short of a dovetail's notch at 43.17 mm, loose, folds an edge + at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, at + 14.075 and 14.125 mm across, at every size from there into the notch, and with no + counterbore. A guard out that far would refuse sizes that build clean on both sides + of it and still miss the next, 0.1 mm off. A wall of 1 mm would refuse the 6 mm + magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always + built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; /* Each cut as { top, sites }: its ceiling, and each site in reach of it as how far a bore's corner circle (`room`) and the bores themselves (`bore`, by their sides) can diff --git a/index.html b/index.html index 9b379f0..ee86cc9 100644 --- a/index.html +++ b/index.html @@ -3857,13 +3857,14 @@

Your drawers

below the largest (`gaps`), between the one that stops MOUNT_SEAM short and the one that breaks in. Past the weld's reach there is still the lottery the room measured here does not see, about one design in a thousand, single sizes with clean ones on - either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch - at 43.17 mm, loose, folds an edge at the notch's corner, byte for byte as on main, - and is clean at 2.35 mm deep, at 14.075 and 14.125 mm across, at every size from there - into the notch, and with no counterbore. A guard out that far would refuse sizes that - build clean on both sides of it and still miss the next, 0.1 mm off. A wall of 1 mm - would refuse the 6 mm magnet from beneath with a bowtie at 42 mm, which has 0.84 mm - to spare and always built clean. */ + either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 + to 3 mm deep, 0.09 mm short of a dovetail's notch at 43.17 mm, loose, folds an edge + at the notch's corner, byte for byte as on main, and is clean at 2.35 mm deep, at + 14.075 and 14.125 mm across, at every size from there into the notch, and with no + counterbore. A guard out that far would refuse sizes that build clean on both sides + of it and still miss the next, 0.1 mm off. A wall of 1 mm would refuse the 6 mm + magnet from beneath with a bowtie at 42 mm, which has 0.84 mm to spare and always + built clean. */ const pad = platePad(cfg), again = !!known && known.pad === pad; /* Each cut as { top, sites }: its ceiling, and each site in reach of it as how far a bore's corner circle (`room`) and the bores themselves (`bore`, by their sides) can diff --git a/sw.js b/sw.js index cbbadc1..fe7e827 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "606285c4d6be"; +const VERSION = "a4f5f4b84bfe"; const FILES = [ "./", "bins/", From 8c020592bb7adc650f4c4d58cc9d7b053e455edd Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 15:01:27 +0000 Subject: [PATCH 14/15] Round a dovetail's refused sizes to hundredths and name the sizes taken The sizes a pocket may not stop just short of a dovetail's notch at are a window about 0.02 mm wide, and mountLimits rounded each one out to the tenths, as the cap is: at 36 mm on the page's design 5.51 to 5.69 and 5.71 to 5.79 mm were refused, where the windows are near 5.6 and 5.73. The field takes hundredths, so the gaps are now rounded out to the hundredth: 5.59, 5.6, 5.73 and 5.74 are refused there, and 5.65 and 5.75 are taken and build watertight. At 42 mm, 12.51, 12.52, 12.61 and 12.62. The advice for a size in a gap named the sizes either side of that one gap, and two gaps can meet at one size: at 36 mm, 5.65 said "5.7 mm or more" and 5.75 was refused next. It now names the sizes taken round the run of gaps: "Use 11.89 mm or less, 11.92 mm, or 11.95 mm or more" at 41.49 mm. Over the page's design from 30 to 56 mm every 0.01, at three clearances, two gaps meet in 298 of 7,546 fields with gaps, against 2,727 of 7,498 rounded to tenths. A gap can start under the field's least (a 1 mm magnet at 31 mm with no clearance said "Use 0.9 mm or less"); the advice keeps inside the field's range: "Use 1.01 mm, or 1.04 mm or more". A notch's ceiling is 2.2 + 0.2, 2.4000000000000004 as summed, so a pocket 2.35 mm deep was taken and one 2.45 mm deep was called level. The ceiling is kept to the micron and the distance measured to the micron, so both are taken; 12.7 x 2.45 at 42 mm builds watertight. The hint for a key put in from beneath now says what it buys: keys housed inside the walls and put in from above keep out of the solid floor under these pockets. The audit takes 12.7 x 2.45 at 42 mm and 5.65 at 36 mm, both refused before; the page refuses 5.6 at 36 mm with the new sizes, and the two new advice cases. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- docs/ENGINE.md | 8 ++++++-- src/core.js | 21 +++++++++++++++------ src/ui.js | 28 +++++++++++++++++++++------- test/plate-audit.js | 11 +++++++---- test/ui/plates-robustness.spec.js | 10 ++++++++-- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/docs/ENGINE.md b/docs/ENGINE.md index 6d80ab6..cc15ae4 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -768,7 +768,8 @@ currently installed): clear of the key or tab, 7 of 2,519 such pockets at the default fit or tighter went bad (0.02 to 0.14 mm in), and 8 of 1,151 at looser fits (0.2 to 0.65 mm in). - **A dovetail's notch takes a pocket from beneath**, a sliver or deep, unless it is - level with the notch or the magnet or screw in it would reach the other piece's tab, + level with the notch (within 0.05 mm either way, `MOUNT_LEVEL`, measured to the + micron) or the magnet or screw in it would reach the other piece's tab, which stands the fit clearance inside the notch. None of 3,699 such designs went bad, 1,086 of them on the page's design at 40.5 to 44.5 mm. A 12.7 mm magnet at 42 mm, 2 or 3 mm thick, is taken: its pocket is 0.04 to 0.09 mm into the notch and the magnet @@ -783,7 +784,10 @@ currently installed): through. 4 of 715 pockets less than 0.005 mm short went bad, and none of 1,941 from 0.005 to 0.03 mm. Under a dovetail's notch that leaves a few hundredths of a millimetre of refused sizes below the largest, between the pocket that stops 0.01 mm short and the one - that breaks in; the page says so at the field. Past the weld's reach there is still the + that breaks in, about 0.02 mm wide and rounded out to the hundredth either side, as the + field takes them: at 36 mm on the page's design 5.59, 5.6, 5.73 and 5.74 mm are refused, + and 5.58, 5.61, 5.72 and 5.75 are taken. The page says so at the field and names the + sizes taken either side. Past the weld's reach there is still the lottery the room cannot see, about one design in a thousand, single sizes with clean ones on either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch at 43.17 mm, loose, diff --git a/src/core.js b/src/core.js index b60cd2b..944947a 100644 --- a/src/core.js +++ b/src/core.js @@ -2405,7 +2405,7 @@ function mountLimits(cfg, layout, known) { const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL; const bosses = cfg.baseMode === 'bosses'; const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell; - const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // the fields step in tenths + const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // a cap is given in tenths, rounded down /* A cell's four sites are 2 × holeOffset apart, 26 mm, so past a pitch of about 50 mm the room above lets a cut reach the one beside it before it reaches anything else: two 1-inch magnet pockets met at a 55 mm pitch and left 52 open edges. Each cut stops @@ -2514,7 +2514,9 @@ function mountLimits(cfg, layout, known) { const part = plan.kind === 'recess' ? keyHalf(plan.shape, edge, 0, 0, plan.prm, 0) : cfg.connector === 'puzzle' ? puzzleShape(OPP[edge], 0, 0, cfg.puzzle, 0, false) : tabFootprint(OPP[edge], 0, 0, cfg.tab.wr, cfg.tab.wt, cfg.tab.dp, 0.8); - return (shapes[edge] = { segs, bb, ceiling, part: ring(part) }); + // the ceiling to the micron: a notch's is 2.2 + 0.2, 2.4000000000000004 as summed + const roof = Math.round(ceiling * 1e6) / 1e6; + return (shapes[edge] = { segs, bb, ceiling: roof, part: ring(part) }); }; // how far a point is from the footprint, less than none inside it const from = (segs, x, y) => { @@ -2587,7 +2589,12 @@ function mountLimits(cfg, layout, known) { for (const c of jointCuts) { // a pocket from above clears a cut whose ceiling it leaves a layer of floor over if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; - const stop = above ? 'floor' : !notch ? 'cut' : Math.abs(ceiling - c.top) < MOUNT_LEVEL ? 'level' : 'part'; + /* Level within MOUNT_LEVEL, measured to the micron, so a pocket that far above the + notch's ceiling and one that far below it are taken alike: 2.35 and 2.45 mm deep + against a notch 2.4 mm high, which both build clean. Unrounded, 2.45 counted as + level, and with the ceiling alone rounded 2.35 would. */ + const level = Math.round(Math.abs(ceiling - c.top) * 1e6) / 1e6 < MOUNT_LEVEL; + const stop = above ? 'floor' : !notch ? 'cut' : level ? 'level' : 'part'; for (const s of c.sites) { const short = fits(s.bore[sides] - MOUNT_SEAM); const size = stop === 'part' ? 2 * s.body : short; @@ -2602,11 +2609,13 @@ function mountLimits(cfg, layout, known) { const cell = BORE[f].fits(own[f]), J = jointFor(f); let size = r10(Math.min(cell, J.cap)); joint[f] = J.cap < cell && J.why; - /* The sizes `near` refuses, out to the tenths either side, as the cap is: each gap is - [from, to], both taken. One that reaches the cap brings it down to where it starts. */ + /* The sizes `near` refuses, out to the hundredths either side, since the field takes + hundredths: each gap is [from, to], both taken. A window is about 0.02 mm wide, so + rounded out to the tenths as the cap is, it refused up to a tenth that builds clean + (5.51 to 5.69 at 36 mm). One that reaches the cap brings it down to where it starts. */ const out = []; for (const [a, b] of J.near.sort((x, y) => x[0] - y[0])) { - const from = r10(a), to = (Math.floor(b * 10 + 1e-9) + 1) / 10; + const from = Math.floor(a * 100 + 1e-9) / 100, to = (Math.floor(b * 100 + 1e-9) + 1) / 100; if (to <= 0) continue; if (out.length && from < out[out.length - 1][1]) out[out.length - 1][1] = Math.max(out[out.length - 1][1], to); else out.push([from, to]); diff --git a/src/ui.js b/src/ui.js index 9b27609..21d5ab1 100644 --- a/src/ui.js +++ b/src/ui.js @@ -118,7 +118,8 @@ const mountWhy = (opens, field) => { : opens ? 'a cut open to the socket has to stay on the socket floor' : 'a pocket under the floor has to stay inside its cell') + (joint && KEYED.includes(state.connector) && !keyFromTop() - ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above leave the floor clear` : ''); + ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above ` + + 'keep out of the solid floor under these pockets' : ''); }; // why a size under the largest is refused (mountLimits' `gaps`) const nearWhy = () => `${atPitch()} — its pocket would come too near the edge of the ${cutsNamed()} to cut cleanly`; @@ -265,12 +266,25 @@ function readNumber(id) { return hi; } /* A size under the largest can be refused as well, where its pocket would come too near - the edge of a dovetail's notch (mountLimits' `gaps`); the sizes either side are taken. */ - const gap = inPlay && lim.gaps && lim.gaps().find(([a, b]) => v > a && v < b); - if (gap) { - say(`${lim.label} of ${both(v)} is refused ${nearWhy()}. Use ${both(gap[0])} or less, ` + - `or ${both(gap[1])} or more.`); - return gap[0]; + the edge of a dovetail's notch (mountLimits' `gaps`); the sizes either side are taken. + Two gaps can meet at one taken size, so the advice names the sizes taken round the + run of gaps the size is in, inside the field's range: "Use 11.89 mm or less, 11.92 mm, + or 11.95 mm or more" at 41.49 mm, never a size in the next gap, under the field's least + or over its largest. */ + const gaps = inPlay && lim.gaps ? lim.gaps() : []; + const at = gaps.findIndex(([a, b]) => v > a && v < b); + if (at >= 0) { + let i = at, j = at; + while (i > 0 && gaps[i - 1][1] >= gaps[i][0] - 1e-9) i--; + while (j < gaps.length - 1 && gaps[j + 1][0] <= gaps[j][1] + 1e-9) j++; + const ok = []; + if (gaps[i][0] > lo) ok.push(`${both(gaps[i][0])} or less`); + else if (gaps[i][0] === lo) ok.push(both(lo)); + for (let k = i; k < j; k++) if (gaps[k][1] >= lo) ok.push(both(gaps[k][1])); + ok.push(gaps[j][1] < hi ? `${both(gaps[j][1])} or more` : both(gaps[j][1])); + say(`${lim.label} of ${both(v)} is refused ${nearWhy()}. Use ` + + (ok.length > 1 ? `${ok.slice(0, -1).join(', ')}, or ${ok[ok.length - 1]}` : ok[0]) + '.'); + return gaps[at][0] >= lo ? gaps[at][0] : gaps[at][1]; } return v; } diff --git a/test/plate-audit.js b/test/plate-audit.js index 4087fa4..ba25df4 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -2049,10 +2049,11 @@ console.log('\nthe other limits, built at their ends:'); from beneath that breaks into it, unless the two ceilings are level or the magnet reaches the tab: the half-inch magnet on the page's default design at 42 mm, 2 and 3 mm thick, has to be taken and come out watertight; 2.4 thick, level with the - notch, it built 96 bad edges and has to be refused; and 13.2 mm, 2 thick, builds - clean but would touch the tab. At 36 mm a 5.6 mm magnet's pocket would stand right - on the notch's wall, under MOUNT_SEAM from it, so it is refused there (a gap) and - 5.7, which breaks in, is taken. Any other cut takes none: the snap clip at 36.52 mm + notch, it built 96 bad edges and has to be refused, but 2.45 thick, as far off level + as 2.35, is taken; and 13.2 mm, 2 thick, builds clean but would touch the tab. At + 36 mm a 5.6 mm magnet's pocket would stand right on the notch's wall, under + MOUNT_SEAM from it, so it is refused there (a gap), and 5.65 and 5.7, which break in, + are taken. Any other cut takes none: the snap clip at 36.52 mm is the review's, a 1.5 mm magnet at a fit clearance of 0.5 whose pocket is only 0.019 mm into the recess, and main built it with 6 bad edges at 2.5 mm deep (and at 1.9, 2.1 and 2.4). The refused ones are built too, to show what main would have, but @@ -2065,8 +2066,10 @@ console.log('\nthe other limits, built at their ends:'); ['dovetail, 12.7 x 2, page', { ...PAGE, magnetH: 2 }, 'magnetD', 12.7, false], ['dovetail, 12.7 x 3, page', { ...PAGE, magnetH: 3 }, 'magnetD', 12.7, false], ['dovetail, 12.7 x 2.4, page', { ...PAGE, magnetH: 2.4 }, 'magnetD', 12.7, 'level'], + ['dovetail, 12.7 x 2.45, page', { ...PAGE, magnetH: 2.45 }, 'magnetD', 12.7, false], ['dovetail, 13.2 x 2, page', { ...PAGE, magnetH: 2 }, 'magnetD', 13.2, 'part'], ['dovetail, 5.6 x 2, page, 36', { ...PAGE, pitch: 36, magnetH: 2 }, 'magnetD', 5.6, 'gap'], + ['dovetail, 5.65 x 2, page, 36', { ...PAGE, pitch: 36, magnetH: 2 }, 'magnetD', 5.65, false], ['dovetail, 5.7 x 2, page, 36', { ...PAGE, pitch: 36, magnetH: 2 }, 'magnetD', 5.7, false], ['snap, 1.5 x 2.5, 36.52', SNAP, 'magnetD', 1.5, 'cut']]) { const cfg = designCfg(sized(o, f, d)); diff --git a/test/ui/plates-robustness.spec.js b/test/ui/plates-robustness.spec.js index 4f7adde..0e8ea58 100644 --- a/test/ui/plates-robustness.spec.js +++ b/test/ui/plates-robustness.spec.js @@ -110,7 +110,7 @@ test.describe('ranges on the geometry fields', () => { beneath reached a bowtie's recess at 42 mm, and the plate built with 19 bad edges a piece and Download on; from above, an 8 mm one stood over the key. */ [`${BOWTIE_42}&mg=1&md=10`, 'errMagnet', - /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — mounting holes sit 13 mm from each cell centre, where the Gridfinity spec puts them, and a hole has to stay out of the recesses the bowtie keys fit into; keys housed inside the walls and put in from above leave the floor clear\./], + /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — mounting holes sit 13 mm from each cell centre, where the Gridfinity spec puts them, and a hole has to stay out of the recesses the bowtie keys fit into; keys housed inside the walls and put in from above keep out of the solid floor under these pockets\./], [`${BOWTIE_42}&mg=1&ms=top&md=8`, 'errMagnet', /Magnet Ø must be 7\.6 mm or less at a 42 mm pitch — .* the recesses the bowtie keys fit into/], [`${BOWTIE_42.replace('cn=bowtie', 'cn=snap')}&sc=1&sd=10`, 'errScrew', @@ -123,7 +123,13 @@ test.describe('ranges on the geometry fields', () => { ['#mg=1&mh=2.4&md=13', 'errMagnet', /Magnet Ø must be 12\.5 mm or less at a 42 mm pitch — .* a pocket 2\.4 mm deep, as deep as the notches the dovetail tabs fit into, has to stay out of them\./], ['#pi=36&mg=1&md=5.6', 'errMagnet', - /Magnet Ø of 5\.6 mm is refused at a 36 mm pitch — its pocket would come too near the edge of the notches the dovetail tabs fit into to cut cleanly\. Use 5\.5 mm or less, or 5\.7 mm or more\./], + /Magnet Ø of 5\.6 mm is refused at a 36 mm pitch — its pocket would come too near the edge of the notches the dovetail tabs fit into to cut cleanly\. Use 5\.58 mm or less, or 5\.61 mm or more\./], + /* Two gaps can meet at one size, taken between them, and the advice names it rather + than pointing into the next gap; nor does it name a size under the field's least. */ + ['#pi=41.49&mg=1&md=11.93', 'errMagnet', + /Magnet Ø of 11\.93 mm is refused at a 41\.49 mm pitch — .* Use 11\.89 mm or less, 11\.92 mm, or 11\.95 mm or more\./], + ['#pi=31&cl=0&mg=1&md=1', 'errMagnet', + /Magnet Ø of 1 mm is refused at a 31 mm pitch — .* Use 1\.01 mm, or 1\.04 mm or more\./], ]; for (const [hash, errId, msg] of CASES) { test(`${hash} is refused at the field`, async ({ page }) => { From c6d6ada898a00aa0992761cabc6bb619836e3a15 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 15:01:31 +0000 Subject: [PATCH 15/15] Rebuild the pages Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uqqb1cvhXxrpb3P6y6ykBY --- bins/index.html | 21 +++++++++++++++------ index.html | 49 ++++++++++++++++++++++++++++++++++++------------- sw.js | 2 +- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/bins/index.html b/bins/index.html index 695041b..b4927b6 100644 --- a/bins/index.html +++ b/bins/index.html @@ -4011,7 +4011,7 @@

Your drawers

const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL; const bosses = cfg.baseMode === 'bosses'; const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell; - const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // the fields step in tenths + const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // a cap is given in tenths, rounded down /* A cell's four sites are 2 × holeOffset apart, 26 mm, so past a pitch of about 50 mm the room above lets a cut reach the one beside it before it reaches anything else: two 1-inch magnet pockets met at a 55 mm pitch and left 52 open edges. Each cut stops @@ -4120,7 +4120,9 @@

Your drawers

const part = plan.kind === 'recess' ? keyHalf(plan.shape, edge, 0, 0, plan.prm, 0) : cfg.connector === 'puzzle' ? puzzleShape(OPP[edge], 0, 0, cfg.puzzle, 0, false) : tabFootprint(OPP[edge], 0, 0, cfg.tab.wr, cfg.tab.wt, cfg.tab.dp, 0.8); - return (shapes[edge] = { segs, bb, ceiling, part: ring(part) }); + // the ceiling to the micron: a notch's is 2.2 + 0.2, 2.4000000000000004 as summed + const roof = Math.round(ceiling * 1e6) / 1e6; + return (shapes[edge] = { segs, bb, ceiling: roof, part: ring(part) }); }; // how far a point is from the footprint, less than none inside it const from = (segs, x, y) => { @@ -4193,7 +4195,12 @@

Your drawers

for (const c of jointCuts) { // a pocket from above clears a cut whose ceiling it leaves a layer of floor over if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; - const stop = above ? 'floor' : !notch ? 'cut' : Math.abs(ceiling - c.top) < MOUNT_LEVEL ? 'level' : 'part'; + /* Level within MOUNT_LEVEL, measured to the micron, so a pocket that far above the + notch's ceiling and one that far below it are taken alike: 2.35 and 2.45 mm deep + against a notch 2.4 mm high, which both build clean. Unrounded, 2.45 counted as + level, and with the ceiling alone rounded 2.35 would. */ + const level = Math.round(Math.abs(ceiling - c.top) * 1e6) / 1e6 < MOUNT_LEVEL; + const stop = above ? 'floor' : !notch ? 'cut' : level ? 'level' : 'part'; for (const s of c.sites) { const short = fits(s.bore[sides] - MOUNT_SEAM); const size = stop === 'part' ? 2 * s.body : short; @@ -4208,11 +4215,13 @@

Your drawers

const cell = BORE[f].fits(own[f]), J = jointFor(f); let size = r10(Math.min(cell, J.cap)); joint[f] = J.cap < cell && J.why; - /* The sizes `near` refuses, out to the tenths either side, as the cap is: each gap is - [from, to], both taken. One that reaches the cap brings it down to where it starts. */ + /* The sizes `near` refuses, out to the hundredths either side, since the field takes + hundredths: each gap is [from, to], both taken. A window is about 0.02 mm wide, so + rounded out to the tenths as the cap is, it refused up to a tenth that builds clean + (5.51 to 5.69 at 36 mm). One that reaches the cap brings it down to where it starts. */ const out = []; for (const [a, b] of J.near.sort((x, y) => x[0] - y[0])) { - const from = r10(a), to = (Math.floor(b * 10 + 1e-9) + 1) / 10; + const from = Math.floor(a * 100 + 1e-9) / 100, to = (Math.floor(b * 100 + 1e-9) + 1) / 100; if (to <= 0) continue; if (out.length && from < out[out.length - 1][1]) out[out.length - 1][1] = Math.max(out[out.length - 1][1], to); else out.push([from, to]); diff --git a/index.html b/index.html index ee86cc9..20920a6 100644 --- a/index.html +++ b/index.html @@ -3798,7 +3798,7 @@

Your drawers

const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL; const bosses = cfg.baseMode === 'bosses'; const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell; - const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // the fields step in tenths + const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // a cap is given in tenths, rounded down /* A cell's four sites are 2 × holeOffset apart, 26 mm, so past a pitch of about 50 mm the room above lets a cut reach the one beside it before it reaches anything else: two 1-inch magnet pockets met at a 55 mm pitch and left 52 open edges. Each cut stops @@ -3907,7 +3907,9 @@

Your drawers

const part = plan.kind === 'recess' ? keyHalf(plan.shape, edge, 0, 0, plan.prm, 0) : cfg.connector === 'puzzle' ? puzzleShape(OPP[edge], 0, 0, cfg.puzzle, 0, false) : tabFootprint(OPP[edge], 0, 0, cfg.tab.wr, cfg.tab.wt, cfg.tab.dp, 0.8); - return (shapes[edge] = { segs, bb, ceiling, part: ring(part) }); + // the ceiling to the micron: a notch's is 2.2 + 0.2, 2.4000000000000004 as summed + const roof = Math.round(ceiling * 1e6) / 1e6; + return (shapes[edge] = { segs, bb, ceiling: roof, part: ring(part) }); }; // how far a point is from the footprint, less than none inside it const from = (segs, x, y) => { @@ -3980,7 +3982,12 @@

Your drawers

for (const c of jointCuts) { // a pocket from above clears a cut whose ceiling it leaves a layer of floor over if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; - const stop = above ? 'floor' : !notch ? 'cut' : Math.abs(ceiling - c.top) < MOUNT_LEVEL ? 'level' : 'part'; + /* Level within MOUNT_LEVEL, measured to the micron, so a pocket that far above the + notch's ceiling and one that far below it are taken alike: 2.35 and 2.45 mm deep + against a notch 2.4 mm high, which both build clean. Unrounded, 2.45 counted as + level, and with the ceiling alone rounded 2.35 would. */ + const level = Math.round(Math.abs(ceiling - c.top) * 1e6) / 1e6 < MOUNT_LEVEL; + const stop = above ? 'floor' : !notch ? 'cut' : level ? 'level' : 'part'; for (const s of c.sites) { const short = fits(s.bore[sides] - MOUNT_SEAM); const size = stop === 'part' ? 2 * s.body : short; @@ -3995,11 +4002,13 @@

Your drawers

const cell = BORE[f].fits(own[f]), J = jointFor(f); let size = r10(Math.min(cell, J.cap)); joint[f] = J.cap < cell && J.why; - /* The sizes `near` refuses, out to the tenths either side, as the cap is: each gap is - [from, to], both taken. One that reaches the cap brings it down to where it starts. */ + /* The sizes `near` refuses, out to the hundredths either side, since the field takes + hundredths: each gap is [from, to], both taken. A window is about 0.02 mm wide, so + rounded out to the tenths as the cap is, it refused up to a tenth that builds clean + (5.51 to 5.69 at 36 mm). One that reaches the cap brings it down to where it starts. */ const out = []; for (const [a, b] of J.near.sort((x, y) => x[0] - y[0])) { - const from = r10(a), to = (Math.floor(b * 10 + 1e-9) + 1) / 10; + const from = Math.floor(a * 100 + 1e-9) / 100, to = (Math.floor(b * 100 + 1e-9) + 1) / 100; if (to <= 0) continue; if (out.length && from < out[out.length - 1][1]) out[out.length - 1][1] = Math.max(out[out.length - 1][1], to); else out.push([from, to]); @@ -7584,7 +7593,8 @@

Your drawers

: opens ? 'a cut open to the socket has to stay on the socket floor' : 'a pocket under the floor has to stay inside its cell') + (joint && KEYED.includes(state.connector) && !keyFromTop() - ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above leave the floor clear` : ''); + ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above ` + + 'keep out of the solid floor under these pockets' : ''); }; // why a size under the largest is refused (mountLimits' `gaps`) const nearWhy = () => `${atPitch()} — its pocket would come too near the edge of the ${cutsNamed()} to cut cleanly`; @@ -7731,12 +7741,25 @@

Your drawers

return hi; } /* A size under the largest can be refused as well, where its pocket would come too near - the edge of a dovetail's notch (mountLimits' `gaps`); the sizes either side are taken. */ - const gap = inPlay && lim.gaps && lim.gaps().find(([a, b]) => v > a && v < b); - if (gap) { - say(`${lim.label} of ${both(v)} is refused ${nearWhy()}. Use ${both(gap[0])} or less, ` + - `or ${both(gap[1])} or more.`); - return gap[0]; + the edge of a dovetail's notch (mountLimits' `gaps`); the sizes either side are taken. + Two gaps can meet at one taken size, so the advice names the sizes taken round the + run of gaps the size is in, inside the field's range: "Use 11.89 mm or less, 11.92 mm, + or 11.95 mm or more" at 41.49 mm, never a size in the next gap, under the field's least + or over its largest. */ + const gaps = inPlay && lim.gaps ? lim.gaps() : []; + const at = gaps.findIndex(([a, b]) => v > a && v < b); + if (at >= 0) { + let i = at, j = at; + while (i > 0 && gaps[i - 1][1] >= gaps[i][0] - 1e-9) i--; + while (j < gaps.length - 1 && gaps[j + 1][0] <= gaps[j][1] + 1e-9) j++; + const ok = []; + if (gaps[i][0] > lo) ok.push(`${both(gaps[i][0])} or less`); + else if (gaps[i][0] === lo) ok.push(both(lo)); + for (let k = i; k < j; k++) if (gaps[k][1] >= lo) ok.push(both(gaps[k][1])); + ok.push(gaps[j][1] < hi ? `${both(gaps[j][1])} or more` : both(gaps[j][1])); + say(`${lim.label} of ${both(v)} is refused ${nearWhy()}. Use ` + + (ok.length > 1 ? `${ok.slice(0, -1).join(', ')}, or ${ok[ok.length - 1]}` : ok[0]) + '.'); + return gaps[at][0] >= lo ? gaps[at][0] : gaps[at][1]; } return v; } diff --git a/sw.js b/sw.js index fe7e827..3af8f97 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "a4f5f4b84bfe"; +const VERSION = "d4d7bc3b8d8c"; const FILES = [ "./", "bins/",