1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 17:24:20 +02:00
This commit is contained in:
Justin Lin
2022-05-07 17:50:44 +08:00
parent 8bcdb263d3
commit 0fae2d5dce

View File

@@ -11,24 +11,18 @@ function _remove_same_pts(pts1, pts2) =
function _golden_spiral_from_ls_or_eql_to(from, to, point_distance, rt_dir) =
let(
f1 = __fast_fibonacci(from),
f2 = __fast_fibonacci(from + 1),
fn = floor(f1 * PI * 2 / point_distance),
$fn = fn + 4 - (fn % 4),
circle_pts = shape_circle(radius = f1, n = $fn / 4 + 1),
len_pts = len(circle_pts),
a_step = 360 / $fn * rt_dir,
range_i = [0:len_pts - 1],
arc_points_angles = (
rt_dir == 1 ?
[for(i = range_i) [circle_pts[i], a_step * i]] :
[for(i = range_i) let(idx = len_pts - i - 1) [circle_pts[idx], a_step * i]]
),
d_f2f1 = f2 - f1,
off_p = rt_dir == 1 ? [0, -d_f2f1, 0] : [-d_f2f1, 0, 0],
d_f1f2 = f1 - __fast_fibonacci(from + 1),
off_p = rt_dir == 1 ? [0, d_f1f2, 0] : [d_f1f2, 0, 0],
za = 90 * rt_dir,
ra = [0, 0, za]
ra = [0, 0, za],
len_pts_1 = len(circle_pts) - 1,
as = [each [0:len_pts_1]] * (360 / $fn * rt_dir),
range = rt_dir == 1 ? [0:len_pts_1] : [len_pts_1:-1:-1]
) _remove_same_pts(
arc_points_angles,
[for(i = range) [circle_pts[i], as[i]]],
[
for(pt_a = _golden_spiral(from + 1, to, point_distance, rt_dir))
[
@@ -39,8 +33,7 @@ function _golden_spiral_from_ls_or_eql_to(from, to, point_distance, rt_dir) =
);
function _golden_spiral(from, to, point_distance, rt_dir) =
from <= to ?
_golden_spiral_from_ls_or_eql_to(from, to, point_distance, rt_dir) : [];
from > to ? [] : _golden_spiral_from_ls_or_eql_to(from, to, point_distance, rt_dir);
function _golden_spiral_impl(from, to, point_distance, rt_dir) =
_golden_spiral(from, to, point_distance, (rt_dir == "CT_CLK" ? 1 : -1));