mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-06 14:56:47 +02:00
add star
This commit is contained in:
25
src/polyhedra/geom_star.scad
Normal file
25
src/polyhedra/geom_star.scad
Normal 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
6
src/polyhedra/star.scad
Normal 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]);
|
||||||
|
}
|
Reference in New Issue
Block a user