3
$\begingroup$

Bug persisting in 11.3


I found RegionMember quite useful in retrieving the condition for which a point $(x,y)$ belongs to a region. Thus, this command works:

RegionMember[Disk[{0, 0}, 3, {-\[Pi]/2, \[Pi]/4}]][{x, y}]

$$(x|y)\in \mathbb{R}\land x^2+y^2\leq 9\land \frac{x}{3}\geq 0\land -\frac{y}{3 \sqrt{2}}\geq -\frac{x}{3 \sqrt{2}}$$

However, it does not for this self-intersecting polygon:

RegionMember[Polygon[{{0, 0}, {1, 1}, {0, 1}, {1, 0}}]][{x, y}]

MMA returns

{}[{x, y}]

or

RegionMember[Polygon[{{0, 0}, {1, 1}, {0, 1}, {1, 0}}],{x, y}]

MMA returns the same:

RegionMember[Polygon[{{0, 0}, {1, 1}, {0, 1}, {1, 0}}], {x, y}]

Anyone could explain why RegionMember fails in this case. The region seems to be not complicated.

$\endgroup$
5
  • 2
    $\begingroup$ Looks like a bug to me. The documentation doesn't list any sort of restrictions, like self-intersections. Because it's not documented, then I would say it is not working as described. Particularly this: RegionMember[Polygon[{{0, 0}, {1, 1}, {0, 1}, {1, 0}}]] $\endgroup$
    – ktm
    Jan 29 '18 at 20:56
  • $\begingroup$ If we apply DiscretizeRegion to the polygon, then we get a region that works with RegionMember. $\endgroup$
    – LouisB
    Jan 30 '18 at 6:24
  • $\begingroup$ @LouisB what you propose does not work for me (MMA ver. 11.2). Further, why the need of discretizing the polygon and not the disk? $\endgroup$ Jan 30 '18 at 11:41
  • $\begingroup$ I have just contacted support for assistance $\endgroup$ Jan 30 '18 at 13:17
  • $\begingroup$ Perhaps RegionMember[RegionUnion@@Rationalize[Graphics`PolygonUtils`SimplePolygonPartition[Polygon[{{0,0},{1,1},{0,1},{1,0}}]]],{x,y}]. $\endgroup$
    – chyanog
    Jun 17 '18 at 7:33
2
$\begingroup$

The fact that the one-argument form returns an empty list is simply a bug.

For sufficiently complicated algorithm, it may be hard/impossible to return a useful answer. This true even of self-intersecting polygons, though this particular one is admittedly not that complicated. But then it should return unevaluated, rather than an empty list.

$\endgroup$

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.