计算两条线之间的表面

Computing the surface between two lines

我有下图,我在其中绘制了两个曲面,我想指出它们两个的交点。为此,我执行了以下操作:

zdiff = z1-z2;
C = contours(x,y,zdiff,[0 0]);
xL = C(1, 2:end);
yL = C(2, 2:end);
zL = interp2(x, y, z1, xL, yL);
line(xL, yL, zL, 'Color', 'k', 'LineWidth', 2,'Linestyle','--'); hold on;
line(xL, yL, zeros(size(zL)), 'Color', 'k', 'LineWidth', 2); hold off;

现在,我想绘制实际交点(虚线)与其在 XY 上的投影(实线)之间的垂直面,但我不知道该怎么做那。有什么想法吗?

为什么不手动计算?

类似于(未测试):

Area = 0
for i=1:numel(xL)-1
    base = sqrt(   (xL(i)-xL(i+1))^2 + (yL(i)-yL(i+1))^2);
    Area =Area + base * (zL(i) + zL(i+1))/2;
end;

可能不漂亮,但它是一条单线飞机,它可能会成功。也许您必须调整格式,因为此代码适用于 (1,N) 向量

   xL=(1:100); %size 1 100
   yL=(1:100) ;%size 1 100
   zL=rand(1,100);%size 1 100

   line(xL,yL,zL)
   line(xL,yL,zeros(size(zL)))
   hold on 
   surf(repmat(xL,100,1),repmat(yL,100,1),cell2mat(arrayfun(@(x,y) linspace(x,y,100)',zL,zeros(size(zL)),'UniformOutput',false)))

另一个非常简单的选项:

dist  = (diff(xL).^2+diff(yL).^2).^0.5; %distance between x,y
cdist = [0, cumsum(dist)]; %cumsum of the distance
area  = trapz(cdist,zL); %The area
xL=sin((1:30)/10);  % Data generation for test only. Use your data
yL=cos((1:30)/10);  % Data generation for test only. Use your data
zL=2+xL.*yL;        % Data generation for test only. Use your data
surf([xL;xL],[yL;yL],[zeros(size(zL));zL]); % plot the surface