5
$\begingroup$

Bug introduced in 12.2.0 or earlier. Fixed in 13.0.0 or earlier.


There appears to be an issue with RegionMember in Mathematica 12.2 when it comes to simple polygons and points.

poly=Polygon[{{1220.8,1293.36},{1223.43,1135.43},{1212.37,1135.54},{1214.34,980.877},{1412.85,983.389},{1410.92,1138.27},{1396.75,1138.7},{1395.27,1230.33},{1395.81,1261.74},{1384.48,1267.41},{1379.62,1279.57},{1382.03,1291.72},{1393.39,1298.2},{1392.58,1422.18},{1375.57,1416.5},{1353.66,1418.14},{1326.93,1425.42},{1293.73,1435.97},{1264.54,1435.97},{1237.81,1429.49},{1219.17,1420.58},{1218.59,1378.55},{1218.35,1361.41},{1228.9,1348.45},{1232.94,1328.98},{1230.5,1308.75}}];
pts={{1309.22,1183.11},{1380.98,1246.29}};
Graphics[{{Opacity[0.5],poly},Point@pts}]

enter image description here

However, this:

RegionMember[poly, pts]

results in {False,False} even though, this:

RegionMember[poly,{{1300,1300},{1350,1350}}] works fine.

$\endgroup$

2 Answers 2

3
$\begingroup$
RegionMember[DiscretizeRegion[poly], pts]
RegionMember[BoundaryDiscretizeRegion@poly, pts]

{True, True}

RegionMember[poly // Rationalize, pts]

{True, True}

$\endgroup$
5
  • 2
    $\begingroup$ So what's the big picture takeaway here? Just don't ever use RegionMember with actual regions, instead always discretize your regions first? How could anyone ever know to do this? Is there a reason the function is called RegionMember when it's generally incapable of determining actual region membership? $\endgroup$
    – Nickolas
    Commented Mar 10, 2021 at 8:27
  • $\begingroup$ Rationalize is another way. $\endgroup$
    – cvgmt
    Commented Mar 10, 2021 at 8:46
  • 1
    $\begingroup$ Version 12.1 RegionMember gives True. Seems to be a bug that has been fixed in 12.1 $\endgroup$ Commented Mar 10, 2021 at 10:12
  • $\begingroup$ Thank you, @cvgmt for the work-arounds, but I am with Nickolas - there appears to be a bug if this function does not recognize a simple polygon as a correct region. Daniel Huber: I am using 12.2, so if it works in 12.1, the issue must have (re)appeared recently? $\endgroup$
    – drk
    Commented Mar 11, 2021 at 3:16
  • $\begingroup$ An update: @cvgmt Rationalize does NOT always work - I found other examples. DiscretizeRegion worked (at least on my data). $\endgroup$
    – drk
    Commented Mar 11, 2021 at 14:56
1
$\begingroup$

The issue appears to have been fixed in V13.0.0

fixed

$\endgroup$
2
  • 1
    $\begingroup$ Yes, I confirm that RegionMember is now working for the example I had originally provided. $\endgroup$
    – drk
    Commented May 16, 2022 at 23:04
  • $\begingroup$ @drk many thanks for letting me know :) $\endgroup$
    – bmf
    Commented May 17, 2022 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.