1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-archimedean_spiral.md

71 lines
2.3 KiB
Markdown
Raw Normal View History

2017-03-27 15:32:36 +08:00
# archimedean_spiral
2017-03-30 17:45:54 +08:00
Gets all points and angles on the path of an archimedean spiral. The distance between two points is almost constant.
2017-03-27 15:32:36 +08:00
It returns a vector of `[[x, y], angle]`.
An `init_angle` less than 180 degrees is not recommended because the function uses an approximate approach. If you really want an `init_angle` less than 180 degrees, a larger `arm_distance` is required. To reduce the error value at the calculated distance between two points, you may try a smaller `point_distance`.
## Parameters
- `arm_distance` : If any ray from the origin intersects two successive turnings of the spiral, we'll have two points. The `arm_distance` is the distance between these two points.
- `init_angle` : In polar coordinates `(r, θ)` Archimedean spiral can be described by the equation `r = bθ ` where `θ` is measured in radians. For being consistent with OpenSCAD, the function here use degrees. The `init_angle` is which angle the first point want to start.
- `point_distance` : Distance between two points on the path.
- `num_of_points` : How many points do you want?
2017-03-30 12:21:00 +08:00
- `rt_dir` : `"CT_CLK"` for counterclockwise. `"CLK"` for clockwise. The default value is `"CT_CLK"`.
2017-03-27 15:32:36 +08:00
## Examples
2017-06-24 20:31:02 +08:00
2020-01-28 17:51:20 +08:00
use <polyline2d.scad>;
use <archimedean_spiral.scad>;
2017-03-27 15:32:36 +08:00
points_angles = archimedean_spiral(
arm_distance = 10,
init_angle = 180,
point_distance = 5,
num_of_points = 100
);
points = [for(pa = points_angles) pa[0]];
polyline2d(points, width = 1);
2021-02-24 21:09:54 +08:00
![archimedean_spiral](images/lib3x-archimedean_spiral-1.JPG)
2017-03-27 15:32:36 +08:00
2020-01-28 17:51:20 +08:00
use <archimedean_spiral.scad>;
2017-03-30 14:22:48 +08:00
2017-03-27 15:32:36 +08:00
points_angles = archimedean_spiral(
arm_distance = 10,
init_angle = 180,
point_distance = 5,
num_of_points = 100
);
for(pa = points_angles) {
translate(pa[0])
circle(2);
}
2021-02-24 21:09:54 +08:00
![archimedean_spiral](images/lib3x-archimedean_spiral-2.JPG)
2017-03-27 15:32:36 +08:00
2017-03-30 14:22:48 +08:00
include <archimedean_spiral.scad>;
2017-03-27 15:35:42 +08:00
t = "3.141592653589793238462643383279502884197169399375105820974944592307816406286";
2017-03-27 15:32:36 +08:00
points = archimedean_spiral(
arm_distance = 15,
init_angle = 450,
point_distance = 12,
num_of_points = len(t)
);
for(i = [0: len(points) - 1]) {
translate(points[i][0])
rotate(points[i][1] + 90)
text(t[i], valign = "center", halign = "center");
}
2021-02-24 21:09:54 +08:00
![archimedean_spiral](images/lib3x-archimedean_spiral-3.JPG)
2017-03-27 15:32:36 +08:00