1
$\begingroup$

I have this 3D image where on top(below) there is a hemisphere(blue) and an inner cylinder(green), you can see there is some overlap/artifact being displayed. How can I remove this?

r = 0.5;
rbelow = 0.5;
dbelow = {0, 0, -1.5};
rabove = 0.5;
dabove = {0, 0, 1.5};
HemisphereBelow = ParametricPlot3D[rbelow {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]} + dbelow, {u, -\[Pi]/2, \[Pi]/2}, {v, -\[Pi]/2, \[Pi]/2}, PlotPoints -> {25, 25}, PlotStyle -> Blue, Boxed -> False, Axes -> None][[1]];
HemisphereAbove = ParametricPlot3D[rabove {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]} + dabove, {u, -\[Pi]/2, \[Pi]/2}, {v, \[Pi]/2, 3 \[Pi]/2}, PlotPoints -> {25, 25}, PlotStyle -> Blue, Boxed -> False, Axes -> None][[1]];
InnerCylinder = ParametricPlot3D[{r Cos[u], r Sin[u], z}, {u, 0, 2 \[Pi]}, {z, -1.5, 1.5}, PlotPoints -> 25, PlotStyle -> Green, Boxed -> False, Axes -> None][[1]];
QuarterCircleBelow = RevolutionPlot3D[Sqrt[0.5^2 - (r - 1)^2] - 1.5, {r, 0.5, 1}, PlotStyle -> Red, Boxed -> False, Axes -> None][[1]];
QuarterCircleAbove = RevolutionPlot3D[-Sqrt[0.5^2 - (r - 1)^2] + 1.5, {r, 0.5, 1}, PlotStyle -> Red, Boxed -> False, Axes -> None][[1]];
Graphics3D[{Opacity[0.03, Black], Cylinder[{{0, 0, -1.5}, {0, 0, 1.5}}, 1], Opacity[0.4, Green], InnerCylinder, Opacity[0.5, Blue], HemisphereBelow, Opacity[0.5, Blue], HemisphereAbove, Opacity[0.4, Red], QuarterCircleBelow, Opacity[0.4, Red], QuarterCircleAbove, Black, Thickness[0.005], Line[{{0, 0, -1}, {0, 0, 1}}], Black, PointSize[Large], Point[{{0, 0, -0.10}, {0, 0, 0.10}}]}, Boxed -> False]

Image

$\endgroup$

1 Answer 1

2
$\begingroup$

You could just shift slightly the various elements e.g. rbelow =0.49 ?

r = 0.5;
rbelow = 0.49;
dbelow = {0, 0, -1.5};
rabove = 0.49;
dabove = {0, 0, 1.5};
HemisphereBelow = 
  ParametricPlot3D[
    rbelow {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]} + 
     dbelow, {u, -\[Pi]/2, \[Pi]/2}, {v, -\[Pi]/2, \[Pi]/2}, 
    PlotPoints -> {25, 25}, PlotStyle -> Blue, Boxed -> False, 
    Axes -> None][[1]];
HemisphereAbove = 
  ParametricPlot3D[
    rabove {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]} + 
     dabove, {u, -\[Pi]/2, \[Pi]/2}, {v, \[Pi]/2, 3 \[Pi]/2}, 
    PlotPoints -> {25, 25}, PlotStyle -> Blue, Boxed -> False, 
    Axes -> None][[1]];
InnerCylinder = 
  ParametricPlot3D[{r Cos[u], r Sin[u], z}, {u, 0, 2 \[Pi]}, {z, -1.5,
      1.5}, PlotPoints -> 25, PlotStyle -> Green, Boxed -> False, 
    Axes -> None][[1]];
QuarterCircleBelow = 
  RevolutionPlot3D[Sqrt[0.5^2 - (r - 1)^2] - 1.5, {r, 0.5, 1}, 
    PlotStyle -> Red, Boxed -> False, Axes -> None][[1]];
QuarterCircleAbove = 
  RevolutionPlot3D[-Sqrt[0.5^2 - (r - 1)^2] + 1.5, {r, 0.5, 1}, 
    PlotStyle -> Red, Boxed -> False, Axes -> None][[1]];
Graphics3D[{Opacity[0.03, Black], 
  Cylinder[{{0, 0, -1.5}, {0, 0, 1.5}}, 0.99], Opacity[0.4, Green], 
  InnerCylinder, Opacity[0.5, Blue], HemisphereBelow, 
  Opacity[0.5, Blue], HemisphereAbove, Opacity[0.4, Red], 
  QuarterCircleBelow, Opacity[0.4, Red], QuarterCircleAbove, Black, 
  Thickness[0.005], Line[{{0, 0, -1}, {0, 0, 1}}], Black, 
  PointSize[Large], Point[{{0, 0, -0.10}, {0, 0, 0.10}}]}, 
 Boxed -> False]

enter image description here

$\endgroup$
3
  • $\begingroup$ What causes this to happen? Your answer is nice but it tries to avoid this problem for this specific problem only. Is there a general function/command that removes this? $\endgroup$
    – mathemania
    Commented Sep 30, 2021 at 5:19
  • 1
    $\begingroup$ I thought this arises from inconsistency in placements of (nearly) overlapping surfaces. But the Method option "RelieveDPZFighting"->True doesn't help in this case. $\endgroup$
    – tad
    Commented Sep 30, 2021 at 18:11
  • 1
    $\begingroup$ A simpler version of the problem: Graphics3D[{Green, InnerCylinder, Blue, HemisphereAbove}, Boxed -> False] $\endgroup$
    – tad
    Commented Sep 30, 2021 at 18:22

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.