diff --git a/docs/images/lib2x-footprints2-1.JPG b/docs/images/lib2x-footprints2-1.JPG new file mode 100644 index 00000000..5315ff4c Binary files /dev/null and b/docs/images/lib2x-footprints2-1.JPG differ diff --git a/docs/lib2x-footprints2.md b/docs/lib2x-footprints2.md index bea5d649..221cedd0 100644 --- a/docs/lib2x-footprints2.md +++ b/docs/lib2x-footprints2.md @@ -7,7 +7,7 @@ Drive a turtle with `["forward", length]` or `["turn", angle]`. This function is ## Parameters - `cmds` : A list of `["forward", length]`s and `["turn", angle]`s. -- `start` : Set the start point of the turtle. +- `start` : Set the start point of the turtle. Default to `[0, 0]`. ## Examples @@ -50,5 +50,5 @@ Drive a turtle with `["forward", length]` or `["turn", angle]`. This function is polyline2d(poly, width = 1); -![t3d](images/lib2x-footprints2-1.JPG) +![footprints2](images/lib2x-footprints2-1.JPG) diff --git a/docs/lib2x-footprints3.md b/docs/lib2x-footprints3.md new file mode 100644 index 00000000..24534a57 --- /dev/null +++ b/docs/lib2x-footprints3.md @@ -0,0 +1,55 @@ +# footprints3 + +A 3D verion of [footprint2](https://openhome.cc/eGossip/OpenSCAD/lib2x-footprints2.html). + +**Since:** 2.4 + +## Parameters + +- `cmds` : A list of `["forward", length]`s, `["turn", angle]`s, `["roll", angle]`s and `["pitch", angle]`s. +- `start` : Set the start point of the turtle. Default to `[0, 0, 0]`. + +## Examples + + use ; + use ; + + 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] + ] + ) + ); + + hull_polyline3d(poly, thickness = 1); + +![footprints3](images/lib2x-footprints2-1.JPG) + diff --git a/src/turtle/footprints3.scad b/src/turtle/footprints3.scad index 78ec1f8d..4ee10d2b 100644 --- a/src/turtle/footprints3.scad +++ b/src/turtle/footprints3.scad @@ -1,53 +1,16 @@ +/** +* footprints3.scad +* +* @copyright Justin Lin, 2020 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-footprints3.html +* +**/ + use <_impl/_footprints3.scad>; use ; -/* - cmds: "forward" ("xu_move"), "turn" ("zu_turn"), "roll" (negative "xu_turn"), "pitch" (negative "yu_turn"), - "xu_move", "yu_move", "zu_move", "xu_turn", "yu_turn", "turn" - -``` -use ; -use ; - -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]] - ); - -// cmds: "forward" ("xu_move"), "turn" ("zu_turn"), "roll" (negative "xu_turn"), "pitch" (negative "yu_turn") -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] - ] - ) -); - -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]]),