1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-26 07:55:16 +02:00

c-style for and each

This commit is contained in:
Justin Lin
2019-06-14 08:50:35 +08:00
parent 78bfb2f31d
commit 0510b18516

View File

@@ -12,18 +12,19 @@ function __outer_points_shape_starburst(r1, r2, n) =
let( let(
a = 360 / n a = 360 / n
) )
[for(i = [0:n-1]) [r1 * cos(a * i), r1 * sin(a * i)]]; [for(i = 0; i < n; i = i + 1) [r1 * cos(a * i), r1 * sin(a * i)]];
function __inner_points_shape_starburst(r1, r2, n) = function __inner_points_shape_starburst(r1, r2, n) =
let ( let (
a = 360 / n, a = 360 / n,
half_a = a / 2 half_a = a / 2
) )
[for(i = [0:n-1]) [r2 * cos(a * i + half_a), r2 * sin(a * i + half_a)]]; [for(i = 0; i < n; i = i + 1) [r2 * cos(a * i + half_a), r2 * sin(a * i + half_a)]];
function __one_by_one_shape_starburst(outer_points, inner_points, i = 0) = function shape_starburst(r1, r2, n) =
len(outer_points) == i ? [] : let(
concat([outer_points[i], inner_points[i]], __one_by_one_shape_starburst(outer_points, inner_points, i + 1)); outer_points = __outer_points_shape_starburst(r1, r2, n),
inner_points = __inner_points_shape_starburst(r1, r2, n),
function shape_starburst(r1, r2, n) = __one_by_one_shape_starburst( leng = len(outer_points)
__outer_points_shape_starburst(r1, r2, n), __inner_points_shape_starburst(r1, r2, n) )
); [for(i = 0; i < leng; i = i + 1) each [outer_points[i], inner_points[i]]];