3
$\begingroup$

I'm creating a region out of two component regions. Before anyone suggests it (because a lot of similar questions are about it), I don't think the problem is increasing PlotPoints. I've increased it to 100 in a few steps and the problem seems to stay.

hCub = 1.5;
W = 5;
L = 10;
AAOrad = W/30;
shellthickness = AAOrad/10;

Clear[x, y, z];
cylcenter = {W, L/2, 0};
region["cub"] = 
  ImplicitRegion[
   0 <= x <= W && 0 <= y <= L && 0 <= z <= hCub, {x, y, z}];
region["halfcyl"] = 
  ImplicitRegion[
   0 <= (x - cylcenter[[1]])^2 + (y - cylcenter[[2]])^2 <= AAOrad && 
    0 <= (z - 0) <= hCub && x <= cylcenter[[1]], {x, y, z}];
region["thinshellhalfcyl"] = 
  ImplicitRegion[(AAOrad - 
       shellthickness) <= (x - cylcenter[[1]])^2 + (y - 
         cylcenter[[2]])^2 <= AAOrad && 0 <= (z - 0) <= hCub && 
    x <= cylcenter[[1]], {x, y, z}];
region["cubNoHalfCyl"] = 
 ImplicitRegion[{x, y, z} \[Element] 
    region["cub"] && {x, y, z} \[NotElement] region["halfcyl"], {x, y,
    z}]
RegionPlot3D[
 {region["cubNoHalfCyl"], region["thinshellhalfcyl"]}, 
 PlotPoints -> 100, 
 PlotStyle -> {{Black, Lighting -> "Neutral", 
    Opacity@.8}, {Lighting -> "Neutral", 
    Gray}},(*BoundaryStyle\[Rule]{None,Black},*)Boxed -> False, 
 ImageSize -> 800]

Here's what that produces, from two different angles:

enter image description here enter image description here

As you can see, it's filled with these ugly weird shards. If I plot just the box, you still see them:

RegionPlot3D[Evaluate@region["cub"], 
 PlotStyle -> Directive[Black, Lighting -> "Neutral", Opacity@.8], 
 PlotPoints -> 100]

enter image description here

I tried setting PlotPoints->500, which seems like it shouldn't be necessary. It's still trying to evaluate that for just the box example, so if it completes and looks better I'll amend this.

What's going on?

$\endgroup$
1
$\begingroup$

I associate the shards with wrongly oriented polygons or some other such glitch. Instead of tracking them down, I tried doing a plot with a function instead of a region, and it seemed to work.

rp1 = RegionPlot3D[
   RegionMember[region["cubNoHalfCyl"], {x, y, z}],  (* region function *)
   Evaluate[                                         (* create the domain specs *)
    Sequence @@ 
     PadLeft[RegionBounds@region["cubNoHalfCyl"], {Automatic, 3}, 
      List /@ {x, y, z}]],
   PlotPoints -> 100, Mesh -> None,
   PlotStyle -> {{Black, Lighting -> "Neutral", Opacity@.8}},
   Boxed -> False];

Show[
 RegionPlot3D[region["thinshellhalfcyl"], PlotPoints -> 100, 
  PlotStyle -> {{Lighting -> "Neutral", Gray}}, Boxed -> False],
 rp1,
 PlotRange -> All
 ]

Mathematica graphics

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