⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iterat.m

📁 用MATLAB编写的蒙特卡罗算法,用于检测光子成象.非常不错,大牛编写!!!!开发环境:MATLAB
💻 M
字号:
function output=iterat(input,step)
x=input(1);y=input(2);z=input(3);ux=input(4);uy=input(5);uz=input(6);
g=0.8;
step=step*log10(rand(1))/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];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -