Showing intersection line between several surfaces in a 3D plot

33 views (last 30 days)
Hi all,
I would like to generate a 2D (x,y) plot into which the intersections of 3D surfaces (x,y,z) are projected.
At the moment, I am generating a 3 D plot with all the surfaces in different colors, and then rotate that plot such that the viewer looks along the z axis (i.e. it looks like a 2D plot). Next, I am importing that 2D image into a graphics program, draw the intersection lines manually, and then change the colors of the various surfaces to white.
Is there any better way to do this? Ideally, I'd like MATLAB to show the intersection lines automatically, without the need to do the post-processing in a graphics program.
Thanks for your help!
Sincerely, Patrick

Accepted Answer

John D'Errico
John D'Errico on 9 Mar 2011
If the two surfaces are defined on a rectangular grid, then it is easy to do. Call one of the surfaces f(x,y), the second g(x,y). They are each functions, even though you may not know their functional forms.
The "line" of intersection is a 1-manifold, a level set of points that has the property that
z(x,y) = f(x,y) - g(x,y) = 0.
This set of points lives in the (x,y) plane.
How do you find that set? Use the contour plotting functionality in MATLAB. It can generate the set of points such that the above relationship holds.
I would use the contourc function to return the contour at z = 0. (There may be more than one such curve, so you need to check for that.) Along this manifold in (x,y), you can get the height by interpolation. Use interp2 to find that height at each point.
I would do the plot differently from how you describe though. Plot the two surfaces as semi-transparent surfaces. Set the facealpha (and edgealpha) properties to be less than 1, so you can see through the surfaces. Now just plot the intersection curve as a solid line, in black. It will stand out from the surfaces because you will not plot it as transparent.

More Answers (1)

Patrick
Patrick on 18 Mar 2011
I finally got around to trying this out, thanks a lot for your help!

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!