The new RegionUnion[] function is just what I needed if only I could get it to work. I have many non-overlapping regions that I will need to use as plotting domains and integration domains. The following simple code illustrates my problem.

Make a simple $n$-gon

ngon[r_, n_, c_: {0, 0}] := 
c + r {Cos[q], Sin[q]}, 
{q, 0, 2 Pi, (2 Pi)/n}]];

Make a ring of hexagons:

 n = 4;
 R = 3;
 polys = Table[
    ngon[1, 6, R {Cos[q], Sin[q]}], 
   {q, 0, 2 Pi, (2 Pi)/n}];

This will display them:


Now use them as regions in a simple Plot3D[]

 Plot3D[1, {x, y} \[Element] RegionUnion[polys]]

If you have been running this code you will see that everything works as expected. But when I increase the number of regions to n=9 my computer works and works until the kernel runs out of memory. My real problem will be much more complex than what I have shown here.

Is there a better way to combine regions? Am I doing things poorly?

Mathematica Ver: 10.0.1 running on Ubuntu Linix


1 Answer 1


DiscretizeRegion makes it is easier to deal with Regions:

 Module[{p = 
    Table[ngon[1, n, r {Cos[q], Sin[q]}], {q, 0, 2 Pi, (2 Pi)/n}], ps},
  ps = RegionUnion[DiscretizeRegion /@ p];
  Plot3D[1, {x, y} \[Element] ps, Mesh -> False]], {r, 1, 6}, {n, 
  Range[4, 12]}]

enter image description here


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.