1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 04:51:26 +02:00

refactor: use radians, degrees

This commit is contained in:
Justin Lin
2022-04-16 16:42:23 +08:00
parent d69e08c506
commit 5ddc184e8b

View File

@@ -1,25 +1,26 @@
function _radian_step(b, theta, l) =
let(
r_square = (b * theta) ^ 2,
double_r_square = 2 * r_square
)
acos((double_r_square - l ^ 2) / double_r_square) / 180 * PI;
use <../util/radians.scad>;
use <../util/degrees.scad>;
function _find_radians(b, point_distance, radians, n, count = 1) =
let(pre_radians = radians[count - 1])
count == n ? radians : (
function _radian_step(b, theta, dist) =
let(r_square = (b * theta) ^ 2)
radians(acos(1 - dist ^ 2 / (2 * r_square)));
function _find_radians(b, point_distance, rads, n, count = 1) =
let(pre_rads = rads[count - 1])
count == n ? rads : (
_find_radians(
b,
point_distance,
[each radians, pre_radians + _radian_step(b, pre_radians, point_distance)],
[each rads, pre_rads + _radian_step(b, pre_rads, point_distance)],
n,
count + 1)
count + 1
)
);
function _archimedean_spiral_impl(arm_distance, init_angle, point_distance, num_of_points, rt_dir) =
let(b = arm_distance / (2 * PI), init_radian = init_angle * PI / 180, sgn = rt_dir == "CT_CLK" ? 1 : -1)
let(b = arm_distance / (2 * PI), init_radian = radians(init_angle), sgn = rt_dir == "CT_CLK" ? 1 : -1)
[
for(theta = _find_radians(b, point_distance, [init_radian], num_of_points))
let(r = b * theta, a = sgn * theta * 57.2958)
[r * [cos(a), sin(a)], a]
let(r = b * theta, a = degrees(sgn * theta))
[r * [cos(a), sin(a)], a]
];