@rulecad/gears 0.3.2 → 0.3.4

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/diagram.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  // the geometry its numbers come from: the pitch circles rolling on each other at the pitch point, the base circles the
3
3
  // flanks unwind from, the line of action tangent to both, and the stretch of it where the teeth touch (the path of
4
4
  // contact, whose length over the base pitch is the contact ratio).
5
- import { gearModel, internalModel, rackModel, spurProfile, internalProfile, rackProfile, mesh, phase, rackPhase } from './gears.mjs';
5
+ import { gearModel, internalModel, rackModel, spurProfile, internalProfile, rackProfile, mesh, phase, rackPhase } from './core.mjs';
6
6
 
7
7
  const DEG = Math.PI / 180;
8
8
  const C = { a: '#2f6fb3', b: '#e07a1f', aFill: '#d6e4f3', bFill: '#f9e0c8', line: '#333', faint: '#999', contact: '#c0392b' };
package/gears.d.mts CHANGED
@@ -1,423 +1,5 @@
1
- /**
2
- * A spur gear's numbers: its circles, tooth thickness, and the limits it was checked against. Refuses a gear whose teeth
3
- * would be undercut (fewer than about 17 at 20°: give it a profile shift) or come to a point.
4
- * @param {GearSpec} p
5
- * @returns {GearModel}
6
- */
7
- export function gearModel(p: GearSpec): GearModel;
8
- /**
9
- * An internal (ring) gear's numbers: the teeth point inwards, tip circle inside the pitch circle. Its spaces are shaped
10
- * as an outer gear's teeth would be. `rim` is the ring's outer diameter (default: the root diameter and six modules).
11
- * @param {GearSpec & { rim?: number }} p
12
- * @returns {GearModel & { rim: number, space: number }}
13
- */
14
- export function internalModel(p: GearSpec & {
15
- rim?: number;
16
- }): GearModel & {
17
- rim: number;
18
- space: number;
19
- };
20
- /**
21
- * A rack's numbers: a gear of infinite radius, its teeth straight-flanked at the pressure angle. Its pitch line is y = 0,
22
- * teeth up +y, the first space centred at x = 0. `height` is how much bar there is under the roots (default 3 modules).
23
- * @param {GearSpec & { height?: number }} p
24
- */
25
- export function rackModel(p: GearSpec & {
26
- height?: number;
27
- }): {
28
- kind: string;
29
- module: any;
30
- teeth: any;
31
- pressureAngle: any;
32
- shift: number;
33
- backlash: any;
34
- height: any;
35
- thickness: number;
36
- helix: any;
37
- hand: any;
38
- herringbone: boolean;
39
- thrust: number;
40
- length: number;
41
- tipLine: number;
42
- rootLine: number;
43
- circularPitch: number;
44
- basePitch: number;
45
- topLand: number;
46
- rootThickness: number;
47
- rack: {
48
- pressureAngle: any;
49
- addendum: any;
50
- dedendum: any;
51
- rootFillet: any;
52
- tipRound: any;
53
- };
54
- };
55
- /**
56
- * A spur gear's outline in 2D, as loops of [x, y] points (the first the outside, counter-clockwise; then holes,
57
- * clockwise), and the fillet and round it was drawn with (smaller than asked where the asked one didn't fit).
58
- * @param {GearSpec & { bore?: number, flat?: number }} p
59
- * @param {number} [grow] outwards along the outline's normal, mm (negative: inwards)
60
- */
61
- export function spurProfile(p: GearSpec & {
62
- bore?: number;
63
- flat?: number;
64
- }, grow?: number): {
65
- loops: number[][][];
66
- fillet: any;
67
- round: any;
68
- model: GearModel;
69
- };
70
- /** An internal gear's outline: the rim (counter-clockwise), then the teeth's inner outline (clockwise). */
71
- export function internalProfile(p: any, grow?: number): {
72
- loops: any[][];
73
- fillet: any;
74
- round: any;
75
- model: GearModel & {
76
- rim: number;
77
- space: number;
78
- };
79
- };
80
- /** A rack's outline: one loop, counter-clockwise, its pitch line on y = 0, teeth up +y from x = 0. */
81
- export function rackProfile(p: any, grow?: number): {
82
- loops: any[][];
83
- fillet: any;
84
- round: any;
85
- model: {
86
- kind: string;
87
- module: any;
88
- teeth: any;
89
- pressureAngle: any;
90
- shift: number;
91
- backlash: any;
92
- height: any;
93
- thickness: number;
94
- helix: any;
95
- hand: any;
96
- herringbone: boolean;
97
- thrust: number;
98
- length: number;
99
- tipLine: number;
100
- rootLine: number;
101
- circularPitch: number;
102
- basePitch: number;
103
- topLand: number;
104
- rootThickness: number;
105
- rack: {
106
- pressureAngle: any;
107
- addendum: any;
108
- dedendum: any;
109
- rootFillet: any;
110
- tipRound: any;
111
- };
112
- };
113
- };
114
- /** @typedef {{ width: number, chamfer?: number | [number, number], bore?: number, flat?: number }} Solid width up z; chamfer at the bed face (and the top); bore and flat for a shaft */
115
- /**
116
- * A spur gear: the profile extruded up z, its first tooth on +x, the bed face chamfered.
117
- * @param {GearSpec & Solid} p
118
- * @returns {object} a JSCAD geom3
119
- */
120
- export function spur(p: GearSpec & Solid): object;
121
- /** A helical gear: a spur gear's profile turned along its width by the helix angle. Meshes with one of the opposite hand. @param {GearSpec & Solid & { helix: number, hand?: 'right' | 'left' }} p */
122
- export function helical(p: GearSpec & Solid & {
123
- helix: number;
124
- hand?: "right" | "left";
125
- }): any;
126
- /** A herringbone gear: helical one way to the middle of its width and back, so it pushes no thrust along its axis and stays on its shaft. Prints with no supports. @param {GearSpec & Solid & { helix?: number }} p */
127
- export function herringbone(p: GearSpec & Solid & {
128
- helix?: number;
129
- }): any;
130
- /** An internal (ring) gear, its rim round it. @param {GearSpec & Solid & { rim?: number }} p */
131
- export function internal(p: GearSpec & Solid & {
132
- rim?: number;
133
- }): jscad.geometries.geom3.Geom3;
134
- /** A rack along x, its teeth up +y, its width up z. @param {GearSpec & Solid & { height?: number }} p */
135
- export function rack(p: GearSpec & Solid & {
136
- height?: number;
137
- }): jscad.geometries.geom3.Geom3;
138
- /**
139
- * How two gears mesh: the centre distance they need (with their profile shifts), the ratio (turns of b for one of a,
140
- * negative when they turn opposite ways; for a rack, mm for one turn of the pinion), the contact ratio (how many teeth
141
- * share the load on average: under 1 the drive jumps, under 1.2 it is rough), and findings. Give `centre` (mm) to have
142
- * a centre distance checked: closer than needed jams the teeth, further adds backlash.
143
- * @param {GearModel} a @param {GearModel} b @param {{ centre?: number }} [o]
144
- */
145
- export function mesh(a: GearModel, b: GearModel, { centre, width }?: {
146
- centre?: number;
147
- }): any;
148
- /**
149
- * The phase that puts a tooth in a gap: b's angle is ratio × a's angle + phase. Both gears have their first tooth at
150
- * their own angle 0; `angle` is the direction from a's centre to b's, in degrees, in the frame both angles are measured in.
151
- * For a pinion in a ring, a is the pinion. Returns degrees, in [0, 360 / b's teeth).
152
- * @param {GearModel} a @param {GearModel} b @param {number} [angle]
153
- */
154
- export function phase(a: GearModel, b: GearModel, angle?: number): number;
155
- /**
156
- * Where a rack must stand so the pinion's teeth fall in its spaces: the rack's travel is (π × pitch diameter / 360) ×
157
- * the pinion's angle + this, in mm. The rack lies along x with its pitch line on y = 0 and its first space at x = 0;
158
- * the pinion's centre is at x = `at`, above the rack, its first tooth pointing along +x at angle 0.
159
- * @param {GearModel} pinion @param {number} [at] @returns {number} mm, in [0, the circular pitch)
160
- */
161
- export function rackPhase(pinion: GearModel, at?: number): number;
162
- /**
163
- * How a gear prints on a printer ({ line, layer, nozzle?, wall_min? }): the module against the nozzle, lines across a
164
- * tooth at its root and its tip, and the width in layers. Findings in the kit's shape, each placed on the first tooth.
165
- * @param {GearModel} g @param {{ line: number, layer: number, nozzle?: number, wall_min?: number }} printer @param {number} [width]
166
- */
167
- export function printable(g: GearModel, printer: {
168
- line: number;
169
- layer: number;
170
- nozzle?: number;
171
- wall_min?: number;
172
- }, width?: number): any[];
173
- /**
174
- * How much of the power a stage passes on: DEFAULTS.efficiency per mesh a tooth force goes through. A planetary's
175
- * goes through two (sun to planet, planet to ring); a worm's is its own, from its lead angle and friction.
176
- * @param {'spur' | 'helical' | 'herringbone' | 'rack' | 'internal' | 'bevel' | 'planetary' | 'worm'} kind
177
- * @param {{ efficiency?: number, worm?: { efficiency: number } }} [o] efficiency: your measured figure per mesh
178
- * @returns {number} from 0 to 1
179
- */
180
- export function stageEfficiency(kind: "spur" | "helical" | "herringbone" | "rack" | "internal" | "bevel" | "planetary" | "worm", o?: {
181
- efficiency?: number;
182
- worm?: {
183
- efficiency: number;
184
- };
185
- }): number;
186
- /** The Lewis form factor Y for z teeth (20° full depth); Infinity for a rack. @param {number} z */
187
- export function lewisFactor(z: number): number;
188
- /**
189
- * How strong a gear's teeth are by the Lewis equation: the bending stress at the root of a tooth carrying the whole
190
- * load at its tip, σ = F_t / (b m Y), against the material's strength. Give a torque (N·mm) for the stress and safety
191
- * factor at it; give a safety factor for the torque the gear carries at it. Helical teeth are read in their normal
192
- * section (m cos β, z / cos³β teeth). A speed (rpm) adds Barth's velocity factor, (3.05 + V) / 3.05 for a cut (here a
193
- * printed) profile. A first number: the root fillet and a tooth's neighbours help, a printed tooth's layers and
194
- * voids hurt. Where it matters, measure it, or analyse the tooth (fea).
195
- * @param {GearModel} g
196
- * @param {{ width: number, material: { strength: number, name?: string }, torque?: number, safety?: number, speed?: number }} o
197
- */
198
- export function strength(g: GearModel, o?: {
199
- width: number;
200
- material: {
201
- strength: number;
202
- name?: string;
203
- };
204
- torque?: number;
205
- safety?: number;
206
- speed?: number;
207
- }): {
208
- Y: number;
209
- velocity: number;
210
- force: number;
211
- torque: number;
212
- findings: any[];
213
- };
214
- /**
215
- * A straight bevel gear's numbers, for a mate of `mate` teeth with the shafts at `shaftAngle` (90° by default): the
216
- * pitch cone angle δ (tan δ = sin Σ / (z₂/z₁ + cos Σ)), the cone distance R (to the apex along the pitch cone), the
217
- * virtual teeth z / cos δ of its back cone (Tredgold), and the face width's limit R / 3. Module and diameters at the
218
- * back (large) end.
219
- * @param {{ module: number, teeth: number, mate: number, shaftAngle?: number, width?: number, pressureAngle?: number, backlash?: number }} p
220
- */
221
- export function bevelModel(p: {
222
- module: number;
223
- teeth: number;
224
- mate: number;
225
- shaftAngle?: number;
226
- width?: number;
227
- pressureAngle?: number;
228
- backlash?: number;
229
- }): {
230
- kind: string;
231
- mate: any;
232
- shaftAngle: number;
233
- pitchAngle: number;
234
- coneDistance: number;
235
- virtualTeeth: number;
236
- width: any;
237
- height: number;
238
- smallEnd: number;
239
- module: number;
240
- teeth: number;
241
- /**
242
- * degrees
243
- */
244
- pressureAngle: number;
245
- /**
246
- * times the module
247
- */
248
- shift: number;
249
- /**
250
- * mm, this gear's share is half
251
- */
252
- backlash: number;
253
- /**
254
- * pitch diameter, module × teeth
255
- */
256
- pitch: number;
257
- /**
258
- * base circle diameter
259
- */
260
- base: number;
261
- /**
262
- * tip diameter
263
- */
264
- tip: number;
265
- /**
266
- * root diameter
267
- */
268
- root: number;
269
- /**
270
- * tooth thickness on the pitch circle (an arc, mm), less half the backlash
271
- */
272
- thickness: number;
273
- /**
274
- * π × module
275
- */
276
- circularPitch: number;
277
- /**
278
- * π × module × cos(pressure angle)
279
- */
280
- basePitch: number;
281
- /**
282
- * the tooth's width across its tip (mm)
283
- */
284
- topLand: number;
285
- /**
286
- * the tooth's width where it meets the root (mm)
287
- */
288
- rootThickness: number;
289
- /**
290
- * the basic rack it was drawn from
291
- */
292
- rack: {
293
- pressureAngle: number;
294
- addendum: number;
295
- dedendum: number;
296
- rootFillet: number;
297
- tipRound: number;
298
- };
299
- };
300
- /**
301
- * A straight bevel gear: its back (large) end on the bed at z = 0, its axis up z toward the cone's apex, the spur
302
- * profile of its back end scaled toward the apex up the face width, so every tooth runs straight to the apex and the
303
- * pitch surface is the cone. (A printable approximation to the octoidal profile: close for teeth of 12 or more.)
304
- * @param {{ module: number, teeth: number, mate: number, shaftAngle?: number, width?: number, bore?: number, chamfer?: number }} p
305
- */
306
- export function bevel(p: {
307
- module: number;
308
- teeth: number;
309
- mate: number;
310
- shaftAngle?: number;
311
- width?: number;
312
- bore?: number;
313
- chamfer?: number;
314
- }): jscad.geometries.geom3.Geom3;
315
- /**
316
- * How two bevel gears mesh: turns of b for one of a, the cone angles (they add to the shaft angle), and the contact
317
- * ratio of their back cones' equivalent spur gears (Tredgold). @param {object} a @param {object} b the gears' parameters
318
- */
319
- export function bevelMesh(a: object, b: object): {
320
- ratio: number;
321
- pitchAngles: number[];
322
- coneDistance: number;
323
- contact: any;
324
- findings: any[];
325
- };
326
- /**
327
- * The defaults, each with the rule it comes from. Coefficients are times the module.
328
- * @type {Record<string, { value: number, unit: string, rule: string, kind: string }>}
329
- */
330
- export const DEFAULTS: Record<string, {
331
- value: number;
332
- unit: string;
333
- rule: string;
334
- kind: string;
335
- }>;
1
+ export * from "./core.mjs";
336
2
  export { contact } from "./contact.mjs";
