|
小例子:球与平面的交线.
不一样的曲面如果有具体函数,就把程序中的w1,w2,表达式换掉,一样可以画出交线来
syms x y;
w1=sqrt(25-x^2-y^2);%曲面1的函数表达式
w2=-0.1*x-0.1*y+3; %曲面2的函数表达式
k=1;
[a,b]=meshgrid([-6:k:6],[-6:k:6]);
z1=double(subs(w1,{'x','y'},{a,b}));
a1=find(imag(z1));z1(a1)=NaN;
z2=double(subs(w2,{'x','y'},{a,b}));
a2=find(imag(z2));z2(a2)=NaN;
h1=surf(a,b,z1);hold on;
h2=surf(a,b,z2);shading flat
g=find(abs(z1-z2)<=10.^(-2));
while length(g)<200
a=[];b=[];
k=k/4;[a,b]=meshgrid([-6:k:6],[-6:k:6]);
z1=double(subs(w1,{'x','y'},{a,b}));
a1=find(imag(z1));z1(a1)=NaN;
z2=double(subs(w2,{'x','y'},{a,b}));
a2=find(imag(z2));z2(a2)=NaN;
g=find(abs(z1-z2)<=10.^(-2));
end
plot3(a(g),b(g),z2(g),'*black');axis equal;
[ 本帖最后由 donkeyxu 于 2007-11-8 20:08 编辑 ] |
|