Mesh on cross section of meshes / 2D Region on cross section of 3D Regions
One can use DiscretizeRegion
to obtain a mesh:
slice = DiscretizeRegion[
RegionIntersection[
Ball[],
InfinitePlane[{0, 0, 0}, {{1, 0, 0}, {0, 1, 0}}]
],
MeshCellStyle -> {1 -> Black}
]
Or SliceDensityPlot3D
to get a visual:
SliceDensityPlot3D[1, {"ZStackedPlanes", 10}, {x, y, z} ∈ Ball[], Axes -> False, Boxed -> False]
3D surface plotters like Plot3D
can plot over 2D regions. We can take slice
and project to 2D:
slice2d = MeshRegion[MeshCoordinates[slice][[All, 1;;2]], MeshCells[slice, 2]];
Plot3D[x^2 + y^2, {x, y} ∈ slice2d]
If the 3D slice lies in a different cardinal plane, we'll need to project with different coordinate indices. Here's an example over a y-z plane:
reg = ImplicitRegion[(x^2 + 9/4 y^2 + z^2 - 1)^3 - x^2 z^3 - 9/80 y^2 z^3 <= 0, {x, y, z}];
slice = DiscretizeRegion[RegionIntersection[reg,
InfinitePlane[{0, 0, 0}, {{0, 1, 0}, {0, 0, 1}}]]];
slice2d = MeshRegion[MeshCoordinates[slice][[All, {2, 3}]], MeshCells[slice, 2]];
Plot3D[x^2 + y^2, {x, y} ∈ slice2d]
Note that your region has
RegionBounds[R]
{{-1, 1}, {-1, 1}, {0, 0}}
This is why the FEM mesh generation complains. See that this works:
Needs["NDSolve`FEM`"]
ToBoundaryMesh[R, {{-1, 1}, {-1, 1}, {-1, 1}}]["Wireframe"]
Note the difference in behavior for the embedding dimension of the returned object between DiscretizeRegion
and the ElementMesh
family of functions.
Now, let us consider a different R
. You can visualize the computed values on the intersection.
R = RegionIntersection[Ball[],
InfinitePlane[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}]];
Show[
Graphics3D[{Opacity[0.5], Ball[]}],
SliceContourPlot3D[Exp[-(x^2 + y^2 + z^2)],
R, {x, y, z} \[Element] Ball[]], Boxed -> False]
To refine the contours the Contour
option can be used:
Show[Graphics3D[{Opacity[0.25], Ball[]}],
SliceContourPlot3D[Exp[-(x^2 + y^2 + z^2)],
R, {x, y, z} \[Element] Ball[], Contours -> 25], Boxed -> False]
You can also specify a MeshRegion
R = RegionIntersection[Ball[],
InfinitePlane[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}]];
Show[Graphics3D[{Opacity[0.25], Ball[]}],
SliceContourPlot3D[Exp[-(x^2 + y^2 + z^2)],
DiscretizeRegion[R], {x, y, z} \[Element] Ball[], Contours -> 25],
Boxed -> False]