3D plot intersection with plane

6 vues (au cours des 30 derniers jours)
Rebecca Vos
Rebecca Vos le 1 Avr 2016
Commenté : Rebecca Vos le 1 Avr 2016
Hello!
So I have a 3D surface, (lots of x,y,z, points) and I want to somehow export the intersection of that surface with a plane.
The trouble I have is that:
1. I'm not 100% sure how to define the plane (but at the moment I'm just specifying the corners - something like specifying the normal, size and position would be better).
2. I have no idea how to get the 2D intersection from my data. - I feel like I should do something like interpolate the 3D data, then export the line where the 3D data = the plane?? I don't want to use something interactive like a gui method as I'll need to do this many times - it'll happen in a loop at different locations.
Thanks in advance for any help!
my code so far:
data = csvread(filename,1,0); % first line is headers
xdata = data(:,4);
ydata = data(:,5);
zdata = data(:,6);
scatter3(xdata,ydata,zdata,'.')
hold on
pointA = [-40,60,10];
pointB = [40,-20,10];
pointC = [40,160,10];
points=[pointA' pointB' pointC'];
fill3(points(1,:),points(2,:),points(3,:),'r')
grid on
alpha(0.3)

Réponses (1)

John D'Errico
John D'Errico le 1 Avr 2016
No. You don't have a surface. You have scattered data points, that your eye chooses to see as a surface. The two are VERY DIFFERENT things.
A simple solution, that will work SOME of the time, is to rotate the problem so the plane lies parallel to two of the axes, so rotate your scattered data too. Now, IF after rotation, your surface still represents a single valued function, then use an interpolation tool like griddata. Finally, the intersection that you desire is now simply a contour plot (i.e., level contour of the rotated surface.) You can then undo the planar rotation to recover the desired intersection in the original space.
A better scheme is to form a meshed surface from your original data. This surface would be composed of a set of triangles in the 3-d domain of your data. Then you would find which triangles the plane passes through, as a set of line segments. In aggregate, that will be the intersection you desire.
  2 commentaires
Rebecca Vos
Rebecca Vos le 1 Avr 2016
I tried to use meshgrid to make it a "proper" surface, but it wouldn't work becaue there are too many points. Could you suggest something else?
Rebecca Vos
Rebecca Vos le 1 Avr 2016
I have tried this but now my data is no longer a "tube-y" shape - just a single surface.
[xcoords,ycoords] = meshgrid(-40:40,-100:200); vq = griddata(xdata,ydata,zdata,xcoords,ycoords);
figure(3) surf(vq)

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by