discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Easy way to get the area area of a polygon?

E
Experimentalist
Tue, Apr 12, 2016 6:58 PM

Hi

Thanks everyone for your answers, I shall play

Ex

--
View this message in context: http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17084.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi Thanks everyone for your answers, I shall play Ex -- View this message in context: http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17084.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DM
doug moen
Tue, Apr 12, 2016 9:38 PM

Ronaldo gave an example of an "ambiguous" model:

Consider an extrusion of the polygon:

p = [ [0,0], [7,0], [7,7], [3,7], [3,3], [10,3], [10,10], [0,10] ];
polygon(p);

which has a hole in it. If you process that extrusion with slic3r and
Simplify3D you will get rather different results. Each one choose its own
interpretation of the hole of polygon(). Slic3r does preserve the hole,
Simplify3D fill it.

We don't really like to tolerate ambiguity in interchange formats for 3D
objects. Ideally, everybody should interpret a given file the same way, or
report an error that the file is invalid.

Unfortunately, STL doesn't have a well defined interpretation. So what
OpenSCAD tries to do is give a warning message when exporting an ambiguous
STL file. In your example, there is no warning, and that is a bug. So I
reported it: https://github.com/openscad/openscad/issues/1621

In the case of AMF, the standard explicitly forbids self intersection. When
you try to export this model to AMF, you get a fatal error message on the
console. So that works.

In the case of 3MF, the standard explicitly supports self intersection, and
dictates that the Non-zero Winding Number Rule (aka Positive Fill Rule)
should be used to disambiguate. We don't support 3MF export yet, but if we
did, then this model would not be ambiguous.

Doug.

On 12 April 2016 at 11:29, Ronaldo rcmpersiano@gmail.com wrote:

doug.moen wrote

Self-intersecting polygons do not work, which is inconsistent with the
polygon() primitive. So the area won't match what polygon() draws on the
screen in this case.

To calculate area or even to fill a self-intersecting polygons is
ambiguous.
The drawing of a self-intersecting polygon done by primitive polygon() is
just one of the alternatives. Consider an extrusion of the polygon:

p = [ [0,0], [7,0], [7,7], [3,7], [3,3], [10,3], [10,10], [0,10] ];
polygon(p);

which has a hole in it. If you process that extrusion with slic3r and
Simplify3D you will get rather different results. Each one choose its own
interpretation of the hole of polygon(). Slic3r does preserve the hole,
Simplify3D fill it. And nobody can argue that one of them is wrong.

--
View this message in context:
http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17081.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

Ronaldo gave an example of an "ambiguous" model: ---- Consider an extrusion of the polygon: > p = [ [0,0], [7,0], [7,7], [3,7], [3,3], [10,3], [10,10], [0,10] ]; > polygon(p); which has a hole in it. If you process that extrusion with slic3r and Simplify3D you will get rather different results. Each one choose its own interpretation of the hole of polygon(). Slic3r does preserve the hole, Simplify3D fill it. ---- We don't really like to tolerate ambiguity in interchange formats for 3D objects. Ideally, everybody should interpret a given file the same way, or report an error that the file is invalid. Unfortunately, STL doesn't have a well defined interpretation. So what OpenSCAD tries to do is give a warning message when exporting an ambiguous STL file. In your example, there is no warning, and that is a bug. So I reported it: https://github.com/openscad/openscad/issues/1621 In the case of AMF, the standard explicitly forbids self intersection. When you try to export this model to AMF, you get a fatal error message on the console. So that works. In the case of 3MF, the standard explicitly supports self intersection, and dictates that the Non-zero Winding Number Rule (aka Positive Fill Rule) should be used to disambiguate. We don't support 3MF export yet, but if we did, then this model would not be ambiguous. Doug. On 12 April 2016 at 11:29, Ronaldo <rcmpersiano@gmail.com> wrote: > doug.moen wrote > > Self-intersecting polygons do not work, which is inconsistent with the > > polygon() primitive. So the area won't match what polygon() draws on the > > screen in this case. > > To calculate area or even to fill a self-intersecting polygons is > ambiguous. > The drawing of a self-intersecting polygon done by primitive polygon() is > just one of the alternatives. Consider an extrusion of the polygon: > > > p = [ [0,0], [7,0], [7,7], [3,7], [3,3], [10,3], [10,10], [0,10] ]; > > polygon(p); > > which has a hole in it. If you process that extrusion with slic3r and > Simplify3D you will get rather different results. Each one choose its own > interpretation of the hole of polygon(). Slic3r does preserve the hole, > Simplify3D fill it. And nobody can argue that one of them is wrong. > > > > -- > View this message in context: > http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17081.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 > > >
R
Ronaldo
Wed, Apr 13, 2016 4:40 PM

