Skip to content
120 changes: 80 additions & 40 deletions bins/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10360,14 +10360,19 @@ <h2 id="drawersTitle">Your drawers</h2>
/* Whether a bin's stacking lip is the one notched at its slots, for removable dividers:
a lip, over a wall thinner than its base (lipLevels). Over a wall as thick as the
base the lip stands on the wall and nowhere over the cavity, so a plate clears it.
None on a bin counted as one whose finger slot takes its lip away (`lipTaken`,
dividersBuilt and countedAs), which keeps its lip as asked for everything else: its
holes across the floor are laid out clear of the lip (holeLayout) before the slots
are settled over them, and so built. Counted with `lip` false, they were laid out
with room the bin does not give them: a 1x0.5x2 with a 0.4 mm wall asking for AAA
cells, none of which fit, was counted as if a row of 3 did, which leaves its back
wall no room for the slot it is built with, and so as if it had the label shelf that
slot takes away: it was built with 1 plate along, not 2. */
None on a bin counted as one whose finger slot takes its lip away (`lipTaken`, set by
dividersBuilt and countedAs). This is where the engine reads that, and so what drops
the lip's rule from railedLimit and its corners from plateLayout for such a bin, and
from the reasons dividersWhy gives, which asks both of the bin countedAs marks. The
page reads it too (setDividerLimit): a bin so marked has its field for the plates
across held to dividersBuilt's count, as the one along always is, since more plates
across could leave it no slot, and so its lip back. It keeps its lip as asked for
everything else: its holes across the floor are laid out clear of the lip (holeLayout)
before the slots are settled over them, and so built. Counted with `lip` false, they
were laid out with room the bin does not give them: a 1x0.5x2 with a 0.4 mm wall
asking for AAA cells, none of which fit, was counted as if a row of 3 did, which
leaves its back wall no room for the slot it is built with, and so as if it had the
label shelf that slot takes away: it was built with 1 plate along, not 2. */
const lipNotched = (c) => !!c.lip && !c.lipTaken && !c.solid && ['f', 'b', 'l', 'r'].every((k) => wallEdge(c, k) >= 1) &&
LIP[0][1] - c.wall >= BLOAT;
/* The scoop's radius as buildBin builds it, 0 for none: no taller than the front wall it
Expand Down Expand Up @@ -10544,14 +10549,16 @@ <h2 id="drawersTitle">Your drawers</h2>
const out = dividersCounted(c);
/* A finger slot takes the lip away, as a lowered wall does (buildBin), and the notches
with it, which railedLimit and plateLayout keep clear of the lip's corners. So a bin
asking for slots is counted without that rule as well (`lipTaken`, which only the
rule reads: its holes are laid out clear of its lip all the same, as they are built,
lipNotched), and built with that count where a slot is still built between the
plates it gives, which can be narrower or stand elsewhere: settled between those
plates (fingerSlotPlan), as buildBin then settles them. Where none would be, the bin
keeps its lip and the count the lip allows. Counted with the lip's rule, a 1x1x3 with
a 0.4 mm wall and a slot in the front was built with 10 plates along where 11 fit,
and Checks put it down to a lip it does not have. */
asking for slots is counted without that rule as well (`lipTaken`: lipNotched reads
it and drops the rule and the corners, for this count and for dividersWhy's reasons,
and the page's field for the plates across reads it, to be held to what this builds;
its holes are laid out clear of its lip all the same, as they are built), and built
with that count where a slot is still built between the plates it gives, which can
be narrower or stand elsewhere: settled between those plates (fingerSlotPlan), as
buildBin then settles them. Where none would be, the bin keeps its lip and the count
the lip allows. Counted with the lip's rule, a 1x1x3 with a 0.4 mm wall and a slot in
the front was built with 10 plates along where 11 fit, and Checks put it down to a
lip it does not have. */
if (c.divRemovable && c.lip && slotsAsked(c)) {
const free = dividersCounted(Object.assign({}, c, { lipTaken: true }));
if ((free.divX !== out.divX || free.divY !== out.divY) && fingerSlotPlan(c, free).n) return free;
Expand Down Expand Up @@ -10580,7 +10587,10 @@ <h2 id="drawersTitle">Your drawers</h2>
in it, which leaves it no lip, the same bin counted without one (`lipTaken`,
dividersBuilt). What Checks says stopped the count (dividersWhy) and how many the
fields let a bin ask for go by it, so neither says or stops at the lip of a bin that
has none. */
has none: dividersWhy asks railedLimit and plateLayout of it, which lipNotched then
keeps from the lip's rule and corners, and setDividerLimit holds the fields to
railedMost of it and, where it is marked, the one for the plates across to
dividersBuilt's count too. */
function countedAs(cfg) {
const c = Object.assign({}, BIN_DEFAULTS, cfg);
return c.divRemovable && c.lip && slotsAsked(c) && fingerSlotPlan(c).n ? Object.assign(c, { lipTaken: true }) : c;
Expand All @@ -10603,11 +10613,21 @@ <h2 id="drawersTitle">Your drawers</h2>
and 'crossCorners' when both would. It was asked of as many as the rails allow, and
named the plates' keep wherever both went wrong there, whichever stopped one more.
A bin with a finger slot built in it has no lip, and is said by the rules it is counted
by without one (countedAs), never the lip's; 'slot' where it is built with the count
its lip would allow all the same, because between more plates no slot would be built,
and it would have its lip. That is a fallback no bin swept has reached: the lip's rule
binds only on plates packed too close for a slot between them, so more of them move no
slot (dividersBuilt).
by without one (countedAs), never the lip's, and it is always built with that count.
The lip stops only plates that would stand under 6 mm apart, so the ones it keeps
stand under 9: its rule and its corners bind where the last plate stands within half
a plate, its clearance and 3.4 mm of the cavity's wall, and the rails let plates stand
that close only where half a plate and its clearance are under 2.2 mm. A finger slot
needs 15 mm between two plates' rails, or a rail and the wall's corner, so the walls
those plates meet have no slot with the lip's count or without it. And all else a
slot is settled by is the same with either: the plates the other way, unless the lip
stopped those as well, which leaves no wall a slot; the scoop; and the shelf, as no
note prints between plates that close. So where a slot is built between
the plates the lip allows, one is built between the plates without it, and the bin is
built with those (dividersBuilt). This had 'slot' for a bin built with the lip's count
all the same, as between more plates no slot would be built, and none of 900,000
random bins nor of a million aimed at the lip reached it; the audit holds bins to
that ("counted with no lip").
Null where it is built with all it asks for, and where it has no rails at all: a
carved shape, a solid block or a floor that fills the bin (plateLayout's railed), or
holes across its floor (binDividers). Those are built with none whatever they ask for,
Expand All @@ -10616,13 +10636,12 @@ <h2 id="drawersTitle">Your drawers</h2>
function dividersWhy(cfg) {
const c = Object.assign({}, BIN_DEFAULTS, cfg), built = dividersBuilt(c), out = { divX: null, divY: null };
if (!c.divRemovable || !plateLayout(c, built).railed || (insertOf(c) && insertPlan(c).n)) return out;
const by = countedAs(c), free = by.lipTaken ? dividersCounted(by) : null;
const by = countedAs(c);
for (const [key, axis] of [['divX', 'x'], ['divY', 'y']]) {
const asked = c[key] || 0;
if (built[key] >= asked) continue;
const L = railedLimit(by, axis);
if (built[key] >= Math.min(asked, L.most)) { out[key] = L.by; continue; }
if (free && built[key] < free[key]) { out[key] = 'slot'; continue; }
const P = plateLayout(by, Object.assign({}, built, { [key]: built[key] + 1 }));
out[key] = !P.fitsY && !P.corners ? 'crossCorners' : !P.fitsY ? 'cross' : 'lipCorners';
}
Expand Down Expand Up @@ -12526,11 +12545,38 @@ <h2 id="drawersTitle">Your drawers</h2>
bin with holes across its floor, which the holes divide, as buildBin builds it
(binDividers, which asks the holes as holesIn does), with the new-bin settings at a
1x1 as these are. A bin with finger slots ticked asks the holes of its kept plan
(insertPlanOf), as binDividers would ask them of the slots all over again. */
(insertPlanOf), as binDividers would ask them of the slots all over again.
Kept by the settings that asked, as fingerPlan is: a refresh asks this of each bin ten
times over, for its key, its name, Checks and its compartments, and 63 bins with
removable plates spent 60 to 150 ms of an 85 to 180 ms refresh in dividersBuilt with
finger slots ticked, about three quarters of it, and 20 to 45 of 35 to 85 without;
kept, the whole refresh takes 12 to 50. Everything it goes by is binCfg's, and whether
the bin has a size of its own, so nothing here changes an answer under its key. */
const keptDivs = new Map();
const builtDivs = (b) => {
const c = Object.assign(binCfg(b), { u: b.u || 1, v: b.v || 1 });
if (!(b.u && b.v && fingerPlan(b))) return binDividers(c);
return +c.insert > 0 && insertPlanOf(b).n ? { divX: 0, divY: 0 } : dividersBuilt(c);
const key = (b.u && b.v ? '' : '1x1 ') + JSON.stringify(c);
let d = keptDivs.get(key);
if (!d) {
if (keptDivs.size >= 500) keptDivs.clear();
keptDivs.set(key, (d = !(b.u && b.v && fingerPlan(b)) ? binDividers(c)
: +c.insert > 0 && insertPlanOf(b).n ? { divX: 0, divY: 0 } : dividersBuilt(c)));
}
return { divX: d.divX, divY: d.divY };
};
/* And why a removable bin is built with fewer than it asks for (dividersWhy), kept the
same way for `cfg`, the bin's binCfg at its size: Checks asks it of every such bin each
refresh, at 0.3 to 1 ms a bin, and with all 63 asking for more plates than fit it took
30 to 50 ms of an 80 to 100 ms refresh once their dividers were kept. */
const keptWhys = new Map();
const divsWhy = (cfg) => {
const key = JSON.stringify(cfg);
let w = keptWhys.get(key);
if (!w) {
if (keptWhys.size >= 500) keptWhys.clear();
keptWhys.set(key, (w = dividersWhy(cfg)));
}
return { divX: w.divX, divY: w.divY };
};
// and how many compartments they make, or 0 for a bin with none
const compartments = (b) => {
Expand Down Expand Up @@ -14549,7 +14595,7 @@ <h2 id="drawersTitle">Your drawers</h2>
// what makes it safe for the labels to shorten or drop a line in a small bin
const tip = document.createElementNS(SVGNS, 'title');
tip.textContent = (b.note ? b.note + ' — ' : '') +
`${b.u}×${b.v}, ${b.hUnits} units (${b.hUnits * SPEC.unitH} mm)`;
`${b.u}×${b.v}, ${plural(b.hUnits, 'unit')} (${b.hUnits * SPEC.unitH} mm)`;
r.appendChild(tip);
if (issues.length) {
const warn = el('text', { class: 'bwarn', x: b.x * S + 13, y: sy(b.y, b.v) + 20 });
Expand Down Expand Up @@ -15373,7 +15419,7 @@ <h2 id="drawersTitle">Your drawers</h2>
/* What brought each direction's count down (dividersWhy). The rails' own rules are
said together as one note; what stands over a slot, the lip and the shelf, and what
the plates keep where they cross or stand on the scoop, each in a note of its own. */
const why = dividersWhy(cfg);
const why = divsWhy(cfg);
/* The rails' own rules, said together as one note (railedLimit): the slots, the
corners, and two more. 'lone': room for one divider's slot and a rail either side,
but not for the rails the other way beside it, which are kept room for whether or
Expand Down Expand Up @@ -15415,11 +15461,6 @@ <h2 id="drawersTitle">Your drawers</h2>
// both, where one more would go wrong both ways (dividersWhy)
crossCorners: (any) => `${any ? 'no more' : 'none'} keep ${PLATE_END} mm of plate where they ${stand}, ` +
`and ${any ? 'more' : 'any'} would notch the stacking lip too close to its corners`,
/* A bin with a finger slot has no lip, and is counted without it, but for this: with
more plates it would have no slot, and so its lip, which they would notch too close
to its corners (dividersWhy). A fallback: no bin swept has reached it. */
slot: (any) => `${any ? 'more' : 'any'} would leave no room for its finger slots, and it would have the ` +
`stacking lip back, which ${any ? 'no more' : 'none'} can have a notch through clear of its corners`,
};
const MANY = {
lip: 'no more can have a notch through the stacking lip clear of its corners',
Expand All @@ -15428,8 +15469,6 @@ <h2 id="drawersTitle">Your drawers</h2>
lipCorners: 'more along would notch the stacking lip too close to its corners',
crossCorners: `no more along keep ${PLATE_END} mm of plate where they cross the ones across, or stand on the ` +
'scoop, and more would notch the stacking lip too close to its corners',
slot: 'more would leave no room for their finger slots, and they would have the stacking lip back, which ' +
'no more can have a notch through clear of its corners',
};
for (const r of Object.keys(REASON)) {
const these = short.filter(([k]) => why[k] === r);
Expand Down Expand Up @@ -16093,11 +16132,12 @@ <h2 id="drawersTitle">Your drawers</h2>
(inch ? ` (${gw} × ${gd} mm, ${FIELDS.inchText(gw)} × ${FIELDS.inchText(gd)} in)` : '') +
/* With no room there is no tallest bin either, nor with room under a 1-unit bin and
its lip: capUnits is never under 1, and it said "tallest single bin 1 units" there
while Checks said no 1-unit bin fits. */
while Checks said no 1-unit bin fits. Where one unit is the tallest, it is "1 unit",
as Checks says it: it said "1 units" there too. */
(noRoomAbove(g) ? ` · no room above the baseplate, as ${whyNoRoom(also)}` :
` · ${g.avail.toFixed(1)} mm${also(g.avail)} above the baseplate · ` + (unitsUnder(g.avail) < 1
? `too little for even a 1-unit bin (${SPEC.unitH} mm${also(SPEC.unitH)} + lip)`
: `tallest single bin ${capUnits} units (${capUnits * SPEC.unitH} mm${also(capUnits * SPEC.unitH)} + lip), limited by ${capBy}`));
: `tallest single bin ${plural(capUnits, 'unit')} (${capUnits * SPEC.unitH} mm${also(capUnits * SPEC.unitH)} + lip), limited by ${capBy}`));
// and the half cell under the size fields, which said 21 mm whatever the drawer was in
$('halfCellLen').textContent = `${SPEC.pitch / 2} mm${also(SPEC.pitch / 2)}`;
const src = scratch || (selected >= 0 && B()[selected] ? B()[selected] : state);
Expand Down Expand Up @@ -16761,7 +16801,7 @@ <h2 id="drawersTitle">Your drawers</h2>
function sceneLabel(empty, shell, g) {
if (fBin()) {
const b = fBin();
return `3D preview: one ${b.u} by ${b.v} bin, ${b.hUnits} units tall, ` +
return `3D preview: one ${b.u} by ${b.v} bin, ${plural(b.hUnits, 'unit')} tall, ` +
'on a baseplate of its own size.';
}
if (empty && !shell)
Expand Down Expand Up @@ -16845,7 +16885,7 @@ <h2 id="drawersTitle">Your drawers</h2>
function showTip(e, b, k) {
const el = $('tip');
el.textContent = (b.note ? b.note + ' — ' : '') +
`${b.u}×${b.v}, ${b.hUnits} units (${b.hUnits * SPEC.unitH} mm)` +
`${b.u}×${b.v}, ${plural(b.hUnits, 'unit')} (${b.hUnits * SPEC.unitH} mm)` +
(k !== undefined && layers.length > 1 ? ` · layer ${k + 1}` : '');
el.style.display = 'block';
const pad = 14;
Expand Down
11 changes: 9 additions & 2 deletions docs/ENGINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,12 @@ construction plus overlapping shells, so none of §2 is reachable. Keep it that
`dividersBuilt` counts the plates with the lip's rule and without it, and takes the
count without it where a slot is still built between those plates (settled with them,
`fingerSlotPlan` given the count), and otherwise keeps the lip and its count. Counted
so, the bin is marked `lipTaken`, which only the lip's rule reads (`lipNotched`): it
so, the bin is marked `lipTaken`. In the engine only `lipNotched` reads it, which
drops the lip's rule and its corners for that bin wherever they are asked: in the
count, and in the reasons Checks gives, as `dividersWhy` asks `railedLimit` and
`plateLayout` of the marked bin. On the page `setDividerLimit` reads it as well, and
holds the field for the plates across to `dividersBuilt`'s count, as the one along
always is, since more plates across can leave no slot and bring the lip back. The bin
keeps its lip as asked for all else, and above all for its holes, which are laid out
clear of the lip before the slots are settled over them. Asked as a bin with `lip`
false, its holes had room it does not give them, and a row that is not built held its
Expand All @@ -322,7 +327,9 @@ construction plus overlapping shells, so none of §2 is reachable. Keep it that
plate across a front one.
The lip's rule only binds on plates packed a few millimetres apart, with no room for a
slot between them, so the walls their ends meet have no slot either way, and the slots
in the others stay where they were, as do the rails beside them.
in the others stay where they were, as do the rails beside them. So a bin with a slot
between the plates its lip allows has one between the plates without its lip as well,
and is built with those: Checks never has a slot to blame for fewer plates.
`fingerSlots` hands its answer to `buildBin` and `insertPlan` (`floor`), so the page
counts the holes that are built, and to `binVolume`, which weighs the bin from it: no
lip, the dips (`area`, the mean of the wall's two faces, times the wall) off the walls,
Expand Down
Loading
Loading