mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-09 00:06:42 +02:00
rewrote to use polygon
This commit is contained in:
@@ -13,20 +13,32 @@
|
|||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
|
|
||||||
module circular_sector(radius, angles) {
|
module circular_sector(radius, angles) {
|
||||||
|
function unit_xy(a) = [cos(a), sin(a)];
|
||||||
|
|
||||||
frags = __frags(radius);
|
frags = __frags(radius);
|
||||||
|
|
||||||
r = radius / cos(180 / frags);
|
a_step = 360 / frags;
|
||||||
step = -360 / frags;
|
|
||||||
|
|
||||||
points = concat([[0, 0]],
|
m = floor(angles[0] / a_step) + 1;
|
||||||
[for(a = [angles[0] : step : angles[1] - 360])
|
n = floor(angles[1] / a_step);
|
||||||
[r * cos(a), r * sin(a)]
|
|
||||||
|
half_a_step = a_step / 2;
|
||||||
|
leng = radius * cos(half_a_step);
|
||||||
|
|
||||||
|
function edge_r_begin(a) =
|
||||||
|
leng / cos(m * a_step - half_a_step - a);
|
||||||
|
|
||||||
|
function edge_r_end(a) =
|
||||||
|
leng / cos((n + 0.5) * a_step - a);
|
||||||
|
|
||||||
|
points = concat(
|
||||||
|
[[0, 0], edge_r_begin(angles[0]) * unit_xy(angles[0])],
|
||||||
|
[
|
||||||
|
for(i = [m:n])
|
||||||
|
radius * unit_xy(a_step * i)
|
||||||
],
|
],
|
||||||
[[r * cos(angles[1]), r * sin(angles[1])]]
|
[edge_r_end(angles[1]) * unit_xy(angles[1])]
|
||||||
);
|
);
|
||||||
|
|
||||||
difference() {
|
|
||||||
circle(radius);
|
|
||||||
polygon(points);
|
polygon(points);
|
||||||
}
|
}
|
||||||
}
|
|
Reference in New Issue
Block a user