mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 17:24:20 +02:00
add doc
This commit is contained in:
@@ -237,7 +237,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp
|
|||||||
|
|
||||||
- [curve](https://openhome.cc/eGossip/OpenSCAD/lib2x-curve.html)
|
- [curve](https://openhome.cc/eGossip/OpenSCAD/lib2x-curve.html)
|
||||||
- [bauer_spiral](https://openhome.cc/eGossip/OpenSCAD/lib2x-bauer_spiral.html)
|
- [bauer_spiral](https://openhome.cc/eGossip/OpenSCAD/lib2x-bauer_spiral.html)
|
||||||
- fibonacci_lattice
|
- [fibonacci_lattice](https://openhome.cc/eGossip/OpenSCAD/lib2x-fibonacci_lattice.html)
|
||||||
|
|
||||||
### Voxel
|
### Voxel
|
||||||
|
|
||||||
|
BIN
docs/images/lib2x-fibonacci_lattice-1.JPG
Normal file
BIN
docs/images/lib2x-fibonacci_lattice-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
BIN
docs/images/lib2x-fibonacci_lattice-2.JPG
Normal file
BIN
docs/images/lib2x-fibonacci_lattice-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
53
docs/lib2x-fibonacci_lattice.md
Normal file
53
docs/lib2x-fibonacci_lattice.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# fibonacci_lattice
|
||||||
|
|
||||||
|
Creates visually even spacing of n points on the surface of the sphere. Nearest-neighbor points will all be approximately the same distance apart. There're 10 spirals on the sphere.
|
||||||
|
|
||||||
|
(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 <fibonacci_lattice.scad>;
|
||||||
|
|
||||||
|
n = 200;
|
||||||
|
radius = 20;
|
||||||
|
pts = fibonacci_lattice(n, radius);
|
||||||
|
|
||||||
|
for(p = pts) {
|
||||||
|
translate(p)
|
||||||
|
sphere(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphere(radius);
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
use <fibonacci_lattice.scad>;
|
||||||
|
use <hull_polyline3d.scad>;
|
||||||
|
|
||||||
|
n = 200;
|
||||||
|
radius = 20;
|
||||||
|
pts = fibonacci_lattice(n, radius);
|
||||||
|
|
||||||
|
for(p = pts) {
|
||||||
|
translate(p)
|
||||||
|
sphere(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphere(radius);
|
||||||
|
|
||||||
|
spirals = [for(j = [0:9])
|
||||||
|
[for(i = j; i < len(pts); i = i + 8) pts[i]]
|
||||||
|
];
|
||||||
|
|
||||||
|
for(spiral = spirals) {
|
||||||
|
hull_polyline3d(spiral, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|

|
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* fibonacci_lattice.scad
|
||||||
|
*
|
||||||
|
* @copyright Justin Lin, 2020
|
||||||
|
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||||
|
*
|
||||||
|
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-fibonacci_lattice.html
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
function fibonacci_lattice(n, radius = 1, dir = "CT_CLK") =
|
function fibonacci_lattice(n, radius = 1, dir = "CT_CLK") =
|
||||||
let(
|
let(
|
||||||
toDegrees = 180 / PI,
|
toDegrees = 180 / PI,
|
||||||
|
Reference in New Issue
Block a user