2

I am trying to plot a "wavy" cuboid with a hole in it. The final result does not look great because of jagged edges of the cylindrical hole. Are there any ways to fix it?

I have tried to increase the PlotPoints option to 150 but it is taking nearly a minute without significant improvements.

Is there a smarter way to circumvent this problem?

My code is attached below (MMA 13.1):

RegionPlot3D[z > Sin[x + y^2]/10 && z < 2 + Sin[x + y^2]/10 && (x - 1)^2 + y^2 > 1,
 {x,-5, 5}, {y, -5, 5}, {z, -1, 7}, PlotPoints -> 100, MeshStyle -> None]

Result: enter image description here

1 Answers1

1

With a restricted z range, I get the following picture:

RegionPlot3D[
 z > Sin[x + y^2]/10 && 
  z < 2 + Sin[x + y^2]/10 && (x - 1)^2 + y^2 > 1, {x, -5, 5}, {y, -5, 
  5}, {z, -0.5, 2.5}, PlotPoints -> 100, MeshStyle -> None]

enter image description here

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
  • Maybe I am missing the obvious, but isn't the cylindrical hole still jagged in the picture you've attached? Also, I have other elements on my plot (that I have not included), so I would like the z plot range to be a little larger, in case that changes anything. – Mohit Kumar Jan 02 '24 at 19:50
  • Simply increase PlotPoints. You may increase the z range, this does change nothing essential. – Daniel Huber Jan 02 '24 at 19:59
  • Okay, so looks like it means that increasing PlotPoints is the only way to go. (My question specifically asked for ways apart from this approach because it takes more and more time.) – Mohit Kumar Jan 02 '24 at 20:07
  • 1
    It may be possible to get refinement at the cylinder intersection with BoundaryMeshRegion where you specify finely spaced vertices and edges along the intersections programmatically--or programmatically with a MeshRefinementFunction. It would be tedious. – Craig Carter Jan 02 '24 at 20:32