1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-07-31 20:10:36 +02:00

refactor deps

This commit is contained in:
Justin Lin
2020-01-27 16:18:00 +08:00
parent 4779343a85
commit e6274d6202
3 changed files with 24 additions and 20 deletions

View File

@@ -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]]];

View File

@@ -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]]];
_shape_starburst_impl(r1, r2, n);

View File

@@ -1,5 +1,5 @@
include <unittest.scad>;
include <shape_starburst.scad>;
use <unittest.scad>;
use <shape_starburst.scad>;
module test_shape_starburst() {
echo("==== test_shape_starburst ====");