5
$\begingroup$

Consider these four regions:

regions = Disk[#, 1] & /@ Tuples[{0, 4/5}, {2}]

Graphics[{FaceForm[Opacity[0.2]], EdgeForm[Black], regions}]

enter image description here

I was looking to get subregions which are part of some of these and not part of others. BooleanRegion should be able to do this.

For example,

BooleanRegion[And, BoundaryDiscretizeRegion /@ regions]

enter image description here

But any non-trivial combination (i.e. anything else than using the simple operators And, Or, etc.) seems to fail when more than two regions are present.

For example, try

BooleanRegion[#1 && #2 && ! #3 && ! #4 &, BoundaryDiscretizeRegion /@ regions]

Is this a bug? Am I doing something wrong?

I was very surprised to see this because if these cases don't work, then BooleanRegion seems to be pointless. We might as well just use a single RegionUnion, RegionIntersection, etc. Also, the computation I'm after can be expressed in terms of several region unions, intersections and differences. Thus what I'm expecting from BooleanRegion does not seem to be difficult to implement.

$\endgroup$
3
  • 2
    $\begingroup$ The problem seems to exist only for MeshRegions and BoundaryMeshRegions. For example, BoundaryDiscretizeRegion@ BooleanRegion[#1 && #2 && ! #3 && ! #4 &, regions] works as expected... $\endgroup$ Commented May 16, 2018 at 11:30
  • $\begingroup$ @HenrikSchumacher You're right! I was so convinced that it is much easier to compute with discretized regions that I didn't even try descretizing only afterwards. $\endgroup$
    – Szabolcs
    Commented May 16, 2018 at 11:40
  • 1
    $\begingroup$ Moreover, I think that the problem with discretized regions is BooleanRegion[Not, region] because that cannot be represented by a discrete region. Maybe one needs to replace Not somehow by the RegionComplement with respect to a common BoundingRegion... Maybe it is also possible to modify the boolean function with BooleanConvert... $\endgroup$ Commented May 16, 2018 at 11:46

0

Your Answer

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