337
3
  export { toothStress } from "./tooth.mjs";
338
- /**
339
- * width up z; chamfer at the bed face (and the top); bore and flat for a shaft
340
- */
341
- export type Solid = {
342
- width: number;
343
- chamfer?: number | [number, number];
344
- bore?: number;
345
- flat?: number;
346
- };
347
- export type GearSpec = {
348
- module: number;
349
- teeth: number;
350
- pressureAngle?: number;
351
- shift?: number;
352
- backlash?: number;
353
- addendum?: number;
354
- dedendum?: number;
355
- rootFillet?: number;
356
- tipRound?: number;
357
- };
358
- export type GearModel = {
359
- kind: "external" | "internal";
360
- module: number;
361
- teeth: number;
362
- /**
363
- * degrees
364
- */
365
- pressureAngle: number;
366
- /**
367
- * times the module
368
- */
369
- shift: number;
370
- /**
371
- * mm, this gear's share is half
372
- */
373
- backlash: number;
374
- /**
375
- * pitch diameter, module × teeth
376
- */
377
- pitch: number;
378
- /**
379
- * base circle diameter
380
- */
381
- base: number;
382
- /**
383
- * tip diameter
384
- */
385
- tip: number;
386
- /**
387
- * root diameter
388
- */
389
- root: number;
390
- /**
391
- * tooth thickness on the pitch circle (an arc, mm), less half the backlash
392
- */
393
- thickness: number;
394
- /**
395
- * π × module
396
- */
397
- circularPitch: number;
398
- /**
399
- * π × module × cos(pressure angle)
400
- */
401
- basePitch: number;
402
- /**
403
- * the tooth's width across its tip (mm)
404
- */
405
- topLand: number;
406
- /**
407
- * the tooth's width where it meets the root (mm)
408
- */
409
- rootThickness: number;
410
- /**
411
- * the basic rack it was drawn from
412
- */
413
- rack: {
414
- pressureAngle: number;
415
- addendum: number;
416
- dedendum: number;
417
- rootFillet: number;
418
- tipRound: number;
419
- };
420
- };
421
- import jscad from '@jscad/modeling';
422
- export { planetary, planetaryRatio, compoundPlanetary, compoundRatio, compoundEfficiency } from "./planetary.mjs";
4
+ export { planetary, planetaryRatio, compoundPlanetary, compoundRatio, compoundEfficiency, compoundPlay } from "./planetary.mjs";
423
5
  export { wormModel, worm, wormWheel, wormMesh } from "./worm.mjs";