mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-02-11 19:04:32 +01:00
add footprints3.scad
This commit is contained in:
parent
72896c76a1
commit
6e6f64036b
9
src/turtle/_impl/_footprints3.scad
Normal file
9
src/turtle/_impl/_footprints3.scad
Normal file
@ -0,0 +1,9 @@
|
||||
use <../turtle3d.scad>;
|
||||
|
||||
function _footprints3(cmds, t, leng, i = 0) =
|
||||
i == leng ? [] :
|
||||
let(
|
||||
nxt = turtle3d(cmds[i][0], t, cmds[i][1]),
|
||||
pts = _footprints3(cmds, nxt, leng, i + 1)
|
||||
)
|
||||
cmds[i][0] != "forward" && cmds[i][0] != "yu_move" && cmds[i][0] != "zu_move" ? pts : concat([turtle3d("pt", nxt)], pts);
|
56
src/turtle/footprints3.scad
Normal file
56
src/turtle/footprints3.scad
Normal file
@ -0,0 +1,56 @@
|
||||
use <_impl/_footprints3.scad>;
|
||||
use <turtle3d.scad>;
|
||||
|
||||
/*
|
||||
cmds: "forward" ("xu_move"), "turn" ("zu_turn"), "roll" ("xu_turn"), "pitch" ("yu_turn"),
|
||||
"xu_move", "yu_move", "zu_move", "xu_turn", "yu_turn", "turn"
|
||||
|
||||
```
|
||||
use <hull_polyline3d.scad>;
|
||||
use <turtle/footprints3.scad>;
|
||||
|
||||
function xy_arc_cmds(radius, angle, steps) =
|
||||
let(
|
||||
fa = angle / steps,
|
||||
ta = fa / 2,
|
||||
leng = sin(ta) * radius * 2
|
||||
)
|
||||
concat(
|
||||
[["turn", ta]],
|
||||
[
|
||||
for(i = [0:steps - 2])
|
||||
each [["forward", leng], ["turn", fa]]
|
||||
],
|
||||
[["forward", leng], ["turn", ta]]
|
||||
);
|
||||
|
||||
poly = footprints3(
|
||||
concat(
|
||||
[
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10]
|
||||
],
|
||||
xy_arc_cmds(5, 180, 12),
|
||||
[
|
||||
["pitch", -90],
|
||||
["forward", 10],
|
||||
["roll", -90]
|
||||
],
|
||||
xy_arc_cmds(5, 180, 12),
|
||||
[
|
||||
["forward", 10],
|
||||
["roll", -90]
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
hull_polyline3d(poly, thickness = 1);
|
||||
```
|
||||
*/
|
||||
function footprints3(cmds, start = [0, 0, 0]) =
|
||||
let(
|
||||
t = turtle3d("create", start, [[1, 0, 0], [0, 1, 0], [0, 0, 1]]),
|
||||
leng = len(cmds)
|
||||
)
|
||||
concat([turtle3d("pt", t)], _footprints3(cmds, t, leng));
|
Loading…
x
Reference in New Issue
Block a user