用matlab画球谐函数 dz2 图像出错

游戏攻略05

用matlab画球谐函数 dz2 图像出错,第1张

用matlab画球谐函数 dz2 图像出错
导读:原因分析你把公式错了,得到的图当然有问题。把最后的一句y=sqrt(5/16/pi)abs(3cos (theta)cos (theta)cos(phi));改成y=sqrt(5/16/pi)abs(3cos(theta)cos(thet

原因分析

你把公式输错了,得到的图当然有问题。

把最后的一句

y=sqrt(5/16/pi)abs(3cos (theta)cos (theta)cos(phi));

改成

y=sqrt(5/16/pi)abs(3cos(theta)cos(theta)-1);

即可(不知你原来的公式从哪里来的?)

 

 

进一步改进

我给稍微调整了一下视角,并加了光照效果,可能更接近原图:

function y
figure;
p=-pi:pi/100:pi;t=0:2pi/150:pi;[P,T]=meshgrid(p,t);
theta=pi/2-P;phi=T;
R=Ypz(theta,phi);[X,Y,Z]=sph2cart(T,P,R);
surf(X,Y,Z,'facecolor',[0 7 1],'edgecolor','none');
light
lighting phong
material shiny
axis equal;
view(60,15)
xlabel('X');ylabel('Y');zlabel('Z');title('Y_{dz^2}')
function y=Ypz(theta,phi);
y=sqrt(5/16/pi)abs(3cos(theta)cos(theta)-1);