I have a polygon generated by some data. Sometimes, I cannot compute the area of some of the generated polygons and I cannot correctly apply function NMaxmize
on its region either. (For some polygons these work well but they fail to work for specific ones). I wonder why this happens and how to fix it.
For example, this is a successful one
pol = Polygon[{{1.073332569964023`, -1.8576544111276834`, -3.06965`}, \
{-1.0734323825132777`, -1.8576544111276834`, -3.06965`}, \
{-2.0717542556690365`, -3.587970838511705`, \
-0.00008236145274327066`}, {2.0716585508349357`, \
-3.5879842572471317`, -0.00005855672236896324`}, {1.073332569964023`, \
-1.8576544111276834`, -3.06965`}}]
Area[pol]
NMaximize[xi, {xi, yi, zi} \[Element] pol]
and this is a failed one
pol = Polygon[{{1.073345506818552`, 1.857637206027929`,
3.0696499694419788`}, {2.0716892525829143`,
3.587975340418905`, -0.00006534259886672701`}, \
{4.1439268249396655`, -0.000023855261707517`, \
-0.00008236145274327066`}, {2.146229106755889`, \
-0.000009315675120787797`, 3.0696499694419788`}, {1.073345506818552`,
1.857637206027929`, 3.0696499694419788`}}]
Area[pol]
NMaximize[xi, {xi, yi, zi} \[Element] pol]
Concerning if all points are in the same plane, I did some tests. Based on my tests(only based on upon several data sets), I found that if all points are exactly in a single plane the issues don't exist, but for points that are not exactly in one plane the issues sometimes appear and sometimes don't. Here are two examples: This is an example where all points are NOT judged to be in one plane and we can compute its area and use NMaximize:
points = {{2.146229106755889`, -9.315675120787797`*^-6,
3.0696499694419788`}, {4.1439268249396655`, \
-0.000023855261707517`, -0.00008236145274327066`}, \
{2.0716585508349357`, -3.5879842572471317`, \
-0.00005855672236896324`}, {1.0733325799020568`, -1.857654428352594`,
3.0696499694419788`}, {2.146229106755889`, \
-9.315675120787797`*^-6, 3.0696499694419788`}};
pol = Polygon[points]
Area[pol]
NMaximize[xi, {xi, yi, zi} \[Element] pol]
pp = InfinitePlane[Take[points, 3]];
RegionMember[pp, points]
and this is where they are NOT judged to be in one plane either and issues appear:
points = {{2.0716585508349357`, -3.5879842572471317`, \
-0.00005855672236896324`}, {4.1439268249396655`, \
-0.000023855261707517`, -0.00008236145274327066`}, \
{2.1462290868694445`, -9.315675187064002`*^-6, -3.06965`}, \
{1.073332569964023`, -1.8576544111276834`, -3.06965`}, \
{2.0716585508349357`, -3.5879842572471317`, -0.00005855672236896324`}};
pol = Polygon[points]
Area[pol]
NMaximize[xi, {xi, yi, zi} \[Element] pol]
pp = InfinitePlane[Take[points, 3]];
RegionMember[pp, points]