mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-20 05:21:38 +02:00
added two shapes
This commit is contained in:
22
src/shape_pentagram.scad
Normal file
22
src/shape_pentagram.scad
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
function shape_pentagram(r) =
|
||||||
|
[
|
||||||
|
// shape points
|
||||||
|
[
|
||||||
|
[0, 1], [-0.224514, 0.309017],
|
||||||
|
[-0.951057, 0.309017], [-0.363271, -0.118034],
|
||||||
|
[-0.587785, -0.809017], [0, -0.381966],
|
||||||
|
[0.587785, -0.809017], [0.363271, -0.118034],
|
||||||
|
[0.951057, 0.309017], [0.224514, 0.309017]
|
||||||
|
] * r,
|
||||||
|
// triangles
|
||||||
|
[
|
||||||
|
[0, 1, 9],
|
||||||
|
[2, 3, 1],
|
||||||
|
[4, 5, 3],
|
||||||
|
[6, 7, 5],
|
||||||
|
[8, 9, 7],
|
||||||
|
[1, 3, 5],
|
||||||
|
[1, 5, 7],
|
||||||
|
[1, 7, 9]
|
||||||
|
]
|
||||||
|
];
|
30
src/shape_square.scad
Normal file
30
src/shape_square.scad
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
function shape_square(size, corner_r = 0) =
|
||||||
|
let(
|
||||||
|
frags = $fn > 0 ?
|
||||||
|
($fn >= 3 ? $fn : 3) :
|
||||||
|
max(min(360 / $fa, corner_r * 6.28318 / $fs), 5),
|
||||||
|
remain = frags % 4,
|
||||||
|
corner_frags = (remain / 4) > 0.5 ? frags - remain + 4 : frags - remain,
|
||||||
|
step_a = 360 / corner_frags,
|
||||||
|
x = len(size) == undef ? size : size[0],
|
||||||
|
y = len(size) == undef ? size : size[1],
|
||||||
|
half_x = x / 2,
|
||||||
|
half_y = y / 2,
|
||||||
|
half_w = half_x - corner_r,
|
||||||
|
half_h = half_y - corner_r,
|
||||||
|
shape_pts = concat(
|
||||||
|
[[half_x, -half_h], [half_x, half_h]],
|
||||||
|
[for(a = [step_a:step_a:90 - step_a]) [corner_r * cos(a) + half_w, corner_r * sin(a) + half_h]],
|
||||||
|
[[half_w, half_y], [-half_w, half_y]],
|
||||||
|
[for(a = [90 + step_a:step_a:180 - step_a]) [corner_r * cos(a) - half_w, corner_r * sin(a) + half_h]],
|
||||||
|
[[-half_x, half_h], [-half_x, -half_h]],
|
||||||
|
[for(a = [180 + step_a:step_a:270 - step_a]) [corner_r * cos(a) - half_w, corner_r * sin(a) - half_h]],
|
||||||
|
[[-half_w, -half_y], [half_w, -half_y]],
|
||||||
|
[for(a = [270 + step_a:step_a:360 - step_a]) [corner_r * cos(a) + half_w, corner_r * sin(a) - half_h]]
|
||||||
|
),
|
||||||
|
triangles = [for(i = [1:len(shape_pts) - 2]) [0, i, i + 1]]
|
||||||
|
)
|
||||||
|
[
|
||||||
|
shape_pts,
|
||||||
|
triangles
|
||||||
|
];
|
Reference in New Issue
Block a user