I have the following openScad code:
module point(x,y) translate([x,y]) circle(0.01);
module oddCurve(R,r) {
for(i =[0:360]) {
x = (R - r)*cos(i) + r * cos((R-r)*i/r);
y = (R - r)*sin(i) + r * sin((R-r)*i/r);
point(x,y);
}
}
oddCurve(20,4);
Now this code doesn't behave as I expected (but maybe the example I took it
from was using polar coordinates), but for now that isn't my question.
What it is doing is making a series of disconnected points, when I actually
want them connected. If I could find a "line" command I could draw a line
from one point to the next one. But I can't find a line. If I could put
the points "into" the polygon command that would be nice but I'm not sure
how I do that. Any tips?
On 09/20/2016 03:53 AM, Dan Shriver wrote:
If I could put the points "into" the polygon command that
would be nice but I'm not sure how I do that. Any tips?
There is not really any point() or line() as such. OpenSCAD
does not have much features for generating 2D drawings.
Depending on where this is supposed to go, that might help:
// calculate [ x, y ] for one point
function point(i, R, r) = [
(R - r)*cos(i) + r * cos((R-r)*i/r),
(R - r)*sin(i) + r * sin((R-r)*i/r)
];
// generate list of points
points = [ for (i = [0:2:359]) point(i, 20, 4) ];
// calculate 2D outline
difference() {
offset(0.01) polygon(points);
polygon(points);
}
ciao,
Torsten.
That doesn't preview correctly for me.
It looks like a convexity problem but setting convexity to 10 for both
polygons doesn't fix it. Is there a bug with offset not passing on the
correct convexity?
On 20 September 2016 at 03:05, Torsten Paul Torsten.Paul@gmx.de wrote:
On 09/20/2016 03:53 AM, Dan Shriver wrote:
If I could put the points "into" the polygon command that
would be nice but I'm not sure how I do that. Any tips?
There is not really any point() or line() as such. OpenSCAD
does not have much features for generating 2D drawings.
Depending on where this is supposed to go, that might help:
// calculate [ x, y ] for one point
function point(i, R, r) = [
(R - r)*cos(i) + r * cos((R-r)*i/r),
(R - r)*sin(i) + r * sin((R-r)*i/r)
];
// generate list of points
points = [ for (i = [0:2:359]) point(i, 20, 4) ];
// calculate 2D outline
difference() {
offset(0.01) polygon(points);
polygon(points);
}
ciao,
Torsten.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 09/20/2016 09:31 AM, nop head wrote:
That doesn't preview correctly for me.
Yeah, I noticed that too. I'm not sure there is actually
a way to set convexity for 2D objects.
ciao,
Torsten.
Polygon takes a convexity parameter according to the documentation.
On 20 September 2016 at 13:12, Torsten Paul Torsten.Paul@gmx.de wrote:
On 09/20/2016 09:31 AM, nop head wrote:
That doesn't preview correctly for me.
Yeah, I noticed that too. I'm not sure there is actually
a way to set convexity for 2D objects.
ciao,
Torsten.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org