diff --git a/README.md b/README.md index 3ced532a..58944b71 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp - [mz_square_walls](https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_square_walls.html) - [mz_hex_walls](https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_hex_walls.html) - [mz_square_initialize](https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_square_initialize.html) -- mz_hamiltonian +- [mz_hamiltonian](https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_hamiltonian.html) ---- diff --git a/docs/images/lib2x-mz_hamiltonian-1.JPG b/docs/images/lib2x-mz_hamiltonian-1.JPG new file mode 100644 index 00000000..40973a3b Binary files /dev/null and b/docs/images/lib2x-mz_hamiltonian-1.JPG differ diff --git a/docs/images/lib2x-mz_hamiltonian-2.JPG b/docs/images/lib2x-mz_hamiltonian-2.JPG new file mode 100644 index 00000000..90afbb4c Binary files /dev/null and b/docs/images/lib2x-mz_hamiltonian-2.JPG differ diff --git a/docs/lib2x-mz_hamiltonian.md b/docs/lib2x-mz_hamiltonian.md new file mode 100644 index 00000000..ddf526bb --- /dev/null +++ b/docs/lib2x-mz_hamiltonian.md @@ -0,0 +1,29 @@ +# mz_hamiltonian + +Creates a hamiltonian path from a maze. The path is the result of maze traversal using [Wall follower](https://en.wikipedia.org/wiki/Maze_solving_algorithm#Wall_follower). + +**Since:** 2.5 + +## Parameters + +- `rows` : The rows of a maze. +- `columns` : The columns of a maze. +- `start` : The start point to travel the maze. Default to `[0, 0]`. +- `seed` : The maze is traveling randomly. Use `seed` to initialize the pseudorandom number generator. + +## Examples + + use ; + use ; + + rows = 5; + columns = 10; + + path = mz_hamiltonian(rows, columns, [0, 0]); + hull_polyline2d(path, .5); + +![mz_hamiltonian](images/lib2x-mz_hamiltonian-1.JPG) + +The [senbon_torii](https://github.com/JustinSDK/dotSCAD/blob/master/examples/maze/senbon_torii.scad) is based on `mz_hamiltonian`. + +![mz_hamiltonian](images/lib2x-mz_hamiltonian-2.JPG) diff --git a/src/maze/mz_hamiltonian.scad b/src/maze/mz_hamiltonian.scad index 1ab7a247..4eb15d9e 100644 --- a/src/maze/mz_hamiltonian.scad +++ b/src/maze/mz_hamiltonian.scad @@ -1,3 +1,13 @@ +/** +* mz_hamiltonian.scad +* +* @copyright Justin Lin, 2020 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_hamiltonian.html +* +**/ + use <_impl/_mz_hamiltonian_impl.scad>; use ; use ;