# Intersection of a ListPlot3D surface with a plane

I'm trying to use Mathematica to analyze some physics data from an experiment, more precisely, I have to fit a 2D data series with a one dimension function.

At the moment I'm able to load and plot correctly all the data, using the following command:

ListPlot3D[Img3, Mesh -> 20, PlotStyle -> Orange, InterpolationOrder -> 2,
MaxPlotPoints -> 150]


Where Img3 is a list with about 523000 {x, y, z} points. I obtain the following 3-D plot:  I would like to make a section of the plotted surface with a vertical plane (and I will have to adjust the vertical plane x,y direction to obtain a good cross intersection with the little "waves" on the top of the surface), and fit the profile of the intersection with a gaussian function + another function (this 3Dplot is the intensity profile of two interfering laser beams).

Is that possible? I've looked around a lot to search how to do it, but I didn't find anything that matches with my needs, right now I'm not able to get the profile of the intersection of this ListPlot3D surface with a plane. (I will manage by my own to fit the profile)

I guess what you are looking for can be easily achieved (and adjusted) with the RegionFunction option. Let me give an example using Plot3D. It should work similarly with ListPlot3D:

 Manipulate[
Plot3D[Sin[10 x + 0.1 y]^2*Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2},
PlotRange -> {Automatic, Automatic, {0, 1}},
PlotPoints -> 25,
RegionFunction -> Function[{x, y, z}, z < height],
BoundaryStyle -> Directive[Thick, Red]
],
{{height, 1}, 0, 1}
] ### Edit

@MarcoB just pointed out that you are not interested in a graphics but the points of your cross section. One pretty easy way to get started is to forget the ListPlot3D and just concentrate on what you want:

A contour of your function in a certain height z. So let's do this instead and extract the points of those contours. I'm using the exact same function and it should work for you too when you use ListContourPlot:

gr = ContourPlot[
Sin[10 x + 0.1 y]^2*Exp[-(x^2 + y^2)] - .3 == 0, {x, -2, 2}, {y, -2,
2}, PlotPoints -> 50, MaxRecursion -> 3] Now we use the fact that those closed contours are stored as separate point list. The variable section will be a list of paths, where each path is a list of 2d points:

sections = Cases[Normal[gr], Line[pts__] :> pts, Infinity];
ListLinePlot[sections] • Would it be possible to extract the numerical values corresponding to those boundaries from the OP's ListPlot3D or from the data itself, however? My understanding of the question was that the OP needed to extract the shape of those profiles to be able to fit them to his expression. – MarcoB May 17 '15 at 23:42
• @MarcoB I see. Finding and tracing the contours so that you get a (interpolating) function or a path of points is a different story. It can be done by extracting the points from a contour plot, but I'm not sure I would rely on this for a scientific project. – halirutan May 18 '15 at 0:15
• Looks great! Thank you for following up on this point. As for the robustness of this approach when fed experimental data, I guess that will be for the OP to investigate. (+1, of course) – MarcoB May 18 '15 at 0:29
• My interpretation of the question was that he wanted to slice the surface with a plane perpendicular to the $x$-$y$ plane, so I thought he could form an InterpolatingFunction[] from his data, and then maybe apply that to the result of RotationMatrix[θ].({x, y} - pt) for some value of θ and pt. – J. M.'s technical difficulties May 18 '15 at 3:44
• @Guesswhoitis. If this is the case then the problem is of course much easier. – halirutan May 18 '15 at 7:11