I found these a while ago - and I use them quite frequently, I'm afraid
they were examples found in a trawl so I am unable to provide credit to
the originator [sorry :-(]
The first two modules provide the core elements, the third is an example
of usage.
There is a problem with the intersections, which is the purpose of
adding and subtracting 3
module arc(radius, angles, width = 1, fn = 100) {
angles = [angles[0]+3,angles[1]-3];
echo (angles[0]);
difference() {
sector(radius + width, angles, fn);
sector(radius, angles, fn);
}
}
module sector(radius, angles, fn = 100) {
echo ("sector from apex modules");
r = radius / cos(180 / fn);
step = -360 / fn;
points = concat([[0, 0]],
[for(a = [angles[0] : step : angles[1] - 360])
[r * cos(a), r * sin(a)]
],
[[r * cos(angles[1]), r * sin(angles[1])]]
);
difference() {
circle(radius, $fn = fn);
polygon(points);
}
}// end module sector
module rounded_end_slot_arc
(arc_radius=10,arc_width=4,arc_z=10,start_angle=0,end_angle=20,local_roundness=60)
{
slot_width = arc_width;
slot_rad = arc_radius;
slot_angles = [start_angle,end_angle];
slot_z = arc_z;
arc_rad = slot_rad - slot_width/2;
// rotate ([0,0,slot_angles[0]+3])
// translate ([slot_rad,0,-0.1])
// cylinder (d=slot_width,h=slot_z,$fn=local_roundness);
// rotate ([0,0,slot_angles[1]-3])
// translate ([slot_rad,0,-0.1])
// cylinder (d=slot_width,h=slot_z,$fn=local_roundness);
translate ([0,0,-0.1])
linear_extrude (slot_z)
arc(arc_rad,slot_angles, slot_width, $fn=100);
}// end module
rounded_end_slot_arc (15,4,6,0,20,60);
If you uncomment the cylinders from the above example you get a round
end object you can cut a slot with. By changing the arc radius and the
width you can achieve a pie slice of any height you need, no differences
required.
HTH
Roger