[英]MATLAB intersection of 2 surfaces
我认为自己是MATLAB的初学者,所以如果我的问题的答案很明显,请多多包涵。
Phi=0:pi/100:2*pi;
Theta=0:pi/100:2*pi;
[PHI,THETA]=meshgrid(Phi,Theta);
R=(1 + cos(PHI).*cos(PHI)).*(1 + cos(THETA).*cos(THETA));
[X,Y,Z]=sph2cart(THETA,PHI,R);
surf(X,Y,Z); %display
hold on;
x1=-4:.1:4;
[X1,Y1] = meshgrid(x1);
a=1.8; b=0; c=3; d=0;
Z1=(d- a * X1 - b * Y1)/c;
shading flat;
surf(X1,Y1,Z1);
我已经编写了这段代码,该代码绘制了与花生形物体成一定角度相交的平面的3d笛卡尔图。
我需要在2D上获得这些的相交(将成为花生的轮廓,但是由于相交是倾斜的,所以有点偏斜),但不知道如何。
谢谢
如果只想获取相交曲线,可以将曲面的坐标插入平面方程中,并找到几乎位于平面中的点。
%# find the distance of `X,Y,Z` to the plane
dist2plane = a*X(:)+b*Y(:)+c*Z(:)-d;
%# find index of the small distances
lowDistIdx = abs(dist2plane)<0.05; %# or some other distance threshold
%# plot the result - note that it's not quite a peanut
figure,plot3(X(lowDistIdx),Y(lowDistIdx),Z(lowDistIdx),'.')
如果要在2D中使用这些坐标,则需要进行坐标转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.