如果要切割曲面的平面的法向矢量始終位於xy平面中,則可以將數據沿切片線中的x,y座標插值到曲面上,例如,讓該平面被定義爲從點(0,15)將所述點(50,35)
![enter image description here](https://i.stack.imgur.com/LynvN.png)
% Create Data
z=peaks(50);
% Create x,y coordinates of the data
[x,y]=meshgrid(1:50);
% Plot Data and the slicing plane
surf(z);
hold on
patch([0,0,50,50],[15,15,35,35],[10,-10,-10,10],'w','FaceAlpha',0.7);
% Plot an arbitrary origin axis for the slicing plane, this will be relevant later
plot3([0,0],[15,15],[-10,10],'r','linewidth',3);
因爲它是一個平面,是相對容易獲得在x,y使用linspace
對切片平面進行座標切割,得到100個點,然後將這些100個點插入到原始數據中。
% Create x and y over the slicing plane
xq=linspace(0,50,100);
yq=linspace(15,35,100);
% Interpolate over the surface
zq=interp2(x,y,z,xq,yq);
現在,我們有z的值,我們需要反對什麼陰謀反對他們,這就是你需要定義一個任意原點軸爲您拼接飛機,我在(0,15)定義爲地雷方便起見,然後計算每個x,y對與該軸的距離,然後我們可以將獲得的z與該距離作圖。
dq=sqrt((xq-0).^2 + (yq-15).^2);
plot(dq,zq)
axis([min(dq),max(dq),-10,10]) % to mantain a good perspective
![enter image description here](https://i.stack.imgur.com/m8l7l.png)
幾個問題。您定義的平面是平行於z軸嗎?還是它有三個自由度?而且,如何在輸出圖中定義x軸? –
@NoelSegura我對法向矢量總是在xy平面上的切割平面感興趣。也就是說,一個切割x,y的任何方向但總是垂直的平面。 – ConfusinglyCuriousTheThird