Message Boards Message Boards

0
|
3710 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to make the cutting edge smooth in Region?

I want to extrude a cylinder through a ball with the following code

r = 4;
Region[Ball[{0, 0, 0}, r]]
Region[Cylinder[{{0, 0, -5}, {0, 0, 5}}, Sqrt[r^2 - 9]]]
R = RegionDifference[Region[Ball[{0, 0, 0}, r]], 
  Region[Cylinder[{{0, 0, -5}, {0, 0, 5}}, Sqrt[r^2 - 9]]]]
Region[R]

However the cutting edge is not smooth
How can I improve the image ?
enter image description here

4 Replies

Thank you

Thank you very much for your reply. So the key function is DiscretizeRegion before any region difference action.

Posted 3 years ago

I don't have real knowledge of why, but experience shows me that for visualizing or 3d printing, it's best to Discretize before applying region logic. You can improve RegionPlot somewhat with PlotPoints, but it becomes very time-expensive to get anything with tolerable accuracy.

The Discretize* functions also allow you to control accuracy, e.g. MaxCellMeasure option. This also adds time, but seems much less expensive than PlotPoints + RegionPlot.

If your surface is amenable to Graphics (like with Plot3D, ParametricPlot3D, or assembling graphics primitives), then DiscretizeGraphics is often even better than DiscretizeRegion.

Anyway, to demonstrate MaxCellMeasure, compare this:

RegionDifference[
  DiscretizeRegion[Ball[{0, 0, 0}, r]], 
  DiscretizeRegion[Cylinder[{{0, 0, -5}, {0, 0, 5}}, Sqrt[r^2 - 9]]]]

to this:

RegionDifference[
 DiscretizeRegion[Ball[{0, 0, 0}, r], MaxCellMeasure -> .005], 
 DiscretizeRegion[Cylinder[{{0, 0, -5}, {0, 0, 5}}, Sqrt[r^2 - 9]], MaxCellMeasure -> .005]]
POSTED BY: Eric Rimbey

This gives a smooth edge, but don't ask me why:

RegionPlot3D[RegionDifference[
  DiscretizeRegion@Ball[{0, 0, 0}, 4], 
  DiscretizeRegion@Cylinder[{{0, 0, -5}, {0, 0, 5}}, Sqrt[4^2 - 9]]]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract