@rulecad/fixings 0.1.6 → 0.1.7

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/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ What changed in each release, for someone upgrading a workspace. A **printed siz
4
4
  print (a hole's diameter, a seat's depth, a part's outline). Each release says whether any printed size moved, and
5
5
  why.
6
6
 
7
+ ## 0.1.7: a slotted snap skirt and printed bolts into slot nuts
8
+ ### Added
9
+
10
+ - **A slotted skirt for the annular snap** (issue 309): `annularSnapModel` takes `slots: { count, reach, width }`, the
11
+ lid's skirt cut into fingers, each a cantilever clamped at the slots' closed end (`skirtFinger`: the exact second
12
+ moment of a ring's sector, k = 3 E I / L³, root strain 3 c y / L²). The fingers' root strain is held to the same
13
+ limit as a hoop strain, and the finding `snap.fingers` says what a whole skirt would take for the same bead.
14
+ `snapSlots` cuts the slots, each ending in a full round. New rule `fixings.snap_slot` (1 mm, an estimate), and the
15
+ printer's `print_gap` is borrowed from the X1C where a printer lacks it. Refused by name: under 3 fingers, a slot
16
+ narrower than `print_gap`, a reach under twice the skirt or past the lid's top, fingers narrower than the skirt.
17
+ The bead bears on each finger at the groove's bottom edge, so the finger's arm is the reach plus the groove's
18
+ height (`slots.arm`), and a sized bead is worked at its own arm. So is `most.undercut`, the most undercut a failing
19
+ bead's findings name: a smaller bead has a shorter, stiffer arm, so the limit at the given bead's arm would fail.
20
+ For the 60 mm pot with its bead 14 mm under the rim, 16 fingers bring the push on from 329.9 N (a whole skirt
21
+ there) to 31.8 N. The bench's `snap-pot` gains a `slotted` variant and the assembly `snap-pot-slotted-closed`.
22
+
23
+ ### Printed sizes
24
+
25
+ - None moved: without `slots` every figure and solid is as before (checked against the pot's model before the change).
26
+
7
27
  ## 0.1.6: the annular snap: lids that click on (#76)
8
28
 
9
29
  ### Added
package/README.md CHANGED
@@ -69,7 +69,7 @@ and stresses in MPa.
69
69
  | [Pins](#pins) | `pinModel`, `pinHole`, `pin`, `snapPin`, `snapSocket`, `snapPinModel`, `parsePin`, `isPinName` |
70
70
  | [Printed bolts](#printed-bolts) | `printedBoltModel`, `printedBolt` |
71
71
  | [Magnets](#magnets) | `magnetModel`, `magnetSeatModel`, `magnetSeat`, `magnet`, `parseMagnet`, `isMagnetName`, `fieldShare` |
72
- | [Annular snaps](#annular-snaps) | `annularSnapModel`, `annularBead`, `annularGroove`, `hubFactor`, `shaftFactor`, `tubeRing` |
72
+ | [Annular snaps](#annular-snaps) | `annularSnapModel`, `annularBead`, `annularGroove`, `snapSlots`, `skirtFinger`, `hubFactor`, `shaftFactor`, `tubeRing` |
73
73
  | [Measuring the printer's fits](#measuring-the-printers-fits) | the fixings coupon and the holds coupon |
74
74
  | [Refusals and printability](#refusals-and-printability) | `printable` |
75
75
 
@@ -796,6 +796,72 @@ the most. The beam's own checks: a long tube deflects 1/8 under a ring load, and
796
796
  example project `enclosures` in the repository's bench draws this pot and lid (`snap-pot`) and puts the lid on
797
797
  (`snap-pot-closed`).
798
798
 
799
+ ### A slotted skirt
800
+
801
+ A whole skirt on a stiff box takes a hard push: 351.1 N square for the pot above. Slots cut up from the skirt's mouth
802
+ part it into fingers, and each finger bends as a cantilever, far more easily than a ring stretches, so the push falls
803
+ several times over. Give `slots: { count, reach, width }`: `count` fingers (3 or more), `reach` from the slots' closed
804
+ end to the groove's top edge, and `width` the slots' (default `fixings.snap_slot`,
805
+ 1 mm, at least the printer's `print_gap`). `snapSlots(model, { at, mouth })` is the cutter: the slots through the
806
+ skirt, in the same place as the bead and groove, each ending in a full round so the root that takes the bending has
807
+ no square corner.
808
+
809
+ **The sums.** `skirtFinger` gives one finger. Its section is a sector of the skirt's ring, its sides taken as radial,
810
+ 2φ round with φ = π / n - w / (2 rm). Its second moment about its own centroid, square to its line of symmetry, is
811
+ ∫x² dA - A x̄², worked exactly for the sector, so a wide finger's curve counts: for the pot's 16 fingers it is 2.14 mm⁴,
812
+ where a flat strip as wide is 1.85. The bead bears on a finger at the groove's bottom edge, the end nearest the mouth:
813
+ going on, the lip below the groove rides over the bead's crest, and coming off, the groove's lower face rides up the
814
+ bead's return face, each pushing the finger out the whole undercut as that edge passes the crest. So its arm L is
815
+ `reach` plus the groove's height, the bead's length and the clearance at each end (`slots.arm` in the model; a bigger
816
+ bead lengthens it, so a sized bead is worked at its own arm). Clamped at its root and pushed out y at L, a finger takes
817
+ k y with k = 3 E I / L³, and its root strains 3 c y / L², c its farthest fibre from that axis: the beam formulas for a
818
+ cantilever with an end load. The fingers side by side are n k / 2 per mm of diameter, in series with the box's wall as
819
+ before, and their root strain is held to the same limit as a hoop strain. The lid's top no longer holds the groove
820
+ round: each finger is clamped at its root already. The finding `snap.fingers` says what a whole skirt would take for
821
+ the same bead.
822
+
823
+ **Reach.** A short finger strains more than the ring it was cut from, so a slotted skirt wants a deeper lid: reaching
824
+ 5.8 mm (borne on at 7.411 mm), eight fingers on the pot above hold the bead to 0.097 mm of undercut, under the least the print holds. Refused
825
+ by name: under 3 fingers, a slot narrower than `print_gap`, a reach under twice the skirt (too short to bend as a beam)
826
+ or past the lid's top (`lidTop`), and fingers narrower than the skirt is thick.
827
+
828
+ ```js
829
+ import { annularSnapModel, snapSlots, skirtFinger } from '@rulecad/fixings';
830
+
831
+ const joint = { diameter: 60, wall: 1.68, skirt: 1.26, boxEnd: 14, lidEnd: 1.5, lidTop: 13.8, boxFloor: 23.3 };
832
+ const slotted = annularSnapModel({ ...joint, slots: { count: 16, reach: 11.8 } }, { pull: 10 });
833
+ console.log(slotted.bead, slotted.force, slotted.insertion, slotted.removal, slotted.margin, slotted.lid.strain, slotted.slots.whole);
834
+ console.log(slotted.slots.finger);
835
+ const one = skirtFinger({ count: 16, width: 1, reach: 11.8, inside: 30.2, outside: 31.46 }, 2680);
836
+ console.log(+one.stiffness.toFixed(2), +(one.strainPerY * 100).toFixed(3));
837
+ const slots = snapSlots(slotted, { at: 20, mouth: 18.3 });
838
+ console.log(slots.model === slotted);
839
+ try { annularSnapModel({ ...joint, slots: { count: 16, reach: 14 } }); } catch (e) { console.log(e.message.slice(0, 89)); }
840
+ ```
841
+
842
+ ```text
843
+ 0.4 21 31.8 63 6.3 0.003 217.8
844
+ {
845
+ angle: 20.64,
846
+ width: 11.11,
847
+ inertia: 2.1412,
848
+ fibre: 0.9564,
849
+ stiffness: 6.7
850
+ }
851
+ 10.48 2.061
852
+ true
853
+ annularSnapModel: slots.reach of 14 mm runs past the lid's top, 13.8 mm from the groove (
854
+ ```
855
+
856
+ The first line reads: the same pot with its bead 14 mm under the rim, the lid's skirt in 16 fingers by 1 mm slots,
857
+ each 11.8 mm from its root to the groove's top edge. The bead is the least the print holds, 0.4 mm, and bears on the
858
+ fingers 13.693 mm from their root (11.8 mm, the bead's 1.493 mm length and 0.2 mm clearance at each end). Its
859
+ transverse force is 21 N, where a whole skirt there would take 217.8 N: it goes on square with 31.8 N and comes off
860
+ with 63 N, 6.3 times the 10 N pull. The fingers' roots strain 0.30%, under PLA's 0.61%. Each finger is 20.64° round,
861
+ 11.11 mm wide at its middle, and takes 6.7 N per mm it is pushed out where the bead bears. `skirtFinger` alone takes
862
+ the arm it is given: at 11.8 mm it takes 10.48 N per mm, and each millimetre strains its root 2.061%. The bench's `snap-pot`
863
+ has this lid as its `slotted` variant, and `snap-pot-slotted-closed` puts it on.
864
+
799
865
  ## Measuring the printer's fits
800
866
 
801
867
  Every clearance a hole, a seat or a pocket is drawn with is a rule of the printer's, and most are estimates until two
@@ -890,7 +956,7 @@ hole: depth is a number above 0, in mm (got -2)
890
956
  `press`, `thread_gap`, `snap_clearance`, `pin_press`, `pin_slip`, `magnet_press`, `magnet_glue` and `magnet_crush`; a steel dowel's shear strength and the play a
891
957
  snap pin's shaft may have; a magnet's pull at a grade other than its seller's and across a gap, the grip of a press
892
958
  or of crush ribs on a magnet, the three layers under a magnet's pocket, and every strength of a printed bolt; the layers and line a printed thread needs; the layer left over a nut put in mid-print;
893
- an annular snap's friction (`snap_friction`, 0.5) and least undercut (`snap_least`), its stiffness between a free end
959
+ an annular snap's friction (`snap_friction`, 0.5), least undercut (`snap_least`) and slot width (`snap_slot`, 1 mm), a slotted skirt's fingers clamped at their roots with radial sides, its stiffness between a free end
894
960
  and a remote joint, a closed end taken as fully closed, the skirt's full thickness at its groove, and its plastic's yield strain (strength over modulus) and modulus in place of the guide's secant modulus;
895
961
  a material's shear strength (its tensile strength over √3) and what it bears under a head (its strength); the nut
896
962
  factor K (0.2); the diameter of thread asked in an insert; the millimetre kept at a screw's tip; and every mass.
@@ -954,6 +1020,7 @@ with its `rule`, `kind` and `source`.
954
1020
  | Its forces along the push | W = P (μ + tan α) / (1 - μ tan α), α the lead going on and the return face coming off; refused where μ tan α ≥ 1 on the lead | The same guide (page 14) |
955
1021
  | A closed end near the joint | w'''' + 4 w = 0 in ξ = βx, β⁴ = 3 (1 - ν²) / (R² t²); a ring load q steps w''' by q / (D β³), D = E t³ / 12 (1 - ν²); a free end has w'' = w''' = 0, a closed one w = w' = 0; the part is stiffer by w(open) / w(closed) | Hetényi, Beams on Elastic Foundation (1946): a long tube gives w = Pβ / 2k, a free end 2Pβ / k; the end taken as fully closed, an estimate on the stiff side |
956
1022
  | The bending at a closed end | M = w''(ξ) q / β, q = P / (π d); ε = 6 M (1 - ν²) / (E t²) | Plate bending, with the same beam |
1023
+ | A slotted skirt's finger | φ = π / n - w / (2 rm); A = φ (ro² - ri²), A x̄ = 2 (ro³ - ri³) sin φ / 3, I = (ro⁴ - ri⁴)(φ + sin φ cos φ) / 4 - A x̄²; k = 3 E I / L³; root strain 3 c y / L²; the lid n k / 2 per mm of diameter | The area moments of a ring's sector, and the cantilever with an end load (deflection P L³ / 3 E I, root stress P L c / I) from Euler-Bernoulli beam theory; the root taken as clamped, an estimate on the stiff side |
957
1024
 
958
1025
  VDI 2230 and Machinery's Handbook are named because the plan asked for them. Neither was read at first hand for
959
1026
  this package: the handbook's thread shear area and stress area are applied as the pages above give them, and VDI
@@ -986,6 +1053,7 @@ this package: the handbook's thread shear area and stress area are applied as th
986
1053
  - **Start**: one of the separate threads wound side by side on a multi-start screw.
987
1054
  - **Stripping**: a thread failing by its teeth shearing off.
988
1055
  - **Secant modulus**: a plastic's stress over its strain at a given strain, a little under its modulus at small strains.
1056
+ - **Slotted skirt**: a lid's skirt cut by slots from its mouth into fingers, each a cantilever, so an annular snap goes on with a smaller push.
989
1057
  - **Teardrop**: a round hole with a pointed top, so a hole lying on its side prints with no support.
990
1058
  - **Trapezoidal thread**: the flat-topped thread of a lead screw, with flanks 30° apart.
991
1059
  - **Undercut**: how far a snap's bead stands past the part it has to pass, so the parts must bend to let it by.
package/fixings.d.mts CHANGED
@@ -36,4 +36,4 @@ export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGro
36
36
  export { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName, PIN_KINDS, PIN_FITS, PIN_GRAMMAR } from "./pins.mjs";
37
37
  export { printedBoltModel, printedBolt, BOLT_NUTS } from "./bolts.mjs";
38
38
  export { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare, MAGNET_GRADES, MAGNET_FITS, MAGNET_SIZES, MAGNET_GRAMMAR } from "./magnets.mjs";
39
- export { annularSnapModel, annularBead, annularGroove, hubFactor, shaftFactor, tubeRing, SNAP_USES } from "./snaps.mjs";
39
+ export { annularSnapModel, annularBead, annularGroove, snapSlots, skirtFinger, hubFactor, shaftFactor, tubeRing, SNAP_USES } from "./snaps.mjs";
package/fixings.mjs CHANGED
@@ -20,7 +20,7 @@ import { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGro
20
20
  import { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName } from './pins.mjs';
21
21
  import { printedBoltModel, printedBolt } from './bolts.mjs';
22
22
  import { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare } from './magnets.mjs';
23
- import { annularSnapModel, annularBead, annularGroove, hubFactor, shaftFactor, tubeRing } from './snaps.mjs';
23
+ import { annularSnapModel, annularBead, annularGroove, snapSlots, skirtFinger, hubFactor, shaftFactor, tubeRing } from './snaps.mjs';
24
24
 
25
25
  export { fixingModel, parseName, threads, GRAMMAR, HEADS, NUTS, DEFAULTS } from './model.mjs';
26
26
  export { holeModel, hole, HOLE_KINDS } from './holes.mjs';
@@ -31,7 +31,7 @@ export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGro
31
31
  export { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName, PIN_KINDS, PIN_FITS, PIN_GRAMMAR } from './pins.mjs';
32
32
  export { printedBoltModel, printedBolt, BOLT_NUTS } from './bolts.mjs';
33
33
  export { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare, MAGNET_GRADES, MAGNET_FITS, MAGNET_SIZES, MAGNET_GRAMMAR } from './magnets.mjs';
34
- export { annularSnapModel, annularBead, annularGroove, hubFactor, shaftFactor, tubeRing, SNAP_USES } from './snaps.mjs';
34
+ export { annularSnapModel, annularBead, annularGroove, snapSlots, skirtFinger, hubFactor, shaftFactor, tubeRing, SNAP_USES } from './snaps.mjs';
35
35
 
36
36
  /**
37
37
  * What this release is. `release` is `'placeholder'` until the package has functions to call (0.1.0), then `'ready'`:
@@ -62,7 +62,7 @@ export function fixingsFor({ sets, printer, ops, display } = {}) {
62
62
  out.lengthFor = (stack, m, o = {}) => lengthFor(stack, m, with_(o));
63
63
  out.screwGroup = screwGroup;
64
64
  // (a snap pin from plain figures, as @rulecad/flexures draws it, built with the design's booleans)
65
- Object.assign(out, { snapPin: (p, o) => snapPin(p, o ?? ops ?? undefined), snapSocket, snapPinModel, parsePin, isPinName, parseMagnet, isMagnetName, fieldShare, hubFactor, shaftFactor, tubeRing });
65
+ Object.assign(out, { snapPin: (p, o) => snapPin(p, o ?? ops ?? undefined), snapSocket, snapPinModel, parsePin, isPinName, parseMagnet, isMagnetName, fieldShare, hubFactor, shaftFactor, tubeRing, skirtFinger, snapSlots });
66
66
  for (const [k, f] of Object.entries(JOINED)) out[k] = (m, o = {}) => (ops ? f(m, with_(o), ops) : f(m, with_(o)));
67
67
  return out;
68
68
  }
package/model.d.mts CHANGED
@@ -102,7 +102,7 @@ export function fixingOf(what: string, m: Fixing | string, o?: {
102
102
  /**
103
103
  * The printer's rules as fixings reads them. Handed nothing, the kit's X1C. Handed a rule set ({ name, rules }), its
104
104
  * figures with their kinds and sources. Handed plain numbers (a design's v.x1c), those, marked as given. A basic
105
- * clearance the printer lacks (hole_comp, fit, layer, line, chamfer, bridge, overhang, slip, press, thread_gap, snap_clearance, pin_press, pin_slip, magnet_press, magnet_glue, magnet_crush) is borrowed from the X1C
105
+ * clearance the printer lacks (hole_comp, fit, layer, line, chamfer, bridge, overhang, slip, press, thread_gap, snap_clearance, pin_press, pin_slip, magnet_press, magnet_glue, magnet_crush, print_gap) is borrowed from the X1C
106
106
  * and cited as the X1C's; a measured figure (pilot_m3) is never borrowed, since it was measured on that machine.
107
107
  * @param {string} what @param {object} [p] @returns {Printer}
108
108
  */
package/model.mjs CHANGED
@@ -62,7 +62,8 @@ export const DEFAULTS = {
62
62
  snap_often: { value: 0.6, unit: '× brief strain', rule: 'A snap opened and closed often, as a lid is, is held to this share of the brief-snap strain', kind: 'community', source: 'Bayer MaterialScience, Snap-Fit Joints for Plastics: A Design Guide, copy at https://fab.cba.mit.edu/classes/S62.12/people/vernelle.noel/Plastic_Snap_fit_design.pdf, page 12, Table 2: for frequent separation and rejoining, use about 60% of these values', checked: '2026-11-23' },
63
63
  snap_remote: { value: 3, unit: '× near-end force', rule: 'An annular snap at least 1.8 √(d t) in from its tube\'s free end is about this many times as stiff as one at the end: four times in theory, and tests rarely give more than three. Between the two the kit takes a straight line, an estimate', kind: 'community', source: 'Bayer MaterialScience, Snap-Fit Joints for Plastics: A Design Guide, copy at https://fab.cba.mit.edu/classes/S62.12/people/vernelle.noel/Plastic_Snap_fit_design.pdf, page 22', checked: '2026-11-23' },
64
64
  snap_friction: { value: 0.5, unit: 'μ', rule: 'Friction between two printed parts of one plastic sliding over each other as a snap goes home: an estimate. The guide lists no PLA or PETG; for the glassy plastics nearest them it gives 0.40 to 0.60 on steel (PS, SAN, PC, PMMA), and 1.2 times that for a plastic on itself', kind: 'estimate', source: 'Bayer MaterialScience, Snap-Fit Joints for Plastics: A Design Guide, copy at https://fab.cba.mit.edu/classes/S62.12/people/vernelle.noel/Plastic_Snap_fit_design.pdf, page 15, Table 3', checked: '2026-11-23' },
65
- snap_least: { value: 0.2, unit: 'mm', rule: 'The least radial undercut an annular snap is drawn with: twice x1c.hole_comp, the error a printed round comes out with, so the print\'s own error cannot take the whole of it', kind: 'estimate', source: 'A working figure of this package, from x1c.hole_comp (0.1 mm); the fixings coupon has no snap ring yet to measure it', checked: '2026-11-23' }
65
+ snap_least: { value: 0.2, unit: 'mm', rule: 'The least radial undercut an annular snap is drawn with: twice x1c.hole_comp, the error a printed round comes out with, so the print\'s own error cannot take the whole of it', kind: 'estimate', source: 'A working figure of this package, from x1c.hole_comp (0.1 mm); the fixings coupon has no snap ring yet to measure it', checked: '2026-11-23' },
66
+ snap_slot: { value: 1, unit: 'mm', rule: 'The width a slotted snap skirt\'s slots are drawn: wide enough to print apart with room to spare (x1c.print_gap, 0.3 mm, is the narrowest gap that does) and to keep clean, and narrow enough to leave the fingers most of the skirt. An estimate', kind: 'estimate', source: 'A working figure of this package, over x1c.print_gap (0.3 mm); the fixings coupon has no slotted skirt yet to measure it', checked: '2026-11-23' }
66
67
  };
67
68
 
68
69
  // ---------- small things every module here uses ----------
@@ -353,7 +354,7 @@ export function fixingOf(what, m, o = {}) {
353
354
  }
354
355
 
355
356
  // ---------- the printer ----------
356
- const BASICS = ['hole_comp', 'fit', 'layer', 'line', 'chamfer', 'bridge', 'overhang', 'slip', 'press', 'thread_gap', 'snap_clearance', 'pin_press', 'pin_slip', 'magnet_press', 'magnet_glue', 'magnet_crush'];
357
+ const BASICS = ['hole_comp', 'fit', 'layer', 'line', 'chamfer', 'bridge', 'overhang', 'slip', 'press', 'thread_gap', 'snap_clearance', 'pin_press', 'pin_slip', 'magnet_press', 'magnet_glue', 'magnet_crush', 'print_gap'];
357
358
  /**
358
359
  * @typedef {{ name: string, figure: (k: string) => (Figure & { name: string, borrowed?: boolean }) | null, n: (k: string) => number, cite: (k: string) => string, rest: (k: string) => object }} Printer
359
360
  * figure: a rule of the printer's own (never borrowed); n: a basic clearance as a number, the printer's own or, where it
@@ -362,7 +363,7 @@ const BASICS = ['hole_comp', 'fit', 'layer', 'line', 'chamfer', 'bridge', 'overh
362
363
  /**
363
364
  * The printer's rules as fixings reads them. Handed nothing, the kit's X1C. Handed a rule set ({ name, rules }), its
364
365
  * figures with their kinds and sources. Handed plain numbers (a design's v.x1c), those, marked as given. A basic
365
- * clearance the printer lacks (hole_comp, fit, layer, line, chamfer, bridge, overhang, slip, press, thread_gap, snap_clearance, pin_press, pin_slip, magnet_press, magnet_glue, magnet_crush) is borrowed from the X1C
366
+ * clearance the printer lacks (hole_comp, fit, layer, line, chamfer, bridge, overhang, slip, press, thread_gap, snap_clearance, pin_press, pin_slip, magnet_press, magnet_glue, magnet_crush, print_gap) is borrowed from the X1C
366
367
  * and cited as the X1C's; a measured figure (pilot_m3) is never borrowed, since it was measured on that machine.
367
368
  * @param {string} what @param {object} [p] @returns {Printer}
368
369
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/fixings",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Screws, nuts, washers and inserts from rule sets, and the holes and seats they need in printed parts: a fixing as a model with sourced figures, holes sized by what they are for, counterbores, countersinks, nut pockets and insert bosses that print without supports, light solids of the hardware for an assembly, threads cut for printing, and first sums for a joint (engagement, stripping, preload, seating, the sold length that fits).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -61,7 +61,7 @@
61
61
  "@jscad/modeling": "^2.12.0"
62
62
  },
63
63
  "dependencies": {
64
- "@rulecad/rules": "^0.3.19",
64
+ "@rulecad/rules": "^0.3.20",
65
65
  "@rulecad/shapes": "^0.4.4"
66
66
  }
67
67
  }
package/snaps.d.mts CHANGED
@@ -19,27 +19,35 @@ export function tubeRing(a: number, b: number, ends?: {
19
19
  bendB: number;
20
20
  };
21
21
  /**
22
- * @typedef {{ diameter: number, inside: number, outside: number, wall: number, end: number, far: number, factor: number,
23
- * remote: number, X: number, stiffness: number, deflection: number, strain: number, closed: number | null, stiffer?: number, decay?: number, root?: number }} SnapPart
24
- * one part of the joint: its diameters at the joint, wall, how far the joint is from its free end and the guide's
25
- * "remote" distance, the stiffening that gives (remote), and with a closed end's too (factor), the geometric factor, its stiffness (N per mm of diameter),
26
- * how much of the interference it takes (on the diameter) and the hoop strain that leaves in it; with a closed end
27
- * (closed, its distance from the joint), how much stiffer that end makes it, the length 1/β over which its wall
28
- * bends, and the bending strain at the end's root
29
- */
30
- /**
31
- * @typedef {{ kind: 'annular snap', diameter: number, wall: number, skirt: number, clearance: number, bead: number, length: number, undercut: number,
32
- * interference: number, lead: number, back: number, land: number, sized: boolean, uses: 'often' | 'once', material: string,
33
- * lidMaterial: string, friction: number, permissible: number, box: SnapPart, lid: SnapPart, force: number, insertion: number,
34
- * removal: number, holds: boolean, pull: number | null, margin: number | null, most: { undercut: number, removal: number },
35
- * groove: { inner: number, outer: number, depth: number }, rests: object[], findings: object[] }} AnnularSnap
36
- * diameter: the box's wall outside at the joint; bead: how far the bead stands off it (radial); length: the bead's
37
- * height along the axis, return face, land and lead face; undercut: the
38
- * bead less the clearance, the radial overlap the skirt is spread by; interference: the same on the diameter, shared
39
- * between the parts; force: the transverse force P that takes; insertion and removal: along the push, N;
40
- * permissible: the hoop strain each part may see; most: the largest undercut that strain allows and the removal
41
- * force it would give; groove: the groove's radii and depth in the skirt
22
+ * One finger of a slotted skirt as a cantilever, clamped at the slots' closed end and pushed out at reach from it: its
23
+ * section is a ring's sector between ri and ro, its sides taken as radial, 2φ round where φ = π / n − w / (2 rm) leaves
24
+ * the slot w at the mean radius rm. Its second moment about the axis it bends on (the sector's own centroid, square to
25
+ * its line of symmetry): ∫x² dA − A x̄², with ∫x² dA = (ro⁴ − ri⁴)(φ + sin φ cos φ) / 4, A = φ (ro² − ri²) and
26
+ * A x̄ = 2 (ro³ − ri³) sin φ / 3. Pushed out by y at reach L it takes k y, k = 3 E I / L³, and its root strains
27
+ * 3 y c / L², c the farthest fibre from that axis (the ends of the beam formulas for a cantilever with an end load:
28
+ * deflection P L³ / 3 E I, root stress P L c / I). Thin and narrow, it is the rectangle's w t³ / 12, k = E w t³ / 4 L³.
29
+ * @param {{ count: number, width: number, reach: number, inside: number, outside: number }} f the finger count, slot
30
+ * width, reach (from the root to where the finger is pushed, its arm L) and the skirt's radii, mm
31
+ * @param {number} E the plastic's modulus, MPa
32
+ * @returns {{ angle: number, width: number, area: number, inertia: number, fibre: number, stiffness: number, strainPerY: number }}
33
+ * angle: the finger's whole angle, degrees; width: its arc at the mean radius; inertia, mm⁴; fibre: c; stiffness: N per
34
+ * mm of radial push at reach; strainPerY: the root strain per mm of that push
42
35
  */
36
+ export function skirtFinger({ count: n, width: w, reach: L, inside: ri, outside: ro }: {
37
+ count: number;
38
+ width: number;
39
+ reach: number;
40
+ inside: number;
41
+ outside: number;
42
+ }, E: number): {
43
+ angle: number;
44
+ width: number;
45
+ area: number;
46
+ inertia: number;
47
+ fibre: number;
48
+ stiffness: number;
49
+ strainPerY: number;
50
+ };
43
51
  /**
44
52
  * An annular snap: a lid with a skirt that clicks over a bead round a round box's rim. Each part is a tube; the
45
53
  * interference (the bead less the clearance, on the diameter) is shared between them as two springs in series, each
@@ -51,14 +59,20 @@ export function tubeRing(a: number, b: number, ends?: {
51
59
  * tube, angles outside 0° to 90°, a lead friction locks, a groove deeper than the skirt. A closed end near the joint
52
60
  * (the box's floor, the lid's top) is a beam on an elastic foundation held round there (Hetényi): the part is stiffer,
53
61
  * so its mate takes more of the interference, and the bending at that end's root is held to the same limit.
54
- * @param {{ diameter: number, wall: number, skirt: number, bead?: number, lead?: number, back?: number, land?: number, boxEnd?: number, lidEnd?: number, boxFloor?: number, lidTop?: number }} p
62
+ * @param {{ diameter: number, wall: number, skirt: number, bead?: number, lead?: number, back?: number, land?: number, boxEnd?: number, lidEnd?: number, boxFloor?: number, lidTop?: number, slots?: { count: number, reach: number, width?: number } }} p
55
63
  * diameter: the box's wall outside, at the joint, mm; wall: the box's wall thickness there; skirt: the lid's skirt
56
64
  * thickness; bead: how far the bead stands off the wall (default sized); lead: the face the lid pushes over, its
57
65
  * angle from the axis (default 30); back: the return face's (default 45: the steepest the box prints without support,
58
66
  * as it is the underside of the bead); land: the bead's flat top, along the axis (default two layers); boxEnd: from the
59
67
  * bead to the box's rim, its free end; lidEnd: from the groove to the skirt's mouth (each default 0, at the end);
60
68
  * boxFloor: from the bead to the box's floor, its closed end; lidTop: from the groove to the underside of the lid's
61
- * top (each default none: far enough off not to count; each at least its part's wall, the box's wall or the skirt)
69
+ * top (each default none: far enough off not to count; each at least its part's wall, the box's wall or the skirt);
70
+ * slots: the skirt slotted into fingers, count of them (3 or more), each reach mm from the slots' closed end to the
71
+ * groove's top edge (no further than lidTop), the slots width mm wide (default fixings.snap_slot, at least the
72
+ * printer's print_gap). Each finger is then a cantilever (skirtFinger) and the lid's top no longer holds the skirt
73
+ * round at the groove. The bead bears on each finger at the groove's bottom edge, both going on (the lip below the
74
+ * groove rides over the bead's crest) and coming off (the groove's lower face rides up the return face), so the
75
+ * finger's arm is reach + the bead's length + twice the clearance (slots.arm in the model)
62
76
  * @param {{ material?: string | object, lidMaterial?: string | object, printer?: object, sets?: object, uses?: 'often' | 'once', friction?: number, pull?: number, push?: number }} [o]
63
77
  * material: the box's plastic (default PLA); lidMaterial: the lid's (default the box's); printer: the printer's rule
64
78
  * set or values (default the X1C: its fit is the clearance, its overhang the steepest return face); uses: often (the
@@ -79,6 +93,11 @@ export function annularSnapModel(p: {
79
93
  lidEnd?: number;
80
94
  boxFloor?: number;
81
95
  lidTop?: number;
96
+ slots?: {
97
+ count: number;
98
+ reach: number;
99
+ width?: number;
100
+ };
82
101
  }, o?: {
83
102
  material?: string | object;
84
103
  lidMaterial?: string | object;
@@ -107,6 +126,21 @@ export function annularBead(p: object | AnnularSnap, o?: object): object;
107
126
  * @returns {object} a JSCAD geom3 to subtract, with .model
108
127
  */
109
128
  export function annularGroove(p: object | AnnularSnap, o?: object): object;
129
+ /**
130
+ * The slots to cut from a slotted skirt (a model with slots), in the same frame as annularBead and annularGroove: each
131
+ * runs radially through the skirt from below the mouth (mouth, as annularGroove's) up to the slots' closed end, the
132
+ * model's reach above the groove's top edge, and ends in a full round half the slot wide, so the root that takes each
133
+ * finger's bending has no square corner. The first slot is centred on +x.
134
+ * @param {AnnularSnap} m a model from annularSnapModel with slots
135
+ * @param {{ at?: number, mouth: number, segments?: number }} o at: the bead's foot (default 0); mouth: the z of the skirt's
136
+ * open end; segments: faces round the slot's end (default 24)
137
+ * @returns {object} a JSCAD geom3 to subtract, the slots together, with .model
138
+ */
139
+ export function snapSlots(m: AnnularSnap, o?: {
140
+ at?: number;
141
+ mouth: number;
142
+ segments?: number;
143
+ }): object;
110
144
  /** The uses an annular snap is sized for: opened often (a lid, the guide's 60% of the brief-snap strain) or snapped once. */
111
145
  export const SNAP_USES: string[];
112
146
  export function hubFactor(k: number, nu: number): number;
package/snaps.mjs CHANGED
@@ -5,12 +5,16 @@
5
5
  // each part from the Bayer snap-fit design guide's annular joint (a beam on an elastic foundation: P = y d Es X, with
6
6
  // X from the tube's proportions), the two parts as springs in series where both give, and the strain held to the
7
7
  // plastic's limit by the guide's rule for a brief snap. annularBead is the bead to add to the box's wall, annularGroove
8
- // the groove (and the skirt's lead-in) to cut from the lid. Units: mm, N, MPa, degrees.
8
+ // the groove (and the skirt's lead-in) to cut from the lid. A whole skirt on a stiff box takes a hard push; slotted into
9
+ // fingers (slots), each finger bends as a cantilever and the push falls many times over: snapSlots cuts the slots.
10
+ // Units: mm, N, MPa, degrees.
9
11
  import { DEFAULTS, printerOf, rest, finding, positive, oneOf, isNum, shown, mm, r3 } from './model.mjs';
10
- import { lathe } from './draw.mjs';
12
+ import jscad from '@jscad/modeling';
13
+ import { lathe, OUT } from './draw.mjs';
11
14
  import { optionsOf } from './holes.mjs';
12
15
  import { materialOf } from './strength.mjs';
13
16
 
17
+ const { polygon } = jscad.primitives, { extrudeLinear } = jscad.extrusions, { translate, rotateY, rotateZ } = jscad.transforms, { geom3 } = jscad.geometries;
14
18
  const n1 = (x) => +x.toFixed(1), n2 = (x) => +x.toFixed(2), n4 = (x) => +x.toFixed(4), pc = (x) => `${mm(n2(x * 100))}%`;
15
19
  const tan = (deg) => Math.tan((deg * Math.PI) / 180);
16
20
  /** The uses an annular snap is sized for: opened often (a lid, the guide's 60% of the brief-snap strain) or snapped once. */
@@ -87,6 +91,29 @@ const closedEnd = (free, shut, Rm, t, d, E, nu) => {
87
91
  return { beta, stiffer: open.w / closed.w, perP };
88
92
  };
89
93
 
94
+ /**
95
+ * One finger of a slotted skirt as a cantilever, clamped at the slots' closed end and pushed out at reach from it: its
96
+ * section is a ring's sector between ri and ro, its sides taken as radial, 2φ round where φ = π / n − w / (2 rm) leaves
97
+ * the slot w at the mean radius rm. Its second moment about the axis it bends on (the sector's own centroid, square to
98
+ * its line of symmetry): ∫x² dA − A x̄², with ∫x² dA = (ro⁴ − ri⁴)(φ + sin φ cos φ) / 4, A = φ (ro² − ri²) and
99
+ * A x̄ = 2 (ro³ − ri³) sin φ / 3. Pushed out by y at reach L it takes k y, k = 3 E I / L³, and its root strains
100
+ * 3 y c / L², c the farthest fibre from that axis (the ends of the beam formulas for a cantilever with an end load:
101
+ * deflection P L³ / 3 E I, root stress P L c / I). Thin and narrow, it is the rectangle's w t³ / 12, k = E w t³ / 4 L³.
102
+ * @param {{ count: number, width: number, reach: number, inside: number, outside: number }} f the finger count, slot
103
+ * width, reach (from the root to where the finger is pushed, its arm L) and the skirt's radii, mm
104
+ * @param {number} E the plastic's modulus, MPa
105
+ * @returns {{ angle: number, width: number, area: number, inertia: number, fibre: number, stiffness: number, strainPerY: number }}
106
+ * angle: the finger's whole angle, degrees; width: its arc at the mean radius; inertia, mm⁴; fibre: c; stiffness: N per
107
+ * mm of radial push at reach; strainPerY: the root strain per mm of that push
108
+ */
109
+ export function skirtFinger({ count: n, width: w, reach: L, inside: ri, outside: ro }, E) {
110
+ const rm = (ri + ro) / 2, phi = Math.PI / n - w / (2 * rm);
111
+ const A = phi * (ro * ro - ri * ri), Ax = (2 * (ro ** 3 - ri ** 3) * Math.sin(phi)) / 3, xbar = Ax / A;
112
+ const I = ((ro ** 4 - ri ** 4) * (phi + Math.sin(phi) * Math.cos(phi))) / 4 - A * xbar * xbar;
113
+ const c = Math.max(ro - xbar, xbar - ri * Math.cos(phi));
114
+ return { angle: (2 * phi * 180) / Math.PI, width: 2 * phi * rm, area: A, inertia: I, fibre: c, stiffness: (3 * E * I) / L ** 3, strainPerY: (3 * c) / (L * L) };
115
+ }
116
+
90
117
  /**
91
118
  * @typedef {{ diameter: number, inside: number, outside: number, wall: number, end: number, far: number, factor: number,
92
119
  * remote: number, X: number, stiffness: number, deflection: number, strain: number, closed: number | null, stiffer?: number, decay?: number, root?: number }} SnapPart
@@ -110,6 +137,23 @@ const closedEnd = (free, shut, Rm, t, d, E, nu) => {
110
137
  * force it would give; groove: the groove's radii and depth in the skirt
111
138
  */
112
139
 
140
+ // A slotted skirt's figures, refused by name: 3 fingers or more, each at least as wide as the skirt is thick, a slot
141
+ // that prints apart, and a reach that stays in the skirt (no further than the lid's top) and is a beam, twice the skirt
142
+ const slotsOf = (what, v, s, lidTop, pr, d) => {
143
+ if (v == null) return null;
144
+ if (typeof v !== 'object' || Array.isArray(v)) throw new Error(`${what}: slots is { count, reach, width }: the fingers, how far the groove is from the slots' closed end and the slots' width (got ${shown(v)})`);
145
+ for (const key of Object.keys(v)) if (!['count', 'reach', 'width'].includes(key)) throw new Error(`${what}: slots has no ${key}: it takes count, reach and width`);
146
+ if (!(Number.isInteger(v.count) && v.count >= 3)) throw new Error(`${what}: slots.count is how many fingers the skirt is slotted into, a whole number, 3 or more (got ${shown(v.count)})`);
147
+ const gap = pr.n('print_gap'), width = v.width ?? DEFAULTS.snap_slot.value;
148
+ if (!(isNum(width) && width >= gap - 1e-9)) throw new Error(`${what}: slots.width is the slots' width, at least the ${pr.cite('print_gap')} ${mm(gap)} mm that prints apart (got ${shown(v.width)})`);
149
+ const reach = positive(what, 'slots.reach', v.reach);
150
+ if (reach < 2 * s - 1e-9) throw new Error(`${what}: slots.reach of ${mm(reach)} mm is under twice the ${mm(s)} mm skirt, too short to bend as a finger: give ${mm(r3(2 * s))} mm or more`);
151
+ if (lidTop != null && reach > lidTop + 1e-9) throw new Error(`${what}: slots.reach of ${mm(reach)} mm runs past the lid's top, ${mm(lidTop)} mm from the groove (lidTop): the slots end in the skirt, so give ${mm(lidTop)} mm or less`);
152
+ const rm = (d + 2 * pr.n('fit') + s) / 2, arc = (2 * Math.PI * rm) / v.count - width;
153
+ if (arc < s - 1e-9) throw new Error(`${what}: ${v.count} fingers with ${mm(width)} mm slots leave each ${mm(r3(arc))} mm wide, under the ${mm(s)} mm skirt: give fewer, at most ${Math.floor((2 * Math.PI * rm) / (s + width))}`);
154
+ return { count: v.count, width, reach, given: v.width != null };
155
+ };
156
+
113
157
  /**
114
158
  * An annular snap: a lid with a skirt that clicks over a bead round a round box's rim. Each part is a tube; the
115
159
  * interference (the bead less the clearance, on the diameter) is shared between them as two springs in series, each
@@ -121,14 +165,20 @@ const closedEnd = (free, shut, Rm, t, d, E, nu) => {
121
165
  * tube, angles outside 0° to 90°, a lead friction locks, a groove deeper than the skirt. A closed end near the joint
122
166
  * (the box's floor, the lid's top) is a beam on an elastic foundation held round there (Hetényi): the part is stiffer,
123
167
  * so its mate takes more of the interference, and the bending at that end's root is held to the same limit.
124
- * @param {{ diameter: number, wall: number, skirt: number, bead?: number, lead?: number, back?: number, land?: number, boxEnd?: number, lidEnd?: number, boxFloor?: number, lidTop?: number }} p
168
+ * @param {{ diameter: number, wall: number, skirt: number, bead?: number, lead?: number, back?: number, land?: number, boxEnd?: number, lidEnd?: number, boxFloor?: number, lidTop?: number, slots?: { count: number, reach: number, width?: number } }} p
125
169
  * diameter: the box's wall outside, at the joint, mm; wall: the box's wall thickness there; skirt: the lid's skirt
126
170
  * thickness; bead: how far the bead stands off the wall (default sized); lead: the face the lid pushes over, its
127
171
  * angle from the axis (default 30); back: the return face's (default 45: the steepest the box prints without support,
128
172
  * as it is the underside of the bead); land: the bead's flat top, along the axis (default two layers); boxEnd: from the
129
173
  * bead to the box's rim, its free end; lidEnd: from the groove to the skirt's mouth (each default 0, at the end);
130
174
  * boxFloor: from the bead to the box's floor, its closed end; lidTop: from the groove to the underside of the lid's
131
- * top (each default none: far enough off not to count; each at least its part's wall, the box's wall or the skirt)
175
+ * top (each default none: far enough off not to count; each at least its part's wall, the box's wall or the skirt);
176
+ * slots: the skirt slotted into fingers, count of them (3 or more), each reach mm from the slots' closed end to the
177
+ * groove's top edge (no further than lidTop), the slots width mm wide (default fixings.snap_slot, at least the
178
+ * printer's print_gap). Each finger is then a cantilever (skirtFinger) and the lid's top no longer holds the skirt
179
+ * round at the groove. The bead bears on each finger at the groove's bottom edge, both going on (the lip below the
180
+ * groove rides over the bead's crest) and coming off (the groove's lower face rides up the return face), so the
181
+ * finger's arm is reach + the bead's length + twice the clearance (slots.arm in the model)
132
182
  * @param {{ material?: string | object, lidMaterial?: string | object, printer?: object, sets?: object, uses?: 'often' | 'once', friction?: number, pull?: number, push?: number }} [o]
133
183
  * material: the box's plastic (default PLA); lidMaterial: the lid's (default the box's); printer: the printer's rule
134
184
  * set or values (default the X1C: its fit is the clearance, its overhang the steepest return face); uses: often (the
@@ -155,6 +205,7 @@ export function annularSnapModel(p, o = {}) {
155
205
  const shut = (k, what2, wall, wallName) => { if (p[k] == null) return null; const v = p[k]; if (!(isNum(v) && v >= wall - 1e-9)) throw new Error(`${what}: ${k} is how far the joint is from ${what2}, its closed end, at least the ${mm(wall)} mm ${wallName} (got ${shown(v)}): a joint nearer its closed end than that is a solid corner that cannot give, so move it further off`); return v; };
156
206
  const boxFloor = shut('boxFloor', 'the box\'s floor', t, 'wall'), lidTop = shut('lidTop', 'the lid\'s top', s, 'skirt');
157
207
  const boxEnd = end('boxEnd'), lidEnd = end('lidEnd'), uses = oneOf(what, 'uses', o.uses ?? 'often', SNAP_USES);
208
+ const slots = slotsOf(what, p.slots, s, lidTop, printerOf(what, o.printer), d);
158
209
  const mu = o.friction ?? DEFAULTS.snap_friction.value;
159
210
  if (!(isNum(mu) && mu >= 0 && mu < 1)) throw new Error(`${what}: friction is μ between the parts, 0 or more and under 1 (got ${shown(o.friction)})`);
160
211
  if (mu * tan(lead) >= 1 - 1e-9) throw new Error(`${what}: a ${mm(lead)}° lead at friction ${mm(mu)} locks: μ tan α is ${mm(n2(mu * tan(lead)))}, 1 or more, so no push slides the skirt over it. Give a lead under ${mm(n1((Math.atan(1 / mu) * 180) / Math.PI))}° at that friction, 30° to 45° is usual`);
@@ -180,30 +231,71 @@ export function annularSnapModel(p, o = {}) {
180
231
  return { diameter: r3(diameter), inside: r3(inside), outside: r3(outside), wall, end: endAt, far: r.far, remote: n2(r.factor), factor: n2(factor), X, stiffness: factor * diameter * E * X,
181
232
  closed: closedAt, ...(ce ? { stiffer: n2(ce.stiffer), decay: n2(1 / ce.beta), rootPerP: ce.perP } : {}) };
182
233
  };
183
- const B = part(d, di, d, t, boxEnd, boxFloor, shaftFactor(d / di, box.poisson.value), box), L = part(dh, dh, d0, s, lidEnd, lidTop, hubFactor(d0 / dh, lidMat.poisson.value), lidMat);
184
- const k = 1 / (1 / B.stiffness + 1 / L.stiffness);
185
- // The most force (and so interference) the strain allows: P = ε k_i d_i in each part
234
+ const B = part(d, di, d, t, boxEnd, boxFloor, shaftFactor(d / di, box.poisson.value), box), whole = part(dh, dh, d0, s, lidEnd, lidTop, hubFactor(d0 / dh, lidMat.poisson.value), lidMat);
235
+ // The strain per N of P: a tube's hoop strain is its share over its diameter
236
+ B.perP = 1 / (B.stiffness * B.diameter); whole.perP = 1 / (whole.stiffness * whole.diameter);
237
+ // Slotted, the lid is its fingers side by side: P = n k y for a radial push y, so n k / 2 per mm of diameter, and each
238
+ // root strains 3 c y / L² (skirtFinger), the lid's top no longer holding the groove round. The bead bears on a finger
239
+ // at the groove's bottom edge, not at its top (reach's end): going on, the lip below the groove rides over the bead's
240
+ // crest, and is pushed out the whole undercut until the crest reaches that edge; coming off, the groove's lower face
241
+ // rides up the bead's return face, and is pushed out the whole undercut as that edge reaches the crest. So the arm is
242
+ // reach + the groove's height (the bead's length and the clearance at each end), and as that grows with the bead, the
243
+ // springs are worked for a given bead (a longer arm is softer: k goes as 1 / L³)
244
+ const lengthOf = (b) => r3(b / tan(back) + land + b / tan(lead)), armOf = (u) => slots.reach + lengthOf(r3(u + c)) + 2 * c;
245
+ const springs = (u) => {
246
+ if (!slots) return { L: whole, finger: null, arm: null };
247
+ const arm = armOf(u), finger = skirtFinger({ ...slots, reach: arm, inside: dh / 2, outside: d0 / 2 }, lidMat.modulus.value);
248
+ return { arm, finger, L: { diameter: r3(dh), inside: r3(dh), outside: r3(d0), wall: s, end: lidEnd, far: null, remote: 1, factor: 1, X: null, closed: null,
249
+ stiffness: (slots.count * finger.stiffness) / 2, perP: finger.strainPerY / (slots.count * finger.stiffness) } };
250
+ };
186
251
  // The most force (and so interference) the strain allows: P = ε k_i d_i in each part, and at a closed end's root P = ε / (strain per N)
187
- const Pmost = Math.min(permissible * B.stiffness * B.diameter, permissible * L.stiffness * L.diameter, ...[B, L].filter((q) => q.rootPerP).map((q) => permissible / q.rootPerP)), mostUndercut = Pmost / k / 2;
252
+ const limits = (L) => { const k = 1 / (1 / B.stiffness + 1 / L.stiffness), Pmost = Math.min(permissible / B.perP, permissible / L.perP, ...[B, L].filter((q) => q.rootPerP).map((q) => permissible / q.rootPerP)); return { k, Pmost, mostUndercut: Pmost / k / 2 }; };
188
253
  // to the thousandth: the sized bead is rounded up to what the pull needs and down to what the strain allows
189
254
  const up = (x) => Math.ceil(x * 1000 - 1e-6) / 1000, down = (x) => Math.floor(x * 1000 + 1e-6) / 1000;
190
255
  const least = DEFAULTS.snap_least.value, back1 = per(back, mu), want = DEFAULTS.load_margin.value;
191
- let undercut, sized = false, sizeSays = null;
192
- if (p.bead != null) undercut = p.bead - c;
256
+ let undercut, sized = false, sizeSays = null, sp, lim;
257
+ if (p.bead != null) { undercut = p.bead - c; sp = springs(undercut); lim = limits(sp.L); }
193
258
  else {
194
259
  sized = true;
195
- const need = pull != null && Number.isFinite(back1) ? (want * pull) / back1 / k / 2 : 0;
196
- undercut = Math.max(least, up(need));
260
+ // Sized against the springs of the bead it sizes: each pass works the arm from the last bead, and a bigger bead
261
+ // only lengthens the arm (softer fingers, so a bigger bead again), so the beads rise to one that gives itself back
262
+ let need = 0;
263
+ undercut = least;
264
+ for (let i = 0; i < 50; i++) {
265
+ sp = springs(undercut); lim = limits(sp.L);
266
+ need = pull != null && Number.isFinite(back1) ? (want * pull) / back1 / lim.k / 2 : 0;
267
+ let next = Math.max(least, up(need));
268
+ if (next > lim.mostUndercut) next = Math.max(down(lim.mostUndercut), 0);
269
+ next = r3(next);
270
+ if (!slots || next === undercut) { undercut = next; break; }
271
+ undercut = next;
272
+ }
273
+ sp = springs(undercut); lim = limits(sp.L);
197
274
  sizeSays = need > least ? `sized from the ${mm(pull)} N pull: ${mm(want)} times it over the ${mm(back)}° return face` : `sized as the smallest the print holds, fixings.snap_least ${mm(least)} mm${pull != null ? `, which already holds the ${mm(pull)} N pull ${mm(want)} times over` : ''}`;
198
- if (undercut > mostUndercut) { sizeSays += `, more than the ${mm(r3(mostUndercut))} mm the strain allows, so held to that`; undercut = Math.max(down(mostUndercut), 0); }
199
- undercut = r3(undercut);
275
+ if (Math.max(least, up(need)) > lim.mostUndercut) sizeSays += `, more than the ${mm(r3(lim.mostUndercut))} mm the strain allows, so held to that`;
200
276
  }
201
- const bead = r3(undercut + c), Y = 2 * undercut, P = k * Y, length = r3(bead / tan(back) + land + bead / tan(lead));
277
+ const { L, finger, arm } = sp, { k, Pmost, mostUndercut } = lim;
278
+ // The most undercut the strain allows, worked at its own arm: slotted, the arm (and so the fingers' stiffness and root
279
+ // strain per mm) follows the bead, and the box's share of the stiffness keeps the limit from simply falling or rising
280
+ // with it, so the thousandths are searched over the whole range the skirt allows (a bead under the skirt's thickness)
281
+ // for the largest undercut that passes at its own arm, whatever bead was given; it holds what that bead holds
282
+ const mostAtOwnArm = () => {
283
+ if (!slots) return { undercut: down(mostUndercut), removal: Number.isFinite(back1) ? n1(back1 * Pmost) : Infinity };
284
+ const passes = (u) => { const l = limits(springs(u).L); return { ok: 2 * u * l.k <= l.Pmost * (1 + 1e-9), l }; };
285
+ let best = { u: 0, l: limits(springs(0).L) };
286
+ for (let m = 1; m / 1000 + c < s - 1e-9; m++) { const u = m / 1000, r = passes(u); if (r.ok) best = { u, l: r.l }; }
287
+ return { undercut: best.u, removal: Number.isFinite(back1) ? n1(back1 * 2 * best.u * best.l.k) : Infinity };
288
+ };
289
+ // (worked before the parts' figures are rounded for show below)
290
+ const mostOwn = mostAtOwnArm();
291
+ const bead = r3(undercut + c), Y = 2 * undercut, P = k * Y, length = lengthOf(bead);
202
292
  // The strains are judged unrounded (exact, below), and shown to 4 places: a bead held to the strain's limit could round over it
203
293
  const exact = new Map();
204
- for (const q of [B, L]) { const e = { strain: P / q.stiffness / q.diameter, root: q.rootPerP != null ? P * q.rootPerP : null }; exact.set(q, e);
205
- q.deflection = r3(P / q.stiffness); q.strain = n4(e.strain); if (q.rootPerP != null) { q.root = n4(e.root); delete q.rootPerP; } q.X = +q.X.toPrecision(3); q.stiffness = n1(q.stiffness); }
206
- const insertion = along(P, lead, mu), removal = along(P, back, mu), holds = !Number.isFinite(removal), most = { undercut: down(mostUndercut), removal: Number.isFinite(back1) ? n1(back1 * Pmost) : Infinity };
294
+ // What a whole skirt would take for the same bead, to say what the slots save
295
+ const Pwhole = Y / (1 / B.stiffness + 1 / whole.stiffness);
296
+ for (const q of [B, L]) { const e = { strain: P * q.perP, root: q.rootPerP != null ? P * q.rootPerP : null }; exact.set(q, e);
297
+ q.deflection = r3(P / q.stiffness); q.strain = n4(e.strain); if (q.rootPerP != null) { q.root = n4(e.root); delete q.rootPerP; } delete q.perP; if (q.X != null) q.X = +q.X.toPrecision(3); q.stiffness = n1(q.stiffness); }
298
+ const insertion = along(P, lead, mu), removal = along(P, back, mu), holds = !Number.isFinite(removal), most = mostOwn;
207
299
 
208
300
  const out = [], rests = [], cited = (m) => `${m.strength.name} ${mm(m.strength.value)} MPa over ${m.modulus.name} ${mm(m.modulus.value)} MPa`;
209
301
  rests.push(pr.rest('fit'), pr.rest('overhang'), rest(box.modulus.name, box.modulus), rest(box.strength.name, box.strength), rest(box.poisson.name, box.poisson),
@@ -211,12 +303,13 @@ export function annularSnapModel(p, o = {}) {
211
303
  if (lidMat !== box && lidMat.name !== box.name) rests.push(rest(lidMat.modulus.name, lidMat.modulus), rest(lidMat.strength.name, lidMat.strength), rest(lidMat.poisson.name, lidMat.poisson));
212
304
  if (o.friction == null) rests.push(rest('fixings.snap_friction', DEFAULTS.snap_friction));
213
305
  if (sized) rests.push(rest('fixings.snap_least', DEFAULTS.snap_least));
306
+ if (slots && !slots.given) rests.push(rest('fixings.snap_slot', DEFAULTS.snap_slot));
214
307
  if (pull != null) rests.push(rest('fixings.load_margin', DEFAULTS.load_margin));
215
308
  out.push(finding('info', `a ${mm(bead)} mm bead round the ${mm(d)} mm box, in a skirt ${mm(c)} mm clear of the wall (${pr.cite('fit')}): ${mm(undercut)} mm of undercut, ${mm(r3(Y))} mm on the diameter, shared by the box's wall (${mm(B.deflection)} mm) and the lid's skirt (${mm(L.deflection)} mm)${sized ? `, ${sizeSays}` : ''}`,
216
309
  'snap.undercut', { values: { bead, undercut, interference: r3(Y), box: B.deflection, lid: L.deflection } }));
217
- for (const [q, name, m] of [[B, 'the box\'s wall', box], [L, 'the lid\'s skirt', lidMat]]) {
218
- const ok = exact.get(q).strain <= permissible * (1 + 1e-9);
219
- out.push(finding(ok ? 'pass' : 'fail', `${name} is ${ok ? '' : 'over its limit: '}${pc(q.strain)} hoop strain (${mm(q.deflection)} mm over ${mm(q.diameter)} mm) where ${m.name} may see ${pc(permissible)}: ${mm(DEFAULTS.snap_brief.value)} of its yield strain, ${cited(m)}${uses === 'often' ? `, and ${mm(DEFAULTS.snap_often.value)} of that since it is opened often` : ''}${ok ? '' : `. The most undercut the strain allows is ${mm(most.undercut)} mm: a smaller bead, a thinner ${q === B ? 'wall' : 'skirt'}, or a bigger box`}`,
310
+ for (const [q, name, m] of [[B, 'the box\'s wall', box], [L, slots ? 'the lid\'s fingers' : 'the lid\'s skirt', lidMat]]) {
311
+ const ok = exact.get(q).strain <= permissible * (1 + 1e-9), bent = q === L && slots;
312
+ out.push(finding(ok ? 'pass' : 'fail', `${name} ${bent ? 'are' : 'is'} ${ok ? '' : 'over its limit: '}${pc(q.strain)} ${bent ? `bending strain at their root (each pushed out ${mm(r3(q.deflection / 2))} mm at ${mm(r3(arm))} mm from it, where the bead bears)` : `hoop strain (${mm(q.deflection)} mm over ${mm(q.diameter)} mm)`} where ${m.name} may see ${pc(permissible)}: ${mm(DEFAULTS.snap_brief.value)} of its yield strain, ${cited(m)}${uses === 'often' ? `, and ${mm(DEFAULTS.snap_often.value)} of that since it is opened often` : ''}${ok ? '' : `. The most undercut the strain allows is ${mm(most.undercut)} mm: a smaller bead, a thinner ${q === B ? 'wall' : 'skirt'}, ${bent ? 'longer fingers' : 'or a bigger box'}`}`,
220
313
  'snap.strain', { values: { strain: q.strain, permissible: n4(permissible), deflection: q.deflection, diameter: q.diameter }, refs: { part: q === B ? 'box' : 'lid', material: m.name } }));
221
314
  }
222
315
  for (const [q, name, m, endName] of [[B, 'the box\'s wall', box, 'floor'], [L, 'the lid\'s skirt', lidMat, 'top']]) {
@@ -232,9 +325,11 @@ export function annularSnapModel(p, o = {}) {
232
325
  out.push(finding(thick ? 'pass' : 'fail', `the groove leaves ${mm(left)} mm of the ${mm(s)} mm skirt behind it${thick ? `, at least the ${pr.cite('line')} ${mm(line)} mm line` : `, under the ${pr.cite('line')} ${mm(line)} mm line, so it prints thin or not at all: a thicker skirt, or a smaller bead`}`,
233
326
  'snap.skirt', { values: { left, skirt: s, line } }));
234
327
  if (undercut < least - 1e-9) out.push(finding('warn', `an undercut of ${mm(undercut)} mm is under fixings.snap_least, ${mm(least)} mm: the print's own error is that size, so the lid may not catch, or catch only in places`, 'snap.least', { values: { undercut, least } }));
235
- out.push(finding('info', `${mm(n1(insertion))} N to push the lid on square and ${holds ? 'it holds for good (a square return face)' : `${mm(n1(removal))} N to pull it off square`}: a transverse force of ${mm(n1(P))} N (P = y d Es X, Bayer's annular snap joint, X ${mm(B.X)} for the wall and ${mm(L.X)} for the skirt) through the ${mm(lead)}° lead and ${mm(back)}° return faces at μ ${mm(mu)}. Pressed on at a tilt, a part of the bead at a time, it takes much less, as the guide says of a lid put on by hand`,
328
+ if (slots) out.push(finding('info', `the skirt is slotted into ${slots.count} fingers by ${mm(slots.width)} mm slots${slots.given ? '' : ' (fixings.snap_slot)'}, each ${mm(n2(finger.width))} mm wide and ${mm(slots.reach)} mm from the slots' closed end to the groove, and borne on by the bead at the groove's bottom edge, ${mm(r3(arm))} mm from it: ${mm(n1(finger.stiffness))} N per mm pushed out there, a cantilever (3 E I / L³, I ${mm(n2(finger.inertia))} mm⁴). A whole skirt would take ${mm(n1(Pwhole))} N of transverse force for this bead, the fingers ${mm(n1(P))} N, ${mm(n1(Pwhole / P))} times less`,
329
+ 'snap.fingers', { values: { count: slots.count, width: slots.width, reach: slots.reach, arm: r3(arm), finger: n2(finger.width), stiffness: n1(finger.stiffness), force: n1(P), whole: n1(Pwhole), less: n2(Pwhole / P) } }));
330
+ out.push(finding('info', `${mm(n1(insertion))} N to push the lid on square and ${holds ? 'it holds for good (a square return face)' : `${mm(n1(removal))} N to pull it off square`}: a transverse force of ${mm(n1(P))} N (${slots ? `the wall as Bayer's annular snap joint, P = y d Es X with X ${mm(B.X)}, and the skirt as ${slots.count} cantilever fingers` : `P = y d Es X, Bayer's annular snap joint, X ${mm(B.X)} for the wall and ${mm(L.X)} for the skirt`}) through the ${mm(lead)}° lead and ${mm(back)}° return faces at μ ${mm(mu)}. Pressed on at a tilt, a part of the bead at a time, it takes much less, as the guide says of a lid put on by hand`,
236
331
  'snap.forces', { values: { force: n1(P), insertion: n1(insertion), removal: Number.isFinite(removal) ? n1(removal) : null, friction: mu } }));
237
- if (B.remote > 1 || L.remote > 1) out.push(finding('info', `the joint lies in from a free end (box ${mm(boxEnd)} mm of ${mm(B.far)}, lid ${mm(lidEnd)} mm of ${mm(L.far)}, where 1.8 √(d t) counts as remote), so it is stiffer by ${mm(B.remote)} and ${mm(L.remote)} times: the guide gives 3 at a remote joint, and the line between is an estimate`, 'snap.remote', { values: { box: B.remote, lid: L.remote } }));
332
+ if (B.remote > 1 || L.remote > 1) out.push(finding('info', `the joint lies in from a free end (box ${mm(boxEnd)} mm of ${mm(B.far)}${slots ? '' : `, lid ${mm(lidEnd)} mm of ${mm(L.far)}`}, where 1.8 √(d t) counts as remote), so it is stiffer by ${slots ? `${mm(B.remote)} times (the fingers are cantilevers, which have no remote joint)` : `${mm(B.remote)} and ${mm(L.remote)} times`}: the guide gives 3 at a remote joint, and the line between is an estimate`, 'snap.remote', { values: { box: B.remote, lid: L.remote } }));
238
333
  if (push != null) { const ok = insertion <= push; out.push(finding(ok ? 'pass' : 'warn', `pushed with ${mm(push)} N, the lid goes on ${ok ? `square, ${mm(n1(insertion))} N` : `only at a tilt: square it takes ${mm(n1(insertion))} N. A shallower lead or a smaller bead lowers it`}`, 'snap.push', { values: { push, insertion: n1(insertion) } })); }
239
334
  const margin = pull != null ? (holds ? Infinity : n2(removal / pull)) : null;
240
335
  if (pull != null) out.push(finding(margin >= want ? 'pass' : margin >= 1 ? 'warn' : 'fail', `pulled with ${mm(pull)} N, the lid stays on ${holds ? 'for good' : `${mm(margin)} times over (${mm(n1(removal))} N)`}${margin >= want ? '' : margin >= 1 ? `, under the ${mm(want)} times fixings.load_margin asks` : ': it comes off'}${margin >= want ? '' : `. The strain allows up to ${mm(most.undercut)} mm of undercut, which would hold ${mm(most.removal)} N`}`,
@@ -248,7 +343,7 @@ export function annularSnapModel(p, o = {}) {
248
343
  : `the ${mm(back)}° return face is past ${pr.cite('overhang')} ${mm(overhang)}°: under the box's bead and over the lid's groove it needs support. Give back ${mm(overhang)}° or less; a steeper face holds harder, so let the bead be taller instead`, 'snap.printable', { values: { back, overhang } }));
249
344
  const groove = { inner: r3(dh / 2), outer: r3(dh / 2 + bead), depth: bead };
250
345
  return { kind: 'annular snap', diameter: d, wall: t, skirt: s, clearance: c, bead, length, undercut, interference: r3(Y), lead, back, land, sized, uses, material: box.name, lidMaterial: lidMat.name, friction: mu,
251
- permissible: n4(permissible), box: B, lid: L, force: n1(P), insertion: Number.isFinite(insertion) ? n1(insertion) : Infinity, removal: Number.isFinite(removal) ? n1(removal) : Infinity, holds, pull, margin, most, groove, rests, findings: out };
346
+ permissible: n4(permissible), box: B, lid: L, ...(slots ? { slots: { count: slots.count, width: slots.width, reach: slots.reach, arm: r3(arm), finger: { angle: n2(finger.angle), width: n2(finger.width), inertia: n4(finger.inertia), fibre: n4(finger.fibre), stiffness: n1(finger.stiffness) }, whole: n1(Pwhole) } } : {}), force: n1(P), insertion: Number.isFinite(insertion) ? n1(insertion) : Infinity, removal: Number.isFinite(removal) ? n1(removal) : Infinity, holds, pull, margin, most, groove, rests, findings: out };
252
347
  }
253
348
 
254
349
  // The bead's outline in [radius, z] from its foot on the wall at z: up the return face, along the land, down the lead
@@ -291,3 +386,30 @@ export function annularGroove(p, o = {}) {
291
386
  const top = Math.min(o.mouth + rise, ring[1][1]);
292
387
  return Object.assign(lathe([[R - sink, z], [R + h, z], [R + h, o.mouth], [R + h - (top - o.mouth) * tan(m.lead), top], ...(top < ring[1][1] ? [[R, top], [R, ring[1][1]]] : []), ...ring.slice(1, -1), [R - sink, ring.at(-1)[1]]], n), { model: m });
293
388
  }
389
+
390
+ /**
391
+ * The slots to cut from a slotted skirt (a model with slots), in the same frame as annularBead and annularGroove: each
392
+ * runs radially through the skirt from below the mouth (mouth, as annularGroove's) up to the slots' closed end, the
393
+ * model's reach above the groove's top edge, and ends in a full round half the slot wide, so the root that takes each
394
+ * finger's bending has no square corner. The first slot is centred on +x.
395
+ * @param {AnnularSnap} m a model from annularSnapModel with slots
396
+ * @param {{ at?: number, mouth: number, segments?: number }} o at: the bead's foot (default 0); mouth: the z of the skirt's
397
+ * open end; segments: faces round the slot's end (default 24)
398
+ * @returns {object} a JSCAD geom3 to subtract, the slots together, with .model
399
+ */
400
+ export function snapSlots(m, o = {}) {
401
+ const what = 'snapSlots';
402
+ if (m?.kind !== 'annular snap' || !m.slots) throw new Error(`${what}: give an annular snap's model with slots (annularSnapModel({ ..., slots: { count, reach } })), not ${shown(m?.kind ?? m)}`);
403
+ const at = o.at ?? 0, n = o.segments ?? 24, { count, width: w, reach } = m.slots;
404
+ if (!isNum(at)) throw new Error(`${what}: at is the bead's foot up z, in mm (got ${shown(o.at)})`);
405
+ const root = at + m.length + m.clearance + reach;
406
+ if (!(isNum(o.mouth) && o.mouth < root - w)) throw new Error(`${what}: mouth is the z of the skirt's open end, below the slots' closed end at ${mm(r3(root))} mm (got ${shown(o.mouth)})`);
407
+ // The slot's outline in (z, across): up from below the mouth to its round end, drawn in the xy plane and stood up
408
+ const r = w / 2, z0 = o.mouth - OUT, zc = root - r;
409
+ const outline = [[z0, -r], ...Array.from({ length: n + 1 }, (_, i) => { const a = -Math.PI / 2 + (Math.PI * i) / n; return [zc + r * Math.cos(a), r * Math.sin(a)]; }), [z0, r]];
410
+ const ri = m.diameter / 2 + m.clearance - OUT, ro = m.diameter / 2 + m.clearance + m.skirt + OUT;
411
+ // extruded along z from -ro to -ri, then turned so its x is up z and its extrusion runs out along +x
412
+ const one = rotateY(-Math.PI / 2, translate([0, 0, -ro], extrudeLinear({ height: ro - ri }, polygon({ points: outline }))));
413
+ const polys = Array.from({ length: count }, (_, i) => geom3.toPolygons(rotateZ((2 * Math.PI * i) / count, one))).flat();
414
+ return Object.assign(geom3.create(polys), { model: m });
415
+ }