discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Rounding(?) problem with polygon()

KM
Kuba Marek
Sun, Apr 10, 2016 11:51 AM

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

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
RP
Ronaldo Persiano
Sun, Apr 10, 2016 3:23 PM

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 blue.cube@seznam.cz:

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <blue.cube@seznam.cz>: > 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
DM
doug moen
Sun, Apr 10, 2016 4:01 PM

This is a known bug, and scaling up is the workaround.

https://github.com/openscad/openscad/issues/999

On 10 April 2016 at 07:51, Kuba Marek blue.cube@seznam.cz 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

This is a known bug, and scaling up is the workaround. https://github.com/openscad/openscad/issues/999 On 10 April 2016 at 07:51, Kuba Marek <blue.cube@seznam.cz> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
MK
Marius Kintel
Sun, Apr 10, 2016 4:02 PM

On Apr 10, 2016, at 07:51 AM, Kuba Marek blue.cube@seznam.cz 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?

On Apr 10, 2016, at 07:51 AM, Kuba Marek <blue.cube@seznam.cz> 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
KM
Kuba Marek
Sun, Apr 10, 2016 4:30 PM

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 blue.cube@seznam.cz:

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <blue.cube@seznam.cz>: > > > 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 > > Discuss@lists.openscad.org > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > >
RP
Ronaldo Persiano
Sun, Apr 10, 2016 6:37 PM

Besides, observe that the Naca profile has a very fast variation of the
tangent near x=0 and which varies slowly to the right. You may consider a
varying discretization on sampling x, starting with a fine discretization
for low x and enlaging it for greater x.

2016-04-10 13:30 GMT-03:00 Kuba Marek blue.cube@seznam.cz:

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 blue.cube@seznam.cz:

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Besides, observe that the Naca profile has a very fast variation of the tangent near x=0 and which varies slowly to the right. You may consider a varying discretization on sampling x, starting with a fine discretization for low x and enlaging it for greater x. 2016-04-10 13:30 GMT-03:00 Kuba Marek <blue.cube@seznam.cz>: > 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 <blue.cube@seznam.cz>: > > > > > 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 > > > Discuss@lists.openscad.org > > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Sun, Apr 10, 2016 8:45 PM

You might want to have a look into this NACA-library:
http://www.thingiverse.com/thing:898554

--
View this message in context: http://forum.openscad.org/Rounding-problem-with-polygon-tp17020p17032.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

You might want to have a look into this NACA-library: http://www.thingiverse.com/thing:898554 -- View this message in context: http://forum.openscad.org/Rounding-problem-with-polygon-tp17020p17032.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Sun, Apr 10, 2016 9:26 PM

It would be great if you extended the existing NACA library with some more of
the NACA algorithms/codes.

--
View this message in context: http://forum.openscad.org/Rounding-problem-with-polygon-tp17020p17033.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

It would be great if you extended the existing NACA library with some more of the NACA algorithms/codes. -- View this message in context: http://forum.openscad.org/Rounding-problem-with-polygon-tp17020p17033.html Sent from the OpenSCAD mailing list archive at Nabble.com.
KM
Kuba Marek
Sun, Apr 10, 2016 9:39 PM

Yes, that was the plan after I get the rest of my project working :-)

Besides, observe that the Naca profile has a very fast variation of
the tangent near x=0 and which varies slowly to the right. You may
consider a varying discretization on sampling x, starting with a fine
discretization for low x and enlaging it for greater x.

2016-04-10 13:30 GMT-03:00 Kuba Marek blue.cube@seznam.cz:

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 blue.cube@seznam.cz:

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes, that was the plan after I get the rest of my project working :-) > Besides, observe that the Naca profile has a very fast variation of > the tangent near x=0 and which varies slowly to the right. You may > consider a varying discretization on sampling x, starting with a fine > discretization for low x and enlaging it for greater x. > > 2016-04-10 13:30 GMT-03:00 Kuba Marek <blue.cube@seznam.cz>: > > > 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 <blue.cube@seznam.cz>: > > > > > > > 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 > > > > Discuss@lists.openscad.org > > > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > > > > > > > > _______________________________________________ > > OpenSCAD mailing list > > Discuss@lists.openscad.org > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
KM
Kuba Marek
Sun, Apr 10, 2016 9:45 PM

I'd like to do that, but what I have is a new implementation rather than
an extension :-)
So far it can do all 4 digit codes (based on wikipedia) with
regular discretization in X axis and output to a list or polygon.
Is there a way I can make a pull request to the thingieverse?
Anyway I'm planning to put my code up on github sometime soon.

It would be great if you extended the existing NACA library with some
more of the NACA algorithms/codes.

--
View this message in context:
http://forum.openscad.org/Rounding-problem-with-polygon-tp17020p17033.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I'd like to do that, but what I have is a new implementation rather than an extension :-) So far it can do all 4 digit codes (based on wikipedia) with regular discretization in X axis and output to a list or polygon. Is there a way I can make a pull request to the thingieverse? Anyway I'm planning to put my code up on github sometime soon. > It would be great if you extended the existing NACA library with some > more of the NACA algorithms/codes. > > > > -- > View this message in context: > http://forum.openscad.org/Rounding-problem-with-polygon-tp17020p17033.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org