@rulecad/frames 0.0.1 → 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/profile.d.mts ADDED
@@ -0,0 +1,268 @@
1
+ /**
2
+ * A slot family by name, from its rule set, or from a rule set of your own in the same names.
3
+ * @param {string | RuleSet} which 'slot-6-misumi', or a rule set with "part": "slot"
4
+ * @param {Record<string, number | string | Figure>} [change] a different or measured figure, by its rule's name
5
+ * @param {Given} [given]
6
+ * @returns {Slot}
7
+ */
8
+ export function slotModel(which: string | RuleSet, change?: Record<string, number | string | Figure>, given?: Given): Slot;
9
+ /**
10
+ * A slot's outline as it cuts into a face: points [u, v], u along the face from the slot's centre, v the depth below
11
+ * the face, from the left edge of its mouth round the cavity to the right edge. Open: the face closes it.
12
+ * @param {Slot} slot @returns {number[][]}
13
+ */
14
+ export function slotPath(slot: Slot): number[][];
15
+ /**
16
+ * A measured outline held to its format: a name, the source it was measured from and that source's licence, and closed
17
+ * loops of [x, y] points in mm. Comes back with the outside of the metal counter-clockwise and each hole clockwise,
18
+ * whichever way the file ran them (a loop inside an odd number of others is a hole).
19
+ * @param {any} data the file's JSON: { name, source, licence, loops: [[[x, y], ...], ...] }
20
+ * @returns {MeasuredOutline}
21
+ */
22
+ export function readOutline(data: any): MeasuredOutline;
23
+ /**
24
+ * A profile by name, from its rule set and its slot families', or from a rule set of your own (for a section not in
25
+ * the catalogue). Cells are expanded: every slot on every face and every bore has its place.
26
+ * @param {string | RuleSet} which 'profile-2020-misumi-hfs5' (or without the 'profile-'), or a rule set with "part": "profile"
27
+ * @param {Record<string, number | string | number[] | Figure>} [change] a different or measured figure, by its
28
+ * rule's name: { bore_diameter: 5 } or { area: { value: 161, kind: 'measured', source: 'weighed a metre' } }
29
+ * @param {Given} [given] slot families, threads and materials of your own, and a measured outline to use in place of the drawn one
30
+ * @returns {Profile}
31
+ */
32
+ export function profileModel(which: string | RuleSet, change?: Record<string, number | string | number[] | Figure>, given?: Given): Profile;
33
+ /**
34
+ * A profile's section as closed loops of [x, y] points in mm: the outside of the metal first, counter-clockwise, with
35
+ * every open slot cut into it, then each hole clockwise (bores, the hollows between cells and in corners, a tube's inside). Drawn
36
+ * from the interface values (envelope, corner radius, slots, bores), or the measured outline where the model has one.
37
+ * @param {Profile} model
38
+ * @returns {{ loops: number[][][], measured: boolean, source: string }}
39
+ */
40
+ export function outline(model: Profile): {
41
+ loops: number[][][];
42
+ measured: boolean;
43
+ source: string;
44
+ };
45
+ /**
46
+ * What a profile's section is worth as a beam, worked out from its outline, each figure beside the sheet's: area,
47
+ * centroid, second moments about the centroid's axes, the torsion constant, and mass per metre from the material's
48
+ * density. `sheet` holds, for each figure the sheet gives, { sheet, computed, difference }, the difference as a share
49
+ * of the sheet's figure (0.03 is 3% over).
50
+ * @param {Profile} model
51
+ * @param {{ torsion?: boolean, cells?: number }} [o] torsion: false leaves the torsion constant out (it is the slow
52
+ * part: a tenth of a second or so); cells: raster cells for it (DEFAULTS.cells)
53
+ * @returns {{ area: number, centroid: [number, number], inertiaX: number, inertiaY: number, inertiaXY: number,
54
+ * modulusX: number, modulusY: number, torsion: number | null, massPerMetre: number | null, measured: boolean,
55
+ * sheet: Record<string, { sheet: number, computed: number, difference: number }> }} mm², mm, mm⁴, mm³, kg/m
56
+ */
57
+ export function section(model: Profile, o?: {
58
+ torsion?: boolean;
59
+ cells?: number;
60
+ }): {
61
+ area: number;
62
+ centroid: [number, number];
63
+ inertiaX: number;
64
+ inertiaY: number;
65
+ inertiaXY: number;
66
+ modulusX: number;
67
+ modulusY: number;
68
+ torsion: number | null;
69
+ massPerMetre: number | null;
70
+ measured: boolean;
71
+ sheet: Record<string, {
72
+ sheet: number;
73
+ computed: number;
74
+ difference: number;
75
+ }>;
76
+ };
77
+ /**
78
+ * The figures to design a beam of this profile with: each one the maker's sheet gives, as the sheet gives it, and each it
79
+ * does not give worked out from the outline. A plain section (tube, angle, bar) has no sheet, so all of its are worked
80
+ * out; a maker's profile mostly has its own. Every figure says which it is.
81
+ * @param {Profile} model
82
+ * @param {{ cells?: number }} [o] raster cells for the torsion constant, solved only where the sheet gives none
83
+ * @returns {Record<'area' | 'inertiaX' | 'inertiaY' | 'modulusX' | 'modulusY' | 'torsion' | 'massPerMetre', { value: number | null, unit: string, kind: string, source: string, from: 'sheet' | 'outline' }>}
84
+ */
85
+ export function beamFigures(model: Profile, o?: {
86
+ cells?: number;
87
+ }): Record<"area" | "inertiaX" | "inertiaY" | "modulusX" | "modulusY" | "torsion" | "massPerMetre", {
88
+ value: number | null;
89
+ unit: string;
90
+ kind: string;
91
+ source: string;
92
+ from: "sheet" | "outline";
93
+ }>;
94
+ /**
95
+ * What a check of a profile finds, in the kit's one shape: slots that do not fit inside the section or run into each
96
+ * other, a bore that a slot or a hollow breaks into, a bore too wide or too tight for the thread it is tapped to, and
97
+ * section figures on the sheet that the drawn outline does not bear out. 'fail' is a set that cannot be right, 'warn' one to look at, 'info' something to know (a bore that leaves a thin thread). An empty list is a clean pass.
98
+ * @param {Profile} model
99
+ * @param {{ torsion?: boolean, cells?: number }} [o] as section() takes
100
+ * @returns {{ level: 'fail' | 'warn' | 'info', code: string, text: string, rule?: string, at?: number[], values?: Record<string, number | string> }[]}
101
+ */
102
+ export function profileFindings(model: Profile, o?: {
103
+ torsion?: boolean;
104
+ cells?: number;
105
+ }): {
106
+ level: "fail" | "warn" | "info";
107
+ code: string;
108
+ text: string;
109
+ rule?: string;
110
+ at?: number[];
111
+ values?: Record<string, number | string>;
112
+ }[];
113
+ /**
114
+ * What this release is: `'ready'` from 0.1.0, when the package has functions to call (`'placeholder'` before).
115
+ * @type {Readonly<{ release: 'placeholder' | 'ready', plan: string }>}
116
+ */
117
+ export const status: Readonly<{
118
+ release: "placeholder" | "ready";
119
+ plan: string;
120
+ }>;
121
+ /**
122
+ * The rules this package adds to the profiles' own figures, each with what it comes from.
123
+ * @type {Record<string, { value: number, unit: string, rule: string, kind: string }>}
124
+ */
125
+ export const DEFAULTS: Record<string, {
126
+ value: number;
127
+ unit: string;
128
+ rule: string;
129
+ kind: string;
130
+ }>;
131
+ export function profiles(): string[];
132
+ export function slots(): string[];
133
+ export function slotNuts(): string[];
134
+ export type Figure = {
135
+ value: number | string | number[];
136
+ unit?: string;
137
+ kind: string;
138
+ source: string;
139
+ rule?: string;
140
+ checked?: string;
141
+ };
142
+ export type RuleSet = {
143
+ name?: string;
144
+ part?: string;
145
+ rules: Record<string, any>;
146
+ };
147
+ /**
148
+ * rule sets
149
+ * of your own by name (a slot family, a thread, a material), a function that finds one, and a measured outline
150
+ */
151
+ export type Given = {
152
+ sets?: Record<string, RuleSet>;
153
+ load?: (name: string) => RuleSet | undefined;
154
+ outline?: object;
155
+ };
156
+ export type Slot = {
157
+ kind: "slot";
158
+ name: string;
159
+ figures: Record<string, Figure>;
160
+ opening: number;
161
+ mouth: number;
162
+ lip: number;
163
+ lipAngle: number;
164
+ cavityWidth: number;
165
+ cavityDepth: number;
166
+ floorWidth: number;
167
+ flankAngle: number;
168
+ straight: number;
169
+ trackWidth: number;
170
+ trackAngle: number;
171
+ grooveWidth: number;
172
+ grooveDepth: number;
173
+ nutFamily: string;
174
+ };
175
+ export type FaceSlot = {
176
+ face: "top" | "bottom" | "front" | "back";
177
+ index: number;
178
+ slot: string | null;
179
+ at: [number, number];
180
+ normal: [number, number];
181
+ along: [number, number];
182
+ };
183
+ export type Bore = {
184
+ at: [number, number];
185
+ diameter: number;
186
+ thread: string | null;
187
+ threadSet: string | null;
188
+ tapDrill: number | null;
189
+ major: number | null;
190
+ threadPitch: number | null;
191
+ where: "cell" | "corner" | "given";
192
+ };
193
+ /**
194
+ * the
195
+ * closed hollow between two cells: axis x between cells side by side (its width runs up y), axis y between cells one
196
+ * above the other (its width runs along x); ends are its half widths toward - and + along that width; depth is how far it reaches each side of the line between the cells
197
+ */
198
+ export type Chamber = {
199
+ at: [number, number];
200
+ axis: "x" | "y";
201
+ width: number;
202
+ length: number;
203
+ depth: number;
204
+ ends: [number, number];
205
+ slot: string;
206
+ };
207
+ /**
208
+ * a closed square hollow in a corner, by its centre and side
209
+ */
210
+ export type Hollow = {
211
+ at: [number, number];
212
+ width: number;
213
+ };
214
+ export type MeasuredOutline = {
215
+ loops: number[][][];
216
+ source: string;
217
+ licence: string;
218
+ name?: string;
219
+ };
220
+ export type Profile = {
221
+ kind: "profile";
222
+ name: string;
223
+ family: string;
224
+ series: number;
225
+ cells: [number, number];
226
+ absent: [number, number][];
227
+ pitch: [number, number];
228
+ title: string;
229
+ width: number;
230
+ height: number;
231
+ cornerRadius: number;
232
+ wall: number;
233
+ figures: Record<string, Figure>;
234
+ faces: Record<"top" | "bottom" | "front" | "back", FaceSlot[]>;
235
+ slots: Record<string, Slot>;
236
+ bores: Bore[];
237
+ chambers: Chamber[];
238
+ hollows: Hollow[];
239
+ sheet: {
240
+ area: number | null;
241
+ inertiaX: number | null;
242
+ inertiaY: number | null;
243
+ modulusX: number | null;
244
+ modulusY: number | null;
245
+ torsion: number | null;
246
+ massPerMetre: number | null;
247
+ };
248
+ material: {
249
+ name: string;
250
+ alloy: string | null;
251
+ density: number | null;
252
+ modulus: number | null;
253
+ poisson: number | null;
254
+ strength: number | null;
255
+ figures: Record<string, Figure>;
256
+ } | null;
257
+ supply: {
258
+ lengths: number[];
259
+ cutMin: number | null;
260
+ cutMax: number | null;
261
+ cutTolerance: number | null;
262
+ straightness: number | null;
263
+ twist: number | null;
264
+ };
265
+ measured: MeasuredOutline | null;
266
+ rests: string[];
267
+ };
268
+ export { polygonSection, torsionConstant, signedArea } from "./section.mjs";