6
$\begingroup$

Bug introduce in version 10 and presist in 11.2

In my this answer,I get some overlapped disk like this placed with red arrow point out

But actually that function of diskMake is designed to produce nonoverlapping disk.And I don't think I write a wrong code. :) For this question I have some digs like following:

wordRegion = 
  BoundaryDiscretizeGraphics[
   Text[Style["21", FontFamily -> "Arial"]], _Text];
disks = {Disk[{-2.4107273705611387`, 3.2155412094306577`}, 
    0.10357806335605606`], 
   Disk[{-1.4610266485101935`, -0.1848766412849958`}, 
    0.1371293137456506`], 
   Disk[{3.9597015795674757`, -2.0248306466733403`}, 
    0.21070473733708972`], 
   Disk[{-1.4133143443551681`, -0.5609218789129127`}, 
    0.2141073441827654`], 
   Disk[{3.4232452614725304`, 1.1487829210947051`}, 
    0.062352195066279315`]};
disk = Fold[RegionDifference, wordRegion, 
   BoundaryDiscretizeRegion /@ disks];
r = .3;(*You can change the value to 0.3 or 0.6*)
Row[Magnify[#, 5] & /@ 
  MapThread[
   Labeled, {{disk, 
     Show[Graphics[{Opacity[.2], Red, Disk[{-1.5, 3}, r]}], 
      RegionDifference[disk, 
        DiscretizeRegion@Disk[{-1.5, 3}, r]]]}, {Style[
      "Before RegionDifference", 6, Red], 
     Style["After RegionDifference", 6, Blue]}}]]

You can find the small disk I have point out with red arrow will disappear when the $r<0.3$.$\color{red}{\text{I think I get these overlapped disks caused by this}}$.

What about this?And how to avoid it?

$\endgroup$
  • $\begingroup$ Unfortunately I do not understand your question. You may want to simplify your problem to produce a minimal working example. Can you distill the problem down to e.g. one disk, and one simpler region (e.g. a square)? Then explain explicitly what you think is wrong with the result you obtain, and what would be the desired outcome instead. $\endgroup$ – MarcoB Jun 6 '16 at 20:26
  • $\begingroup$ @MarcoB I'm very sorry.It seem I can't understand what you said completely.And this problem(maybe a bug) is difficult to reproduce.So I don't know how to simplify it.But if you change the $r$ to 0.6 from 0.3,maybe you will found what I have said. :) $\endgroup$ – yode Jun 9 '16 at 12:50
  • 1
    $\begingroup$ It looks like the problem arises because the little disk (the one that vanishes) is touching the boundary of the 1. If you reduce its radius by some small amount the problem goes away. I'm not sure why the touching boundaries cause this issue, or how you could prevent it from happening. $\endgroup$ – Simon Woods Jun 13 '16 at 20:02
  • $\begingroup$ @SimonWoods Wow..Thanks for your point out.It can be saved me. $\endgroup$ – yode Jun 14 '16 at 4:27
11
$\begingroup$

It is confirmed as an improper behavior of RegionDifference by Wolfram support([CASE:3624735]).

Here is their workaround:

Instead of using boundary representation of geometric regions as given below, try using just the geometric regions in geometric computations.

To be specific, here is the solution to this problem. Assuming wordRegion and disks have been initialized as given, and compare the old and new code:

old = Fold[RegionDifference, wordRegion, BoundaryDiscretizeRegion /@ disks];
RegionDifference[old, BoundaryDiscretizeRegion[Disk[{-1.5, 3}, 0.3]]]

enter image description here

new = Fold[RegionDifference, wordRegion, disks];
BoundaryDiscretizeRegion@RegionDifference[new, Disk[{-1.5, 3}, 0.3]]

enter image description here

As you can see, the small circle on the left of 1 is not missing anymore.

$\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.