@mylasertools/kerfscript 0.6.0 → 0.8.0
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 +201 -1
- package/LANGUAGE.md +169 -30
- package/README.md +8 -2
- package/THIRD-PARTY-NOTICES.md +113 -0
- package/dist/analysis.d.cts +20 -0
- package/dist/analysis.d.ts +20 -0
- package/dist/assembly.d.cts +28 -1
- package/dist/assembly.d.ts +28 -1
- package/dist/ast.d.cts +9 -0
- package/dist/ast.d.ts +9 -0
- package/dist/cli.js +10333 -4650
- package/dist/diff.d.cts +18 -0
- package/dist/diff.d.ts +18 -0
- package/dist/evaluator.d.cts +34 -0
- package/dist/evaluator.d.ts +34 -0
- package/dist/functions.d.cts +1 -0
- package/dist/functions.d.ts +1 -0
- package/dist/geometry.d.cts +22 -0
- package/dist/geometry.d.ts +22 -0
- package/dist/hardware.d.cts +13 -0
- package/dist/hardware.d.ts +13 -0
- package/dist/highlight.cjs +2 -2
- package/dist/highlight.js +2 -2
- package/dist/index.cjs +2278 -52
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +2278 -52
- package/dist/instructions.d.cts +3 -0
- package/dist/instructions.d.ts +3 -0
- package/dist/language.cjs +2235 -50
- package/dist/language.js +2235 -50
- package/dist/libraries.cjs +2211 -26
- package/dist/libraries.d.cts +3 -0
- package/dist/libraries.d.ts +3 -0
- package/dist/libraries.js +2211 -26
- package/dist/png.d.cts +9 -0
- package/dist/png.d.ts +9 -0
- package/dist/render.d.cts +22 -1
- package/dist/render.d.ts +22 -1
- package/dist/signatures.cjs +269 -11
- package/dist/signatures.js +269 -11
- package/dist/slots.d.cts +8 -0
- package/dist/slots.d.ts +8 -0
- package/dist/values.d.cts +6 -1
- package/dist/values.d.ts +6 -1
- package/dist/verify/command.d.cts +1 -0
- package/dist/verify/command.d.ts +1 -0
- package/dist/verify/geometry.d.cts +25 -0
- package/dist/verify/geometry.d.ts +25 -0
- package/dist/verify/index.d.cts +10 -0
- package/dist/verify/index.d.ts +10 -0
- package/dist/verify/joints.d.cts +7 -0
- package/dist/verify/joints.d.ts +7 -0
- package/dist/verify/mechanics.d.cts +11 -0
- package/dist/verify/mechanics.d.ts +11 -0
- package/dist/verify/motion.d.cts +8 -0
- package/dist/verify/motion.d.ts +8 -0
- package/dist/verify/pose.d.cts +5 -0
- package/dist/verify/pose.d.ts +5 -0
- package/dist/verify/relations.d.cts +8 -0
- package/dist/verify/relations.d.ts +8 -0
- package/dist/verify/snapshot.d.cts +11 -0
- package/dist/verify/snapshot.d.ts +11 -0
- package/dist/verify/solids.d.cts +40 -0
- package/dist/verify/solids.d.ts +40 -0
- package/dist/verify/spec.d.cts +9 -0
- package/dist/verify/spec.d.ts +9 -0
- package/dist/verify/summary.d.cts +17 -0
- package/dist/verify/summary.d.ts +17 -0
- package/dist/verify/types.d.cts +301 -0
- package/dist/verify/types.d.ts +301 -0
- package/docs/cli.md +87 -15
- package/docs/javascript.md +57 -25
- package/docs/layers.md +42 -2
- package/docs/library.md +501 -3
- package/docs/parts-and-sheets.md +199 -1
- package/docs/shared-libraries.md +8 -1
- package/docs/specification.md +78 -23
- package/docs/verification.md +363 -0
- package/docs/versions.md +2 -2
- package/package.json +2 -1
- package/dist/import/dbg.d.cts +0 -1
- package/dist/import/dbg.d.ts +0 -1
package/docs/library.md
CHANGED
|
@@ -26,6 +26,15 @@ show each module's description when you hover over it.
|
|
|
26
26
|
| [`kerf/hanging`](#hanging) | Keyholes, holes and loops for hanging things on a wall |
|
|
27
27
|
| [`kerf/enclosure`](#enclosures) | Boxes with a screwed-on lid, cutouts for ports and vents |
|
|
28
28
|
| [`kerf/calibration`](#calibration) | Test pieces that measure the kerf and how your sheet fits |
|
|
29
|
+
| [`kerf/gears`](#gears-and-cams) | Gears, racks, cams, Geneva drives, ratchets and pawls |
|
|
30
|
+
| [`kerf/linkage`](#linkages) | Where linkage joints are at a crank angle |
|
|
31
|
+
| [`kerf/cones`](#cones) | Cones and cut-off cones cut flat, to roll up |
|
|
32
|
+
| [`kerf/lock`](#lock) | A lock with a key, three layers deep |
|
|
33
|
+
| [`kerf/rings`](#rings) | Round things of stacked rings on a crossed core |
|
|
34
|
+
| [`kerf/joints`](#joints) | Two profiles halved into each other: crosses, fonts, domes |
|
|
35
|
+
| [`kerf/sizes`](#sizes) | Paper, card and photo sizes |
|
|
36
|
+
| [`kerf/symbols`](#symbols) | 867 pictograms by name |
|
|
37
|
+
| [`kerf/geo`](#maps) | The world's land, for maps and globes |
|
|
29
38
|
|
|
30
39
|
Sizes are in millimetres. Joints use `$thickness`, the sheet thickness, so
|
|
31
40
|
set it to what you measure. Each section has an example in the gallery that
|
|
@@ -39,16 +48,26 @@ you can open in the playground.
|
|
|
39
48
|
|
|
40
49
|
Finger-jointed boxes. Example: [box.kerf](../examples/box.kerf).
|
|
41
50
|
|
|
42
|
-
### `box(size, lid = false, finger)`
|
|
51
|
+
### `box(size, lid = false, finger, name = "")`
|
|
43
52
|
|
|
44
53
|
The panels of a box as parts `bottom`, `front`, `back`, `left`, `right` and,
|
|
45
|
-
with a lid, `lid`, placed for the assembled view.
|
|
54
|
+
with a lid, `lid`, placed for the assembled view. Shapes given to `box()`
|
|
55
|
+
go on the front, drawn from its bottom left corner as seen from outside.
|
|
56
|
+
Wrap it in `place()` to set it anywhere:
|
|
57
|
+
|
|
58
|
+
```kerf
|
|
59
|
+
use <kerf/box>
|
|
60
|
+
|
|
61
|
+
place(at = [0, 0, 40]) box([120, 80, 60], name = "crate")
|
|
62
|
+
engrave() translate([60, 30]) text("TEA", size = 14, halign = "center");
|
|
63
|
+
```
|
|
46
64
|
|
|
47
65
|
| Parameter | Default | Meaning |
|
|
48
66
|
| --------- | ------------------------ | ------------------------------------------------------ |
|
|
49
67
|
| `size` | | Outside `[width, depth, height]`, lid included |
|
|
50
68
|
| `lid` | `false` | Add a lid, finger-jointed to the walls like the bottom |
|
|
51
69
|
| `finger` | `max(3 * $thickness, 6)` | Finger width |
|
|
70
|
+
| `name` | `""` | Goes before each panel's name, as `crate front` |
|
|
52
71
|
|
|
53
72
|
### `divider(size, finger)`
|
|
54
73
|
|
|
@@ -149,13 +168,56 @@ bent at the corners. The tabs of part `bottom` go through slots along the
|
|
|
149
168
|
strip. Part `lid` rests on top, and part `lid insert`, glued under it,
|
|
150
169
|
keeps it in place. `size` is the outside `[width, depth, height]`, lid
|
|
151
170
|
included, and `r` the outside corner radius, more than two thicknesses.
|
|
152
|
-
The
|
|
171
|
+
The assembled view shows the strip bent round the bottom.
|
|
153
172
|
|
|
154
173
|
### `flex_panel(size, r, sw, sd)`
|
|
155
174
|
|
|
156
175
|
The bottom of `flex_box()`: a rounded rectangle with tabs on its straight
|
|
157
176
|
edges, `sw` long on the front and back and `sd` on the sides.
|
|
158
177
|
|
|
178
|
+
### `narrow_hinge(size, spacing = 1.5, bridge = 1.5)`
|
|
179
|
+
|
|
180
|
+
A hinge for a narrow strap or band, as lines across `[w, h]`: cuts from
|
|
181
|
+
alternate edges, each stopping `bridge` short of the far edge, so the
|
|
182
|
+
strip zigzags and bends evenly however narrow it is. Use it where
|
|
183
|
+
`living_hinge()` would leave only a cut or two across.
|
|
184
|
+
|
|
185
|
+
### `flex_strip(path, width, name = "strip", tabs = true, straight = 10, r, spacing = 1.5, bridge = 3, narrow = false)`
|
|
186
|
+
|
|
187
|
+
A strip that follows a profile: `path` is a list of `[x, y]` points along
|
|
188
|
+
its middle in a side plate's plane, as `path_points()` or a list
|
|
189
|
+
comprehension gives them. The strip has a living hinge wherever the path
|
|
190
|
+
curves and tabs along both edges wherever it runs straight. It is one
|
|
191
|
+
part, placed in the plate's coordinates with its edge at z = 0 and its
|
|
192
|
+
width running down to `-width`, and bent in the assembled view.
|
|
193
|
+
|
|
194
|
+
```kerf
|
|
195
|
+
use <kerf/hinge>
|
|
196
|
+
|
|
197
|
+
W = 80;
|
|
198
|
+
path = [for (a = [180:5:360]) [40, 40] + 40 * [cos(a), sin(a)]];
|
|
199
|
+
module plate() offset(delta = 12) polygon(concat(path, [[80, 70], [0, 70]]));
|
|
200
|
+
part("end A", rotate = [90, 0, 0], slots = ["tray"]) plate();
|
|
201
|
+
part("end B", at = [0, W + $thickness, 0], rotate = [90, 0, 0], slots = ["tray"]) plate();
|
|
202
|
+
place(rotate = [90, 0, 0]) flex_strip(path, W, name = "tray");
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Wrap it in `place()` with the plate's placement, put the other plate
|
|
206
|
+
`width` away, and give both plates `slots`: they cut the slots for the
|
|
207
|
+
tabs where the strip passes through them. Segments of the path shorter
|
|
208
|
+
than `straight` are taken as curve; a sharp corner bends round radius
|
|
209
|
+
`r`, two thicknesses by default. `narrow` uses `narrow_hinge()`.
|
|
210
|
+
|
|
211
|
+
### `strip_bends(path, straight = 10, r)`
|
|
212
|
+
|
|
213
|
+
The bends `flex_strip()` makes, as `[s0, s1, angle]` along the path:
|
|
214
|
+
where each curve starts and ends and how far it turns, left positive.
|
|
215
|
+
Give them to `part(bend = ...)` for a strip of your own.
|
|
216
|
+
|
|
217
|
+
### `strip_merge(list)`
|
|
218
|
+
|
|
219
|
+
Joins bends from `strip_bends()` that touch into one.
|
|
220
|
+
|
|
159
221
|
## Dividers
|
|
160
222
|
|
|
161
223
|
`use <kerf/dividers>`
|
|
@@ -337,3 +399,439 @@ A pair of finger-jointed pieces for each kerf in `kerfs`, parts
|
|
|
337
399
|
`joint <kerf> out` and `joint <kerf> in`, each cut with that kerf
|
|
338
400
|
compensation. The pair that holds together without glue or forcing has
|
|
339
401
|
the kerf to set for this sheet.
|
|
402
|
+
|
|
403
|
+
## Gears and cams
|
|
404
|
+
|
|
405
|
+
`use <kerf/gears>`
|
|
406
|
+
|
|
407
|
+
Gears, racks, the lantern gears of old mills, and the cams and tappets
|
|
408
|
+
that make a model move. Gears go by their module `mod`: the pitch
|
|
409
|
+
diameter is `mod * teeth`, and two gears mesh when they have the same
|
|
410
|
+
module and their centres are `gear_distance()` apart.
|
|
411
|
+
|
|
412
|
+
```kerf
|
|
413
|
+
use <kerf/gears>
|
|
414
|
+
|
|
415
|
+
part("big") spur_gear(36, 2, bore = 6, spokes = 5);
|
|
416
|
+
part("small", at = [gear_distance(36, 12, 2), 0, 0], rotate = [0, 0, gear_phase(12)])
|
|
417
|
+
spur_gear(12, 2, bore = 6);
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### `spur_gear(teeth, mod = 2, bore = 5, pressure = 20, backlash = 0.1, spokes = 0, square = false)`
|
|
421
|
+
|
|
422
|
+
A gear with involute teeth centred on the origin, a tooth along +x, and a
|
|
423
|
+
hole for its axle: round, or `square` to turn with a square axle.
|
|
424
|
+
`spokes` from 3 to 6 cuts windows between spokes. `backlash` thins each
|
|
425
|
+
tooth so meshed gears don't bind.
|
|
426
|
+
|
|
427
|
+
### `gear_points(teeth, mod = 2, pressure = 20, backlash = 0.1, steps = 6)`
|
|
428
|
+
|
|
429
|
+
The gear's outline as a list of points, for gears of your own shape.
|
|
430
|
+
|
|
431
|
+
### `gear_window(r0, r1, span, w)`
|
|
432
|
+
|
|
433
|
+
One rounded window between two spokes, from radius `r0` to `r1`.
|
|
434
|
+
|
|
435
|
+
### `gear_radius(teeth, mod = 2)`, `gear_distance(teeth_a, teeth_b, mod = 2)`
|
|
436
|
+
|
|
437
|
+
The pitch radius, and the distance between the centres of two gears in
|
|
438
|
+
mesh.
|
|
439
|
+
|
|
440
|
+
### `gear_turn(driver, driven, angle)`
|
|
441
|
+
|
|
442
|
+
How far a gear with `driven` teeth turns when one with `driver` teeth in
|
|
443
|
+
mesh with it turns `angle` degrees: the other way round.
|
|
444
|
+
|
|
445
|
+
### `gear_phase(teeth)`
|
|
446
|
+
|
|
447
|
+
The turn that lines a gear's teeth up with the gear beside it along x.
|
|
448
|
+
|
|
449
|
+
### `train_for(ratio, stages = 2, pinion = [10, 20], wheel = [20, 80])`
|
|
450
|
+
|
|
451
|
+
Tooth counts for a train of `stages` gear pairs (1 to 3) whose ratio, the
|
|
452
|
+
turns in for one turn out, comes nearest `ratio`. Each pair has a pinion
|
|
453
|
+
of `pinion` teeth and a wheel of `wheel` teeth on the next axle. It
|
|
454
|
+
returns `{stages = [[driver, driven], ...], ratio, error}`, `error` being
|
|
455
|
+
how far off it is, as a fraction; of equally near trains it picks the one
|
|
456
|
+
with fewest teeth. A ratio under 1 speeds up, so the wheels drive. It is
|
|
457
|
+
built in, so it works without `use <kerf/gears>`.
|
|
458
|
+
|
|
459
|
+
```kerf
|
|
460
|
+
use <kerf/gears>
|
|
461
|
+
|
|
462
|
+
// A year for the Earth in an orrery: [[10, 73], [10, 76], [12, 79]], 0.002% off
|
|
463
|
+
t = train_for(365.25, 3);
|
|
464
|
+
s = t.stages[0];
|
|
465
|
+
part("pinion") spur_gear(s[0], 1.5);
|
|
466
|
+
part("wheel", at = [gear_distance(s[0], s[1], 1.5), 0, 0], rotate = [0, 0, gear_phase(s[1])])
|
|
467
|
+
spur_gear(s[1], 1.5);
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### `rack(teeth, mod = 2, height, pressure = 20, backlash = 0.1)`
|
|
471
|
+
|
|
472
|
+
A straight rack along +x, its pitch line at y = 0. A `spur_gear()` of the
|
|
473
|
+
same module meshes with it from `gear_radius()` above.
|
|
474
|
+
|
|
475
|
+
### `lantern_disc(staves, r, d = 6, bore = 6, rim)`, `peg_wheel(pegs, r, d = 6, bore = 6, rim)`
|
|
476
|
+
|
|
477
|
+
A lantern gear is two discs with dowel staves between them; `lantern_disc()`
|
|
478
|
+
is one disc, with holes for `staves` staves of diameter `d` on radius `r`.
|
|
479
|
+
A `peg_wheel()` has dowel pegs standing out of its face, which drive the
|
|
480
|
+
staves of a lantern gear at right angles. Match the pitch of the pegs and
|
|
481
|
+
the staves.
|
|
482
|
+
|
|
483
|
+
### `peg_radius(n, pitch)`
|
|
484
|
+
|
|
485
|
+
The radius for `n` pegs or staves `pitch` apart.
|
|
486
|
+
|
|
487
|
+
### `eccentric(r, offset, bore = 6, square = false)`, `snail_cam(r0, r1, bore = 6, steps = 72, square = false)`, `tappets(n, r, w = 10, hub = 14, bore = 6, square = false)`
|
|
488
|
+
|
|
489
|
+
Cams: an `eccentric()` pushes a follower up and down by twice `offset`; a
|
|
490
|
+
`snail_cam()` lifts it slowly from `r0` to `r1` over a turn and drops it at
|
|
491
|
+
once, as a trip hammer works; `tappets()` lift a lever `n` times a turn.
|
|
492
|
+
|
|
493
|
+
### `cam(lift, base_r, follower = "knife", roller_d = 0, bore = 6, steps = 180, square = false)`
|
|
494
|
+
|
|
495
|
+
A cam whose profile comes from a lift curve: `lift` is a function of the
|
|
496
|
+
angle (0 to 360) giving how far the follower rises above the base circle
|
|
497
|
+
of radius `base_r`. The follower rides on the cam's top (+y) and moves
|
|
498
|
+
straight up and down; turned anticlockwise by `a` degrees (`rotate = [0,
|
|
499
|
+
0, a]`) the cam lifts it `lift(a)`. A `"knife"` follower rides the curve
|
|
500
|
+
itself; a `"roller"` of diameter `roller_d` rolls on a profile inside it.
|
|
501
|
+
|
|
502
|
+
```kerf
|
|
503
|
+
use <kerf/gears>
|
|
504
|
+
|
|
505
|
+
$fn = 48;
|
|
506
|
+
turn = 0; // the cam's angle
|
|
507
|
+
// A bird that pecks twice, then rests
|
|
508
|
+
peck = function(a) cam_rise(a, 0, 40, 8) - cam_rise(a, 40, 80, 8) + cam_rise(a, 100, 140, 8) - cam_rise(a, 140, 180, 8);
|
|
509
|
+
part("cam", rotate = [0, 0, turn]) cam(peck, 25, "roller", 10);
|
|
510
|
+
part("roller", at = [0, cam_follower(peck, 25, turn, 10), 0]) difference() { circle(d = 10); circle(d = 3); }
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### `cam_rise(a, a0, a1, height)`
|
|
514
|
+
|
|
515
|
+
A smooth (cycloidal) rise of `height` between angles `a0` and `a1`: 0
|
|
516
|
+
before, `height` after. Add and take away rises to make dwells, rises and
|
|
517
|
+
falls.
|
|
518
|
+
|
|
519
|
+
### `cam_follower(lift, base_r, angle, roller_d = 0)`, `cam_pressure(lift, base_r, roller_d = 0)`
|
|
520
|
+
|
|
521
|
+
How high the follower's tip, or its roller's centre, stands above the
|
|
522
|
+
cam's axle at `angle`, to place it from the same curve. `cam_pressure()` is
|
|
523
|
+
the steepest pressure angle over a turn: keep it under about 30 degrees,
|
|
524
|
+
with a bigger base circle or a longer rise, or the follower jams.
|
|
525
|
+
|
|
526
|
+
### `cam_pitch(lift, base_r, roller_d = 0, steps = 180)`
|
|
527
|
+
|
|
528
|
+
The curve the follower's tip or roller centre follows, in the cam's turn.
|
|
529
|
+
|
|
530
|
+
### `geneva_wheel(slots, distance, pin_d = 6, bore = 6, clearance = 0.2)`, `geneva_lock(...)`, `geneva_crank(...)`
|
|
531
|
+
|
|
532
|
+
A Geneva drive: a driver turning all the time steps a wheel on one slot
|
|
533
|
+
each turn and locks it in between, for counters, calendars and carousels
|
|
534
|
+
that stop to show each scene. The driver's axle is at the origin and the
|
|
535
|
+
wheel's `distance` along +x. The wheel and the locking disc lie side by
|
|
536
|
+
side in one plane; the crank above the disc carries a dowel pin of `pin_d`
|
|
537
|
+
that runs in the slots. With many slots the wheel comes close to the
|
|
538
|
+
driver's axle, and `geneva_lock()` says how small the bore must be.
|
|
539
|
+
|
|
540
|
+
```kerf
|
|
541
|
+
use <kerf/gears>
|
|
542
|
+
|
|
543
|
+
$fn = 48;
|
|
544
|
+
a = 0; // the driver's turn
|
|
545
|
+
part("wheel", at = [60, 0, 0], rotate = [0, 0, geneva_turn(6, 60, a)]) geneva_wheel(6, 60, 6);
|
|
546
|
+
part("lock", at = [0, 0, 0], rotate = [0, 0, a]) geneva_lock(6, 60, 6);
|
|
547
|
+
part("crank", at = [0, 0, $thickness], rotate = [0, 0, a]) geneva_crank(6, 60, 6);
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### `geneva_turn(slots, distance, angle)`
|
|
551
|
+
|
|
552
|
+
How far the wheel has turned (clockwise) when the driver has turned
|
|
553
|
+
`angle` anticlockwise from its pin pointing at the wheel: `-360 / slots`
|
|
554
|
+
for each whole turn. With `geneva_pin_radius()`, `geneva_wheel_radius()`
|
|
555
|
+
and `geneva_lock_radius()` for the sizes.
|
|
556
|
+
|
|
557
|
+
### `ratchet(teeth, r, depth, bore = 6, square = false)`, `pawl(teeth, r, depth, length, width = 8, bore = 3, at = 90, clearance = 0.2)`
|
|
558
|
+
|
|
559
|
+
A ratchet wheel that turns anticlockwise freely, and a pawl that stops it
|
|
560
|
+
turning back: for a crank that winds one way, a counter or a typewriter
|
|
561
|
+
carriage. The pawl is drawn where it works round the wheel's centre, its
|
|
562
|
+
tip on the tooth face nearest `at` degrees, so give it the wheel's
|
|
563
|
+
placement. It turns on a pin at `pawl_pivot()`, and gravity, a rubber band
|
|
564
|
+
or a spring wire keeps it down on the teeth.
|
|
565
|
+
|
|
566
|
+
```kerf
|
|
567
|
+
use <kerf/gears>
|
|
568
|
+
|
|
569
|
+
$fn = 32;
|
|
570
|
+
part("wheel", at = [0, 0, 0]) ratchet(12, 30, 5);
|
|
571
|
+
part("pawl", at = [0, 0, 0]) pawl(12, 30, 5);
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### `pawl_pivot(teeth, r, depth, length, width = 8, at = 90, clearance = 0.2)`, `pawl_points(...)`, `pawl_min_length(teeth, r, depth, width = 8)`, `pawl_face(teeth, at = 90)`, `pawl_lean(teeth, r, depth)`
|
|
575
|
+
|
|
576
|
+
Where the pawl's pivot pin goes round the wheel's centre, its outline, the
|
|
577
|
+
shortest it can be at a given width, the angle of the tooth face it rests
|
|
578
|
+
on, and how far it leans out from the wheel's edge to clear the teeth as
|
|
579
|
+
they pass. Left at 0, `length` is 0.8 × `r`, or the shortest that clears
|
|
580
|
+
the teeth on a small wheel; a `length` given shorter than that is an
|
|
581
|
+
error.
|
|
582
|
+
|
|
583
|
+
## Linkages
|
|
584
|
+
|
|
585
|
+
`use <kerf/linkage>`
|
|
586
|
+
|
|
587
|
+
Where the joints of a linkage are at a crank angle, so moving parts are
|
|
588
|
+
placed from the same numbers as the links' lengths: steam engine pistons,
|
|
589
|
+
typebars, walking legs, waving arms. Each takes the linkage drawn flat.
|
|
590
|
+
|
|
591
|
+
```kerf
|
|
592
|
+
use <kerf/linkage>
|
|
593
|
+
|
|
594
|
+
$fn = 32;
|
|
595
|
+
angle = 60; // the crank's turn
|
|
596
|
+
j = four_bar(80, 20, 70, 50, angle);
|
|
597
|
+
part("crank", at = [0, 0, 3], rotate = [0, 0, angle]) hull() { circle(d = 10); translate([20, 0]) circle(d = 10); }
|
|
598
|
+
part("rocker", at = [80, 0, 3], rotate = [0, 0, link_angle([80, 0], j[1])])
|
|
599
|
+
hull() { circle(d = 10); translate([50, 0]) circle(d = 10); }
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### `circle_meet(a, ra, b, rb, side = 1)`
|
|
603
|
+
|
|
604
|
+
Where a circle of radius `ra` round `a` meets one of radius `rb` round `b`:
|
|
605
|
+
the point left of the line from `a` to `b`, or right of it with `side =
|
|
606
|
+
-1`. `undef` when they don't meet. Two links of those lengths from those
|
|
607
|
+
pivots join there.
|
|
608
|
+
|
|
609
|
+
### `slider_crank(r, l, angle, offset = 0)`, `slider_stroke(r, l, offset = 0)`
|
|
610
|
+
|
|
611
|
+
A crank of radius `r` round the origin drives a slider along `y = offset`
|
|
612
|
+
through a rod `l` long: `[crank pin, slider pin]` at the crank's `angle`,
|
|
613
|
+
or `undef` where the rod can't reach. `slider_stroke()` is how far the
|
|
614
|
+
slider travels.
|
|
615
|
+
|
|
616
|
+
### `four_bar(ground, crank, coupler, rocker, angle, side = 1)`, `four_bar_turns(ground, crank, coupler, rocker)`
|
|
617
|
+
|
|
618
|
+
A four-bar linkage with the crank's pivot at the origin and the rocker's at
|
|
619
|
+
`[ground, 0]`: `[crank end, rocker end]` at the crank's `angle`, or
|
|
620
|
+
`undef` where the links can't close. `four_bar_turns()` is true when the
|
|
621
|
+
crank turns all the way round (Grashof's rule).
|
|
622
|
+
|
|
623
|
+
### `link_angle(a, b)`
|
|
624
|
+
|
|
625
|
+
The angle of the line from `a` to `b`, to turn a link along it.
|
|
626
|
+
|
|
627
|
+
## Cones
|
|
628
|
+
|
|
629
|
+
`use <kerf/cones>`
|
|
630
|
+
|
|
631
|
+
Cones and cut-off cones cut flat from paper, card, veneer or thin plastic,
|
|
632
|
+
to roll up: gramophone horns, lampshades, funnels.
|
|
633
|
+
|
|
634
|
+
```kerf
|
|
635
|
+
use <kerf/cones>
|
|
636
|
+
|
|
637
|
+
$fn = 64;
|
|
638
|
+
part("shade") cone_flat(60, 25, 70, tab = 8);
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### `cone_flat(r1, r2, h, tab = 0, steps = 0)`
|
|
642
|
+
|
|
643
|
+
The flat pattern of a cone of radius `r1` at one end, `r2` at the other,
|
|
644
|
+
`h` high: a ring sector with its apex at the origin, opening anticlockwise
|
|
645
|
+
from +x. `tab` adds a glue tab along the far edge with its fold scored.
|
|
646
|
+
Equal radii make a cylinder: a rectangle `2 * PI * r1` wide.
|
|
647
|
+
|
|
648
|
+
### `cone_pattern(r1, r2, h)`
|
|
649
|
+
|
|
650
|
+
The sector's `[outer radius, inner radius, angle, slant length]`.
|
|
651
|
+
|
|
652
|
+
## Lock
|
|
653
|
+
|
|
654
|
+
`use <kerf/lock>`
|
|
655
|
+
|
|
656
|
+
A lock with a key, for boxes, diaries and money boxes. A flat key turns an
|
|
657
|
+
eccentric cam that slides a bolt; half a turn throws its nose out past the
|
|
658
|
+
lock's top edge into a notch in whatever it locks. It is three layers of
|
|
659
|
+
the current material: a base, a frame with the cam and the bolt, and a
|
|
660
|
+
plate with the keyhole.
|
|
661
|
+
|
|
662
|
+
### `cam_lock(throw = 7, locked = true, name = "Lock", key = true, ring = true)`
|
|
663
|
+
|
|
664
|
+
The lock's parts, lying flat with the key's axis on the z axis and the
|
|
665
|
+
bolt moving along +y. Wrap it in `place()` to set it on a box front or a
|
|
666
|
+
cover. `throw` is how far the bolt moves; `locked` shows it thrown;
|
|
667
|
+
`ring` engraves a ring round the keyhole.
|
|
668
|
+
|
|
669
|
+
### `lock_bounds(throw = 7)`, `lock_nose(throw = 7)`
|
|
670
|
+
|
|
671
|
+
The lock's outline as `[x0, y0, x1, y1]` round the key's axis, and the
|
|
672
|
+
bolt's nose as `[width, y of its tip when locked]`: cut a notch a little
|
|
673
|
+
wider than the nose where it goes.
|
|
674
|
+
|
|
675
|
+
### `lock_key(t = $thickness, ws = 5)`, `lock_dims(throw)`
|
|
676
|
+
|
|
677
|
+
The key, drawn standing on y = 0, and the lock's inner sizes.
|
|
678
|
+
|
|
679
|
+
## Rings
|
|
680
|
+
|
|
681
|
+
`use <kerf/rings>`
|
|
682
|
+
|
|
683
|
+
Round things built from stacked rings threaded on a core of two crossed
|
|
684
|
+
plates: drums, barrels, vases, towers and turned legs.
|
|
685
|
+
|
|
686
|
+
```kerf
|
|
687
|
+
use <kerf/rings>
|
|
688
|
+
|
|
689
|
+
ring_stack([for (k = [0:11]) 60 + 20 * sin(k * 15)], 30, name = "vase");
|
|
690
|
+
part("base", at = [0, 0, -$thickness], slots = ["vase core A", "vase core B"]) circle(d = 90);
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
### `ring_stack(diameters, hole, name = "ring", count, feet = true, clearance = 0.1)`
|
|
694
|
+
|
|
695
|
+
Rings with outsides `diameters`, bottom up, on z = 0 and the z axis, all
|
|
696
|
+
with a round `hole`; or `count` alike rings of one diameter. The core
|
|
697
|
+
plates, `name core A` and `name core B`, are half-lapped, with two tabs
|
|
698
|
+
each below z = 0 for a base: give the base `slots` naming them. The plates
|
|
699
|
+
keep `$min_width` beside their halving slot and the feet keep it between
|
|
700
|
+
their slots in the base, so a hole too small for either stops with the
|
|
701
|
+
smallest hole that works (about 7 mm, and 12 mm with feet, in 3 mm ply).
|
|
702
|
+
|
|
703
|
+
### `ring_core_width(hole, clearance = 0.1)`
|
|
704
|
+
|
|
705
|
+
The width of a core plate whose corners just clear a round hole.
|
|
706
|
+
|
|
707
|
+
## Joints
|
|
708
|
+
|
|
709
|
+
`use <kerf/joints>`
|
|
710
|
+
|
|
711
|
+
Two profiles halved into each other at right angles, standing on a floor:
|
|
712
|
+
a cross on its foot, a font, a dome, a tree.
|
|
713
|
+
|
|
714
|
+
```kerf
|
|
715
|
+
use <kerf/joints>
|
|
716
|
+
|
|
717
|
+
module tree() polygon([[-14, 0], [14, 0], [14, 4], [4, 4], [4, 8], [20, 8], [0, 50], [-20, 8], [-4, 8], [-4, 4], [-14, 4]]);
|
|
718
|
+
part("floor", at = [-30, -30, -$thickness], slots = ["tree front", "tree side"]) square(60);
|
|
719
|
+
halved_pair("tree", cap = 30, feet = [[-10, 4], [10, 4]]) { tree(); engrave() translate([0, 20]) circle(d = 4); }
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
### `halved_pair(name, at = [0, 0, 0], cap, feet = [], side_feet, clearance = 0.1)`
|
|
723
|
+
|
|
724
|
+
The first child is the profile, drawn with x across and y up, centred on
|
|
725
|
+
x = 0 with the floor at y = 0. The front, `name front`, is the whole
|
|
726
|
+
profile along x, slotted from below; the side, `name side`, is the profile
|
|
727
|
+
along y capped at height `cap` (all of it without), slotted from above, the
|
|
728
|
+
slots meeting halfway up the side. A second child is drawn on both faces,
|
|
729
|
+
clipped to each part: their engraving or print. `feet` are tabs below the
|
|
730
|
+
floor on the front, x positions (3 mm wide) or `[x, width]` pairs, and
|
|
731
|
+
`side_feet` the side's (the same unless given); give the floor `slots`
|
|
732
|
+
naming both parts. The strips beside both slots must keep `$min_width`,
|
|
733
|
+
and a foot may not run into the front's slot: either stops with where.
|
|
734
|
+
|
|
735
|
+
## Sizes
|
|
736
|
+
|
|
737
|
+
`use <kerf/sizes>`
|
|
738
|
+
|
|
739
|
+
Paper, card and photo sizes in millimetres, for holders, folders, frames
|
|
740
|
+
and boxes made to fit them.
|
|
741
|
+
|
|
742
|
+
### `paper_size(name)`, `card_size(name)`, `photo_size(name)`
|
|
743
|
+
|
|
744
|
+
`[width, height]` by name, ignoring case: paper from `"A0"` to `"A8"`,
|
|
745
|
+
`"B4"` to `"B6"`, `"C4"` to `"C6"`, `"DL"`, `"letter"`, `"legal"`,
|
|
746
|
+
`"tabloid"`, `"half letter"`, `"executive"`, `"pocket"` and `"traveler"`,
|
|
747
|
+
standing; cards `"business"`, `"us business"`, `"credit"`, `"japan"`,
|
|
748
|
+
`"playing"`, `"bridge"`, `"tarot"`, `"postcard"` and `"us postcard"`, and
|
|
749
|
+
photos `"4x6"`, `"5x7"`, `"8x10"`, `"10x15"`, `"13x18"` and the instant
|
|
750
|
+
film sizes `"instant mini"`, `"instant square"`, `"instant wide"` and
|
|
751
|
+
`"instant classic"`, lying down. An unknown name stops with the list of
|
|
752
|
+
known ones.
|
|
753
|
+
|
|
754
|
+
### `part_size(name)`
|
|
755
|
+
|
|
756
|
+
A bought part's sizes as a record: `body = [width, depth, height]`, and
|
|
757
|
+
for a part with a shaft its diameter `shaft`, the `shaft_length` it stands
|
|
758
|
+
out of the body and the `hole` to cut for it. `"music-18"` is an 18-note
|
|
759
|
+
wind-up music box movement (its shaft is the winding key's), and
|
|
760
|
+
`"quartz-clock"` a 56 mm quartz clock movement with the 16.5 mm shaft, for
|
|
761
|
+
dials up to `dial = 8` mm thick. `"marble-16"` and `"marble-25"` are
|
|
762
|
+
marbles. These are common retail sizes, which vary: measure yours.
|
|
763
|
+
|
|
764
|
+
```kerf
|
|
765
|
+
use <kerf/sizes>
|
|
766
|
+
|
|
767
|
+
m = part_size("quartz-clock");
|
|
768
|
+
part("dial") difference() { circle(d = 160); circle(d = m.hole); }
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### `landscape(size)`, `portrait(size)`
|
|
772
|
+
|
|
773
|
+
A size turned to lie wider than tall, or to stand taller than wide.
|
|
774
|
+
|
|
775
|
+
### `lookup_size(name, table)`, `size_names(table)`, `lookup_alias(name, aliases)`
|
|
776
|
+
|
|
777
|
+
The size of a name in a table of `[name, size]`, the names in it, and the
|
|
778
|
+
name an older name stands for in a table of `[old, new]`.
|
|
779
|
+
|
|
780
|
+
## Symbols
|
|
781
|
+
|
|
782
|
+
`use <kerf/symbols>`
|
|
783
|
+
|
|
784
|
+
867 pictograms by name, from open icon sets: animals, food, nature,
|
|
785
|
+
sports, travel, holidays, music, flowers and more. Each comes from a set
|
|
786
|
+
under the Apache 2.0, MIT or CC0 licence, named by `symbol_source()`; the
|
|
787
|
+
[notices](../THIRD-PARTY-NOTICES.md) list them.
|
|
788
|
+
|
|
789
|
+
```kerf
|
|
790
|
+
use <kerf/symbols>
|
|
791
|
+
|
|
792
|
+
part("tag") {
|
|
793
|
+
circle(d = 40);
|
|
794
|
+
engrave() symbol("paw", 24);
|
|
795
|
+
}
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn")`
|
|
799
|
+
|
|
800
|
+
The symbol `size` mm across the longer side of what it draws, centred on
|
|
801
|
+
the origin, or with its bottom left corner there. With `box = "grid"`,
|
|
802
|
+
`size` and the centre are those of the icon set's own grid (24 x 24 for
|
|
803
|
+
Material Design Icons), so icons from one set keep their sizes and places
|
|
804
|
+
relative to each other: paw prints in a trail, an icon swapped for another.
|
|
805
|
+
|
|
806
|
+
### `symbol_names(category)`, `symbol_size(name, size = 10, box = "drawn")`, `symbol_source(name)`, `symbol_entry(name)`
|
|
807
|
+
|
|
808
|
+
The names of every symbol, or of one category; the `[width, height]` a
|
|
809
|
+
symbol draws at a size; where it comes from as `[source, licence]`; and
|
|
810
|
+
its row of the table, `[name, category, drawn box, source, path, grid]`,
|
|
811
|
+
the boxes as `[x, y, w, h]`.
|
|
812
|
+
|
|
813
|
+
## Maps
|
|
814
|
+
|
|
815
|
+
`use <kerf/geo>`
|
|
816
|
+
|
|
817
|
+
The world's land from Natural Earth (public domain), for maps, globes and
|
|
818
|
+
country-shaped signs.
|
|
819
|
+
|
|
820
|
+
### `world_map(width = 200, projection = "equirectangular", south = -60)`
|
|
821
|
+
|
|
822
|
+
The land as shapes, a map `width` mm wide centred on the origin, as
|
|
823
|
+
`"equirectangular"` (twice as wide as tall) or `"mercator"`. Land south of
|
|
824
|
+
`south` is left out.
|
|
825
|
+
|
|
826
|
+
### `is_land(lat, lon)`
|
|
827
|
+
|
|
828
|
+
Whether a point is on land, to the nearest degree: quick enough to call
|
|
829
|
+
for every point of a globe.
|
|
830
|
+
|
|
831
|
+
### `geo_point(lat, lon, width = 200, projection = "equirectangular")`
|
|
832
|
+
|
|
833
|
+
Where a place goes on the map, to mark a city or a journey.
|
|
834
|
+
|
|
835
|
+
### `land_polygons()`
|
|
836
|
+
|
|
837
|
+
The land as polygons: each a list of rings of `[longitude, latitude]`.
|