資源簡介
該程序通過蒙特卡洛模擬光聲成像的過程 ,能夠反應光子的運動。

代碼片段和文件信息
function?output=iterat(inputstep)?
input=[000000];
x=input(1);y=input(2);z=input(3);ux=input(4);uy=input(5);uz=input(6);?
g=0.8;?
step=0.49383;
step=step*log10(rand())/log10(2.71828);?
if?(step>5)?
????step=5;?
end?
l=step;%步長?
?
e1=rand(1);?
e2=rand(1);?
if(g==0)?
????costheta=2*e1-1;?
else?
????costheta=(1+g^2-((1-g^2)/(1-g+2*g*e1))^2)/2/g;?
end?
fai=2*pi*e2;?
sinfai=sin(fai);?
cosfai=cos(fai);?
sintheta=(1-(costheta)^2)^0.5;?
if?(abs(uz)<=0.99999)?
????uxx=(sintheta/(1-uz^2)^0.5)*(ux*uz*cosfai-uy*sinfai)+ux*costheta;?
????uyy=(sintheta/(1-uz^2)^0.5)*(uy*uz*cosfai+ux*sinfai)+uy*costheta;?
????uzz=-(1-uz^2)^0.5*sintheta*cosfai+uz*costheta;?
else?
????uxx=sintheta*sinfai?
????uyy=sintheta*sinfai?
????uzz=sign(uz)*costheta?
end?
uuxx=uxx/(uxx^2+uyy^2+uzz^2)^0.5;?
uuyy=uyy/(uxx^2+uyy^2+uzz^2)^0.5;?
uuzz=uzz/(uxx^2+uyy^2+uzz^2)^0.5;?
xx=x+l*uuxx;?
yy=y+l*uuyy;?
zz=z+l*uuzz;?
output=[xx?yy?zz?uuxx?uuyy?uuzz];
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????965??2010-11-30?13:29??mc模擬光聲成像\iterat.m
?????文件???????5495??2010-11-30?14:52??mc模擬光聲成像\mc.m
?????目錄??????????0??2001-05-14?16:32??mc模擬光聲成像
-----------?---------??----------?-----??----
?????????????????6460????????????????????3
- 上一篇:五子棋prolog實現
- 下一篇:冒險島手型鼠標.rar
評論
共有 條評論