Plot the intersection line of multiple 'ListContourPlot3D' surfaces?

Hello,

I hope that you can help me with this.

RE and IM are nXnXn matrices (n>100). I am looking for the intersection line between the isosurfaces RE==0 and IM ==0. I am plotting them with

‘ListContourPlot3D’

and I am looking for a function similar to

BoundaryStyle -> {{1,2} -> {{Green,Tube[0.5]}}}

BoundaryStyle is not defined for Lists. My attempts with ‘RegionFunction’ and ‘Mesh’ failed because I do not know where the intersection lines are. Interpolation is not accurate enough and it takes a long time to be computed.

I will appreciate any type of help or suggestion. Thank you.

Danica

Perhaps try to use SliceContourPlot3D (version 10.2 and up), with the second argument being based on an interpolation function? I have not tried it, but might work.. Surface-surface intersection is not that easy to do ‘out of the box’ I think…

Now that I think of it, did you try something similar to:

?

Thank you Sander.

I tried to use

ContourPlot3D[{h == 0, g == 0}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 MeshFunctions -> {Function[{x, y, z, f}, h - g]}, 
 MeshStyle -> {{Thick, Blue}}, Mesh -> {{0}}, 
 ContourStyle -> 
  Directive[Orange, Opacity[0.5], Specularity[White, 30]]]

but in order to build a MeshFunction you have to interpolate the matrices. I have already solved the problem in the following way using Interpolation functions:

ReI=ListInterpolation[RE]

ImI=ListInterpolation[IM]

ContourPlot3D[{ReI[x,y,z] == 0, ImI[x,y,z]== 0},  {x, 25, 65}, {y, 30, 70}, {z, 30,70}, ContourStyle -> Opacity[0.1],   Mesh -> None,BoundaryStyle -> {{1,2} -> {{Green,Tube[0.5]}}}, AxesLabel->{x,y,z},PlotPoints -> 16]

However, as soon as I increase the number of points in ‘PlotPoints’ (the quality of the graph), the memory used is too much and Mathematica quits after few hours.

Is there any way for you to post the data (save as a “*.m” file and upload to gist.github.com) so that we could give it a try?

Perhaps try InterpolationOrder → 1 in the ListInterpolation to speed things up…

I agree, there should be a faster way, but I can’t come up with something…

Another method is to use ListContourPlot3D to our use to create some polygons, and use these polygons to plot our ListSliceContourplot3D:

n=5;
pts=Table[x^2+y^2+z^2-1,{x,Subdivide[-2,2,n]},{y,Subdivide[-2,2,n]},{z,Subdivide[-2,2,n]}];
surf=Table[x^3+y^2-z^2,{x,Subdivide[-2,2,n]},{y,Subdivide[-2,2,n]},{z,Subdivide[-2,2,n]}];
lcp=ListContourPlot3D[surf,DataRange->{{-2,2},{-2,2},{-2,2}},Contours->{0},Mesh->None,BoundaryStyle->None];

gc=FirstCase[lcp,GraphicsComplex[__],{},\[Infinity]];
gc[[2]]=Cases[gc[[2]],Polygon[_],\[Infinity]];
gc=Drop[gc,-1];
pols=Normal[gc];

Graphics3D[pols]

ListSliceContourPlot3D[pts,pols,DataRange->{{-2,2},{-2,2},{-2,2}},Contours->{0},BoundaryStyle->None,ContourShading->None]

Sorry Jason I cannot publish my matrices as they are the result of my research. I could send them to you in private though.

Thank you. I will try this method and check whether it is faster than mine. The 3 things I found and work well are

  • reduce the resolution of my matrices (for example 41x41x41 works quite well) because the interpolating functions will smooth everything anyway;

  • plot less points in my graph (with a smaller range of x,y,z) and use the command ‘PlotPoints’ in the following way

ContourPlot3D[{ReI[x,y,z] == 0, ImI[x,y,z]== 0},
{x, 1, 41}, {y, 1, 41}, {z, 1,41}, ContourStyle → Opacity[0.1],
Mesh → None,BoundaryStyle → {{1,2} → {{Green,Tube[0.5]}}}, AxesLabel->{x,y,z},PlotPoints → 8]

  • decrease the precision (in this case I use the mesh function method)

ContourPlot3D[{ReI[x,y,z] == 0, ImI[x,y,z]== 0},
{x, 1, 41}, {y, 1, 41}, {z, 1,41}, MeshFunctions → {Function[{x, y, z}, ReI[x,y,z] - ImI[x,y,z]]},
MeshStyle → {{Thick, Blue}}, Mesh → {{0}}, ContourStyle → Opacity[0.1],
AxesLabel->{x,y,z},
WorkingPrecision → 2]

In case you have not figured it out yet, perhaps try something along the lines of:

where the surface ‘person’ is a mesh version of the surface of IM==0, and then use ListSliceContourPlot3D with one contour specification to find RE==0…

Thanks Sander for your reply. I am not really sure that I understood what you mean. I am still interested in finding a fast way of plotting these intersection lines, since my method crashes most of the time. Would you mind to write the analogous function ‘person’ for me, please?

Danica