@rulecad/fixings 0.1.5 → 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 +49 -0
- package/README.md +189 -2
- package/fixings.d.mts +1 -0
- package/fixings.mjs +7 -4
- package/model.d.mts +1 -1
- package/model.mjs +9 -3
- package/package.json +4 -2
- package/snaps.d.mts +219 -0
- package/snaps.mjs +415 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,55 @@ 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
|
+
|
|
27
|
+
## 0.1.6: the annular snap: lids that click on (#76)
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Annular snaps** (`snaps.mjs`, issue 76): a lid that clicks on to a round box. `annularSnapModel` gives the bead,
|
|
32
|
+
the undercut, the share of it the box's wall and the lid's skirt each take as two springs in series, the hoop strain
|
|
33
|
+
in each against the plastic's limit, and the forces to push the lid on and pull it off, from the Bayer snap-fit
|
|
34
|
+
guide's annular joint (P = y d Es X, its geometric factors `hubFactor` and `shaftFactor`); without a bead height it
|
|
35
|
+
is sized from `pull` with twice the margin. `annularBead` and `annularGroove` draw the bead and the groove (with a
|
|
36
|
+
lead-in at the skirt's mouth). Findings: `snap.undercut`, `snap.strain`, `snap.least`, `snap.forces`, `snap.remote`,
|
|
37
|
+
`snap.hold`, `snap.printable`. `SNAP_USES`. Bound in `fixingsFor`.
|
|
38
|
+
- **A closed end near an annular snap** (`boxFloor`, `lidTop`): `tubeRing` works out a ring load on a tube's wall as
|
|
39
|
+
Hetényi's beam on an elastic foundation, each end free, closed or long. A lid's top within a few times 1/β of its
|
|
40
|
+
groove holds the skirt round, so the skirt is stiffer and the box's wall takes more of the snap; the bending strain
|
|
41
|
+
at the closed end's root is held to the same limit. Findings `snap.closed` and `snap.root`. `snap.remote` reports
|
|
42
|
+
the free ends' share alone.
|
|
43
|
+
- Refused by name: a lead that friction locks (μ tan α of 1 or more), and a bead as deep as the skirt, whose groove
|
|
44
|
+
would cut through it. `snap.skirt` fails where the groove leaves less than one of the printer's `line` behind it.
|
|
45
|
+
Given `push`, `snap.push` warns where pushing the lid on square takes more.
|
|
46
|
+
- A sized bead is rounded up to what its pull needs and down to what its strain allows, and the strains are judged
|
|
47
|
+
unrounded (they are shown to 4 places), so a bead held to the strain passes its own strain check whatever the
|
|
48
|
+
limit rounds to.
|
|
49
|
+
- Refused by name: a closed end (`boxFloor`, `lidTop`) nearer the joint than its part's wall, 0 mm included, where
|
|
50
|
+
the wall cannot give and the sums came out as NaN and Infinity.
|
|
51
|
+
- `DEFAULTS` gains `snap_brief` (70% of the yield strain) and `snap_often` (60% of that) and `snap_remote` (3), from
|
|
52
|
+
the guide, and `snap_friction` (0.5) and `snap_least` (0.2 mm), estimates.
|
|
53
|
+
|
|
54
|
+
No printed size moved: nothing drawn before reads these.
|
|
55
|
+
|
|
7
56
|
## 0.1.5: pins, magnet seats and printed bolts (Fixings 4)
|
|
8
57
|
|
|
9
58
|
### Added
|
package/README.md
CHANGED
|
@@ -69,6 +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`, `snapSlots`, `skirtFinger`, `hubFactor`, `shaftFactor`, `tubeRing` |
|
|
72
73
|
| [Measuring the printer's fits](#measuring-the-printers-fits) | the fixings coupon and the holds coupon |
|
|
73
74
|
| [Refusals and printability](#refusals-and-printability) | `printable` |
|
|
74
75
|
|
|
@@ -84,6 +85,7 @@ live elsewhere, each for a reason:
|
|
|
84
85
|
| Snap pins (`snapPin`, `snapSocket`, `snapPinModel`), plain pins | here | moved from `@rulecad/flexures`, which passes the three snap pin functions on unchanged |
|
|
85
86
|
| Magnets and their pockets | here | `@rulecad/frames`' magnet catch takes its pocket and pull from `magnetSeatModel` |
|
|
86
87
|
| Printed bolts | here | a screw named with the word printed |
|
|
88
|
+
| Annular snaps, a lid that clicks on (`annularSnapModel`, `annularBead`, `annularGroove`) | here | their job is to hold a lid on its box; issue 76 listed them with the flexures, which keep the snap hook |
|
|
87
89
|
| Snap hooks, ratchets, pin joints printed in place, travel and angle stops | `@rulecad/flexures` | their bending is their job |
|
|
88
90
|
| A countersink, a nut pocket and a nut trap from plain figures, crush ribs, a teardrop hole | `@rulecad/shapes` | shapes draws from plain numbers and reads no rule sets; this package calls the same shapes with a thread's figures, so moving them would make a cycle |
|
|
89
91
|
| Slot nuts, carriers, brackets, hinges, latches, cable clips | `@rulecad/frames` | each is shaped to a beam's slot |
|
|
@@ -693,6 +695,173 @@ is the field on a magnet's axis at z from its face over the field at its face. I
|
|
|
693
695
|
name magnets (`{ "magnet": "disc magnet 8x3", "count": 2 }`): `cad check` finds their pockets and reports their pull,
|
|
694
696
|
and `cad list` lists them as bought.
|
|
695
697
|
|
|
698
|
+
## Annular snaps
|
|
699
|
+
|
|
700
|
+
An annular snap holds a lid on a round box with no screw: it clicks on and pulls off. A bead runs round the outside
|
|
701
|
+
of the box's wall near its rim, and the lid's skirt has a groove inside it, the bead's shape grown by the printer's
|
|
702
|
+
`fit` all round, with a lead-in at the skirt's mouth. Pushed on, the bead's lead face spreads the skirt and squeezes
|
|
703
|
+
the wall; past it, both spring back and the bead sits in the groove touching neither, so nothing is strained at rest.
|
|
704
|
+
Pulled, the bead's return face has to spread the skirt again. A part whose job is to hold two parts together lives in
|
|
705
|
+
this package, so the annular snap is here, beside the snap pin; a snap hook, whose bending is its job alone, stays in
|
|
706
|
+
`@rulecad/flexures`.
|
|
707
|
+
|
|
708
|
+
`annularSnapModel(figures, options)` gives the numbers and findings; `annularBead` is the bead to add to the box's
|
|
709
|
+
wall and `annularGroove` the groove (and with `mouth`, the lead-in) to cut from the lid's skirt, each about the z axis
|
|
710
|
+
with the bead's foot at `at`, and each with the model on it as `.model`.
|
|
711
|
+
|
|
712
|
+
**The figures.** `diameter` is the box's wall outside at the joint, `wall` its thickness, `skirt` the lid's skirt
|
|
713
|
+
thickness. `bead` is how far the bead stands off the wall; less the clearance (the printer's `fit`) it is the undercut
|
|
714
|
+
the skirt is spread by. `lead` is the angle of the face the lid pushes over, from the axis (default 30°), `back` the
|
|
715
|
+
return face's (default 45°, the steepest the printer's `overhang` allows: it is the underside of the bead as the box
|
|
716
|
+
stands, and the face over the groove as the lid lies on its top). `land` is the bead's flat top (two layers), and
|
|
717
|
+
`boxEnd` and `lidEnd` how far the joint is from each part's free end (the rim, the skirt's mouth). `boxFloor` and
|
|
718
|
+
`lidTop` are how far it is from each part's closed end: the box's floor, and the underside of the lid's top. Each is
|
|
719
|
+
at least its part's own wall (the box's wall, the skirt): nearer than that the corner is solid and cannot give, so
|
|
720
|
+
it is refused.
|
|
721
|
+
|
|
722
|
+
**The sums.** Both parts are tubes. The Bayer snap-fit guide gives each one's transverse force for a spread y on the
|
|
723
|
+
diameter as P = y d Es X, with a geometric factor X from its proportions (X_N for the skirt spread over a rigid
|
|
724
|
+
shaft, X_W for the wall squeezed in a rigid tube). Here both give, so they are two springs in series and share the
|
|
725
|
+
interference by their stiffness: the guide's graphical method for two flexible parts, worked out. The hoop strain in
|
|
726
|
+
each is its share over its diameter, held to the plastic's limit: about 70% of its yield strain for a brief snap in an
|
|
727
|
+
amorphous plastic, and 60% of that for a lid opened often (`uses: 'often'`, the default; `'once'` for a joint snapped
|
|
728
|
+
once). The yield strain is taken as strength over modulus, below the real one. A joint further than 1.8 √(d t) from a
|
|
729
|
+
free end is about three times as stiff; nearer, the kit takes a straight line from 1 to 3. The forces along the push
|
|
730
|
+
are the guide's W = P (μ + tan α) / (1 - μ tan α), over the lead face going on and the return face coming off.
|
|
731
|
+
|
|
732
|
+
**A closed end near the joint.** The guide's tubes are open. A lid's skirt hangs from its top, and the top holds the
|
|
733
|
+
skirt round where they meet: a tube's wall bends over a length of about 1/β, with β⁴ = 3 (1 - ν²) / (R² t²), so a
|
|
734
|
+
groove within a few times 1/β of the top sits in a skirt far stiffer than a free tube, and the box's wall takes most
|
|
735
|
+
of the interference. `tubeRing` works this out as Hetényi's beam on an elastic foundation (the theory the guide's own
|
|
736
|
+
annular joint rests on): a ring load on the tube's wall, each end free, closed or long. The part's stiffness is
|
|
737
|
+
multiplied by the beam's deflection with that end open over the deflection with it closed, and the bending strain at
|
|
738
|
+
the closed end's root, 6 M (1 - ν²) / (E t²), is held to the same limit as the hoop strain (`snap.root`). The end is
|
|
739
|
+
taken as fully closed, the stiffest it can be, so the forces and the mate's strain err high. For the 60 mm pot's lid,
|
|
740
|
+
1/β is 4.9 mm: a groove 1.3 mm under the top makes the skirt 46 times as stiff, and 5.8 mm under it 1.3 times.
|
|
741
|
+
|
|
742
|
+
**Refused and failed.** A lead that friction locks (μ tan α of 1 or more) is refused: no push slides the skirt over
|
|
743
|
+
it. So is a bead as deep as the skirt, whose groove would cut right through it. The groove must leave at least one of
|
|
744
|
+
the printer's `line` behind it (`snap.skirt`). Given `push`, the force the lid is pushed on with, a square push over
|
|
745
|
+
it warns (`snap.push`).
|
|
746
|
+
|
|
747
|
+
**Sizing.** Given no bead, it is sized: the least the print holds (`fixings.snap_least`, 0.2 mm of undercut), or
|
|
748
|
+
more where `pull` asks for it, so the lid stays on against twice the pull (`load_margin`), up to the most the strain
|
|
749
|
+
allows, rounded up to what the pull needs and down to what the strain allows. A bead given too tall fails by name
|
|
750
|
+
(`snap.strain`), with the most undercut that would do.
|
|
751
|
+
|
|
752
|
+
```js
|
|
753
|
+
import { annularSnapModel, annularBead, annularGroove, tubeRing } from '@rulecad/fixings';
|
|
754
|
+
|
|
755
|
+
const joint = { diameter: 60, wall: 1.68, skirt: 1.26, boxEnd: 6, lidEnd: 1.5, lidTop: 5.8, boxFloor: 30.3 };
|
|
756
|
+
const lid = annularSnapModel(joint, { pull: 10 });
|
|
757
|
+
console.log(lid.bead, lid.undercut, lid.box.strain, lid.lid.strain, lid.lid.root, lid.permissible);
|
|
758
|
+
console.log(lid.force, lid.insertion, lid.removal, lid.margin, lid.lid.stiffer, lid.lid.decay);
|
|
759
|
+
const bead = annularBead(lid, { at: 30 }), groove = annularGroove(lid, { at: 30, mouth: 28 });
|
|
760
|
+
console.log(bead.model.length, groove.model.groove);
|
|
761
|
+
const near = annularSnapModel({ ...joint, boxEnd: 1.5, lidTop: 1.3 }, { pull: 10 });
|
|
762
|
+
console.log(near.lid.stiffer, near.box.strain, near.undercut, near.findings.filter((f) => f.level === 'warn').map((f) => f.code));
|
|
763
|
+
const tight = annularSnapModel({ ...joint, bead: 0.9 });
|
|
764
|
+
console.log(tight.findings.filter((f) => f.level === 'fail').map((f) => `${f.code} ${f.refs?.part ?? ''}`), tight.most.undercut);
|
|
765
|
+
console.log(+tubeRing(6, 6).w.toFixed(4), +tubeRing(0, 6, { A: 'free' }).w.toFixed(4));
|
|
766
|
+
try { annularSnapModel({ ...joint, bead: 0.2 }); } catch (e) { console.log(e.message.slice(0, 93)); }
|
|
767
|
+
try { annularSnapModel({ ...joint, lead: 60 }, { friction: 0.6 }); } catch (e) { console.log(e.message.slice(0, 93)); }
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
```text
|
|
771
|
+
0.4 0.2 0.0023 0.0043 0.0032 0.0061
|
|
772
|
+
231.8 351.1 695.4 69.54 1.3 4.9
|
|
773
|
+
1.493 { inner: 30.2, outer: 30.6, depth: 0.4 }
|
|
774
|
+
45.93 0.0061 0.19 [ 'snap.least' ]
|
|
775
|
+
[
|
|
776
|
+
'snap.strain box',
|
|
777
|
+
'snap.strain lid',
|
|
778
|
+
'snap.root lid',
|
|
779
|
+
'snap.skirt '
|
|
780
|
+
] 0.284
|
|
781
|
+
0.125 0.5
|
|
782
|
+
annularSnapModel: a bead of 0.2 mm is no taller than the x1c.fit clearance of 0.2 mm round th
|
|
783
|
+
annularSnapModel: a 60° lead at friction 0.6 locks: μ tan α is 1.04, 1 or more, so no push sl
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
The first line reads: a pot 60 mm across with a wall of four lines and a skirt of three, its lid to stay on against
|
|
787
|
+
10 N, the bead 6 mm under the rim and so the groove 5.8 mm under the lid's top. That needs far less than the least the
|
|
788
|
+
print holds, so the bead is 0.4 mm: 0.2 mm of undercut past the 0.2 mm fit. The wall takes 0.23% hoop strain, the
|
|
789
|
+
skirt 0.43% and the skirt's root 0.32%, under PLA's 0.61% (0.7 × 0.6 × 39 / 2680). Pushed on square it takes 351.1 N
|
|
790
|
+
and pulled off square 695.4 N, 69.54 times the pull. The top makes the skirt 1.3 times as stiff. Those are the guide's forces for the whole bead
|
|
791
|
+
at once: a lid put on by hand goes on at a tilt, a part of the bead at a time, and takes much less, which is why it
|
|
792
|
+
has a tab to lift it by. With the groove 1.3 mm under the top instead, the skirt is 46 times as stiff, the wall takes
|
|
793
|
+
almost all of the snap, and the strain holds the undercut to 0.19 mm, under the least the print holds. A 0.9 mm bead
|
|
794
|
+
strains both parts past the limit and leaves the skirt thinner than a line behind its groove; 0.284 mm of undercut is
|
|
795
|
+
the most. The beam's own checks: a long tube deflects 1/8 under a ring load, and 1/2 with the load at a free end. The
|
|
796
|
+
example project `enclosures` in the repository's bench draws this pot and lid (`snap-pot`) and puts the lid on
|
|
797
|
+
(`snap-pot-closed`).
|
|
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
|
+
|
|
696
865
|
## Measuring the printer's fits
|
|
697
866
|
|
|
698
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
|
|
@@ -778,13 +947,17 @@ hole: depth is a number above 0, in mm (got -2)
|
|
|
778
947
|
- **Measured**: the X1C's M3 pilot (`x1c.pilot_m3`, 2.9 mm, from the kit's fit bar). It is the only measured figure
|
|
779
948
|
so far. The fixings coupon and the holds coupon measure the rest, per printer and plastic, and `cad measured`
|
|
780
949
|
writes each result to the printer's rule set (see [Measuring the printer's fits](#measuring-the-printers-fits)).
|
|
781
|
-
- **Community**:
|
|
950
|
+
- **Community**: the annular snap's share of the yield strain for a brief snap (`snap_brief`, 70%) and for one opened often
|
|
951
|
+
(`snap_often`, 60% of that) and its remote joint's factor (`snap_remote`, 3), from the Bayer snap-fit guide for its own
|
|
952
|
+
plastics, applied to printed PLA and PETG unchecked; magnets' pulls straight off steel (the seller's figures, supermagnete) and the grades' remanence, heat-set inserts (CNC Kitchen's sheet), pilots for M2 to M4 (Bambu Lab's figures for PLA) and for
|
|
782
953
|
the PT screws (the maker's factor for ABS), the engagement rules, the printer's `hole_comp`, `fit` and `bridge`,
|
|
783
954
|
the two layers a nut pocket is sunk, and the three quarters of proof load a fully tightened screw is taken to carry.
|
|
784
955
|
- **Estimates**: pilots for M1.6, M5 and up, and every inch size (nobody has published one); the printer's `slip`,
|
|
785
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
|
|
786
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
|
|
787
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;
|
|
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
|
|
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;
|
|
788
961
|
a material's shear strength (its tensile strength over √3) and what it bears under a head (its strength); the nut
|
|
789
962
|
factor K (0.2); the diameter of thread asked in an insert; the millimetre kept at a screw's tip; and every mass.
|
|
790
963
|
A mass comes from the part's outline, with no socket and no knurls, and an insert's alloy is assumed.
|
|
@@ -841,6 +1014,13 @@ with its `rule`, `kind` and `source`.
|
|
|
841
1014
|
| A press's grip on a magnet | p = E i / d / (1 + ν), i = magnet_press; hold = μ p π d h; the pocket's wall stretched round its hoop at p | A rigid disc pressed into a hole in a wide plate (Lamé's thick cylinder with an infinite outer radius); μ is clamp_friction. An estimate, which creep lowers |
|
|
842
1015
|
| Crush ribs' grip | hold = μ × strength × n w h, n ribs a line w wide, crushed to the plastic's strength | An estimate of this package |
|
|
843
1016
|
| A magnet's mass | m = 7.5 g/cm³ × its volume | magnets.density, worked from sellers' weights |
|
|
1017
|
+
| An annular snap's geometric factor | X_N = 0.62 √((k - 1)/(k + 1)) / ((k² + 1)/(k² - 1) + ν), k = d0 / d, for the skirt; X_W the same with - ν and k = d / di, for the wall | Bayer, Snap-Fit Joints for Plastics, the annular snap joint (pages 21 and 22) |
|
|
1018
|
+
| Its transverse force | P = y d Es X for each part alone, y on the diameter; the two in series, k = 1 / (1/k_box + 1/k_lid) with k = factor × d E X; factor 1 at a free end, 3 from 1.8 √(d t) in, a straight line between | The same guide (pages 21 and 22, and page 24 for two flexible parts); Es taken as the modulus, and the line an estimate |
|
|
1019
|
+
| Its hoop strain | ε = (P / k_part) / d_part, held to 0.7 × strength / modulus, × 0.6 for a joint opened often | The same guide (page 11, and the note to Table 2 on page 12); yield strain as strength over modulus, an estimate on the safe side |
|
|
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) |
|
|
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 |
|
|
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 |
|
|
844
1024
|
|
|
845
1025
|
VDI 2230 and Machinery's Handbook are named because the plan asked for them. Neither was read at first hand for
|
|
846
1026
|
this package: the handbook's thread shear area and stress area are applied as the pages above give them, and VDI
|
|
@@ -848,6 +1028,8 @@ this package: the handbook's thread shear area and stress area are applied as th
|
|
|
848
1028
|
|
|
849
1029
|
## Glossary
|
|
850
1030
|
|
|
1031
|
+
- **Annular snap**: a bead round a round part that clicks into a groove round its mate: a lid that snaps on.
|
|
1032
|
+
- **Hoop strain**: how much a ring is stretched (or squeezed) round its circumference, the change in its diameter over its diameter.
|
|
851
1033
|
- **Clearance hole**: a hole a screw passes through without touching, a little wider than the thread.
|
|
852
1034
|
- **Clamp force, preload**: the force a tightened screw presses the parts together with.
|
|
853
1035
|
- **Counterbore**: a wider, flat-bottomed step at the mouth of a hole that hides a screw's head.
|
|
@@ -870,8 +1052,11 @@ this package: the handbook's thread shear area and stress area are applied as th
|
|
|
870
1052
|
- **Rule set**: a JSON file of named, sourced values in `@rulecad/rules`: one per thread, printer or material.
|
|
871
1053
|
- **Start**: one of the separate threads wound side by side on a multi-start screw.
|
|
872
1054
|
- **Stripping**: a thread failing by its teeth shearing off.
|
|
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.
|
|
873
1057
|
- **Teardrop**: a round hole with a pointed top, so a hole lying on its side prints with no support.
|
|
874
1058
|
- **Trapezoidal thread**: the flat-topped thread of a lead screw, with flanks 30° apart.
|
|
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.
|
|
875
1060
|
|
|
876
1061
|
## Sources
|
|
877
1062
|
|
|
@@ -885,8 +1070,10 @@ Each figure's own source is in its rule (`m.figures.<name>.source`, and `DEFAULT
|
|
|
885
1070
|
- [Bolt group capacity](https://steelcalculator.pages.dev/reference/bolt-group-capacity/), the elastic method: direct and torsional shear in a group.
|
|
886
1071
|
- [Von Mises yield criterion](https://en.wikipedia.org/wiki/Von_Mises_yield_criterion), Wikipedia: shear yield from tensile yield.
|
|
887
1072
|
- [How do you calculate the magnetic flux density?](https://www.supermagnete.de/eng/faq/How-do-you-calculate-the-magnetic-flux-density), supermagnete: the field on a disc's and a block's axis; [Physical magnet data](https://www.supermagnete.de/eng/physical-magnet-data), supermagnete: each grade's remanence; and [Force between magnets](https://en.wikipedia.org/wiki/Force_between_magnets), Wikipedia: the force on an iron face, F = B² A / 2μ0. Read on 2026-11-21; each magnet's pull is its seller's page, named in its rule.
|
|
1073
|
+
- [Snap-Fit Joints for Plastics: A Design Guide](https://fab.cba.mit.edu/classes/S62.12/people/vernelle.noel/Plastic_Snap_fit_design.pdf), Bayer MaterialScience: the annular snap joint (its geometric factors, deflection and mating forces and worked lamp cover), the permissible strain for a snap and the friction table. Read on 2026-11-23.
|
|
1074
|
+
- M. Hetényi, Beams on Elastic Foundation, University of Michigan Press, 1946: a thin tube's wall under a ring load as a beam on an elastic foundation, with its long-tube and free-end deflections (Pβ / 2k and 2Pβ / k), which `tubeRing` reproduces in its tests. Not read at first hand for this package: the equation and the two results are the textbook ones, and the kit checks its solution against them and against a short cantilever's P L³ / 3 D.
|
|
888
1075
|
|
|
889
|
-
|
|
1076
|
+
The rest were read on 2026-11-15. The plan for this package is [issue 212](https://github.com/JoniBach/rulecad/issues/212),
|
|
890
1077
|
and its specification is `docs/fixings-and-frames.md` in the repository. In `@rulecad/cad` the package is to become
|
|
891
1078
|
`v.fixings` in designs and a `fasten` relation in assemblies: that work is not in this release.
|
|
892
1079
|
|
package/fixings.d.mts
CHANGED
|
@@ -36,3 +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, snapSlots, skirtFinger, hubFactor, shaftFactor, tubeRing, SNAP_USES } from "./snaps.mjs";
|
package/fixings.mjs
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
// (engagement, stripping, preload, seating, lengthFor), and pins that hold two parts with no thread: a printed snap pin, a
|
|
8
8
|
// steel dowel, a length of filament or a printed peg, each with its hole's fit from the printer's rules (pinModel, pinHole,
|
|
9
9
|
// pin), and magnets pressed, glued or held by crush ribs in a pocket from the printer's rules, with their pull (magnetModel,
|
|
10
|
-
// magnetSeatModel, magnetSeat, magnet),
|
|
10
|
+
// magnetSeatModel, magnetSeat, magnet), printed bolts with their own strength (printedBoltModel, printedBolt), and annular snaps, a
|
|
11
|
+
// lid that clicks on to a round box, with the forces and hoop strain from the Bayer snap-fit guide (annularSnapModel, annularBead, annularGroove). Where it applies each comes as a pair: one function gives the
|
|
11
12
|
// numbers with findings (holeModel), its twin the solid (hole). Every thread's figures live in @rulecad/rules as open data: this package holds no
|
|
12
13
|
// screw's numbers of its own. Units: mm, degrees, grams. The plan is https://github.com/JoniBach/rulecad/issues/212.
|
|
13
14
|
import { fixingModel } from './model.mjs';
|
|
@@ -19,6 +20,7 @@ import { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGro
|
|
|
19
20
|
import { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName } from './pins.mjs';
|
|
20
21
|
import { printedBoltModel, printedBolt } from './bolts.mjs';
|
|
21
22
|
import { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare } from './magnets.mjs';
|
|
23
|
+
import { annularSnapModel, annularBead, annularGroove, snapSlots, skirtFinger, hubFactor, shaftFactor, tubeRing } from './snaps.mjs';
|
|
22
24
|
|
|
23
25
|
export { fixingModel, parseName, threads, GRAMMAR, HEADS, NUTS, DEFAULTS } from './model.mjs';
|
|
24
26
|
export { holeModel, hole, HOLE_KINDS } from './holes.mjs';
|
|
@@ -29,6 +31,7 @@ export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGro
|
|
|
29
31
|
export { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName, PIN_KINDS, PIN_FITS, PIN_GRAMMAR } from './pins.mjs';
|
|
30
32
|
export { printedBoltModel, printedBolt, BOLT_NUTS } from './bolts.mjs';
|
|
31
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, snapSlots, skirtFinger, hubFactor, shaftFactor, tubeRing, SNAP_USES } from './snaps.mjs';
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* What this release is. `release` is `'placeholder'` until the package has functions to call (0.1.0), then `'ready'`:
|
|
@@ -37,8 +40,8 @@ export { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnet
|
|
|
37
40
|
*/
|
|
38
41
|
export const status = Object.freeze({ release: 'ready', plan: 'https://github.com/JoniBach/rulecad/issues/212' });
|
|
39
42
|
|
|
40
|
-
const MODELS = { engagement, stripping, preload, torqueFor, seating, screwLoad, threadModel, holeModel, counterboreModel, countersinkModel, nutPocketModel, nutTrapModel, squareNutSlotModel, captiveNutModel, insertBossModel, screwModel, nutModel, washerModel, insertModel, pinModel, magnetModel, magnetSeatModel, printedBoltModel };
|
|
41
|
-
const SOLIDS = { thread, hole, counterbore, countersink, nutPocket, nutTrap, squareNutSlot, captiveNut, insertBoss, nut, washer, insert, pinHole, magnetSeat, magnet }, JOINED = { screw, pin, printedBolt };
|
|
43
|
+
const MODELS = { engagement, stripping, preload, torqueFor, seating, screwLoad, threadModel, holeModel, counterboreModel, countersinkModel, nutPocketModel, nutTrapModel, squareNutSlotModel, captiveNutModel, insertBossModel, screwModel, nutModel, washerModel, insertModel, pinModel, magnetModel, magnetSeatModel, printedBoltModel, annularSnapModel };
|
|
44
|
+
const SOLIDS = { thread, hole, counterbore, countersink, nutPocket, nutTrap, squareNutSlot, captiveNut, insertBoss, nut, washer, insert, pinHole, magnetSeat, magnet, annularBead, annularGroove }, JOINED = { screw, pin, printedBolt };
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Every function of this package with a workspace's rule sets and printer already in hand, so a design writes
|
|
@@ -59,7 +62,7 @@ export function fixingsFor({ sets, printer, ops, display } = {}) {
|
|
|
59
62
|
out.lengthFor = (stack, m, o = {}) => lengthFor(stack, m, with_(o));
|
|
60
63
|
out.screwGroup = screwGroup;
|
|
61
64
|
// (a snap pin from plain figures, as @rulecad/flexures draws it, built with the design's booleans)
|
|
62
|
-
Object.assign(out, { snapPin: (p, o) => snapPin(p, o ?? ops ?? undefined), snapSocket, snapPinModel, parsePin, isPinName, parseMagnet, isMagnetName, fieldShare });
|
|
65
|
+
Object.assign(out, { snapPin: (p, o) => snapPin(p, o ?? ops ?? undefined), snapSocket, snapPinModel, parsePin, isPinName, parseMagnet, isMagnetName, fieldShare, hubFactor, shaftFactor, tubeRing, skirtFinger, snapSlots });
|
|
63
66
|
for (const [k, f] of Object.entries(JOINED)) out[k] = (m, o = {}) => (ops ? f(m, with_(o), ops) : f(m, with_(o)));
|
|
64
67
|
return out;
|
|
65
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
|
@@ -57,7 +57,13 @@ export const DEFAULTS = {
|
|
|
57
57
|
snap_play: { value: 0.5, unit: 'mm', rule: 'A snap pin\'s shaft may be at most this much longer than the parts it goes through: the barb clicks out that far past the far face. Longer, and the pin rattles in its hole', kind: 'estimate', source: 'A working figure of this package: the launcher\'s pins are drawn 0.2 mm (x1c.fit) longer than their parts. No coupon row measures it, so it stays an estimate: snap pins a step longer each through one plate, the longest that does not rattle, would measure it', checked: '2026-11-21' },
|
|
58
58
|
pin_least: { value: 2, unit: 'mm', rule: 'The thinnest snap pin or printed plain pin: under this a peg is a few print lines across and breaks as it goes in. Thinner pins are filament or steel', kind: 'estimate', source: 'A working figure of this package: about five 0.42 mm lines across, the thinnest the kit draws a snap pin (2.5 mm, the tensioner\'s) less a margin. No coupon row measures it (the holds coupon\'s thinnest snap pin is 3 mm), so it stays an estimate: snap pins of 1.5, 2 and 2.5 mm pushed through their sockets, the thinnest that does not break, would measure it', checked: '2026-11-21' },
|
|
59
59
|
magnet_floor: { value: 3, unit: 'layers', rule: 'The least floor left under a magnet\'s pocket: three solid layers, so the floor prints whole and the magnet cannot be pulled through it. A floor the magnet pulls through is also its gap, so thinner pulls harder', kind: 'estimate', source: 'A working figure of this package, after Bambu Studio\'s default of three bottom shell layers. No coupon row measures it (the holds coupon\'s pockets have a hole under them), so it stays an estimate: pockets with floors of 2, 3 and 4 layers, the thinnest a magnet does not pull through or show through, would measure it', checked: '2026-11-21' },
|
|
60
|
-
brass_density: { value: 8.47, unit: 'g/cm³', rule: 'Density of free-machining brass CW614N (CuZn39Pb3), taken for a heat-set insert. The insert maker\'s sheet names no alloy, so the alloy is assumed', kind: 'estimate', source: 'Aalco, CW614N brass rod datasheet, https://www.aalco.co.uk/datasheets/Copper-and-Copper-Alloys-CW614N-Brass-Rod_31.ashx', checked: '2026-11-15' }
|
|
60
|
+
brass_density: { value: 8.47, unit: 'g/cm³', rule: 'Density of free-machining brass CW614N (CuZn39Pb3), taken for a heat-set insert. The insert maker\'s sheet names no alloy, so the alloy is assumed', kind: 'estimate', source: 'Aalco, CW614N brass rod datasheet, https://www.aalco.co.uk/datasheets/Copper-and-Copper-Alloys-CW614N-Brass-Rod_31.ashx', checked: '2026-11-15' },
|
|
61
|
+
snap_brief: { value: 0.7, unit: '× yield strain', rule: 'An annular snap may strain a plastic to this share of its yield strain as it snaps: the guide gives about 70% for an amorphous plastic in a single brief snap (a partly crystalline one may go almost to yield). Printed PLA and PETG are amorphous and the guide lists neither, so it is applied to them unchecked; the yield strain is taken as strength over modulus, which sits below the real one, on the safe side', 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 11, Permissible undercut', checked: '2026-11-23' },
|
|
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
|
+
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
|
+
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' },
|
|
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' }
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
// ---------- small things every module here uses ----------
|
|
@@ -348,7 +354,7 @@ export function fixingOf(what, m, o = {}) {
|
|
|
348
354
|
}
|
|
349
355
|
|
|
350
356
|
// ---------- the printer ----------
|
|
351
|
-
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'];
|
|
352
358
|
/**
|
|
353
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
|
|
354
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
|
|
@@ -357,7 +363,7 @@ const BASICS = ['hole_comp', 'fit', 'layer', 'line', 'chamfer', 'bridge', 'overh
|
|
|
357
363
|
/**
|
|
358
364
|
* The printer's rules as fixings reads them. Handed nothing, the kit's X1C. Handed a rule set ({ name, rules }), its
|
|
359
365
|
* figures with their kinds and sources. Handed plain numbers (a design's v.x1c), those, marked as given. A basic
|
|
360
|
-
* 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
|
|
361
367
|
* and cited as the X1C's; a measured figure (pilot_m3) is never borrowed, since it was measured on that machine.
|
|
362
368
|
* @param {string} what @param {object} [p] @returns {Printer}
|
|
363
369
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/fixings",
|
|
3
|
-
"version": "0.1.
|
|
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": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"pins.mjs",
|
|
23
23
|
"magnets.mjs",
|
|
24
24
|
"bolts.mjs",
|
|
25
|
+
"snaps.mjs",
|
|
25
26
|
"fixings.d.mts",
|
|
26
27
|
"model.d.mts",
|
|
27
28
|
"holes.d.mts",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"pins.d.mts",
|
|
34
35
|
"magnets.d.mts",
|
|
35
36
|
"bolts.d.mts",
|
|
37
|
+
"snaps.d.mts",
|
|
36
38
|
"README.md",
|
|
37
39
|
"CHANGELOG.md",
|
|
38
40
|
"LICENSE"
|
|
@@ -59,7 +61,7 @@
|
|
|
59
61
|
"@jscad/modeling": "^2.12.0"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
|
-
"@rulecad/rules": "^0.3.
|
|
64
|
+
"@rulecad/rules": "^0.3.20",
|
|
63
65
|
"@rulecad/shapes": "^0.4.4"
|
|
64
66
|
}
|
|
65
67
|
}
|
package/snaps.d.mts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A ring load on a thin tube, as Hetényi's beam on an elastic foundation (the theory the Bayer guide's annular joint is
|
|
3
|
+
* built on): the tube's wall in ξ = βx, with β⁴ = 3 (1 − ν²) / (R² t²), bends as w'''' + 4 w = 0, and a ring load q
|
|
4
|
+
* per mm round it puts a step of q / (D β³) in w''' (D = E t³ / (12 (1 − ν²))). The load is a from one end and b from
|
|
5
|
+
* the other (each in 1/β), and each end is 'free' (no moment, no shear), 'closed' (held by an end wall: no deflection,
|
|
6
|
+
* no slope, the stiffest an end can be) or 'long' (far enough off not to count). Gives the deflection under the load and
|
|
7
|
+
* the curvature w'' at each end, both per q / (D β³). The free-standing checks: a long tube both ways gives w = 1/8,
|
|
8
|
+
* a free end at the load gives 1/2 (Hetényi, Beams on Elastic Foundation, 1946: w = Pβ / 2k and 2Pβ / k).
|
|
9
|
+
* @param {number} a the load's distance from end A, in 1/β @param {number} b from end B
|
|
10
|
+
* @param {{ A?: 'free' | 'closed' | 'long', B?: 'free' | 'closed' | 'long' }} [ends] (default both long)
|
|
11
|
+
* @returns {{ w: number, bendA: number, bendB: number }}
|
|
12
|
+
*/
|
|
13
|
+
export function tubeRing(a: number, b: number, ends?: {
|
|
14
|
+
A?: "free" | "closed" | "long";
|
|
15
|
+
B?: "free" | "closed" | "long";
|
|
16
|
+
}): {
|
|
17
|
+
w: number;
|
|
18
|
+
bendA: number;
|
|
19
|
+
bendB: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
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
|
|
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
|
+
};
|
|
51
|
+
/**
|
|
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
|
|
53
|
+
* interference (the bead less the clearance, on the diameter) is shared between them as two springs in series, each
|
|
54
|
+
* P = y d Es X (Bayer, Snap-Fit Joints for Plastics, the annular snap joint), with Es taken as the material's modulus.
|
|
55
|
+
* The hoop strain in each is its share over its diameter, held to the plastic's limit: about 70% of its yield strain
|
|
56
|
+
* for a brief snap in an amorphous plastic, and 60% of that for a joint opened often (the same guide). Without a bead
|
|
57
|
+
* height, the bead is sized: the smallest the print can hold (fixings.snap_least), or more where pull asks it, up to
|
|
58
|
+
* what the strain allows. Refused by name: a bead no taller than the clearance (it never catches), walls that leave no
|
|
59
|
+
* tube, angles outside 0° to 90°, a lead friction locks, a groove deeper than the skirt. A closed end near the joint
|
|
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,
|
|
61
|
+
* so its mate takes more of the interference, and the bending at that end's root is held to the same limit.
|
|
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
|
|
63
|
+
* diameter: the box's wall outside, at the joint, mm; wall: the box's wall thickness there; skirt: the lid's skirt
|
|
64
|
+
* thickness; bead: how far the bead stands off the wall (default sized); lead: the face the lid pushes over, its
|
|
65
|
+
* angle from the axis (default 30); back: the return face's (default 45: the steepest the box prints without support,
|
|
66
|
+
* as it is the underside of the bead); land: the bead's flat top, along the axis (default two layers); boxEnd: from the
|
|
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);
|
|
68
|
+
* boxFloor: from the bead to the box's floor, its closed end; lidTop: from the groove to the underside of the lid's
|
|
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)
|
|
76
|
+
* @param {{ material?: string | object, lidMaterial?: string | object, printer?: object, sets?: object, uses?: 'often' | 'once', friction?: number, pull?: number, push?: number }} [o]
|
|
77
|
+
* material: the box's plastic (default PLA); lidMaterial: the lid's (default the box's); printer: the printer's rule
|
|
78
|
+
* set or values (default the X1C: its fit is the clearance, its overhang the steepest return face); uses: often (the
|
|
79
|
+
* default, a lid) or once; friction: μ between the parts (default fixings.snap_friction); pull: the force along the
|
|
80
|
+
* axis the lid must stay on against, N, held to fixings.load_margin; push: the force it is pushed on with, N (warns
|
|
81
|
+
* where pushing it on square takes more)
|
|
82
|
+
* @returns {AnnularSnap}
|
|
83
|
+
*/
|
|
84
|
+
export function annularSnapModel(p: {
|
|
85
|
+
diameter: number;
|
|
86
|
+
wall: number;
|
|
87
|
+
skirt: number;
|
|
88
|
+
bead?: number;
|
|
89
|
+
lead?: number;
|
|
90
|
+
back?: number;
|
|
91
|
+
land?: number;
|
|
92
|
+
boxEnd?: number;
|
|
93
|
+
lidEnd?: number;
|
|
94
|
+
boxFloor?: number;
|
|
95
|
+
lidTop?: number;
|
|
96
|
+
slots?: {
|
|
97
|
+
count: number;
|
|
98
|
+
reach: number;
|
|
99
|
+
width?: number;
|
|
100
|
+
};
|
|
101
|
+
}, o?: {
|
|
102
|
+
material?: string | object;
|
|
103
|
+
lidMaterial?: string | object;
|
|
104
|
+
printer?: object;
|
|
105
|
+
sets?: object;
|
|
106
|
+
uses?: "often" | "once";
|
|
107
|
+
friction?: number;
|
|
108
|
+
pull?: number;
|
|
109
|
+
push?: number;
|
|
110
|
+
}): AnnularSnap;
|
|
111
|
+
/**
|
|
112
|
+
* The bead to add to the box: a ring round the wall's outside, its foot (the bottom of the return face) at z = at.
|
|
113
|
+
* Union it with a box whose wall's outside is the model's diameter about the z axis.
|
|
114
|
+
* @param {object | AnnularSnap} p the joint's figures, as annularSnapModel takes them, or its model
|
|
115
|
+
* @param {object} [o] as annularSnapModel, and at: the bead's foot, mm up z (default 0); segments: faces round (default 96)
|
|
116
|
+
* @returns {object} a JSCAD geom3 with .model
|
|
117
|
+
*/
|
|
118
|
+
export function annularBead(p: object | AnnularSnap, o?: object): object;
|
|
119
|
+
/**
|
|
120
|
+
* The groove to cut from the lid's skirt, in the same place as the bead it takes (at, as annularBead's): the bead's
|
|
121
|
+
* outline grown by the clearance all round, so the seated bead touches nothing, and with mouth, the skirt's mouth's z,
|
|
122
|
+
* a lead-in cone there at the lead angle, as wide as the bead, so the skirt's edge starts over it.
|
|
123
|
+
* @param {object | AnnularSnap} p the joint's figures or its model
|
|
124
|
+
* @param {object} [o] as annularSnapModel, and at: the bead's foot (default 0); mouth: the z of the skirt's open end,
|
|
125
|
+
* below at (default none: no lead-in); segments: faces round (default 96)
|
|
126
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
127
|
+
*/
|
|
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;
|
|
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. */
|
|
145
|
+
export const SNAP_USES: string[];
|
|
146
|
+
export function hubFactor(k: number, nu: number): number;
|
|
147
|
+
export function shaftFactor(k: number, nu: number): number;
|
|
148
|
+
/**
|
|
149
|
+
* one part of the joint: its diameters at the joint, wall, how far the joint is from its free end and the guide's
|
|
150
|
+
* "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),
|
|
151
|
+
* how much of the interference it takes (on the diameter) and the hoop strain that leaves in it; with a closed end
|
|
152
|
+
* (closed, its distance from the joint), how much stiffer that end makes it, the length 1/β over which its wall
|
|
153
|
+
* bends, and the bending strain at the end's root
|
|
154
|
+
*/
|
|
155
|
+
export type SnapPart = {
|
|
156
|
+
diameter: number;
|
|
157
|
+
inside: number;
|
|
158
|
+
outside: number;
|
|
159
|
+
wall: number;
|
|
160
|
+
end: number;
|
|
161
|
+
far: number;
|
|
162
|
+
factor: number;
|
|
163
|
+
remote: number;
|
|
164
|
+
X: number;
|
|
165
|
+
stiffness: number;
|
|
166
|
+
deflection: number;
|
|
167
|
+
strain: number;
|
|
168
|
+
closed: number | null;
|
|
169
|
+
stiffer?: number;
|
|
170
|
+
decay?: number;
|
|
171
|
+
root?: number;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* diameter: the box's wall outside at the joint; bead: how far the bead stands off it (radial); length: the bead's
|
|
175
|
+
* height along the axis, return face, land and lead face; undercut: the
|
|
176
|
+
* bead less the clearance, the radial overlap the skirt is spread by; interference: the same on the diameter, shared
|
|
177
|
+
* between the parts; force: the transverse force P that takes; insertion and removal: along the push, N;
|
|
178
|
+
* permissible: the hoop strain each part may see; most: the largest undercut that strain allows and the removal
|
|
179
|
+
* force it would give; groove: the groove's radii and depth in the skirt
|
|
180
|
+
*/
|
|
181
|
+
export type AnnularSnap = {
|
|
182
|
+
kind: "annular snap";
|
|
183
|
+
diameter: number;
|
|
184
|
+
wall: number;
|
|
185
|
+
skirt: number;
|
|
186
|
+
clearance: number;
|
|
187
|
+
bead: number;
|
|
188
|
+
length: number;
|
|
189
|
+
undercut: number;
|
|
190
|
+
interference: number;
|
|
191
|
+
lead: number;
|
|
192
|
+
back: number;
|
|
193
|
+
land: number;
|
|
194
|
+
sized: boolean;
|
|
195
|
+
uses: "often" | "once";
|
|
196
|
+
material: string;
|
|
197
|
+
lidMaterial: string;
|
|
198
|
+
friction: number;
|
|
199
|
+
permissible: number;
|
|
200
|
+
box: SnapPart;
|
|
201
|
+
lid: SnapPart;
|
|
202
|
+
force: number;
|
|
203
|
+
insertion: number;
|
|
204
|
+
removal: number;
|
|
205
|
+
holds: boolean;
|
|
206
|
+
pull: number | null;
|
|
207
|
+
margin: number | null;
|
|
208
|
+
most: {
|
|
209
|
+
undercut: number;
|
|
210
|
+
removal: number;
|
|
211
|
+
};
|
|
212
|
+
groove: {
|
|
213
|
+
inner: number;
|
|
214
|
+
outer: number;
|
|
215
|
+
depth: number;
|
|
216
|
+
};
|
|
217
|
+
rests: object[];
|
|
218
|
+
findings: object[];
|
|
219
|
+
};
|
package/snaps.mjs
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
// Annular snaps: a lid that clicks on. A bead runs round the outside of a round box's wall near its rim; the lid's
|
|
2
|
+
// skirt has a groove inside it the bead's shape plus a clearance. Pushed on, the bead's lead face spreads the skirt and
|
|
3
|
+
// squeezes the box's wall; past it, both spring back and the bead sits in the groove with no stress left in either.
|
|
4
|
+
// Pulled, the bead's return face has to spread the skirt again. annularSnapModel gives the forces and the hoop strain in
|
|
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
|
+
// X from the tube's proportions), the two parts as springs in series where both give, and the strain held to the
|
|
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. 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.
|
|
11
|
+
import { DEFAULTS, printerOf, rest, finding, positive, oneOf, isNum, shown, mm, r3 } from './model.mjs';
|
|
12
|
+
import jscad from '@jscad/modeling';
|
|
13
|
+
import { lathe, OUT } from './draw.mjs';
|
|
14
|
+
import { optionsOf } from './holes.mjs';
|
|
15
|
+
import { materialOf } from './strength.mjs';
|
|
16
|
+
|
|
17
|
+
const { polygon } = jscad.primitives, { extrudeLinear } = jscad.extrusions, { translate, rotateY, rotateZ } = jscad.transforms, { geom3 } = jscad.geometries;
|
|
18
|
+
const n1 = (x) => +x.toFixed(1), n2 = (x) => +x.toFixed(2), n4 = (x) => +x.toFixed(4), pc = (x) => `${mm(n2(x * 100))}%`;
|
|
19
|
+
const tan = (deg) => Math.tan((deg * Math.PI) / 180);
|
|
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. */
|
|
21
|
+
export const SNAP_USES = ['often', 'once'];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The geometric factor of the Bayer guide's annular snap joint for the outer part, a tube (the hub, here the lid's
|
|
25
|
+
* skirt) spread over a rigid shaft: X_N = 0.62 √((k − 1)/(k + 1)) / ((k² + 1)/(k² − 1) + ν), k = d0 / d.
|
|
26
|
+
* @param {number} k the tube's outside diameter over its inside diameter at the joint @param {number} nu Poisson's ratio
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
export const hubFactor = (k, nu) => (0.62 * Math.sqrt((k - 1) / (k + 1))) / ((k * k + 1) / (k * k - 1) + nu);
|
|
30
|
+
/**
|
|
31
|
+
* The same for the inner part, a hollow shaft (here the box's wall) squeezed in a rigid tube:
|
|
32
|
+
* X_W = 0.62 √((k − 1)/(k + 1)) / ((k² + 1)/(k² − 1) − ν), k = d / di.
|
|
33
|
+
* @param {number} k the shaft's outside diameter at the joint over its inside diameter @param {number} nu Poisson's ratio
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
export const shaftFactor = (k, nu) => (0.62 * Math.sqrt((k - 1) / (k + 1))) / ((k * k + 1) / (k * k - 1) - nu);
|
|
37
|
+
|
|
38
|
+
// The force along the push to make a transverse force P over a face at deg from the axis, with friction mu: the
|
|
39
|
+
// guide's W = P (μ + tan α) / (1 − μ tan α). A square face, or one friction locks, never lets go
|
|
40
|
+
const along = (P, deg, mu) => (deg >= 90 || mu * tan(deg) >= 1 ? Infinity : (P * (mu + tan(deg))) / (1 - mu * tan(deg)));
|
|
41
|
+
const per = (deg, mu) => along(1, deg, mu);
|
|
42
|
+
// How much stiffer a joint is for lying away from its tube's free end: 1 at the end, the guide's 3 once it is at least
|
|
43
|
+
// 1.8 √(d t) in, and straight between (the guide gives only the ends; the line between is an estimate)
|
|
44
|
+
const remote = (end, d, t) => { const far = 1.8 * Math.sqrt(d * t), k = DEFAULTS.snap_remote.value; return { far: n2(far), factor: 1 + (k - 1) * Math.min(1, end / far) }; };
|
|
45
|
+
|
|
46
|
+
// e^(s u) (A cos u + B sin u) and its n-th derivative in u, at u
|
|
47
|
+
const wave = (s, A, B, u, n) => { for (let i = 0; i < n; i++) [A, B] = [s * A + B, s * B - A]; return Math.exp(s * u) * (A * Math.cos(u) + B * Math.sin(u)); };
|
|
48
|
+
const LONG = 12; // a tube this many 1/β long is long: e^-12 of the load is left at its far end
|
|
49
|
+
/**
|
|
50
|
+
* A ring load on a thin tube, as Hetényi's beam on an elastic foundation (the theory the Bayer guide's annular joint is
|
|
51
|
+
* built on): the tube's wall in ξ = βx, with β⁴ = 3 (1 − ν²) / (R² t²), bends as w'''' + 4 w = 0, and a ring load q
|
|
52
|
+
* per mm round it puts a step of q / (D β³) in w''' (D = E t³ / (12 (1 − ν²))). The load is a from one end and b from
|
|
53
|
+
* the other (each in 1/β), and each end is 'free' (no moment, no shear), 'closed' (held by an end wall: no deflection,
|
|
54
|
+
* no slope, the stiffest an end can be) or 'long' (far enough off not to count). Gives the deflection under the load and
|
|
55
|
+
* the curvature w'' at each end, both per q / (D β³). The free-standing checks: a long tube both ways gives w = 1/8,
|
|
56
|
+
* a free end at the load gives 1/2 (Hetényi, Beams on Elastic Foundation, 1946: w = Pβ / 2k and 2Pβ / k).
|
|
57
|
+
* @param {number} a the load's distance from end A, in 1/β @param {number} b from end B
|
|
58
|
+
* @param {{ A?: 'free' | 'closed' | 'long', B?: 'free' | 'closed' | 'long' }} [ends] (default both long)
|
|
59
|
+
* @returns {{ w: number, bendA: number, bendB: number }}
|
|
60
|
+
*/
|
|
61
|
+
export function tubeRing(a, b, ends = {}) {
|
|
62
|
+
const what = 'tubeRing', kinds = ['free', 'closed', 'long'];
|
|
63
|
+
for (const [k, v] of [['a', a], ['b', b]]) if (!(isNum(v) && v >= 0)) throw new Error(`${what}: ${k} is the load's distance from an end, in 1/β, 0 or more (got ${shown(v)})`);
|
|
64
|
+
if (ends == null || typeof ends !== 'object' || Array.isArray(ends)) throw new Error(`${what}: ends is { A, B }, each free, closed or long (got ${shown(ends)})`);
|
|
65
|
+
// An end more than twice LONG away is long whatever it is: e^-24 of the load reaches it, and its e^u waves would
|
|
66
|
+
// overflow a double past about 709/β (its curvature there is then 0 to that precision)
|
|
67
|
+
const A0 = oneOf(what, 'ends.A', ends.A ?? 'long', kinds), B0 = oneOf(what, 'ends.B', ends.B ?? 'long', kinds);
|
|
68
|
+
const A = a > 2 * LONG ? 'long' : A0, B = b > 2 * LONG ? 'long' : B0, la = A === 'long' ? LONG : a, lb = B === 'long' ? LONG : b;
|
|
69
|
+
// Each side of the load has its own four waves, from its start: e^-u cos u, e^-u sin u, e^u cos u, e^u sin u
|
|
70
|
+
const row = (side, u, n, sign = 1) => { const r = Array(8).fill(0); [[-1, 1, 0], [-1, 0, 1], [1, 1, 0], [1, 0, 1]].forEach(([s, c, si], i) => { r[side * 4 + i] = sign * wave(s, c, si, u, n); }); return r; };
|
|
71
|
+
const end = (side, u, kind) => (kind === 'closed' ? [0, 1] : [2, 3]).map((n) => [row(side, u, n), 0]);
|
|
72
|
+
const eqs = [...end(0, 0, A), ...end(1, lb, B)];
|
|
73
|
+
for (const n of [0, 1, 2, 3]) { const l = row(0, la, n, -1), r = row(1, 0, n); eqs.push([l.map((x, i) => x + r[i]), n === 3 ? 1 : 0]); }
|
|
74
|
+
// Gauss with partial pivoting
|
|
75
|
+
const M = eqs.map(([r, v]) => [...r, v]);
|
|
76
|
+
for (let c = 0; c < 8; c++) {
|
|
77
|
+
let p = c; for (let r = c + 1; r < 8; r++) if (Math.abs(M[r][c]) > Math.abs(M[p][c])) p = r;
|
|
78
|
+
[M[c], M[p]] = [M[p], M[c]];
|
|
79
|
+
for (let r = 0; r < 8; r++) if (r !== c) { const k = M[r][c] / M[c][c]; for (let j = c; j < 9; j++) M[r][j] -= k * M[c][j]; }
|
|
80
|
+
}
|
|
81
|
+
const x = M.map((r, i) => r[8] / r[i]), at = (side, u, n) => row(side, u, n).reduce((t, v, i) => t + v * x[i], 0);
|
|
82
|
+
return { w: at(1, 0, 0), bendA: A === A0 ? at(0, 0, 2) : 0, bendB: B === B0 ? at(1, lb, 2) : 0 };
|
|
83
|
+
}
|
|
84
|
+
// A closed end near the joint: how much stiffer it makes the part (the beam's deflection with the end open over that
|
|
85
|
+
// with it closed, the rest of the tube as it is) and the bending strain at the closed end's root per N of P
|
|
86
|
+
const closedEnd = (free, shut, Rm, t, d, E, nu) => {
|
|
87
|
+
const beta = Math.pow((3 * (1 - nu * nu)) / (Rm * Rm * t * t), 0.25), a = free * beta, b = shut * beta;
|
|
88
|
+
const open = tubeRing(a, LONG, { A: 'free' }), closed = tubeRing(a, b, { A: 'free', B: 'closed' });
|
|
89
|
+
// q = P / (π d) per mm round; M = D w''(x) = w''(ξ) q / β; the strain at the face is 6 M (1 − ν²) / (E t²)
|
|
90
|
+
const perP = (6 * Math.abs(closed.bendB) * (1 - nu * nu)) / (Math.PI * d * beta * E * t * t);
|
|
91
|
+
return { beta, stiffer: open.w / closed.w, perP };
|
|
92
|
+
};
|
|
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
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @typedef {{ diameter: number, inside: number, outside: number, wall: number, end: number, far: number, factor: number,
|
|
119
|
+
* remote: number, X: number, stiffness: number, deflection: number, strain: number, closed: number | null, stiffer?: number, decay?: number, root?: number }} SnapPart
|
|
120
|
+
* one part of the joint: its diameters at the joint, wall, how far the joint is from its free end and the guide's
|
|
121
|
+
* "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),
|
|
122
|
+
* how much of the interference it takes (on the diameter) and the hoop strain that leaves in it; with a closed end
|
|
123
|
+
* (closed, its distance from the joint), how much stiffer that end makes it, the length 1/β over which its wall
|
|
124
|
+
* bends, and the bending strain at the end's root
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {{ kind: 'annular snap', diameter: number, wall: number, skirt: number, clearance: number, bead: number, length: number, undercut: number,
|
|
128
|
+
* interference: number, lead: number, back: number, land: number, sized: boolean, uses: 'often' | 'once', material: string,
|
|
129
|
+
* lidMaterial: string, friction: number, permissible: number, box: SnapPart, lid: SnapPart, force: number, insertion: number,
|
|
130
|
+
* removal: number, holds: boolean, pull: number | null, margin: number | null, most: { undercut: number, removal: number },
|
|
131
|
+
* groove: { inner: number, outer: number, depth: number }, rests: object[], findings: object[] }} AnnularSnap
|
|
132
|
+
* diameter: the box's wall outside at the joint; bead: how far the bead stands off it (radial); length: the bead's
|
|
133
|
+
* height along the axis, return face, land and lead face; undercut: the
|
|
134
|
+
* bead less the clearance, the radial overlap the skirt is spread by; interference: the same on the diameter, shared
|
|
135
|
+
* between the parts; force: the transverse force P that takes; insertion and removal: along the push, N;
|
|
136
|
+
* permissible: the hoop strain each part may see; most: the largest undercut that strain allows and the removal
|
|
137
|
+
* force it would give; groove: the groove's radii and depth in the skirt
|
|
138
|
+
*/
|
|
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
|
+
|
|
157
|
+
/**
|
|
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
|
|
159
|
+
* interference (the bead less the clearance, on the diameter) is shared between them as two springs in series, each
|
|
160
|
+
* P = y d Es X (Bayer, Snap-Fit Joints for Plastics, the annular snap joint), with Es taken as the material's modulus.
|
|
161
|
+
* The hoop strain in each is its share over its diameter, held to the plastic's limit: about 70% of its yield strain
|
|
162
|
+
* for a brief snap in an amorphous plastic, and 60% of that for a joint opened often (the same guide). Without a bead
|
|
163
|
+
* height, the bead is sized: the smallest the print can hold (fixings.snap_least), or more where pull asks it, up to
|
|
164
|
+
* what the strain allows. Refused by name: a bead no taller than the clearance (it never catches), walls that leave no
|
|
165
|
+
* tube, angles outside 0° to 90°, a lead friction locks, a groove deeper than the skirt. A closed end near the joint
|
|
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,
|
|
167
|
+
* so its mate takes more of the interference, and the bending at that end's root is held to the same limit.
|
|
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
|
|
169
|
+
* diameter: the box's wall outside, at the joint, mm; wall: the box's wall thickness there; skirt: the lid's skirt
|
|
170
|
+
* thickness; bead: how far the bead stands off the wall (default sized); lead: the face the lid pushes over, its
|
|
171
|
+
* angle from the axis (default 30); back: the return face's (default 45: the steepest the box prints without support,
|
|
172
|
+
* as it is the underside of the bead); land: the bead's flat top, along the axis (default two layers); boxEnd: from the
|
|
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);
|
|
174
|
+
* boxFloor: from the bead to the box's floor, its closed end; lidTop: from the groove to the underside of the lid's
|
|
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)
|
|
182
|
+
* @param {{ material?: string | object, lidMaterial?: string | object, printer?: object, sets?: object, uses?: 'often' | 'once', friction?: number, pull?: number, push?: number }} [o]
|
|
183
|
+
* material: the box's plastic (default PLA); lidMaterial: the lid's (default the box's); printer: the printer's rule
|
|
184
|
+
* set or values (default the X1C: its fit is the clearance, its overhang the steepest return face); uses: often (the
|
|
185
|
+
* default, a lid) or once; friction: μ between the parts (default fixings.snap_friction); pull: the force along the
|
|
186
|
+
* axis the lid must stay on against, N, held to fixings.load_margin; push: the force it is pushed on with, N (warns
|
|
187
|
+
* where pushing it on square takes more)
|
|
188
|
+
* @returns {AnnularSnap}
|
|
189
|
+
*/
|
|
190
|
+
export function annularSnapModel(p, o = {}) {
|
|
191
|
+
const what = 'annularSnapModel';
|
|
192
|
+
if (p == null || typeof p !== 'object' || Array.isArray(p)) throw new Error(`${what}: give the joint's figures ({ diameter: 60, wall: 1.68, skirt: 1.26 }), not ${shown(p)}`);
|
|
193
|
+
optionsOf(what, o, '{ material: \'pla\', pull: 10 }');
|
|
194
|
+
const d = positive(what, 'diameter', p.diameter), t = positive(what, 'wall', p.wall), s = positive(what, 'skirt', p.skirt);
|
|
195
|
+
if (t >= d / 2) throw new Error(`${what}: a wall of ${mm(t)} mm fills a ${mm(d)} mm box: the box's wall is under half its diameter, so it is a tube that gives`);
|
|
196
|
+
const pr = printerOf(what, o.printer), c = pr.n('fit'), layer = pr.n('layer'), overhang = pr.n('overhang');
|
|
197
|
+
const angle = (k, v, dflt) => { const x = v ?? dflt; if (!(isNum(x) && x > 0 && x <= 90)) throw new Error(`${what}: ${k} is an angle from the axis above 0° and at most 90°, in degrees (got ${shown(v)})`); return x; };
|
|
198
|
+
const lead = angle('lead', p.lead, 30), back = angle('back', p.back, 45);
|
|
199
|
+
if (lead >= 90) throw new Error(`${what}: a lead of 90° is a square face the lid cannot be pushed over: give a lead under 90°, 30° to 45° is usual`);
|
|
200
|
+
const land = p.land != null ? positive(what, 'land', p.land) : r3(2 * layer);
|
|
201
|
+
const end = (k) => { const v = p[k] ?? 0; if (!(isNum(v) && v >= 0)) throw new Error(`${what}: ${k} is how far the joint is from that part's free end, 0 mm or more (got ${shown(p[k])})`); return v; };
|
|
202
|
+
// A closed end at the joint itself (0 mm) holds the wall rigid there, so it cannot give at all; one nearer than the
|
|
203
|
+
// wall is thick is a solid corner, not a tube's wall that bends, which the beam on an elastic foundation (a thin-shell
|
|
204
|
+
// theory) does not model, and its sums lose their sign to rounding as the distance goes to 0. Both refused
|
|
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; };
|
|
206
|
+
const boxFloor = shut('boxFloor', 'the box\'s floor', t, 'wall'), lidTop = shut('lidTop', 'the lid\'s top', s, 'skirt');
|
|
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);
|
|
209
|
+
const mu = o.friction ?? DEFAULTS.snap_friction.value;
|
|
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)})`);
|
|
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`);
|
|
212
|
+
const pull = o.pull != null ? positive(what, 'pull (along the axis, in N)', o.pull) : null, push = o.push != null ? positive(what, 'push (along the axis, in N)', o.push) : null;
|
|
213
|
+
if (p.bead != null && !(isNum(p.bead) && p.bead > c + 1e-9)) throw new Error(`${what}: a bead of ${shown(p.bead)} mm is no taller than the ${pr.cite('fit')} clearance of ${mm(c)} mm round the skirt, so it never catches: give a bead over ${mm(c)} mm, or leave it out to have it sized`);
|
|
214
|
+
if (p.bead != null && p.bead >= s - 1e-9) throw new Error(`${what}: a bead of ${mm(p.bead)} mm needs a groove as deep in the ${mm(s)} mm skirt, which cuts right through it: give a skirt thicker than the bead, by a print line or more`);
|
|
215
|
+
const box = materialOf(what, o.material ?? 'pla', o.sets), lidMat = materialOf(what, o.lidMaterial ?? o.material ?? 'pla', o.sets);
|
|
216
|
+
for (const m of [box, lidMat]) if (!m.poisson) throw new Error(`${what}: ${m.name} has no poisson in its rule set, which the guide's geometric factor needs`);
|
|
217
|
+
if (box.cls !== 'plastic' || lidMat.cls !== 'plastic') throw new Error(`${what}: an annular snap is two printed plastic parts; ${box.cls !== 'plastic' ? box.name : lidMat.name} is a ${box.cls !== 'plastic' ? box.cls : lidMat.cls}`);
|
|
218
|
+
|
|
219
|
+
// The permissible hoop strain: the guide's share of the yield strain, the yield strain taken as strength over modulus
|
|
220
|
+
// (a straight line to the strength, so below the real yield strain: on the safe side), and 60% of that if opened often
|
|
221
|
+
const brief = DEFAULTS.snap_brief.value, often = uses === 'often' ? DEFAULTS.snap_often.value : 1;
|
|
222
|
+
const limitOf = (m) => (brief * often * m.strength.value) / m.modulus.value, permissible = Math.min(limitOf(box), limitOf(lidMat));
|
|
223
|
+
|
|
224
|
+
// Each part as a spring on the diameter: P = y d Es X, stiffened where the joint lies away from its free end
|
|
225
|
+
const di = d - 2 * t, dh = d + 2 * c, d0 = dh + 2 * s;
|
|
226
|
+
// A closed end (the box's floor, the lid's top) near the joint holds the tube round there: Hetényi's beam on an elastic
|
|
227
|
+
// foundation gives how much stiffer that makes it than the same tube open, and the bending at the closed end's root
|
|
228
|
+
const part = (diameter, inside, outside, wall, endAt, closedAt, X, m) => {
|
|
229
|
+
const r = remote(endAt, diameter, wall), E = m.modulus.value, nu = m.poisson.value;
|
|
230
|
+
const ce = closedAt == null ? null : closedEnd(endAt, closedAt, (inside + outside) / 4, wall, diameter, E, nu), factor = r.factor * (ce ? ce.stiffer : 1);
|
|
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,
|
|
232
|
+
closed: closedAt, ...(ce ? { stiffer: n2(ce.stiffer), decay: n2(1 / ce.beta), rootPerP: ce.perP } : {}) };
|
|
233
|
+
};
|
|
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
|
+
};
|
|
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)
|
|
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 }; };
|
|
253
|
+
// to the thousandth: the sized bead is rounded up to what the pull needs and down to what the strain allows
|
|
254
|
+
const up = (x) => Math.ceil(x * 1000 - 1e-6) / 1000, down = (x) => Math.floor(x * 1000 + 1e-6) / 1000;
|
|
255
|
+
const least = DEFAULTS.snap_least.value, back1 = per(back, mu), want = DEFAULTS.load_margin.value;
|
|
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); }
|
|
258
|
+
else {
|
|
259
|
+
sized = true;
|
|
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);
|
|
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` : ''}`;
|
|
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`;
|
|
276
|
+
}
|
|
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);
|
|
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
|
|
293
|
+
const exact = new Map();
|
|
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;
|
|
299
|
+
|
|
300
|
+
const out = [], rests = [], cited = (m) => `${m.strength.name} ${mm(m.strength.value)} MPa over ${m.modulus.name} ${mm(m.modulus.value)} MPa`;
|
|
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),
|
|
302
|
+
rest('fixings.snap_brief', DEFAULTS.snap_brief), ...(uses === 'often' ? [rest('fixings.snap_often', DEFAULTS.snap_often)] : []), rest('fixings.snap_remote', DEFAULTS.snap_remote), pr.rest('line'));
|
|
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));
|
|
304
|
+
if (o.friction == null) rests.push(rest('fixings.snap_friction', DEFAULTS.snap_friction));
|
|
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));
|
|
307
|
+
if (pull != null) rests.push(rest('fixings.load_margin', DEFAULTS.load_margin));
|
|
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}` : ''}`,
|
|
309
|
+
'snap.undercut', { values: { bead, undercut, interference: r3(Y), box: B.deflection, lid: L.deflection } }));
|
|
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'}`}`,
|
|
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 } }));
|
|
314
|
+
}
|
|
315
|
+
for (const [q, name, m, endName] of [[B, 'the box\'s wall', box, 'floor'], [L, 'the lid\'s skirt', lidMat, 'top']]) {
|
|
316
|
+
if (q.closed == null) continue;
|
|
317
|
+
out.push(finding('info', `${name} meets its ${endName} ${mm(n2(q.closed))} mm from the joint, where a tube's wall bends over about 1/β = ${mm(q.decay)} mm: ${q.stiffer >= 1.01 ? `held round there, it is ${mm(q.stiffer)} times as stiff as the same tube open` : 'far enough off to make no difference to its stiffness'} (Hetényi's beam on an elastic foundation, the ${endName} taken as fully closed, the stiffest it can be)`,
|
|
318
|
+
'snap.closed', { values: { closed: q.closed, decay: q.decay, stiffer: q.stiffer }, refs: { part: q === B ? 'box' : 'lid' } }));
|
|
319
|
+
const ok = exact.get(q).root <= permissible * (1 + 1e-9);
|
|
320
|
+
out.push(finding(ok ? 'pass' : 'fail', `${name} bends where it meets its ${endName}: ${pc(q.root)} strain at the root where ${m.name} may see ${pc(permissible)}${ok ? '' : `. Move the joint further from the ${endName} (the wall bends over about 1/β, ${mm(q.decay)} mm), or a smaller bead: the most undercut the strain allows is ${mm(most.undercut)} mm`}`,
|
|
321
|
+
'snap.root', { values: { strain: q.root, permissible: n4(permissible), closed: q.closed }, refs: { part: q === B ? 'box' : 'lid', material: m.name } }));
|
|
322
|
+
}
|
|
323
|
+
// The groove is cut the bead's depth into the skirt: what is left behind it must print as a wall of at least one line
|
|
324
|
+
const line = pr.n('line'), left = r3(s - bead), thick = left >= line - 1e-9;
|
|
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`}`,
|
|
326
|
+
'snap.skirt', { values: { left, skirt: s, line } }));
|
|
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 } }));
|
|
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`,
|
|
331
|
+
'snap.forces', { values: { force: n1(P), insertion: n1(insertion), removal: Number.isFinite(removal) ? n1(removal) : null, friction: mu } }));
|
|
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 } }));
|
|
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) } })); }
|
|
334
|
+
const margin = pull != null ? (holds ? Infinity : n2(removal / pull)) : null;
|
|
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`}`,
|
|
336
|
+
'snap.hold', { values: { pull, removal: Number.isFinite(removal) ? n1(removal) : null, margin: Number.isFinite(margin) ? margin : null, want } }));
|
|
337
|
+
else out.push(finding('info', `give pull, the force the lid must stay on against, to have its hold checked`, 'snap.hold'));
|
|
338
|
+
// Printing: the box stands on its floor, so the bead's return face is an overhang; the lid is printed on its top, so
|
|
339
|
+
// the groove's face nearest the mouth, the return face's mate, is a ceiling at the same angle. The lead face and the
|
|
340
|
+
// skirt's lead-in lean the other way and always print
|
|
341
|
+
const prints = back <= overhang + 1e-9;
|
|
342
|
+
out.push(finding(prints ? 'pass' : 'fail', prints ? `the box printed standing on its floor and the lid on its top print with no support: the bead's ${mm(back)}° return face and the groove's mating face are within ${pr.cite('overhang')} ${mm(overhang)}°, and the ${mm(lead)}° lead face leans the way that always prints`
|
|
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 } }));
|
|
344
|
+
const groove = { inner: r3(dh / 2), outer: r3(dh / 2 + bead), depth: bead };
|
|
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,
|
|
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 };
|
|
347
|
+
}
|
|
348
|
+
|
|
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
|
|
350
|
+
// face, sunk into the wall by a little so it joins it
|
|
351
|
+
const beadOutline = (m, z, grow = 0) => {
|
|
352
|
+
const R = m.diameter / 2 + grow, h = m.bead, rise = h / tan(m.back), fall = h / tan(m.lead), sink = Math.min(m.wall / 2, 0.3);
|
|
353
|
+
const z0 = z - grow, top = z0 + rise + m.land + 2 * grow + fall;
|
|
354
|
+
return [[R - sink - grow, z0], [R, z0], [R + h, z0 + rise], [R + h, z0 + rise + m.land + 2 * grow], [R, top], [R - sink - grow, top]];
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* The bead to add to the box: a ring round the wall's outside, its foot (the bottom of the return face) at z = at.
|
|
358
|
+
* Union it with a box whose wall's outside is the model's diameter about the z axis.
|
|
359
|
+
* @param {object | AnnularSnap} p the joint's figures, as annularSnapModel takes them, or its model
|
|
360
|
+
* @param {object} [o] as annularSnapModel, and at: the bead's foot, mm up z (default 0); segments: faces round (default 96)
|
|
361
|
+
* @returns {object} a JSCAD geom3 with .model
|
|
362
|
+
*/
|
|
363
|
+
export function annularBead(p, o = {}) {
|
|
364
|
+
const m = p?.kind === 'annular snap' ? p : annularSnapModel(p, o), at = o.at ?? 0, n = o.segments ?? 96;
|
|
365
|
+
if (!isNum(at)) throw new Error(`annularBead: at is the bead's foot up z, in mm (got ${shown(o.at)})`);
|
|
366
|
+
return Object.assign(lathe(beadOutline(m, at), n), { model: m });
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* The groove to cut from the lid's skirt, in the same place as the bead it takes (at, as annularBead's): the bead's
|
|
370
|
+
* outline grown by the clearance all round, so the seated bead touches nothing, and with mouth, the skirt's mouth's z,
|
|
371
|
+
* a lead-in cone there at the lead angle, as wide as the bead, so the skirt's edge starts over it.
|
|
372
|
+
* @param {object | AnnularSnap} p the joint's figures or its model
|
|
373
|
+
* @param {object} [o] as annularSnapModel, and at: the bead's foot (default 0); mouth: the z of the skirt's open end,
|
|
374
|
+
* below at (default none: no lead-in); segments: faces round (default 96)
|
|
375
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
376
|
+
*/
|
|
377
|
+
export function annularGroove(p, o = {}) {
|
|
378
|
+
const what = 'annularGroove', m = p?.kind === 'annular snap' ? p : annularSnapModel(p, o), at = o.at ?? 0, n = o.segments ?? 96, c = m.clearance;
|
|
379
|
+
if (!isNum(at)) throw new Error(`${what}: at is the bead's foot up z, in mm (got ${shown(o.at)})`);
|
|
380
|
+
const ring = beadOutline(m, at, c);
|
|
381
|
+
if (o.mouth == null) return Object.assign(lathe(ring, n), { model: m });
|
|
382
|
+
if (!(isNum(o.mouth) && o.mouth < at - c - 1e-9)) throw new Error(`${what}: mouth is the z of the skirt's open end, below the groove's foot at ${mm(at - c)} mm (got ${shown(o.mouth)})`);
|
|
383
|
+
// The lead-in: from the groove's full radius at the mouth up to the skirt's inside, joined to the groove by a band at
|
|
384
|
+
// the skirt's inside so the two are one cutter
|
|
385
|
+
const R = m.diameter / 2 + c, h = m.bead, rise = h / tan(m.lead), z = o.mouth - 0.1, sink = Math.min(m.wall / 2, 0.3) + c;
|
|
386
|
+
const top = Math.min(o.mouth + rise, ring[1][1]);
|
|
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 });
|
|
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
|
+
}
|