# Region Intersection for MeshRegion objects embedded in 3D

How can I create a logical intersection of MeshRegion objects that are three-dimensional? The RegionIntersection function will not work (see "possible issues" in the Mathematica documentation https://reference.wolfram.com/language/ref/RegionIntersection.html).

I know that RegionPlot3D allows logical operators - perhaps there is a way to plot the MeshRegions to a RegionPlot3D and use logical operators to create an intersection?

Something else I thought may work is checking for region membership in all the regions I want to intersect of the tetrahedra making up the mesh region, but RegionMember only checks membership of points.

The types of MeshRegions I am working with are 3D Delaunay, for example

DelaunayMesh@RandomReal[{-1, 1}, {25, 3}]


EDIT: I tried to use this solution as suggested in the comments, but it only seems to work for two polyhedra that have the same general shape: only one variable is used for how the vertices should be connected ("faces"). Also, I cannot fully understand the method by which the intersection points were found. It seems to rely on the fact that z convex polyhedron can be defined algebraically as the set of solutions to a system of linear inequalities (see here). Is there perhaps a simpler way?

• I assume you're using 3D Delaunay meshes and they are convex, you have the convenient result that the intersection of two convex sets is also a convex set, so it would be the convex hull of the intersection points. You can already get the intersection points as per this answer using graphics and then just take the convex hull of those points Commented May 29, 2015 at 1:15

In my experience, BoundaryMeshRegions are described by the components of their boundaries. in three dimensions, the boundary components are generally polygons. These regions are filled. MeshRegions are described by their space filling components of their boundaries. in three dimensions, the volume coponents are generally tetrahedrons. These regions are not filled.

Continuing, DelauneyMesh output is a MeshRegion. To do the volume intersection that I believe that you desire, you need BoundaryMeshRegions instead. You can use BoundaryDiscretizeRegion to do the needed conversion.

Then, the RegionIntersection goes smoothly.

The remainder of the code is demonstration and documentation.

regions = BoundaryDiscretizeRegion /@
Table[DelaunayMesh[RandomReal[{-1, 1}, {25, 3}]], 3]
common = RegionIntersection @@ regions
outside = (RegionDifference[#1, common] & ) /@ regions
ImageAssemble[(Show[{Graphics3D[{Opacity[0.2], Red, #1}],
Graphics3D[{Opacity[0.2], Green, common}]}] & ) /@
outside, "Fit", Background -> 1]

\$Version
StringSplit[StringReplace[Import["!wmic os get Caption,Version", "String"], "\r" -> ""], "\n"][[2]]
Map[StringTrim, StringSplit[StringReplace[Import["!wmic cpu get NumberOfCores", "String"], "\r" -> ""], "\n"]]
Map[StringTrim, StringSplit[Select[StringSplit[StringReplace[Import["!Reg Query \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "String"], "\r" -> ""], "\n"], StringContainsQ[#, "DisplayVersion"] &]][[1, {1, -1}]]]


13.2.1 for Microsoft Windows (64-bit) (January 27, 2023)
Microsoft Windows 10 Pro 10.0.19045
{NumberOfCores,8}
{DisplayVersion,22H2}

I may not have understood what you actually desired. If so, then, ask another question, preferably with Mathematica that sets up the problem.

Of course, I may have missed something.