9
$\begingroup$

I usually look at my regions by plugging them into graphics:

Graphics[{Disk[{0, 0}, 2], Disk[{3, 0}, 2]}]

That works. But when I try to create the union of the regions, I can no longer visualize it (this fails):

Graphics[RegionUnion[Disk[{0, 0}, 2], Disk[{3, 0}, 2]]]

Why? And how can I visualize a region constructed through unions?

Incidentally, the documentation for RegionMember suggests that Region[RegionUnion[Disk[{0, 0}, 2], Disk[{3, 0}, 2]]] should generate an image. But it doesn't for me.

$\endgroup$
2
  • 1
    $\begingroup$ What version are you using? Region was introduced in V11.1. $\endgroup$
    – Greg Hurst
    Commented Jul 13, 2017 at 2:10
  • $\begingroup$ @ChipHurst Ahh, I see. I'm using V11.0, naturally. There's a good reason to update! $\endgroup$
    – Shane
    Commented Jul 13, 2017 at 14:39

4 Answers 4

7
$\begingroup$

Amplifying on the answer by e.doroskevic

The Head of RegionUnion is RegionUnion which is not a Graphics primitive.

Head@RegionUnion[Disk[{0, 0}, 2], Disk[{3, 0}, 2]]

(*  RegionUnion  *)

RegionQ@RegionUnion[Disk[{0, 0}, 2], Disk[{3, 0}, 2]]

(*  True  *)

Use RegionPlot

RegionPlot[
 RegionUnion[Disk[{0, 0}, 2], Disk[{3, 0}, 2]], AspectRatio -> 4/7]

enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ You could use AspectRatio -> All instead. $\endgroup$
    – Carl Woll
    Commented Jul 12, 2017 at 16:15
  • $\begingroup$ @CarlWoll - Thanks. $\endgroup$
    – Bob Hanlon
    Commented Jul 12, 2017 at 16:23
  • $\begingroup$ @CarlWoll AspectRatio -> All produces an error in 10.1. Did you mean AspectRatio -> Automatic or is this something new? If the latter how is it different from Automatic? $\endgroup$
    – Mr.Wizard
    Commented Jul 13, 2017 at 2:02
  • $\begingroup$ All was just the first I thing I tried, and in M11 I think All and Automatic are equivalent. $\endgroup$
    – Carl Woll
    Commented Jul 13, 2017 at 5:27
6
$\begingroup$

Another possibility is BoundaryDiscretizeRegion:

BoundaryDiscretizeRegion[
    RegionUnion[{Disk[{0,0},2],Disk[{3,0},2]}]
]

enter image description here

If you want a better discretization, you can use PrecisionGoal/AccuracyGoal:

BoundaryDiscretizeRegion[
    RegionUnion[{Disk[{0,0},2],Disk[{3,0},2]}],
    PrecisionGoal->6
]

enter image description here

$\endgroup$
5
$\begingroup$

Input

RegionPlot @ RegionUnion[{Disk[{0, 0}, 2], Disk[{3, 0}, 2]}]

Output

region plot output

$\endgroup$
4
$\begingroup$

In V11.1.1 a new function Region was introduced, which among other usages, makes viewing compound regions dirt simple.

Region @ RegionUnion[Disk[{0, 0}, 2], Disk[{3, 0}, 2]]

region

$\endgroup$

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.