[OpenSCAD] Creating pie (pizza slice) shape (need a dynamic length array)
Parkinbot
rudolf at digitaldocument.de
Sat Sep 15 17:06:27 EDT 2018
It seems there are many versions of pie out there.
In OpenScad it is always a good idea to avoid Boolean ops. Thus the
following version is more basic. While it doesn't explicitly account for $fs
(indeed polygon() seems to enforce it), it copes well with $fn, $fa, and any
- also negative - angles.
pieSlice(10, 10, 23, $fa=3);
module pieSlice(r=10, start_angle=0, end_angle=45)
{
polygon(pie(r, start_angle, end_angle));
function pie(r=40, a1=0, a2=150) =
let(start = a1%360)
let(end = (a2%360-start)>=0?a2%360:a2%360+360)
let(fa = $fn==0?$fa:360/$fn)
let(step = (end-start)/ceil((end-start)/fa)- 1e-7)
r*[[0,0], for(i=[start:step:end]) [cos(i), sin(i)]];
}
--
Sent from: http://forum.openscad.org/
More information about the Discuss
mailing list