2017-04-25 18:07:25 +08:00
|
|
|
# golden_spiral
|
|
|
|
|
2017-04-25 20:22:55 +08:00
|
|
|
Gets all points and angles on the path of a golden spiral based on Fibonacci numbers. The distance between two points is almost constant.
|
2017-04-25 18:07:25 +08:00
|
|
|
|
|
|
|
It returns a vector of `[[x, y], angle]`.
|
|
|
|
|
2017-04-25 20:20:05 +08:00
|
|
|
Because of depending on `circle_path` and `rotate_p`, remember to include "circle_path.scad" and "rotate_p.scad".
|
|
|
|
|
2017-04-25 18:07:25 +08:00
|
|
|
## Parameters
|
|
|
|
|
2017-04-25 18:18:23 +08:00
|
|
|
- `from` : The nth Fibonacci number you wanna start from.
|
|
|
|
- `to` : The nth Fibonacci number you wanna go to.
|
2017-04-25 18:07:25 +08:00
|
|
|
- `point_distance` : Distance between two points on the path.
|
|
|
|
- `rt_dir` : `"CT_CLK"` for counterclockwise. `"CLK"` for clockwise. The default value is `"CT_CLK"`.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2017-04-25 20:20:05 +08:00
|
|
|
include <circle_path.scad>;
|
|
|
|
include <rotate_p.scad>;
|
|
|
|
include <golden_spiral.scad>;
|
|
|
|
|
|
|
|
pts_angles = golden_spiral(
|
|
|
|
from = 3,
|
|
|
|
to = 10,
|
|
|
|
point_distance = 1
|
|
|
|
);
|
2017-04-25 18:07:25 +08:00
|
|
|
|
2017-04-25 20:20:05 +08:00
|
|
|
for(pt_angle = pts_angles) {
|
|
|
|
translate(pt_angle[0])
|
|
|
|
sphere(0.5);
|
|
|
|
}
|
2017-04-25 18:07:25 +08:00
|
|
|
|
2017-04-25 20:20:05 +08:00
|
|
|

|
2017-04-25 18:07:25 +08:00
|
|
|
|
2017-04-25 20:20:05 +08:00
|
|
|
include <circle_path.scad>;
|
|
|
|
include <rotate_p.scad>;
|
|
|
|
include <golden_spiral.scad>;
|
|
|
|
|
|
|
|
pts_angles = golden_spiral(
|
|
|
|
from = 5,
|
|
|
|
to = 11,
|
|
|
|
point_distance = 4
|
|
|
|
);
|
|
|
|
|
|
|
|
for(pt_angle = pts_angles) {
|
|
|
|
translate(pt_angle[0])
|
|
|
|
rotate([90, 0, pt_angle[1]])
|
|
|
|
linear_extrude(1, center = true)
|
|
|
|
text("A", valign = "center", halign = "center");
|
2017-04-25 18:07:25 +08:00
|
|
|
}
|
|
|
|
|
2017-04-25 20:20:05 +08:00
|
|
|

|