@rulecad/frames 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/panel.mjs ADDED
@@ -0,0 +1,374 @@
1
+ // Panels and the printed parts that hold them: a panel is a sheet (acrylic, polycarbonate, aluminium) by its material
2
+ // and thickness, cut to the bay of a frame it closes, with its mass from the sheet's density; a panel clip screws into
3
+ // a face's slot and holds the panel's edge down; a panel corner holds a corner over two beams; an in-slot panel edge
4
+ // holds a thinner sheet in a slot's opening; a slot cover closes a slot nothing uses; a gasket strip seals a door's
5
+ // gap. Each printed part is drawn from the profile's, the thread's and the printer's rules, prints without supports
6
+ // with a plain first layer, and reports its grams and its margin at a named load.
7
+ //
8
+ // A clip's frame (its fitted pose): x along the slot (0 at the clip's middle), y across it toward the panel (0 on the
9
+ // slot's centre line), z out of the beam's face (0 on the face). It prints on its side: its section in (y, z) is the
10
+ // first layer, the slot's direction up. A strip's frame: x along the slot from 0, y across, z out of the face; it
11
+ // prints lying down. Units: mm, N, grams.
12
+ import jscad from '@jscad/modeling';
13
+ import { hole, holeModel } from '@rulecad/fixings';
14
+ import { FITTING_DEFAULTS, printerOf, pfig, materialOf, options, profileOf, slotSide, roundConcave, ccw, combine, tongueLoop, sold, screwOf } from './fitting.mjs';
15
+
16
+ const { polygon, cuboid } = jscad.primitives, { extrudeLinear } = jscad.extrusions, { intersect, subtract } = jscad.booleans;
17
+ const { translate, transform } = jscad.transforms, { measureVolume } = jscad.measurements;
18
+ const CHECKED = '2026-11-17';
19
+ const isNum = (x) => typeof x === 'number' && Number.isFinite(x);
20
+ const shown = (v) => { const s = v === undefined ? 'nothing' : JSON.stringify(v) ?? String(v); return s.length > 80 ? `${s.slice(0, 77)}...` : s; };
21
+ const mm = (x) => String(+Number(x).toFixed(2));
22
+ const r3 = (x) => +x.toFixed(3);
23
+ const an = (t) => `${/^(M|[aeiou8])/i.test(String(t)) ? 'an' : 'a'} ${t}`; // (an M5, a 6-32)
24
+ const up = (x, step) => Math.ceil(x / step - 1e-9) * step;
25
+ const finding = (level, text, code, extra = {}) => ({ level, text, code, ...extra });
26
+ const rule = (value, unit, text, kind, source) => ({ value, ...(unit ? { unit } : {}), rule: text, kind, source, checked: CHECKED });
27
+
28
+ /**
29
+ * The sheets a panel is cut from, each with its density (from the maker's data sheet) and the thicknesses stockists
30
+ * commonly hold.
31
+ * @type {Record<string, { what: string, density: object, thicknesses: object }>}
32
+ */
33
+ export const SHEETS = {
34
+ acrylic: { what: 'cast acrylic (PMMA) sheet', density: rule(1.19, 'g/cm³', 'Cast acrylic sheet weighs 1.19 g/cm³', 'spec', 'Evonik PLEXIGLAS GS technical information: density 1.19 g/cm³ by ISO 1183'),
35
+ thicknesses: rule([2, 3, 4, 5, 6, 8, 10], 'mm', 'Thicknesses stockists commonly cut cast acrylic from', 'community', 'Stockists\' lists of cast acrylic sheet, not one maker\'s range: check your supplier') },
36
+ polycarbonate: { what: 'solid polycarbonate sheet', density: rule(1.2, 'g/cm³', 'Solid polycarbonate sheet weighs 1.20 g/cm³', 'spec', 'Covestro Makrolon GP / Exolon GP technical data sheet: density 1200 kg/m³ by ISO 1183-1'),
37
+ thicknesses: rule([1, 2, 3, 4, 5, 6], 'mm', 'Thicknesses stockists commonly cut solid polycarbonate from', 'community', 'Stockists\' lists of solid polycarbonate sheet, not one maker\'s range: check your supplier') },
38
+ aluminium: { what: 'aluminium sheet, EN AW-5754', density: rule(2.66, 'g/cm³', 'EN AW-5754 aluminium sheet weighs 2.66 g/cm³', 'spec', 'Aalco data sheet, aluminium alloy 5754 H26 sheet: density 2.66 g/cm³'),
39
+ thicknesses: rule([1, 1.5, 2, 3], 'mm', 'Thicknesses stockists commonly cut 5754 sheet from', 'community', 'Stockists\' lists of 5754 sheet, not one maker\'s range: check your supplier') },
40
+ };
41
+
42
+ /** The working figures of panels and their printed parts, each with what it rests on. */
43
+ export const PANEL_DEFAULTS = {
44
+ gap: rule(0.5, 'mm', 'Room between a panel\'s cut edge and the printed part it lies against: the cut\'s tolerance', 'estimate', 'A working figure of @rulecad/frames: a laser or saw cut to about ±0.2 mm, with room over'),
45
+ grip: rule(6, 'mm', 'How far a clip reaches over the panel\'s edge', 'estimate', 'A working figure of @rulecad/frames'),
46
+ load: rule(30, 'N', 'The design load on one clip where none is given: the panel pushed out by a hand, its share at one clip', 'default', 'A working figure of @rulecad/frames, so every clip is sized and compared at one named load'),
47
+ pitch: rule(150, 'mm', 'Clips along a panel\'s edge are no further apart than this, with one near each end', 'estimate', 'A working figure of @rulecad/frames: a 3 mm sheet between clips this far apart does not lift visibly at the clip\'s load'),
48
+ corner: rule(1, 'mm', 'A panel\'s corners are rounded this much, so they sit in a corner piece\'s rounded step', 'default', 'A working figure of @rulecad/frames'),
49
+ walls: rule(3, 'lines', 'A printed part\'s thinnest wall, in the printer\'s lines', 'default', 'A working figure of @rulecad/frames: three lines hold together where two may part'),
50
+ barb: rule(0.3, 'mm', 'How far a slot cover\'s barb reaches past the slot\'s opening under its lip', 'estimate', 'A working figure of @rulecad/frames, to be checked by a test print'),
51
+ lap: rule(1, 'mm', 'How far a slot cover\'s flange laps the face past the slot\'s opening on each side', 'default', 'A working figure of @rulecad/frames'),
52
+ squeeze: rule(0.5, 'mm', 'How far a door presses its gasket strip down when it closes', 'estimate', 'A working figure of @rulecad/frames'),
53
+ };
54
+ const want = () => FITTING_DEFAULTS.margin.value;
55
+
56
+ // ---------- shared ----------
57
+ /** @internal A bending member's least thickness for a margin: b wide, bent by M. @param {number} M @param {number} b @param {number} S @param {number} k @returns {number} */
58
+ export const bendT = (M, b, S, k) => Math.sqrt((6 * M * k) / (b * S));
59
+ /** @internal A bending member's margin: S over 6M / (b h²). @param {number} M @param {number} b @param {number} h @param {number} S @returns {number} */
60
+ export const bendMargin = (M, b, h, S) => S / ((6 * M) / (b * h * h));
61
+ /** @internal The common setup of a printed part: printer, plastic and their figures. @param {string} what @param {object} o @returns {any} */
62
+ export function partSetup(what, o) {
63
+ const pr = printerOf(what, o.printer), mat = materialOf(what, o.material ?? 'pla');
64
+ return { pr, mat, fit: pfig(pr, 'fit'), layer: pfig(pr, 'layer'), line: pfig(pr, 'line'), S: mat.rules.strength.value, density: mat.rules.density.value };
65
+ }
66
+ /** @internal A sheet's thickness, refused by name. @param {string} what @param {any} t @returns {number} */
67
+ export function sheetThickness(what, t) {
68
+ if (!(isNum(t) && t > 0 && t <= 20)) throw new Error(`${what}: sheet is the panel's thickness in mm, above 0 and up to 20 (got ${shown(t)})`);
69
+ return t;
70
+ }
71
+ /** @internal A load in N, refused by name. @param {string} what @param {any} F @param {string} said @returns {void} */
72
+ export function loadOk(what, F, said) { if (F != null && !(isNum(F) && F > 0)) throw new Error(`${what}: load is ${said}, in N, above 0 (got ${shown(F)})`); }
73
+
74
+ // A teardrop's outline about (0, 0) in (across, up), its point up at 45°
75
+ const teardrop = (r, n = 32) => [[0, r * Math.SQRT2], ...Array.from({ length: n + 1 }, (_, k) => { const a = Math.PI / 4 - (k * 3 * Math.PI) / (2 * n); return [r * Math.cos(a), r * Math.sin(a)]; })];
76
+ const prism = (loop, h) => extrudeLinear({ height: h }, polygon({ points: ccw(loop) }));
77
+ // print frame (X across, Y out of the face, Z along the slot from 0 to w) to the fitted frame (x along, y across, z out)
78
+ /** @internal The turn from a side-printed part's print frame to its fitted frame. @param {number} w @returns {number[]} */
79
+ export const sideToFit = (w) => [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -w / 2, 0, 0, 1];
80
+
81
+ /**
82
+ * @internal A part printed on its side: its section in (y, z) of the fitted frame (as X, Y) extruded w along the slot
83
+ * (Z), a tongue into the slot under it, and holes square to the face, each a teardrop with its point cut flat just over
84
+ * the round so a head's seat is whole. holes: { thread, y, top, kind }, from the face at height top down through the
85
+ * part and its tongue, or { thread, y, depth, kind, from: 'face' }, a blind hole up from the contact face; pockets: { y, top, d, depth }, round pockets from the face at height top.
86
+ * @param {{ loop: number[][], width: number, tongue?: object, holes?: object[], pockets?: object[], pr: object, ops?: object }} o
87
+ * @returns {object} a JSCAD geom3 in its print pose
88
+ */
89
+ export function sidePart({ loop, width, tongue = null, holes = [], pockets = [], pr, ops = null }) {
90
+ const root = pfig(pr, 'fit'), parts = [prism(loop, width)], c = width / 2;
91
+ if (tongue && tongue.depth > 0) parts.push(prism(tongueLoop(tongue.at - tongue.width / 2, tongue.at + tongue.width / 2, tongue.depth, false, root).map(([n, a]) => [a, -n]), width));
92
+ const deep = (top) => top + (tongue?.depth ?? 0) + 2;
93
+ const cuts = holes.map((h) => {
94
+ const g = h.from === 'face' ? hole(h.thread, { kind: h.kind ?? 'pilot', into: '+y', depth: h.depth + 1, at: [h.y, -1, c], printer: pr }) : hole(h.thread, { kind: h.kind ?? 'clearance', into: '-y', depth: deep(h.top), at: [h.y, h.top + 1, c], printer: pr }), r = g.model.diameter / 2;
95
+ return intersect(g, cuboid({ size: [4 * width + 200, 4 * (h.top ?? h.depth) + 200, c + 1.02 * r + 1], center: [h.y, 0, (c + 1.02 * r - 1) / 2] }));
96
+ });
97
+ for (const p of pockets) cuts.push(translate([p.y, p.top + 1, c], transform([1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], prism(teardrop(p.d / 2), p.depth + 1)))); // (u, v) to (X, Z), down along -Y
98
+ return combine(parts, cuts, ops);
99
+ }
100
+
101
+ // The kit's findings every printed part ends with: its size, its margin at its named load, how it prints, its mass
102
+ function closing(m, { S, sizeText, marginText, pose }) {
103
+ const ok = m.margin >= want() - 1e-9;
104
+ m.findings.push(finding('info', `${m.title}: ${sizeText}`, 'fitting.size', { values: { ...m.size } }));
105
+ m.findings.push(finding(ok ? 'pass' : 'fail', `${marginText}, ${mm(m.margin)} times under ${m.material.toUpperCase()}'s ${S} MPa (${ok ? `within the ${want()}× asked` : `short of the ${want()}× asked`}): by beam formulas, an estimate`, 'fitting.margin', { values: { load: m.load.force, stress: m.stress, strength: S, margin: m.margin } }));
106
+ m.findings.push(finding('info', `it is drawn to print ${pose}: a plain first layer, no supports (printcheck's check() reads the solid)`, 'fitting.printable', { values: { pose } }));
107
+ m.findings.push(finding('info', `it weighs ${mm(m.grams)} g of ${m.material} (${mm(m.volume)} mm³)`, 'fitting.mass', { values: { grams: m.grams, volume: m.volume } }));
108
+ }
109
+ /** @internal A finished part's volume and grams from its solid. @param {object} m @param {object} solid @param {number} density @returns {void} */
110
+ export function weigh(m, solid, density) { m.volume = r3(measureVolume(solid)); m.grams = r3((m.volume * density) / 1000); }
111
+ /** @internal The closing findings, shared with the door's and the ends' parts. */
112
+ export { closing as closingFindings };
113
+ const screwFinding = (m, fits, sc) => m.findings.push(fits
114
+ ? finding('pass', `${sc.thread}x${fits.lengths[0]} ${sc.head}: through ${mm(fits.t)} mm of ${m.fitting.replace('-', ' ')}, its tip ${mm(fits.lengths[0] - fits.t)} mm under the face, between ${mm(fits.windows[0].lo)} (its nut's thread engaged) and ${mm(fits.windows[0].hi)} (the slot's floor less ${FITTING_DEFAULTS.floor.value} mm)`, 'fitting.screw', { values: { lengths: fits.lengths, windows: fits.windows } })
115
+ : finding('warn', `no ${sc.thread} ${sc.head} screw sold engages its slot nut fully and stops short of the slot's floor here: the screw's length is the fasten check's to choose`, 'fitting.screw', {}));
116
+ const tongueFinding = (m, sd, pr) => m.findings.push(finding(sd.tongue.depth > 0 ? 'pass' : 'info', sd.tongue.depth > 0 ? `its tongue keys into ${sd.slot.name}: ${mm(sd.tongue.width)} mm wide (the ${mm(sd.slot.opening)} mm opening less ${pr.name}'s fit each side), ${mm(sd.tongue.depth)} mm deep (the lip less ${an(sd.thread)} slot nut's tongue, less the fit)` : `${sd.slot.name}'s lip leaves no room for a tongue over ${an(sd.thread)} slot nut: it lies flat on the face`, 'fitting.tongue', { values: { ...sd.tongue }, refs: { slot: sd.slot.name, nut: sd.nut.name } }));
117
+ const short = (p) => p.name.replace(/^profile-/, '');
118
+
119
+ // ---------- a panel ----------
120
+ /**
121
+ * @typedef {{ kind: 'panel', name: string, title: string, sheet: string, thickness: number, size: number[], corner: number, area: number, grams: number, holes: { thread: string, at: number[], diameter: number }[],
122
+ * findings: object[], rests: object[] }} Panel
123
+ */
124
+ /**
125
+ * A panel: a sheet of a material and thickness cut to a size, its corners rounded, with holes where screws pass. Its
126
+ * mass is the sheet's density times its volume less the holes. A thickness no stockist commonly holds is a warning.
127
+ * @param {string} sheet acrylic, polycarbonate or aluminium @param {number} thickness mm
128
+ * @param {{ size: number[], corner?: number, holes?: { thread: string, at: number[] }[], printer?: object }} o size: [x, y] in mm; holes at [x, y] from the panel's corner
129
+ * @returns {Panel}
130
+ */
131
+ export function panelModel(sheet, thickness, o = {}) {
132
+ const what = 'panelModel';
133
+ const s = SHEETS[String(sheet).toLowerCase()];
134
+ if (!s) throw new Error(`${what}: sheet is one of ${Object.keys(SHEETS).join(', ')} (got ${shown(sheet)})`);
135
+ options(what, o, ['size', 'corner', 'holes', 'printer']);
136
+ const T = sheetThickness(what, thickness);
137
+ if (!(Array.isArray(o.size) && o.size.length === 2 && o.size.every((x) => isNum(x) && x > 0))) throw new Error(`${what}: size is [x, y] in mm, each above 0 (got ${shown(o.size)})`);
138
+ const corner = o.corner ?? PANEL_DEFAULTS.corner.value;
139
+ if (!(isNum(corner) && corner >= 0 && corner < Math.min(...o.size) / 2)) throw new Error(`${what}: corner is the corners' radius in mm, from 0 to under half the panel's least side (got ${shown(o.corner)})`);
140
+ const pr = printerOf(what, o.printer);
141
+ const holes = (o.holes ?? []).map((h, i) => {
142
+ if (!h || typeof h.thread !== 'string' || !(Array.isArray(h.at) && h.at.length === 2 && h.at.every(isNum))) throw new Error(`${what}: hole ${i + 1} is { thread: 'M3', at: [x, y] } (got ${shown(h)})`);
143
+ const d = holeModel(h.thread, { kind: 'clearance', printer: pr }).diameter;
144
+ if (h.at[0] < d / 2 || h.at[1] < d / 2 || h.at[0] > o.size[0] - d / 2 || h.at[1] > o.size[1] - d / 2) throw new Error(`${what}: hole ${i + 1} at [${h.at.map(mm).join(', ')}] is off the ${mm(o.size[0])} x ${mm(o.size[1])} mm panel`);
145
+ return { thread: h.thread, at: h.at.map(r3), diameter: d };
146
+ });
147
+ const [a, b] = o.size.map(r3), area = r3(a * b - (4 - Math.PI) * corner * corner - holes.reduce((t, h) => t + (Math.PI * h.diameter * h.diameter) / 4, 0));
148
+ const grams = r3((area * T * s.density.value) / 1000), name = `panel-${String(sheet).toLowerCase()}-${mm(T)}mm`;
149
+ const findings = [finding('info', `${mm(a)} x ${mm(b)} mm of ${mm(T)} mm ${s.what}, its corners rounded ${mm(corner)} mm${holes.length ? `, ${holes.length} hole${holes.length > 1 ? 's' : ''} for ${[...new Set(holes.map((h) => h.thread))].join(' and ')} screws` : ''}: ${mm(grams)} g`, 'panel.size', { values: { size: [a, b], thickness: T, grams, holes: holes.length } })];
150
+ const stocked = s.thicknesses.value.some((x) => Math.abs(x - T) < 1e-9);
151
+ findings.push(finding(stocked ? 'pass' : 'warn', stocked ? `${mm(T)} mm is a thickness ${sheet} is commonly stocked in (${s.thicknesses.kind})` : `${mm(T)} mm ${sheet} is not commonly stocked: ${s.thicknesses.value.join(', ')} mm are (${s.thicknesses.kind}, check your supplier)`, 'panel.thickness', { values: { thickness: T, stocked: s.thicknesses.value } }));
152
+ return { kind: 'panel', name, title: `${mm(T)} mm ${sheet} panel, ${mm(a)} x ${mm(b)} mm`, sheet: String(sheet).toLowerCase(), thickness: T, size: [a, b], corner, area, grams, holes, findings,
153
+ rests: [{ name: `SHEETS.${sheet}.density`, value: s.density.value, kind: s.density.kind }, { name: 'PANEL_DEFAULTS.corner', value: corner, kind: PANEL_DEFAULTS.corner.kind }] };
154
+ }
155
+
156
+ /**
157
+ * A panel's solid: the sheet from [0, 0] to its size on x and y, z from 0 to its thickness, its corners rounded and its
158
+ * holes cut. @param {Panel} m panelModel's @param {{ printer?: object, ops?: object }} [o] ops: booleans to cut with, JSCAD's where left out
159
+ * @returns {object} a JSCAD geom3, with .model
160
+ */
161
+ export function panel(m, o = {}) {
162
+ if (m?.kind !== 'panel') throw new Error(`panel: give a panel's model (panelModel), not ${shown(m)}`);
163
+ const [a, b] = m.size, r = m.corner, pr = printerOf('panel', o.printer);
164
+ const out = r > 0 ? roundConcave(ccw([[0, 0], [a, 0], [a, b], [0, b]]).reverse(), r).reverse() : [[0, 0], [a, 0], [a, b], [0, b]];
165
+ const body = prism(out, m.thickness), cuts = m.holes.map((h) => hole(h.thread, { kind: 'clearance', into: '-z', depth: m.thickness + 2, at: [h.at[0], h.at[1], m.thickness + 1], printer: pr }));
166
+ return Object.assign(cuts.length ? (o.ops ? o.ops.subtract(body, ...cuts) : subtract(body, ...cuts)) : body, { model: m });
167
+ }
168
+
169
+ // ---------- a panel clip ----------
170
+ /**
171
+ * A printed clip that holds a panel's edge down on a beam's face: a block on the face, screwed into a slot nut on the
172
+ * slot's centre line, keyed into the slot by a tongue, reaching over the panel's edge with a step as deep as the sheet.
173
+ * Sized from a named load (the panel pushed out at the clip) by beam formulas to about twice the margin; then made
174
+ * thick enough that a screw sold engages its nut and stops short of the slot's floor. It prints on its side.
175
+ * @param {string | object} profile @param {{ sheet: number, face?: string, thread?: string, head?: 'cap' | 'button', nut?: string, load?: number, grip?: number, printer?: object, material?: string | object, given?: object }} o
176
+ * sheet: the panel's thickness; grip: how far it reaches over the panel (default PANEL_DEFAULTS.grip)
177
+ * @returns {object} the clip's model: edge (where the panel's edge goes, from the slot's centre line), height, screws, grams, margin, findings
178
+ */
179
+ export function panelClipModel(profile, o = {}) {
180
+ const what = 'panelClipModel';
181
+ options(what, o ?? {}, ['sheet', 'face', 'thread', 'head', 'nut', 'load', 'grip', 'printer', 'material', 'given']);
182
+ const T = sheetThickness(what, o.sheet), given = o.given ?? {}, p = profileOf(what, profile, given), k = partSetup(what, o);
183
+ loadOk(what, o.load, 'the force pushing the panel out at one clip');
184
+ const head = o.head ?? 'button';
185
+ if (!['cap', 'button'].includes(head)) throw new Error(`${what}: head is cap or button (got ${shown(o.head)})`);
186
+ const grip = o.grip ?? PANEL_DEFAULTS.grip.value;
187
+ if (!(isNum(grip) && grip > 0)) throw new Error(`${what}: grip is how far the clip reaches over the panel, in mm, above 0 (got ${shown(o.grip)})`);
188
+ const sd = slotSide(what, p, o.face ?? 'top', o.thread, o.nut, k.fit, given), sc = screwOf(what, sd.thread, head, k.pr);
189
+ const w = sd.cell, gap = PANEL_DEFAULTS.gap.value, e = r3(up(Math.max(FITTING_DEFAULTS.end.value * sc.hd, sc.dk / 2 + FITTING_DEFAULTS.reach.value), 0.5)), reach = r3(e + gap + grip);
190
+ const F = o.load ?? PANEL_DEFAULTS.load.value, M = F * (gap + grip / 2), least = up(PANEL_DEFAULTS.walls.value * k.line, k.layer);
191
+ const tc0 = Math.max(least, up(bendT(M, w, k.S, want()), k.layer)), fits = sold(r3(T + tc0), k.layer, [sd], sd.thread), H = fits ? fits.t : r3(T + tc0), tc = r3(H - T);
192
+ const stress = r3((6 * M) / (w * tc * tc)), margin = r3(k.S / stress);
193
+ const loop = roundConcave(ccw([[-e, 0], [e, 0], [e, T], [reach, T], [reach, H], [-e, H]]), gap, null, 8).map(([y, z]) => [r3(y), r3(z)]);
194
+ const m = { kind: 'fitting', fitting: 'panel-clip', name: `panel-clip-${short(p)}-${sd.thread.toLowerCase()}-${mm(T)}mm`, title: `printed panel clip for ${short(p)}, a ${mm(T)} mm sheet, ${sd.thread}`,
195
+ profile: p.name, face: sd.face, thread: sd.thread, head, sheet: T, width: w, height: H, thickness: tc, edge: r3(e + gap), grip, reach, section: loop,
196
+ tongue: { slot: sd.slot.name, ...sd.tongue, nut: sd.nut.name },
197
+ screws: [{ thread: sd.thread, head, grip: H, at: [0, 0, H], axis: [0, 0, -1], nut: sd.nut.name, nutKind: sd.nut.nutKind, length: fits?.lengths[0] ?? null }],
198
+ load: { force: F, what: `${F} N pushing the panel out at the clip, ${mm(gap + grip / 2)} mm past its step` }, stress, margin, size: { width: w, height: H, thickness: tc, edge: r3(e + gap), grip },
199
+ volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
200
+ rests: [{ name: `${k.mat.name}.strength`, value: k.S }, ...['gap', 'grip', 'load', 'walls'].map((x) => ({ name: `PANEL_DEFAULTS.${x}`, value: PANEL_DEFAULTS[x].value, kind: PANEL_DEFAULTS[x].kind }))] };
201
+ weigh(m, panelClip(m, { printer: k.pr }), k.density);
202
+ tongueFinding(m, sd, k.pr); screwFinding(m, fits, sc);
203
+ closing(m, { S: k.S, sizeText: `${mm(H)} mm high over the face, ${mm(tc)} mm over the panel, ${mm(w)} mm wide; the panel's edge ${mm(e + gap)} mm from the slot's centre line, held ${mm(grip)} mm in`, marginText: `under ${m.load.what}, the step's root bends to ${mm(stress)} MPa`, pose: 'on its side, its section the first layer' });
204
+ return m;
205
+ }
206
+
207
+ /**
208
+ * A panel clip's solid, from panelClipModel's model: on its side to print (pose 'print'), or fitted (pose 'fit').
209
+ * tongues: false leaves the tongue off; ops: booleans to join and cut with.
210
+ * @param {object} m @param {{ pose?: 'print' | 'fit', tongues?: boolean, ops?: object, printer?: object }} [o] @returns {object} a JSCAD geom3, with .model
211
+ */
212
+ export function panelClip(m, o = {}) {
213
+ if (m?.fitting !== 'panel-clip') throw new Error(`panelClip: give a clip's model (panelClipModel), not ${shown(m)}`);
214
+ const pr = printerOf('panelClip', o.printer), g = sidePart({ loop: m.section, width: m.width, tongue: o.tongues === false ? null : { at: 0, ...m.tongue }, holes: [{ thread: m.thread, y: 0, top: m.height }], pr, ops: o.ops });
215
+ return Object.assign(o.pose === 'fit' ? transform(sideToFit(m.width), g) : g, { model: m });
216
+ }
217
+
218
+ // ---------- a panel corner ----------
219
+ /**
220
+ * A printed corner piece over a panel's corner where two beams meet: an L on both beams' faces, a screw into each slot
221
+ * past the crossing, a step as deep as the sheet over the panel's corner, rounded where the panel's corner sits.
222
+ * Its frame: the two slots' centre lines along x and y, crossing at the origin, the panel's corner toward +x +y, z out
223
+ * of the faces. It prints its top face down.
224
+ * @param {string | object} profile @param {{ sheet: number, face?: string, thread?: string, head?: 'cap' | 'button', nut?: string, load?: number, grip?: number, printer?: object, material?: string | object, given?: object }} o
225
+ * @returns {object} the corner's model
226
+ */
227
+ export function panelCornerModel(profile, o = {}) {
228
+ const what = 'panelCornerModel';
229
+ options(what, o ?? {}, ['sheet', 'face', 'thread', 'head', 'nut', 'load', 'grip', 'printer', 'material', 'given']);
230
+ const clip = panelClipModel(profile, { ...o }), k = partSetup(what, o), p = profileOf(what, profile, o.given ?? {});
231
+ const half = Math.max(p.width, p.height) / 2, nutLen = Math.max(...slotSide(what, p, o.face ?? 'top', clip.thread, o.nut, k.fit, o.given ?? {}).nuts.map((n) => n.length));
232
+ const sc = screwOf(what, clip.thread, clip.head, k.pr), s = r3(up(Math.max(half + nutLen / 2 + k.fit, clip.reach + sc.dk / 2), 0.5)), end = r3(up(s + clip.edge - PANEL_DEFAULTS.gap.value, 0.5));
233
+ const e = clip.edge - PANEL_DEFAULTS.gap.value, R = clip.reach;
234
+ const outline = roundConcave(ccw([[-e, -e], [end, -e], [end, R], [R, R], [R, end], [-e, end]]), Math.min(R - e, 3), null, 10).map(([x, y]) => [r3(x), r3(y)]);
235
+ // the clip's load at the corner, on the step along both edges near it (two grips long): sized as a clip is
236
+ const F = clip.load.force, M = F * (PANEL_DEFAULTS.gap.value + clip.grip / 2), b = 2 * clip.grip, tc0 = Math.max(clip.thickness, up(bendT(M, b, k.S, want()), k.layer));
237
+ const sd = slotSide(what, p, o.face ?? 'top', clip.thread, o.nut, k.fit, o.given ?? {}), fits = sold(r3(clip.sheet + tc0), k.layer, [sd], clip.thread), H = fits ? fits.t : r3(clip.sheet + tc0), T = clip.sheet;
238
+ const stress = r3((6 * M) / (b * (H - T) ** 2)), margin = r3(k.S / stress);
239
+ const m = { kind: 'fitting', fitting: 'panel-corner', name: clip.name.replace('panel-clip', 'panel-corner'), title: clip.title.replace('panel clip', 'panel corner'), profile: clip.profile, face: clip.face, thread: clip.thread, head: clip.head,
240
+ sheet: T, height: H, thickness: r3(H - T), edge: clip.edge, outline, arm: end, round: PANEL_DEFAULTS.corner.value, tongue: clip.tongue, cross: half,
241
+ screws: [[s, 0], [0, s]].map(([x, y]) => ({ ...clip.screws[0], grip: H, at: [x, y, H], length: fits?.lengths[0] ?? null })), load: { force: F, what: `${F} N pushing the panel's corner out` }, stress, margin, size: { arm: end, height: H, edge: clip.edge },
242
+ volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [], rests: clip.rests };
243
+ weigh(m, panelCorner(m, { printer: k.pr }), k.density);
244
+ closing(m, { S: k.S, sizeText: `arms ${mm(end)} mm along each slot from the crossing, ${mm(H)} mm high, its screws ${mm(s)} mm along each slot, clear of the other beam`, marginText: `under ${m.load.what}, the step bends to ${mm(stress)} MPa`, pose: 'top face down, its step and tongues up' });
245
+ return m;
246
+ }
247
+
248
+ /**
249
+ * A panel corner's solid: top face down to print (pose 'print'), or fitted (pose 'fit').
250
+ * @param {object} m @param {{ pose?: 'print' | 'fit', tongues?: boolean, ops?: object, printer?: object }} [o] @returns {object} a JSCAD geom3, with .model
251
+ */
252
+ export function panelCorner(m, o = {}) {
253
+ if (m?.fitting !== 'panel-corner') throw new Error(`panelCorner: give a corner's model (panelCornerModel), not ${shown(m)}`);
254
+ const pr = printerOf('panelCorner', o.printer), root = pfig(pr, 'fit'), H = m.height, T = m.sheet, e = m.edge - PANEL_DEFAULTS.gap.value, big = m.arm + 10;
255
+ // in the print frame: y = -y(fit), z = H - z(fit), so the contact face is on top at z = H and the step opens up
256
+ const flip = (pts) => pts.map(([x, y]) => [x, -y]), parts = [prism(flip(m.outline), H)];
257
+ if (o.tongues !== false && m.tongue.depth > 0) {
258
+ const tl = tongueLoop(-m.tongue.width / 2, m.tongue.width / 2, m.tongue.depth, false, root), from = m.cross + root, len = m.arm - root - from;
259
+ parts.push(transform([0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, from, 0, 0, 1], prism(tl.map(([n, a]) => [a, H + n]), len))); // along x: (a, H + n) in (Y, Z)
260
+ parts.push(transform([0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -(from + len), 0, 1], prism(tl.map(([n, a]) => [H + n, a]), len))); // along -y: (H + n, a) in (Z, X)
261
+ }
262
+ // the step over the panel: x > e and y > e (fitted), its corner at (e, e) rounded where the panel's rounded corner sits
263
+ const rr = m.round + PANEL_DEFAULTS.gap.value, arc = Array.from({ length: 13 }, (_, i) => { const t = Math.PI + (i / 12) * (Math.PI / 2); return [e + rr + rr * Math.cos(t), e + rr + rr * Math.sin(t)]; });
264
+ const step = translate([0, 0, H - T], prism(flip([[big, e], [big, big], [e, big], ...arc]), T + 1));
265
+ const holes = m.screws.map((q) => hole(m.thread, { kind: 'clearance', into: '+z', depth: H + 2 + m.tongue.depth, at: [q.at[0], -q.at[1], -1], printer: pr }));
266
+ const g = combine(parts, [step, ...holes], o.ops);
267
+ return Object.assign(o.pose === 'fit' ? transform([1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, H, 1], g) : g, { model: m });
268
+ }
269
+
270
+ // ---------- strips: a slot cover, an in-slot panel edge, a gasket ----------
271
+ // A strip's section in (y, z) of its fitted frame, extruded along x for its length (pose 'fit'); to print, turned over
272
+ // onto its top (bed 'top') or lifted onto its lowest face (bed 'bottom'), lying along the bed
273
+ function stripSolid(loop, length, bed, pose) {
274
+ const fit = transform([0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1], prism(loop, length));
275
+ if (pose === 'fit') return fit;
276
+ const zs = loop.map((q) => q[1]), top = Math.max(...zs), low = Math.min(...zs);
277
+ return bed === 'top' ? transform([1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, top, 1], fit) : translate([0, 0, -low], fit);
278
+ }
279
+ const lengthOk = (what, L) => { if (!(isNum(L) && L > 0 && L <= 2000)) throw new Error(`${what}: length is the strip's, in mm, above 0 and up to 2000 (got ${shown(L)})`); return L; };
280
+
281
+ /**
282
+ * A printed cover that closes a slot nothing uses: a thin flange on the face, a stem in the slot's opening and a barb
283
+ * under each lip, leaning 45° so it prints. It prints lying down, its flange on the bed.
284
+ * @param {string | object} profile @param {{ length: number, face?: string, printer?: object, material?: string | object, given?: object }} o
285
+ * @returns {object} its model
286
+ */
287
+ export function slotCoverModel(profile, o = {}) {
288
+ const what = 'slotCoverModel';
289
+ options(what, o ?? {}, ['length', 'face', 'printer', 'material', 'given']);
290
+ const L = lengthOk(what, o.length), given = o.given ?? {}, p = profileOf(what, profile, given), k = partSetup(what, o);
291
+ const sd = slotSide(what, p, o.face ?? 'top', undefined, null, k.fit, given);
292
+ const op = sd.slot.opening, lip = sd.slot.lip, ws = r3(op - 2 * k.fit), b = PANEL_DEFAULTS.barb.value, tf = r3(up(2 * k.layer + k.layer, k.layer)), lap = PANEL_DEFAULTS.lap.value, half = r3(op / 2 + lap);
293
+ if (ws < 2 * k.line) throw new Error(`${what}: ${sd.slot.name}'s ${mm(op)} mm opening leaves a stem ${mm(ws)} mm wide: too thin to print`);
294
+ const loop = [[-half, 0], [-ws / 2, 0], [-ws / 2, -lip], [-ws / 2 - b, -lip - b], [-ws / 2, -lip - 2 * b], [-ws / 2 + b, -lip - 2 * b - b], [ws / 2 - b, -lip - 3 * b], [ws / 2, -lip - 2 * b], [ws / 2 + b, -lip - b], [ws / 2, -lip], [ws / 2, 0], [half, 0], [half, tf], [-half, tf]].map(([y, z]) => [r3(y), r3(z)]);
295
+ const m = { kind: 'fitting', fitting: 'slot-cover', name: `slot-cover-${sd.slot.name.replace(/^slot-/, '')}-${Math.round(L)}`, title: `printed slot cover for ${sd.slot.name}, ${mm(L)} mm`, profile: p.name, face: sd.face, slot: sd.slot.name, length: L, section: loop,
296
+ flange: tf, stem: ws, barb: b, screws: [], load: { force: 0, what: 'none: it carries nothing' }, stress: 0, margin: Infinity, size: { length: L, flange: tf, stem: ws, barb: b }, volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
297
+ rests: ['barb', 'lap'].map((x) => ({ name: `PANEL_DEFAULTS.${x}`, value: PANEL_DEFAULTS[x].value, kind: PANEL_DEFAULTS[x].kind })) };
298
+ weigh(m, slotCover(m), k.density);
299
+ m.findings.push(finding('info', `${m.title}: a ${mm(tf)} mm flange lapping the face ${mm(lap)} mm past the opening, a ${mm(ws)} mm stem through the ${mm(lip)} mm lip, barbs ${mm(b)} mm past the opening under it (an estimate: try one in a scrap of beam)`, 'fitting.size', { values: { ...m.size } }));
300
+ m.findings.push(finding('info', 'it is drawn to print lying down, its flange on the bed, the barbs\' faces leaning 45°: no supports (printcheck\'s check() reads the solid)', 'fitting.printable', { values: { pose: 'flange down' } }));
301
+ m.findings.push(finding('info', `it weighs ${mm(m.grams)} g of ${m.material} (${mm(m.volume)} mm³)`, 'fitting.mass', { values: { grams: m.grams, volume: m.volume } }));
302
+ return m;
303
+ }
304
+ /** A slot cover's solid: flange down to print (pose 'print'), or fitted (pose 'fit'). @param {object} m @param {{ pose?: 'print' | 'fit' }} [o] @returns {object} */
305
+ export function slotCover(m, o = {}) {
306
+ if (m?.fitting !== 'slot-cover') throw new Error(`slotCover: give a slot cover's model (slotCoverModel), not ${shown(m)}`);
307
+ return Object.assign(stripSolid(m.section, m.length, 'top', o.pose), { model: m });
308
+ }
309
+
310
+ /**
311
+ * A printed edge that holds a sheet thinner than a slot's opening in the slot: a channel as wide as the opening less
312
+ * the fit, a groove as wide as the sheet with the fit, as deep as the lip and the cavity allow. Refused by name where
313
+ * the sheet leaves walls thinner than the printer's lines allow. It prints lying down, its groove up.
314
+ * @param {string | object} profile @param {{ sheet: number, length: number, face?: string, printer?: object, material?: string | object, given?: object }} o
315
+ * @returns {object} its model: depth (how far the sheet goes into the slot past the face)
316
+ */
317
+ export function panelEdgeModel(profile, o = {}) {
318
+ const what = 'panelEdgeModel';
319
+ options(what, o ?? {}, ['sheet', 'length', 'face', 'printer', 'material', 'given']);
320
+ const T = sheetThickness(what, o.sheet), L = lengthOk(what, o.length), given = o.given ?? {}, p = profileOf(what, profile, given), k = partSetup(what, o);
321
+ const sd = slotSide(what, p, o.face ?? 'top', undefined, null, k.fit, given), op = sd.slot.opening, ws = r3(op - 2 * k.fit), groove = r3(T + 2 * k.fit), wall = r3((ws - groove) / 2), least = 2 * k.line;
322
+ if (wall < least - 1e-9) throw new Error(`${what}: a ${mm(T)} mm sheet in ${sd.slot.name}'s ${mm(op)} mm opening leaves walls of ${mm(wall)} mm, under the ${mm(least)} mm two of ${k.pr.name}'s lines make: a sheet of ${mm(Math.max(0, ws - 2 * least - 2 * k.fit))} mm or less, or panel clips on the face`);
323
+ const floor = r3(up(2 * k.layer, k.layer)), depth = r3(Math.min(sd.slot.cavityDepth - FITTING_DEFAULTS.floor.value, sd.slot.lip + 2)), h = depth;
324
+ const loop = [[-ws / 2, -h], [ws / 2, -h], [ws / 2, 0], [groove / 2, 0], [groove / 2, -h + floor], [-groove / 2, -h + floor], [-groove / 2, 0], [-ws / 2, 0]].map(([y, z]) => [r3(y), r3(z)]);
325
+ const m = { kind: 'fitting', fitting: 'panel-edge', name: `panel-edge-${sd.slot.name.replace(/^slot-/, '')}-${mm(T)}mm-${Math.round(L)}`, title: `printed in-slot edge for a ${mm(T)} mm sheet in ${sd.slot.name}, ${mm(L)} mm`, profile: p.name, face: sd.face, slot: sd.slot.name,
326
+ sheet: T, length: L, section: loop, width: ws, groove, wall, depth: r3(h - floor), screws: [], load: { force: 0, what: 'the sheet\'s own weight' }, stress: 0, margin: Infinity, size: { width: ws, groove, wall, depth: r3(h - floor), length: L },
327
+ volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [], rests: [{ name: `${k.pr.name}.fit`, value: k.fit }] };
328
+ weigh(m, panelEdge(m), k.density);
329
+ m.findings.push(finding('info', `${m.title}: ${mm(ws)} mm wide in the ${mm(op)} mm opening, its groove ${mm(groove)} mm (the sheet and the fit each side), walls ${mm(wall)} mm; the sheet goes ${mm(h - floor)} mm into the slot past the face`, 'fitting.size', { values: { ...m.size } }));
330
+ m.findings.push(finding('info', 'it is drawn to print lying down, its floor on the bed and its groove up: no supports', 'fitting.printable', { values: { pose: 'floor down' } }));
331
+ m.findings.push(finding('info', `it weighs ${mm(m.grams)} g of ${m.material} (${mm(m.volume)} mm³)`, 'fitting.mass', { values: { grams: m.grams, volume: m.volume } }));
332
+ return m;
333
+ }
334
+ /** An in-slot panel edge's solid: floor down to print, or fitted. @param {object} m @param {{ pose?: 'print' | 'fit' }} [o] @returns {object} */
335
+ export function panelEdge(m, o = {}) {
336
+ if (m?.fitting !== 'panel-edge') throw new Error(`panelEdge: give a panel edge's model (panelEdgeModel), not ${shown(m)}`);
337
+ return Object.assign(stripSolid(m.section, m.length, 'bottom', o.pose), { model: m });
338
+ }
339
+
340
+ /**
341
+ * A printed gasket strip for a door's gap: a hollow triangle of thin walls, its base taped to the door's inner face,
342
+ * as high as the gap and the squeeze, so the closing door presses it onto the beam's face. Its walls lean 30° from
343
+ * upright, so it prints lying on its base and folds rather than buckles. Best in PETG, which springs back where PLA creeps.
344
+ * @param {{ gap: number, length: number, squeeze?: number, printer?: object, material?: string | object }} o
345
+ * @returns {object} its model: strain (its walls' at the squeeze) against the plastic's limit
346
+ */
347
+ export function gasketStripModel(o = {}) {
348
+ const what = 'gasketStripModel';
349
+ options(what, o ?? {}, ['gap', 'length', 'squeeze', 'printer', 'material']);
350
+ if (!(isNum(o.gap) && o.gap > 0)) throw new Error(`${what}: gap is the door's standoff from the beam's face, in mm, above 0 (got ${shown(o.gap)})`);
351
+ const L = lengthOk(what, o.length), k = partSetup(what, { material: 'petg', ...o }), sq = o.squeeze ?? PANEL_DEFAULTS.squeeze.value;
352
+ if (!(isNum(sq) && sq > 0 && sq < o.gap)) throw new Error(`${what}: squeeze is how far the door presses it, in mm, above 0 and under the gap (got ${shown(o.squeeze)})`);
353
+ const h = r3(o.gap + sq), t = r3(2 * k.line), half = r3(h * Math.tan(Math.PI / 6)), E = k.mat.rules.modulus.value;
354
+ const outer = [[-half, 0], [half, 0], [0, h]], d = t / Math.cos(Math.PI / 6), inner = [[-half + d * 1.8, t], [half - d * 1.8, t], [0, h - 2 * d]];
355
+ // each wall a cantilever of its slant length, pushed sq at its tip: strain 3 t δ / (2 L²)
356
+ const slant = Math.hypot(half, h), strain = r3((3 * t * sq) / (2 * slant * slant)), limit = r3(k.S / E), margin = r3(limit / strain);
357
+ const m = { kind: 'fitting', fitting: 'gasket-strip', name: `gasket-strip-${mm(o.gap)}mm-${Math.round(L)}`, title: `printed gasket strip for a ${mm(o.gap)} mm gap, ${mm(L)} mm`, length: L, height: h, wall: t, base: r3(2 * half), squeeze: sq, outer, inner,
358
+ screws: [], load: { force: 0, what: `the door pressing it ${mm(sq)} mm` }, strain, stress: r3(strain * E), margin, size: { height: h, base: r3(2 * half), wall: t, length: L }, volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
359
+ rests: [{ name: `${k.mat.name}.strength`, value: k.S }, { name: `${k.mat.name}.modulus`, value: E }, { name: 'PANEL_DEFAULTS.squeeze', value: sq, kind: PANEL_DEFAULTS.squeeze.kind }] };
360
+ weigh(m, gasketStrip(m), k.density);
361
+ const ok = margin >= want() - 1e-9;
362
+ m.findings.push(finding('info', `${m.title}: a hollow triangle ${mm(h)} mm high on a ${mm(2 * half)} mm base, walls ${mm(t)} mm (two lines), squeezed ${mm(sq)} mm`, 'fitting.size', { values: { ...m.size } }));
363
+ m.findings.push(finding(ok ? 'pass' : 'warn', `pressed ${mm(sq)} mm, its walls bend to a strain of ${mm(strain * 100)}%, ${mm(margin)} times under ${m.material.toUpperCase()}'s ${mm(limit * 100)}% (its strength over its modulus): by beam formulas, an estimate${m.material === 'pla' ? '. PLA creeps held bent: PETG keeps its spring' : ''}`, 'fitting.margin', { values: { strain, limit, margin } }));
364
+ m.findings.push(finding('info', 'it is drawn to print lying on its base, its walls leaning 30° from upright: no supports', 'fitting.printable', { values: { pose: 'base down' } }));
365
+ m.findings.push(finding('info', `it weighs ${mm(m.grams)} g of ${m.material} (${mm(m.volume)} mm³)`, 'fitting.mass', { values: { grams: m.grams, volume: m.volume } }));
366
+ return m;
367
+ }
368
+ /** A gasket strip's solid, base down (its print pose and, turned over onto the door, its fitted one). @param {object} m @returns {object} */
369
+ export function gasketStrip(m) {
370
+ if (m?.fitting !== 'gasket-strip') throw new Error(`gasketStrip: give a gasket strip's model (gasketStripModel), not ${shown(m)}`);
371
+ const turn = (dy) => [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, dy, 0, 1]; // (u, v) to (X, Z), along -Y
372
+ const body = transform(turn(m.length), prism(m.outer, m.length)), hollow = transform(turn(m.length + 1), prism(m.inner, m.length + 2));
373
+ return Object.assign(subtract(body, hollow), { model: m });
374
+ }
package/rods.d.mts ADDED
@@ -0,0 +1,195 @@
1
+ /**
2
+ * The layout of a rod guide on a face of a profile, with what its drive adds: the rods' spacing across the face and their
3
+ * height over it, the carriage's size, and the sets each part reads. The spacing leaves room for the lead nut's flange
4
+ * between the bearings (ROD_DEFAULTS.web); the height clears the carriage, the nut's flange, the screw's bearing in a
5
+ * holder, the coupler and the motor's body over the face. Refused by name: a set of the wrong part, a spacing or height
6
+ * that leaves no room. @param {string | object} profile
7
+ * @param {{ face?: string, rod?: string, bearing?: string, spacing?: number, height?: number, screw?: string, nut?: string, support?: string | null, coupler?: string, motor?: string, given?: object }} [o]
8
+ * @returns {object} the layout
9
+ */
10
+ export function rodsLayout(profile: string | object, o?: {
11
+ face?: string;
12
+ rod?: string;
13
+ bearing?: string;
14
+ spacing?: number;
15
+ height?: number;
16
+ screw?: string;
17
+ nut?: string;
18
+ support?: string | null;
19
+ coupler?: string;
20
+ motor?: string;
21
+ given?: object;
22
+ }): object;
23
+ /**
24
+ * A printed holder for two rods at one end of a rod guide: a saddle standing across the beam, its legs screwed into the
25
+ * slots of the faces either side, the rods pressed through it along the beam (their holes the rod's diameter with the
26
+ * printer's hole compensation: a light press), and, where a screw drives the carriage, the screw's bearing pressed in a
27
+ * pocket from its inner face (a bearing block at each end). Sized from a load along the beam at the rods' height to about
28
+ * twice the margin, by beam formulas. It prints on its outer face, the rods' holes upright.
29
+ * @param {string | object} profile
30
+ * @param {{ face?: string, end?: 'a' | 'b', rod?: string, bearing?: string, spacing?: number, height?: number, screw?: string, leadNut?: string, support?: string | null, load?: number, thread?: string, head?: 'cap' | 'button', nut?: string, printer?: object, material?: string | object, given?: object }} [o]
31
+ * end: a (its outer face toward end a, the default) or b (turned to face b); leadNut: the lead screw's nut's set; nut: the slot nuts' kind
32
+ * @returns {object} its model
33
+ */
34
+ export function rodHolderModel(profile: string | object, o?: {
35
+ face?: string;
36
+ end?: "a" | "b";
37
+ rod?: string;
38
+ bearing?: string;
39
+ spacing?: number;
40
+ height?: number;
41
+ screw?: string;
42
+ leadNut?: string;
43
+ support?: string | null;
44
+ load?: number;
45
+ thread?: string;
46
+ head?: "cap" | "button";
47
+ nut?: string;
48
+ printer?: object;
49
+ material?: string | object;
50
+ given?: object;
51
+ }): object;
52
+ /** A rod holder's solid: as it prints (on its outer face) or in its fitted frame. @param {object} m rodHolderModel's @param {{ pose?: 'print' | 'fit', ops?: object }} [o] @returns {object} */
53
+ export function rodHolder(m: object, o?: {
54
+ pose?: "print" | "fit";
55
+ ops?: object;
56
+ }): object;
57
+ /**
58
+ * A printed plate that holds a motor of the catalogue on a beam, its shaft along the beam over a face: a saddle standing
59
+ * across the beam, its legs screwed into the side faces' slots, two screws a leg so the motor's torque is held by shear,
60
+ * and the motor's mount cut from its own rules (its mounting holes, the boss's pocket and the shaft's hole, as
61
+ * @rulecad/motors' mount() cuts them; the screws' clearance holes are @rulecad/fixings'). The motor's mounting face lies on
62
+ * the plate's outer face, its body outside, a geared motor's body offset away from the face. The plate is at least half
63
+ * as thick again as the motor's screws (as @rulecad/motors asks) and sized from a load at the shaft to about twice the
64
+ * margin; where its shaft would reach too little into a coupler past it, a recess in its inner face takes the coupler in.
65
+ * It prints on its outer face: the boss's pocket ends in a 45° cone, the recess opens up.
66
+ * @param {string | object} profile
67
+ * @param {{ motor: string, face?: string, height?: number, coupler?: { length: number, D: number }, load?: number, thread?: string, head?: 'cap' | 'button', nut?: string, printer?: object, material?: string | object, given?: object }} o
68
+ * motor: its rule set (28byj48, nema14, nema17); height: the shaft's over the face (default the least the body clears);
69
+ * coupler: its length and diameter, where one goes on the shaft (default coupler-5-8's figures for a 5 mm shaft)
70
+ * @returns {object} its model, with anchors motor (where the motor's own frame goes) and coupler (where its face is)
71
+ */
72
+ export function motorPlateModel(profile: string | object, o?: {
73
+ motor: string;
74
+ face?: string;
75
+ height?: number;
76
+ coupler?: {
77
+ length: number;
78
+ D: number;
79
+ };
80
+ load?: number;
81
+ thread?: string;
82
+ head?: "cap" | "button";
83
+ nut?: string;
84
+ printer?: object;
85
+ material?: string | object;
86
+ given?: object;
87
+ }): object;
88
+ /** A motor plate's solid: as it prints (on its outer face) or in its fitted frame. @param {object} m motorPlateModel's @param {{ pose?: 'print' | 'fit', ops?: object }} [o] @returns {object} */
89
+ export function motorPlate(m: object, o?: {
90
+ pose?: "print" | "fit";
91
+ ops?: object;
92
+ }): object;
93
+ /**
94
+ * A printed carriage for a rod guide: a block over the face, two linear bearings pressed into pockets along the beam
95
+ * (from its inner end, a floor at the far end), and where a screw drives it the lead nut's body in a bore through its
96
+ * middle with the flange screwed to its far end, into pilots. With an endstop, a flag hangs from its far end beside the
97
+ * beam down past the switch's lever. Sized from a load on its middle, between the bearings, by beam formulas. It prints on
98
+ * its far end, the pockets opening up and the flag on the bed.
99
+ * @param {string | object} profile
100
+ * @param {{ face?: string, rod?: string, bearing?: string, spacing?: number, height?: number, screw?: string, leadNut?: string, flag?: { y: number, z: number }, load?: number, printer?: object, material?: string | object, given?: object }} [o]
101
+ * flag: where its tip reaches, in its frame (y across, z over the face: below 0 is beside the beam)
102
+ * @returns {object} its model, with anchors slide (its joint), lm1 and lm2 (the bearings), nut and top
103
+ */
104
+ export function rodCarriageModel(profile: string | object, o?: {
105
+ face?: string;
106
+ rod?: string;
107
+ bearing?: string;
108
+ spacing?: number;
109
+ height?: number;
110
+ screw?: string;
111
+ leadNut?: string;
112
+ flag?: {
113
+ y: number;
114
+ z: number;
115
+ };
116
+ load?: number;
117
+ printer?: object;
118
+ material?: string | object;
119
+ given?: object;
120
+ }): object;
121
+ /** A rod carriage's solid: as it prints (on its far end) or in its fitted frame. @param {object} m rodCarriageModel's @param {{ pose?: 'print' | 'fit', ops?: object }} [o] @returns {object} */
122
+ export function rodCarriage(m: object, o?: {
123
+ pose?: "print" | "fit";
124
+ ops?: object;
125
+ }): object;
126
+ /**
127
+ * A printed mount for a miniature switch (the catalogue's endstop-10t85) on a beam's slotted side face, where a carriage
128
+ * passes: a block on the face, the switch screwed to it through its own holes into pilots, its lever facing along the
129
+ * beam toward b and reaching across the face in the direction toward (+1 or -1 along the mount's y), and the block's screw
130
+ * into the slot ahead of the lever, its head sunk in a counterbore so the carriage's flag passes over it. It prints on the
131
+ * face side. @param {string | object} profile
132
+ * @param {{ switch?: string, face: string, toward?: 1 | -1, load?: number, thread?: string, nut?: string, printer?: object, material?: string | object, given?: object }} o
133
+ * @returns {object} its model: anchors.switch (the switch's own frame), lever (where its lever's face is, in the mount's frame)
134
+ */
135
+ export function endstopMountModel(profile: string | object, o?: {
136
+ switch?: string;
137
+ face: string;
138
+ toward?: 1 | -1;
139
+ load?: number;
140
+ thread?: string;
141
+ nut?: string;
142
+ printer?: object;
143
+ material?: string | object;
144
+ given?: object;
145
+ }): object;
146
+ /** An endstop mount's solid, in its fitted frame (which is how it prints). @param {object} m endstopMountModel's @param {{ pose?: 'print' | 'fit', ops?: object }} [o] @returns {object} */
147
+ export function endstopMount(m: object, o?: {
148
+ pose?: "print" | "fit";
149
+ ops?: object;
150
+ }): object;
151
+ /**
152
+ * A rod carriage's loads against its linear bearings' static rating: the force and moment on the carriage, in its frame
153
+ * about its slide (on the rods' line between them), shared between its two bearings: the forces across the rods half
154
+ * each, a roll about the rods' line as a couple across their spacing, pitch and yaw as a couple along each bearing
155
+ * (ROD_DEFAULTS.couple: an estimate). Each bearing's radial load over its static rating; the margin is the least.
156
+ * The force along the beam is the drive's. @param {object} m rodCarriageModel's (its bearing named)
157
+ * @param {{ force: number[], moment: number[] }} load N and N m, in the carriage's frame
158
+ * @returns {{ bearings: { name: string, radial: number, ratio: number }[], worst: string, margin: number, level: 'pass' | 'warn' | 'fail', rating: number }}
159
+ */
160
+ export function rodMargin(m: object, load: {
161
+ force: number[];
162
+ moment: number[];
163
+ }): {
164
+ bearings: {
165
+ name: string;
166
+ radial: number;
167
+ ratio: number;
168
+ }[];
169
+ worst: string;
170
+ margin: number;
171
+ level: "pass" | "warn" | "fail";
172
+ rating: number;
173
+ };
174
+ export namespace ROD_DEFAULTS {
175
+ namespace gap {
176
+ export { text as rule };
177
+ export { kind };
178
+ export { source };
179
+ export { CHECKED as checked };
180
+ export { unit };
181
+ export { value };
182
+ }
183
+ namespace wall { }
184
+ namespace web { }
185
+ namespace floor { }
186
+ namespace press { }
187
+ namespace load { }
188
+ namespace switchLoad { }
189
+ namespace relief { }
190
+ namespace couple { }
191
+ namespace flag { }
192
+ namespace lever { }
193
+ }
194
+ declare const CHECKED: "2026-11-17";
195
+ export {};