7
$\begingroup$

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?

$\endgroup$
1
  • 1
    $\begingroup$ 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 $\endgroup$
    – Histograms
    Commented May 29, 2015 at 1:15

1 Answer 1

1
$\begingroup$

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}]]]

Showing the intersection

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

John Paul Jones Battle Cry — “I Have Not Yet Begun to Fight.

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.