0
$\begingroup$

I have defined three regions, Slice1, Slice2 and Slice3.

Slice1 = 
  Polygon[{{0, 0}, {1, 0}, {1, 1/(Sqrt[3])}, {1/2, Sqrt[3]/2}}];
Slice2 = 
  Polygon[{{0, 0}, {-1, 0}, {-1, 1/(Sqrt[3])}, {-1/2, Sqrt[3]/2}}];
Slice3 = 
  Polygon[{{0, 
     0}, {-1/2, -Sqrt[3]/2}, {0, -2/Sqrt[3]}, {1/2, -Sqrt[3]/2}}];

CombinedSlice = RegionUnion[Slice1, Slice2, Slice3];
RegionPlot[CombinedSlice, AspectRatio -> Automatic]

When I RegionPlot the combined plot, Slice3 does not have correct boundaries. The boundary shows up correctly when I plot Slice3 individually.

enter image description here

I am using Mathematica 12.0

$\endgroup$
1
  • $\begingroup$ It looks like a bug in RegionUnion[ in cases where we have disjoint regions or regions that have no interior point in common: Try e.g.: CombinedSlice = RegionUnion[Slice1, Slice2]; However, if we have some interior common points: Slice4 = Polygon[{{-0.001, -0.50}, {0.001, -0.5}, {0.001, 0.1}, {-0.001, 0.1}}]; RegionPlot[CombinedSlice, AspectRatio -> Automatic] it works as expected. $\endgroup$ Apr 1 at 8:24
1
$\begingroup$

Such bug also appear in 12.2. We had to draw the boundary and interior separately.

Show[RegionPlot[{RegionBoundary@CombinedSlice}, 
  BoundaryStyle -> Red],
 RegionPlot[CombinedSlice, BoundaryStyle -> None]]

enter image description here

$\endgroup$
2
  • $\begingroup$ BTW, can this affect the result if I numerically integrate a function over the whole region? Is it a good idea to integrate over the individual regions and add them? $\endgroup$ Apr 1 at 8:51
  • $\begingroup$ @ArchismanPanigrahi It doesn't affect the result. For example, {CombinedSlice // Area, Integrate[1, {x, y} \[Element] CombinedSlice], ArcLength[RegionBoundary@CombinedSlice], 3*ArcLength[RegionBoundary@Slice1] // N} $\endgroup$
    – cvgmt
    Apr 1 at 9:04

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.