Skip to content
110 changes: 108 additions & 2 deletions bins/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4070,7 +4070,8 @@ <h2 id="drawersTitle">Your drawers</h2>
* floor, or it crosses the floor's chamfer cone — see ENGINE.md §2;
* - under the floor (a magnet from below, the counterbore): it must stay in its cell;
* - 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 does not grow with the pocket, so it also caps the depth; and one that opens on
* the boss's top must clear the socket's rim over it (#83).
*
* 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, where a dovetail's lets a pocket from
Expand Down Expand Up @@ -4102,8 +4103,28 @@ <h2 id="drawersTitle">Your drawers</h2>
const inCell = half - off - MOUNT_WALL;
const s = half - off; // the site's distance in from the cell's edges
const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL;
/* A corner boss's hole that opens on its top, a magnet put in from above or a screw's
shank, has the socket's rim to pass on the way in or out, as one in a solid floor has
the edge of the socket floor; and over the boss the rim is the socket's wall, which
is not cut (buildPiece cuts the rim away under a boss, up to just under its top;
#83). From 0.7 mm up it stands 2.15 mm in from the cell's edges, and further in at
the socket's rounded corner, which is the way each site faces. Measured on the ring
buildPiece's profile makes (directCellRegion), polygon and all, from each of the four
sites, since its corners are not mirror images of one another, and MOUNT_SEAM short.
The boss alone took a 6 mm magnet from above at 36.13 mm with the rim 0.26 mm over
its pocket, and the default 3 mm screw at 33 mm with the rim 0.53 mm over its hole,
with Download on. */
const dMid = 2.15 + tol;
const rim = roundedRectRing(0, 0, half - dMid, half - dMid, cfg.socketRadius - (dMid - cfg.topCutoff),
cfg.arcSegs || 6);
let onRim = Infinity;
for (const [x, y] of [[off, off], [-off, off], [-off, -off], [off, -off]])
rim.forEach((a, i) => {
const b = rim[(i + 1) % rim.length], ex = b[0] - a[0], ey = b[1] - a[1];
onRim = Math.min(onRim, (ex * (y - a[1]) - ey * (x - a[0])) / Math.hypot(ex, ey) - MOUNT_SEAM);
});
const bosses = cornerBosses(cfg);
const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell;
const top = bosses ? Math.min(inBoss, onRim) : onFloor, under = bosses ? inBoss : inCell;
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:
Expand Down Expand Up @@ -4374,6 +4395,9 @@ <h2 id="drawersTitle">Your drawers</h2>
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 the socket's rim over a corner boss stops (#83)
rim: { magnetD: bosses && cfg.magnetSide === 'top' && own.magnetD === onRim && !joint.magnetD,
screwHoleD: bosses && own.screwHoleD === onRim && !joint.screwHoleD },
// which of the sizes the cut beside it stops, rather than the floor, cell or boss
beside: { magnetD: own.magnetD === beside && !joint.magnetD,
screwHoleD: own.screwHoleD === beside && !joint.screwHoleD,
Expand Down Expand Up @@ -5114,6 +5138,7 @@ <h2 id="drawersTitle">Your drawers</h2>
return polys;
};
let done = 0;
const rims = new Map(); // a whole cell's shell, by its column and row, for the corner bosses' pockets
for (let ix = 0; ix < xs.length-1; ix++) {
for (let iy = 0; iy < ys.length-1; iy++) {
let x0 = Math.max(0, xs[ix] - BLOAT), x1 = Math.min(W, xs[ix+1] + BLOAT);
Expand Down Expand Up @@ -5429,6 +5454,7 @@ <h2 id="drawersTitle">Your drawers</h2>
jointCells.push(cell);
}
if (cellFastener) region = settle(cell, region);
if (!halfX && !halfY) rims.set(ci + ',' + cj, shells.length);
shells.push(region);
done++;
if (onStatus && done % 8 === 0) onStatus(`cells ${done}`);
Expand Down Expand Up @@ -5648,6 +5674,86 @@ <h2 id="drawersTitle">Your drawers</h2>
shells.push(boss);
}
}
/* The socket's rim, cut away under a boss whose pocket it stands in (#83). With nothing
under the sockets a cell is its rim alone, from the bed up: 2.85 mm in from the
cell's edges at the bed, 2.15 from 0.7 mm up, and further in at the socket's rounded
corner, which is the way every pocket faces. The pockets sit holeOffset from the
cell's centre whatever the pitch, so at small pitches they run in under the rim, and
a boss's pocket was cut from the boss alone: the rim, a shell of its own, stood in
it. A 6 mm magnet from beneath at 34.5 mm had 14.6 mm³ of rim in each pocket, in 41%
of its columns, and 1.8 mm³ at 36.13 mm, all with Download on; a solid floor's
pockets are cut into the floor under the rim and had none.
*
So where a boss's pocket runs more than MOUNT_SEAM into its cell's rim, the rim is
cut away under the boss: a box from under the bed to a height under the boss's top,
two BLOATs in from the cell's edges and from the boss's inner sides. The boss stands
round and over all of it, so the plate is the same solid but for the pocket, which
is then the boss's own as a solid floor's is the floor's. A box, and not the pocket
again: cut along the pocket's own walls and roof, the rim came out split on the same
lines as the boss where both stand on the piece's edge, edges used four times (six
more at 34.5 mm), and a box's faces stand off every face of the boss's. Up to under
the boss's top rather than the pocket's roof, so the rim's foot, below 0.7 mm, where
it stands furthest in, goes from under a hole open on the boss's top as well; over
the foot mountLimits holds such a hole clear of the rim, since there no boss stands
round it and cutting it would cut into the socket's wall. The height is the middle
of the widest gap between the planes it could meet, the rim's own rings, the pocket's
floors and roofs and a joint's cuts and housings, so it is level with none of them:
two cuts level with each other went bad wherever #64 tried them.
*
Every whole cell's rim is the same ring, so a corner is cut in every cell or in none.
A pocket the rim does not reach leaves it as it was, and the plate is built as
before. */
const ringZ = prof.zs.slice(1, 5), ringD = prof.ds.slice(1, 5);
// the rim's ring at height z, as directCellRegion makes it; between two rings, where
// their corners have got to, since they move in step
const ringAt = (z) => {
z = Math.max(ringZ[0], Math.min(ringZ[ringZ.length - 1], z));
let k = 0;
while (k < ringZ.length - 2 && z > ringZ[k + 1]) k++;
const d = ringD[k] + (z - ringZ[k]) / (ringZ[k + 1] - ringZ[k]) * (ringD[k + 1] - ringD[k]);
return roundedRectRing(0, 0, half - d, half - d, prof.rTop - (d - ringD[ringD.length - 1]), cfg.arcSegs || 6);
};
// how far the pocket at the corner (sx, sy) runs into the rim, each of its corners
// against the ring at its own height, which the walls straight up from it stand inside
const into = (sx, sy) => {
let most = -Infinity;
for (const p of bossFastener) for (const v of p.verts) {
const ring = ringAt(v[2]), x = v[0] + sx*off, y = v[1] + sy*off;
ring.forEach((a, i) => {
const b = ring[(i + 1) % ring.length], ex = b[0] - a[0], ey = b[1] - a[1];
most = Math.max(most, (ey * (x - a[0]) - ex * (y - a[1])) / Math.hypot(ex, ey));
});
}
return most;
};
const under = [[-1, -1], [-1, 1], [1, -1], [1, 1]].filter(([sx, sy]) => into(sx, sy) > MOUNT_SEAM);
if (under.length) {
const flats = (polys) => polys.filter((p) => Math.abs(p.plane.n[2]) > 0.999).map((p) => p.verts[0][2]);
// over the foot, and over every pocket's roof under the boss's top
const lo = Math.max(ringZ[1], ...bossFastener.filter((p) => p.plane.n[2] > 0.999 && p.verts[0][2] < bossH)
.map((p) => p.verts[0][2]));
const planes = [...ringZ, ...flats(bossFastener), ...fromBelow.flatMap(flats)];
const bo = keyKind === 'recess' ? null : keyed.find((b) => !(plan.junction && offJunction(b, pitch, piece)));
if (bo) {
const op = keySiteOps(keyKind, keyShape, keyPrm, keyClr, bo.edge, bo.e, bo.s, H);
planes.push(...flats(op.cut), ...flats(op.add));
}
const stops = [lo, bossH, ...planes.filter((z) => z > lo && z < bossH)].sort((a, b) => a - b);
let rimTop = lo, gap = -1;
for (let n = 1; n < stops.length; n++)
if (stops[n] - stops[n - 1] > gap) { gap = stops[n] - stops[n - 1]; rimTop = (stops[n] + stops[n - 1]) / 2; }
for (let i = 0; i < piece.nx; i++) for (let j = 0; j < piece.ny; j++) {
const k = rims.get(i + ',' + j);
if (k === undefined) continue;
const cut = [].concat(...under.map(([sx, sy]) => {
const cxr = gx0 + i*pitch + half + sx*half, cyr = gy0 + j*pitch + half + sy*half; // the cell's corner
const x0 = cxr - sx*2*BLOAT, x1 = cxr - sx*(bossW - 2*BLOAT);
const y0 = cyr - sy*2*BLOAT, y1 = cyr - sy*(bossW - 2*BLOAT);
return extrudePoly([[x0, y0], [x1, y0], [x1, y1], [x0, y1]], -0.5, rimTop);
}));
shells[k] = cutAgain(shells[k], cut, csgSubtract(shells[k], cut));
}
}
}

