5
$\begingroup$

Consider the following two regions:

Vol1 = Region@Cylinder[{{0, 0, -26.5}, {0, 0, 26.5}}, 11.3];
Vol2 = Region@
   RegionProduct[
    Annulus[{1.7, 1.8}, {0.001, 20}, {ArcSin[-(28.7/(2*20))] + Pi/2, 
      ArcSin[28.7/(2*20)] + Pi/2}], Line[{{-26.5}, {26.5}}]];

I would like to get their difference:

reg3=RegionDifference[Vol2,Vol2]

However, the resulting region is not accurate:

enter image description here

Namely, the inner radius does not look like a circle. Could you please tell me how to fix it?

$\endgroup$

2 Answers 2

7
$\begingroup$

Rationalizeing the two volumes before taking the region difference fixes the issue:

RegionDifference[Rationalize @ Vol2, Rationalize @ Vol1]

enter image description here

$\endgroup$
4
$\begingroup$

You are using Region unnecessarily in some instances.

$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

Clear["Global`*"]

reg1 = Cylinder[{{0, 0, -26.5}, {0, 0, 26.5}}, 11.3];
reg2 = RegionProduct[
   Annulus[{1.7, 1.8}, {0.001, 20}, {ArcSin[-(28.7/(2*20))] + Pi/2, 
     ArcSin[28.7/(2*20)] + Pi/2}], Line[{{-26.5}, {26.5}}]];

These are valid regions without using Region

RegionQ /@ {reg1, reg2}

(* {True, True} *)

As kglr pointed out, using exact values fixes the issue.

reg3 = RegionDifference[reg2, reg1] // Rationalize;

RegionQ@reg3

(* True *)

Region[reg3]

enter image description here

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