diff --git a/README.md b/README.md index 8912a495..c932d511 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp ### Path - [curve](https://openhome.cc/eGossip/OpenSCAD/lib2x-curve.html) -- bauer_spiral +- [bauer_spiral](https://openhome.cc/eGossip/OpenSCAD/lib2x-bauer_spiral.html) - fibonacci_lattice ### Voxel diff --git a/docs/images/lib2x-bauer_spiral-1.JPG b/docs/images/lib2x-bauer_spiral-1.JPG new file mode 100644 index 00000000..5e6b13fd Binary files /dev/null and b/docs/images/lib2x-bauer_spiral-1.JPG differ diff --git a/docs/images/lib2x-bauer_spiral-2.JPG b/docs/images/lib2x-bauer_spiral-2.JPG new file mode 100644 index 00000000..ffb825f9 Binary files /dev/null and b/docs/images/lib2x-bauer_spiral-2.JPG differ diff --git a/docs/lib2x-bauer_spiral.md b/docs/lib2x-bauer_spiral.md new file mode 100644 index 00000000..d081b0f4 --- /dev/null +++ b/docs/lib2x-bauer_spiral.md @@ -0,0 +1,33 @@ +# bauer_spiral + +Creates visually even spacing of n points on the surface of the sphere. Successive points will all be approximately the same distance apart. + +(It's called "visually even spacing" because only the vertices of the 5 [Platonic solids](https://en.wikipedia.org/wiki/Platonic_solid) can be said to be truly evenly spaced around the surface of a sphere.) + +## Parameters + +- `n` : The number of points. +- `radius` : The sphere radius. Default to 1. +- `rt_dir` : `"CT_CLK"` for counterclockwise. `"CLK"` for clockwise. The default value is `"CT_CLK"`. + +## Examples + + use ; + use ; + + n = 200; + radius = 20; + pts = bauer_spiral(n, radius); + + for(p = pts) { + translate(p) + sphere(1, $fn = 24); + } + + hull_polyline3d(pts, 1); + +![bauer_spiral](images/lib2x-bauer_spiral-1.JPG) + +You can use it to create [Text sphere](https://cults3d.com/en/3d-model/art/bauer-text-sphere). + +![bauer_spiral](images/lib2x-bauer_spiral-2.JPG) \ No newline at end of file diff --git a/src/bauer_spiral.scad b/src/bauer_spiral.scad index 155ba6fd..0e62b59f 100644 --- a/src/bauer_spiral.scad +++ b/src/bauer_spiral.scad @@ -1,9 +1,19 @@ -function bauer_spiral(n, radius = 1, dir = "CT_CLK") = +/** +* bauer_spiral.scad +* +* @copyright Justin Lin, 2019 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-bauer_spiral.html +* +**/ + +function bauer_spiral(n, radius = 1, rt_dir = "CT_CLK") = let( L = sqrt(n * PI), toRadians = PI / 180, toDegrees = 180 / PI, - clk = dir == "CT_CLK" ? 1 : -1 + clk = rt_dir == "CT_CLK" ? 1 : -1 ) [ for(k = 1; k <= n; k = k + 1)