1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00
This commit is contained in:
Justin Lin
2021-10-29 16:49:18 +08:00
parent 756ed377c3
commit 10930e8b1c
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
function star(outerRadius = 1, innerRadius = 0.381966, height = 0.5, n = 5) =
let(
right = 90,
thetaStep = 360 / n,
half_thetaStep = thetaStep / 2,
half_height = height / 2,
leng_star = n * 2,
points = concat(
[
for(i = [0:n - 1])
let(
a = thetaStep * i + right,
outerPoint = [outerRadius * cos(a), outerRadius * sin(a), 0],
innerPoint = [innerRadius * cos(a + half_thetaStep), innerRadius * sin(a + half_thetaStep), 0]
)
each [outerPoint, innerPoint]
],
[[0, 0, half_height], [0, 0, -half_height]]
),
faces = [
for(i = [0:leng_star - 1])
each [[leng_star, (i + 1) % leng_star, i], [i, (i + 1) % leng_star, leng_star + 1]]
]
)
[points, faces];

6
src/polyhedra/star.scad Normal file
View File

@@ -0,0 +1,6 @@
use <geom_star.scad>;
module star(outerRadius = 1, innerRadius = 0.381966, height = 0.5, n = 5) {
points_faces = star(outerRadius, innerRadius, height, n);
polyhedron(points_faces[0], points_faces[1]);
}