Description
I am looking to visualize gas cloud growth within custom modules.
For demonstration purpose, it is assumed gas cloud takes a spherical shape whilst module is defined using a Polygon
.
Among many other things, I struggle to extend RegionIntersection
to include the entire Polygon
as to visualize how gas cloud fills up the available volume.
Please see example below.
Example
Code
DynamicModule[
{radius = 1,
region = {{{0, 0, 0}, {5, 0, 0}, {5, 5, 0}, {4, 5, 0}, {4, 8, 0}, {0, 8, 0}}, {{5, 0, 0}, {5, 0, 5}, {5, 5, 5}, {5, 5, 0}}, {{0, 0, 0}, {0, 0, 5}, {5, 0, 5}, {5, 0, 0}}, {{5, 5, 0}, {5, 5, 5}, {4, 5, 5}, {4, 5, 0}}, {{4, 5, 0}, {4, 5, 5}, {4, 8, 5}, {4, 8, 0}}, {{4, 8, 0}, {4, 8, 5}, {0, 8, 5}, {0, 8, 0}}, {{0, 0, 0}, {0, 0, 5}, {0, 8, 5}, {0, 8, 0}}, {{0, 0, 5}, {5, 0, 5}, {5, 5, 5}, {4, 5, 5}, {4, 8, 5}, {0, 8, 5}}}
},
Labeled[
Panel @ Column[{
(*Controls*)
Manipulator[Dynamic @ radius, {1, 10, 1}],
(*Visual*)
Dynamic @ Show[{
Graphics3D @ {Opacity @ 0.3, Polygon @ region},
(*In RegionIntersection, I use Cuboid to demonstrate what I am after. I would like to replace it with whatever magic necessary to include the entire Polygon*)
RegionPlot3D @ RegionIntersection[Ball[{2, 2, 2}, radius], Cuboid[{0, 0, 0}, {5, 5, 5}]]
},
Boxed -> False,
ImageSize -> Medium]
},
Alignment -> Center],
Style["Example", 24], Top]
]
Output
Objective
Essently, I am looking to replace that Cuboid[{0,0,0},{5,5,5}]
with something that would allow me to include the entire Polygon
. Also, it would be great if solution would be flexible to take any 3D Polygon
as a module.
Issues
I.1 [resolved] - A level of confusion has been experienced when messing around with discretization. When deriving regions using spheres, the result differed from what has been initially expected. See code and output below:
Code
GraphicsRow @ {DiscretizeRegion @
RegionDifference[Sphere[{0, 0, 0}, 1], Sphere[{1, 0, 0}, 1]],
DiscretizeRegion @
RegionUnion[Sphere[{0, 0, 0}, 1], Sphere[{1, 0, 0}, 1]]}
Output
Whilst I was expecting output such as below.
Code
GraphicsRow @ {DiscretizeRegion @
RegionDifference[Ball[{0, 0, 0}, 1], Ball[{1, 0, 0}, 1]],
DiscretizeRegion @
RegionUnion[Ball[{0, 0, 0}, 1], Ball[{1, 0, 0}, 1]]}
Output
Although this issue has been resolved, I am not entirely sure why outputs with Ball
and Sphere
differ. I would be greatful if someone could expand on this matter or provide some reference to read about it.
Ball[]
is a three dimensional solid, andSphere[]
is only the surface (by analogy withDisk[]
andCircle[]
). $\endgroup$ – J. M.'s ennui♦ Jun 9 '16 at 13:39Sphere[]
is treated as a solid is because it's noted here: reference.wolfram.com/language/guide/SolidGeometry.html. That's probably the reason why I cannot get myRegionIntersection[..]
to work $\endgroup$ – e.doroskevic Jun 9 '16 at 13:44