计算很简单,应该是要求画图
程序比较粗糙 但是符合妖气
w=input('请输入射角:(以角度计)')
w=w*pi/180;
n=input('请输入介质的折射率:')
zheshejiao=asin(sin(w)/n);
fprintf('折射角=%4.2f\n', zheshejiao*180/pi)
a=0:0.01:2*pi;
rx=1+sqrt(2)*cos(a);
ry=1+sqrt(2)*sin(a);
%w=60*pi/180
%n=1.5
%zheshejiao=asin(sin(w)/n)
b=0:2;
rrx=b*cos(w+pi/4+pi);
rry=b*sin(w+pi/4+pi);
b=-1:2;
rfx=-b;
rfy=rfx;
b=-2:2;
rnx=-b;
rny=-rnx;
px=sqrt(2)*cos(zheshejiao)*2*cos(zheshejiao+pi/4);
py=sqrt(2)*cos(zheshejiao)*2*sin(zheshejiao+pi/4);
%e1=(px-1)^2+(py-1)^2-2
b=0:0.01:px;
rzx=b;
rzy=b*py/px;
k1=(py-1)/(px-1);
b=(min(px,1)+(px<1)*(-0.2)):0.01:(max(px,1)+(px>1)*0.2);
xxx=b;
yyy=(b-1)*k1+1;
k2=-1/k1;
b=(-0.5+px):0.01:(0.5+px);
rnxx=b;
rnyy=(b-px)*k2+py;
chu=asin(n*sin(zheshejiao));
jiao=atan(k1);
k3=tan(jiao-chu);
b=px:0.01:(px+1);
rcx=b;
rcy=(b-px)*k3+py;
plot(rx,ry,rrx,rry,rfx,rfy,rnx,rny,rzx,rzy,xxx,yyy,rnxx,rnyy,rcx,rcy)
z=-3:3;
zz=[0 0 0 0 0 0 0];
line(z,zz)
line(zz,z)
axis('square','equal')