mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-01 04:20:27 +02:00
add shape_star
This commit is contained in:
20
src/_impl/_shape_star_impl.scad
Normal file
20
src/_impl/_shape_star_impl.scad
Normal file
@@ -0,0 +1,20 @@
|
||||
function __outer_points_shape_star(r1, r2, n) =
|
||||
let(
|
||||
a = 360 / n
|
||||
)
|
||||
[for(i = 0; i < n; i = i + 1) [r1 * cos(90 + a * i), r1 * sin(90 + a * i)]];
|
||||
|
||||
function __inner_points_shape_star(r1, r2, n) =
|
||||
let (
|
||||
a = 360 / n,
|
||||
half_a = a / 2
|
||||
)
|
||||
[for(i = 0; i < n; i = i + 1) [r2 * cos(90 + a * i + half_a), r2 * sin(90 + a * i + half_a)]];
|
||||
|
||||
function _shape_star_impl(r1, r2, n) =
|
||||
let(
|
||||
outer_points = __outer_points_shape_star(r1, r2, n),
|
||||
inner_points = __inner_points_shape_star(r1, r2, n),
|
||||
leng = len(outer_points)
|
||||
)
|
||||
[for(i = 0; i < leng; i = i + 1) each [outer_points[i], inner_points[i]]];
|
13
src/shape_star.scad
Normal file
13
src/shape_star.scad
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* shape_star.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-shape_star.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <_impl/_shape_star_impl.scad>;
|
||||
|
||||
function shape_star(outerRadius = 1, innerRadius = 0.381966, n = 5) = _shape_star_impl(outerRadius, innerRadius, n);
|
Reference in New Issue
Block a user