How to find Intersection of 2 surfaces ?

조회 수: 9 (최근 30일)
Jay Talreja
Jay Talreja 2021년 12월 24일
댓글: Jay Talreja 2021년 12월 27일
Hello
I have two surface made from discreate data. I want to find the cordinates of intersecting line. The surface are named as
Surface1 = (A1,A2,C)
Surface2 = (B1,B2,C)
My problem is that as data is discreate so I am not able to know the precise intersecting points of the surface.
For reference I have attached the file.
I want to find cordinates of this particular line.
Thanks in Advance
  댓글 수: 2
Matt J
Matt J 2021년 12월 24일
편집: Matt J 2021년 12월 24일
Which is X, which is Y, and which is Z?
Jay Talreja
Jay Talreja 2021년 12월 27일
X is A1 and A2.
Y is B1 and B2
Z is C which is same for both graphs.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2021년 12월 24일
편집: Matt J 2021년 12월 27일
One way,
load data
F1=griddedInterpolant({A1,A2},C,'linear','none');
F2=griddedInterpolant({B1,B2},C,'linear','none');
figure(1)
surf(A1,A2,C','FaceColor', [0 0 1],'EdgeColor','none','FaceAlpha',1)
hold on
surf(B1,B2,C','FaceColor', [1 0 0],'EdgeColor','none','FaceAlpha',1)
xlabel x; ylabel y; view(-30,50); axis vis3d
xl=xlim; yl=ylim;
x=linspace(xl(1),xl(2),500);
y=linspace(yl(1),yl(2),500);
C1=F1({x,y});
C2=F2({x,y});
cm=contourc(x,y,(C1-C2)',[0,0]);
[~,coords]=getContourLineCoordinates(cm);
for i=1:numel(coords)
tmp=coords{i};
tmp(:,3)=F2(tmp);
coords{i}=num2cell(tmp,1); %coordinates of the surface intersection
end
for i=1:numel(coords)
[x,y,z]=deal(coords{i}{:});
line(x,y,z,'Color','g','LineWidth',3);
end
hold off
  댓글 수: 3
Matt J
Matt J 2021년 12월 27일
The intersection line which I see from that I need their cordinates. I was unable to to find the variables where these values are stored
I had thought that XData, YData would give you the coordinates, but apparently I was wrong. I have updated my answer, using Adam Danz's File Exchange tool that you referenced. It works well, as the plot shows.
I there a way that I can see this contour line on my actual graph.
That is now demonstrated.
Jay Talreja
Jay Talreja 2021년 12월 27일
Yes now it is working as excepted. Thanks for help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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