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


enter image description here

However, this:

RegionMember[poly, pts]

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

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

RegionMember[DiscretizeRegion[poly], pts]
RegionMember[BoundaryDiscretizeRegion@poly, pts]

{True, True}

RegionMember[poly // Rationalize, pts]

{True, True}

  • 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
    Mar 10 at 8:27
  • $\begingroup$ Rationalize is another way. $\endgroup$
    – cvgmt
    Mar 10 at 8:46
  • 1
    $\begingroup$ Version 12.1 RegionMember gives True. Seems to be a bug that has been fixed in 12.1 $\endgroup$ Mar 10 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
    Mar 11 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
    Mar 11 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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