Create intersection between surface and oriented planes

11 次查看(过去 30 天)
Hi, i am new in Matlab. I would like to know the easiest way to obtain intersection profiles (sort of cross sections) between a complex surface obtained by a point cloud and a series of vertical planes oriented at defined angles compared to the grid and spacing. The purpose will be to perform a best fit analysis of each intersection profile, compare and analyse the results. Thanks and regards
Fabio

回答(1 个)

Mike Garrity
Mike Garrity 2015-12-8
How is your surface defined? A patch object? Are the faces triangles, or perhaps quads?
This blog post covers a related case. You'll need to change things a bit to fit what you're doing.
The basic idea is that you use the plane equation to compute a signed distance from the plane at each vertex in your mesh. Depending on the representation of your planes, that's probably something like:
for i=1:nvert
d(i) = dot(vert(i,:), plane(1:3)) - plane(4);
end
Now you need to look at each face. I'll consider the triangular face case, since it's the simplest. If the 3 vertices of the face all have positive or all have negative distances, then you can ignore the face. If the one vertex has the opposite sign of the other two, then you need to look at the two edges that connect that vertex to the other two. Let's say that we know that vertex i2 has opposite sign from vertex i1 (i1 & i2 are integer indices into the vertex array). Then that edge crosses the plane at the vertex defined by:
t = (0 - d(i2)) / (d(i1) - d(i2)); % between 0 & 1
pt = vert(i2,:) + t*(vert(i1,:) - vert(i2,:));
Since you're doing this for two edges on that triangular face, you'll get two vertices. Connect those with a line. Once you've done this for all of your faces, you'll have a set of lines which trace out the intersection.
If your faces are quads, then it's basically the same, but you'll have some special cases and degenerate to worry about.
Depending on your usage, you might want to connect the lines to form a continuous curve. That can be a bit tricky. One way is to do a spatial search to connect them all. That gets really expensive.
A more efficient way is to an old MATLAB graphics programming trick. Create a sparse array. Every time you create a line segment, save it in an array and put the index into that array into the sparse matrix, indexed by the i1 and i2 you used to create each of the end points. Now, when you create another line from an edge between those two vertices, you can use the sparse array to find the first one and then you can connect them. Did that make any sense?
I hope that helps. Just ask here on MATLAB Answers if you get stuck.
  4 个评论
Mike Garrity
Mike Garrity 2015-12-9
编辑:Mike Garrity 2015-12-9
I should point out that I could also have computed z2 there by substituting x2 and y2 into the plane equation and solving for z. That would probably be much more robust than using interp2, except for the case where the plane is almost normal to the XY plane, which is the case I think you're talking about.
Vignesh Suresh
Vignesh Suresh 2018-6-11
Hi Mike, I am kind of stuck with the same problem. I need to extract the intersection profile of the plane and surface. How to extract the intersection zone as a separate 2D graph.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by