# Mesh on cross section of meshes / 2D Region on cross section of 3D Regions

Context

This is fairly general and simple question, (probably because it has a simple solution?). I want to define a mesh (e.g. to be used with Plot3D or FEM or whatever) as the cross section of a surface and a volume. For instance a ball and a plane.

Question

How can I define a mesh on a 2D intersection of two 3D objects?

or its simpler version

How can I define a mesh on a 2D plane intersection through a 3D object?

Attempt

R=RegionIntersection[Ball[],InfinitePlane[{0,0,0},{{1,0,0},{0,1,0}}];
Plot3D[x^2+y^2,{x, y} \[Element] R]


does not work, neither does

  Needs["NDSolveFEM"]
ToElementMesh[R]


while

 R // Region is well defined.

I believe this would be super handy to e.g. to investigate volumes?

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] RegionBounds[R]
{{-1, 1}, {-1, 1}, {0, 0}}


This is why the FEM mesh generation complains. See that this works:

Needs["NDSolveFEM"]
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] • @chris, give it to Chip. I copied the RegionIntersection from him, since there is a syntax error in yours ;-) – user21 Apr 3 at 14:27
• Oops. How would you refine the quality of the contours? – chris Apr 3 at 14:30