mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-07-31 20:10:36 +02:00
refactor deps
This commit is contained in:
20
src/_impl/_shape_starburst_impl.scad
Normal file
20
src/_impl/_shape_starburst_impl.scad
Normal 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]]];
|
@@ -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);
|
@@ -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 ====");
|
||||
|
Reference in New Issue
Block a user