# Rounding(?) problem with polygon()

10 messages
Open this post in threaded view
|

## Rounding(?) problem with polygon()

 Hi, I'm trying to make a parametric NACA 4digit airfoil shape using polygon(). I have a function that gives me Y coordinate for every X, and I'm calculating a vector of X, Y coordinates using a list comprehension. My problem is that when I select the X spacing too narrow, the resulting polygon looks like it's skipping some points -- the lower the stepping, the more points lost. MWE is attached to this mail. The step size 0.0035 was chosen so that the problem is visible enough. With step size 0.05 it still looks OK, lower than that the problem starts to appear with increasing severity. To verify that the vector fed as an input to the polygons the correct, the example also renders spheres at positions of the control points. When I scale the positions in the vector (set scale variable to 100 int the example), the problem disappears. Is this intended, or a bug? I'm using OpenSCAD 2015.03, built from source with Gentoo ebuild. Kuba Marek_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org polygon_problem_mwe.scad (534 bytes) Download Attachment
Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

 See if you get better results with this:extra_scale = 100; // increase if neededstep = 0.0035;scale = 100*extra_scale;top = [for(x = [0:step:1]) scale * [x,                                    0.12 * naca_thickness(x)]];scale(1/extra_scale ) polygon(points=top);scale(1/extra_scale ) %for(p = top) translate([p[0], p[1], 0]) sphere(scale * 0.005);2016-04-10 8:51 GMT-03:00 Kuba Marek :Hi, I'm trying to make a parametric NACA 4digit airfoil shape using polygon(). I have a function that gives me Y coordinate for every X, and I'm calculating a vector of X, Y coordinates using a list comprehension. My problem is that when I select the X spacing too narrow, the resulting polygon looks like it's skipping some points -- the lower the stepping, the more points lost. MWE is attached to this mail. The step size 0.0035 was chosen so that the problem is visible enough. With step size 0.05 it still looks OK, lower than that the problem starts to appear with increasing severity. To verify that the vector fed as an input to the polygons the correct, the example also renders spheres at positions of the control points. When I scale the positions in the vector (set scale variable to 100 int the example), the problem disappears. Is this intended, or a bug? I'm using OpenSCAD 2015.03, built from source with Gentoo ebuild. Kuba Marek_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

 In reply to this post by cube This is a known bug, and scaling up is the workaround.On 10 April 2016 at 07:51, Kuba Marek wrote:Hi, I'm trying to make a parametric NACA 4digit airfoil shape using polygon(). I have a function that gives me Y coordinate for every X, and I'm calculating a vector of X, Y coordinates using a list comprehension. My problem is that when I select the X spacing too narrow, the resulting polygon looks like it's skipping some points -- the lower the stepping, the more points lost. MWE is attached to this mail. The step size 0.0035 was chosen so that the problem is visible enough. With step size 0.05 it still looks OK, lower than that the problem starts to appear with increasing severity. To verify that the vector fed as an input to the polygons the correct, the example also renders spheres at positions of the control points. When I scale the positions in the vector (set scale variable to 100 int the example), the problem disappears. Is this intended, or a bug? I'm using OpenSCAD 2015.03, built from source with Gentoo ebuild. Kuba Marek_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

 Administrator In reply to this post by cube On Apr 10, 2016, at 07:51 AM, Kuba Marek <[hidden email]> wrote: > > When I scale the positions in the vector (set scale variable to 100 > int the example), the problem disappears. > > Is this intended, or a bug? > This is a known bug: https://github.com/openscad/openscad/issues/999 -Marius _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

 In reply to this post by Ronaldo Weird that I didn't find that bug report :-) Thanks for your answers, the scaling workaround works well enough. > See if you get better results with this: > > extra_scale = 100; // increase if needed > step = 0.0035; > scale = 100*extra_scale; > > top = [for(x = [0:step:1]) scale * [x, >                                     0.12 * naca_thickness(x)]]; > > scale(1/extra_scale ) polygon(points=top); > > scale(1/extra_scale ) %for(p = top) translate([p[0], p[1], 0]) > sphere(scale > * 0.005); > > 2016-04-10 8:51 GMT-03:00 Kuba Marek <[hidden email]>: > > > Hi, > > I'm trying to make a parametric NACA 4digit airfoil shape using > > polygon(). I have a function that gives me Y coordinate for every X, > > and I'm calculating a vector of X, Y coordinates using a list > > comprehension. > > > > My problem is that when I select the X spacing too narrow, the > > resulting polygon looks like it's skipping some points -- the lower > > the stepping, the more points lost. > > > > MWE is attached to this mail. The step size 0.0035 was chosen so > > that the problem is visible enough. With step size 0.05 it still > > looks OK, lower than that the problem starts to appear with > > increasing severity. > > > > To verify that the vector fed as an input to the polygons the > > correct, the example also renders spheres at positions of the > > control points. > > > > When I scale the positions in the vector (set scale variable to 100 > > int the example), the problem disappears. > > > > Is this intended, or a bug? > > > > I'm using OpenSCAD 2015.03, built from source with Gentoo ebuild. > > > > Kuba Marek > > _______________________________________________ > > OpenSCAD mailing list > > [hidden email] > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > >   _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

 In reply to this post by cube You might want to have a look into this NACA-library: http://www.thingiverse.com/thing:898554
Open this post in threaded view
|

## Re: Rounding(?) problem with polygon()

 In reply to this post by cube It would be great if you extended the existing NACA library with some more of the NACA algorithms/codes.