RegionMember[ ] in polygon

I think it's worth reporting this to support. As a workaround you can numericize the polygon:

RegionMember[
    Polygon[
        N@{
            {11,10},{10,11},{9,12},{9,13},{8,14},{7,15},{7,16},
            {6,17},{6,18},{5,18},{4,18},{3,19},{2,18},{1,19},
            {-1,19},{-2,19},{-3,19},{-4,19},{-5,18},{-4,18},
            {-3,16},{-3,16},{-2,14},{-1,14},{-1,12},{0,12},
            {0,10},{1,10},{2,10},{3,10},{4,10},{5,9},{7,10},
            {7,9},{9,9},{10,9}
        }
    ],
    {0,0}
]

False


This seems like a bug. It might even be a bug I have reported in the past.

In particular, your polygon is slightly degenerate: it has {-3, 16} twice in a row, creating a zero-length edge. (This doesn't seem to be a sufficient condition alone to make RegionMember fail.)

You can remove such edges by the following replacement rule:

RegionMember[
 Polygon[poly2 //. {{a___, p : {x_, y_}, {x_, y_}, b___} :> {a, p, b},
                    {p : {x_, y_}, a___, {x_, y_}} :> {a, p}}], {0, 0}]

False

This rule doesn't work for complicated coordinate values which have the same value but a different form (testing equality is untrivial), but it's fine with integers and rationals.

Unfortunately this is not the only kind of degeneracy which can make RegionMember fail. Another sort can be seen on polygons where consecutive edges overlap on the same line (this problem persists in v12.0):

RegionMember[Polygon[{{0, 0}, {2, 0}, {1, 0}, {0, 1}}], {0, 0}]

RegionMember[Polygon[{{0, 0}, {2, 0}, {1, 0}, {0, 1}}], {0, 0}]

Numericizing the coordinates does help even in this case, though.


In version 10.1 it seems I need to remove duplicates and make sure the array is unpacked:

RegionMember[Polygon @ Developer`FromPackedArray @ DeleteDuplicates @ poly2, {0, 0}]
False