diff --git a/src/_impl/_shape_starburst_impl.scad b/src/_impl/_shape_starburst_impl.scad new file mode 100644 index 00000000..b85b5edc --- /dev/null +++ b/src/_impl/_shape_starburst_impl.scad @@ -0,0 +1,20 @@ +function __outer_points_shape_starburst(r1, r2, n) = + let( + a = 360 / n + ) + [for(i = 0; i < n; i = i + 1) [r1 * cos(a * i), r1 * sin(a * i)]]; + +function __inner_points_shape_starburst(r1, r2, n) = + let ( + a = 360 / n, + half_a = a / 2 + ) + [for(i = 0; i < n; i = i + 1) [r2 * cos(a * i + half_a), r2 * sin(a * i + half_a)]]; + +function _shape_starburst_impl(r1, r2, n) = + let( + outer_points = __outer_points_shape_starburst(r1, r2, n), + inner_points = __inner_points_shape_starburst(r1, r2, n), + leng = len(outer_points) + ) + [for(i = 0; i < leng; i = i + 1) each [outer_points[i], inner_points[i]]]; \ No newline at end of file diff --git a/src/shape_starburst.scad b/src/shape_starburst.scad index ae3ee319..cf1f5e0c 100644 --- a/src/shape_starburst.scad +++ b/src/shape_starburst.scad @@ -8,23 +8,7 @@ * **/ -function __outer_points_shape_starburst(r1, r2, n) = - let( - a = 360 / n - ) - [for(i = 0; i < n; i = i + 1) [r1 * cos(a * i), r1 * sin(a * i)]]; +use <_impl/_shape_starburst_impl.scad>; -function __inner_points_shape_starburst(r1, r2, n) = - let ( - a = 360 / n, - half_a = a / 2 - ) - [for(i = 0; i < n; i = i + 1) [r2 * cos(a * i + half_a), r2 * sin(a * i + half_a)]]; - function shape_starburst(r1, r2, n) = - let( - outer_points = __outer_points_shape_starburst(r1, r2, n), - inner_points = __inner_points_shape_starburst(r1, r2, n), - leng = len(outer_points) - ) - [for(i = 0; i < leng; i = i + 1) each [outer_points[i], inner_points[i]]]; \ No newline at end of file + _shape_starburst_impl(r1, r2, n); \ No newline at end of file diff --git a/test/test_shape_starburst.scad b/test/test_shape_starburst.scad index 8c7646ed..810c3a35 100644 --- a/test/test_shape_starburst.scad +++ b/test/test_shape_starburst.scad @@ -1,5 +1,5 @@ -include ; -include ; +use ; +use ; module test_shape_starburst() { echo("==== test_shape_starburst ====");