// ---- puzzle male tabs (protrude at floor level) ----
Expand Down
37 changes: 35 additions & 2 deletions docs/ENGINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,28 @@ other, then both, and the first that comes out clean is kept; if none does, the
stands. Each stands as far off the cell's walls as the first, and none nearer the
pockets.

With nothing under the sockets a cell is its rim alone, from the bed up, and at small
pitches a boss's pocket runs in under it: the rim stands 2.85 mm in from the cell's edges
at the bed and 2.15 from 0.7 mm up, and further in at the socket's rounded corner, which
is the way every pocket faces, while the pockets sit `holeOffset` from the cell's centre
whatever the pitch. The pocket was cut from the boss alone, and the rim, a shell of its
own, stood in it: a 6 mm magnet from beneath at 34.5 mm had 14.6 mm³ of rim in each
pocket, in 41% of its columns, 1.8 mm³ at 36.13 mm, and the default screw's head 13.2
mm³ at 34.5, all with Download on (#83). So where a pocket runs more than `MOUNT_SEAM`
into the rim, the rim is cut away under that corner's boss in every whole cell: a box
from under the bed to under the boss's top, two `BLOAT`s in from the cell's edges and
the boss's inner sides, whose faces stand off every face of the boss's. Cut along the
pocket's own walls instead, the rim split on the boss's lines where both stand on the
piece's edge: six more four-use edges at 34.5 mm. The box's top is the middle of the
widest gap between the planes it could meet (the rim's rings, the pockets' floors and
roofs, a joint's cuts and housings), level with none. Over the boss the rim is the
socket's wall, and is not cut: a hole that opens on the boss's top, a magnet from above
or a screw's shank, is held `MOUNT_SEAM` clear of it by `mountLimits` (`rim`), as a solid
floor's is held to its socket floor. That takes 2.5 mm off the cap of a magnet from above
and of a screw's hole at 34.5 mm (6.3 to 3.8, 6.5 to 4) and 2.4 at 38 (9.7 to 7.3); from
40 mm the boss is the tighter cap. A magnet from beneath and a screw's head lose nothing,
and a pocket the rim does not reach is built as it was, byte for byte.

`connector: 'puzzle'` used to be listed here as the first kind, and it is **no longer
open anywhere**. It is worth reading how, because it needed two unrelated fixes and the
lesson generalises: **an even count and an odd count on the same case are two separate
Expand Down Expand Up @@ -843,11 +865,22 @@ currently installed):
38.5 and a snap clip in the wall up to 35. Of the 1,771 caps it lowers, 1,573 stop a
tenth or two short of the first size that meets the housing, and no size taken meets
one. Where an H-clip's or a snap clip's housing reaches a pocket, the room it takes is
inside the socket rim's corner, which stands in that pocket already with no joint at
all (a boss's pocket may run under the rim, #83), so the pocket has no less room with
inside the socket rim's corner, which stood in that pocket already with no joint at
all (a boss's pocket may run under the rim, #83), so the pocket had no less room with
the joint than without it. The plate can still come out open there: an H-clip from
above at 34 mm took a 4 mm magnet from above with 4 edges open where the cavity meets
the pocket's wall, with Download on. So the cap is held off every housing alike.
Since #83 a pocket from above is held clear of the rim over its boss, and it meets the
rim first at any fit clearance up to 0.25 mm (the default is 0.2), whatever the
tolerance and rim cutoff: from 30 to 42 mm no such pocket then reaches an H-clip's or
a snap clip's cup. A snap clip's fit stops at 0.3, and the rim comes first at every
one. An H-clip's runs to 1 mm, and a looser one widens its cup until the cup comes
first, so the housing's cap holds the pocket instead: from a fit of 0.26 at loose
tolerance and rim cutoff 0.1 (0.52 at cutoff 1), from 0.42 at standard tolerance and
the default cutoff (0.33 to 0.59 as the cutoff goes from 0.1 to 1), and from 0.4 to
0.67 at tight. At loose, cutoff 0.1 and fit 0.3 that is a magnet from above from about
32.3 to 34 mm and a screw hole from 32.1 to 33.8: at 33 mm a 2.1 mm magnet is refused
at 2 for the housing, where the rim alone would take it.
- **A pocket in a corner boss counts the same way**, since the joint is cut from the
boss too (#70), and from above its floor is measured from the boss's top: wall keys
and the dovetail reach a boss's pocket up to about 39 mm, the H-clip up to about 34.5,
Expand Down
Loading
Loading