Kenneth Sloan wrote

Answer (I’m not cruel…): the direction is perpendicular to a “best-fit”
plane through the wrinkled “polygon”, and the length is twice the area of
the projection of the “polygon” onto that best-fit plane.

So…if you have wrinkled polygons and you want the area of the wrinkled
surface…then you do have to triangulate.  Question: in this case, is the
answer unique?

Is the "best-fit" you mentioned the least square one? Do you suggest any
simple criteria to evaluate how much a polygonal in 3D is non-planar?

--
View this message in context: http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17106.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Kenneth Sloan wrote > Answer (I’m not cruel…): the direction is perpendicular to a “best-fit” > plane through the wrinkled “polygon”, and the length is twice the area of > the projection of the “polygon” onto that best-fit plane. > > So…if you have wrinkled polygons and you want the area of the wrinkled > surface…then you *do* have to triangulate. Question: in this case, is the > answer unique? Is the "best-fit" you mentioned the least square one? Do you suggest any simple criteria to evaluate how much a polygonal in 3D is non-planar? -- View this message in context: http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17106.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Mon, Apr 18, 2016 5:03 PM

Ronaldo wrote

Kenneth Sloan wrote

Answer (I’m not cruel…): the direction is perpendicular to a “best-fit”
plane through the wrinkled “polygon”, and the length is twice the area of
the projection of the “polygon” onto that best-fit plane.

So…if you have wrinkled polygons and you want the area of the wrinkled
surface…then you do have to triangulate.  Question: in this case, is
the answer unique?

Is the "best-fit" you mentioned the least square one? Do you suggest any
simple criteria to evaluate how much a polygonal in 3D is non-planar?

Well, I found this one in case you use eigenvectors/eigenvalues method for
least square fitting: the ratio of the minimum eigenvalue (of the covariance
matrix) and the maximum one gives a criteria to decide. A zero ratio means
the polygonal is planar, a low ratio means it is "almost planar". The ratio
grows quadratically with the relative distance from the points to the
fitting plane and it is rather independent of the number of points.

--
View this message in context: http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17154.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ronaldo wrote > > Kenneth Sloan wrote >> Answer (I’m not cruel…): the direction is perpendicular to a “best-fit” >> plane through the wrinkled “polygon”, and the length is twice the area of >> the projection of the “polygon” onto that best-fit plane. >> >> So…if you have wrinkled polygons and you want the area of the wrinkled >> surface…then you *do* have to triangulate. Question: in this case, is >> the answer unique? > Is the "best-fit" you mentioned the least square one? Do you suggest any > simple criteria to evaluate how much a polygonal in 3D is non-planar? Well, I found this one in case you use eigenvectors/eigenvalues method for least square fitting: the ratio of the minimum eigenvalue (of the covariance matrix) and the maximum one gives a criteria to decide. A zero ratio means the polygonal is planar, a low ratio means it is "almost planar". The ratio grows quadratically with the relative distance from the points to the fitting plane and it is rather independent of the number of points. -- View this message in context: http://forum.openscad.org/Easy-way-to-get-the-area-of-a-polygon-tp17045p17154.html Sent from the OpenSCAD mailing list archive at Nabble.com.