1、从光疏介质射入光密介质(n1 = 1,n2 = 1.5)
clear;
clc;
theta1 = 0:pi/20:pi/2; %theta1 is an angle of incidence
%光由光疏介质射入光密介质
n1 = 1;
n2 = 1.5;
n = n1/n2;
Y0 = 0 * theta1; %参考0轴
% theta2 = asin(n1*sin(theta1));%theta1 is a refraction angle
rs = (n*cos(theta1)-sqrt(1-n.^2*(sin(theta1)).^2))./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));
rp = (cos(theta1)-n*sqrt(1-n.^2*(sin(theta1)).^2))./(cos(theta1)+n*sqrt(1-(n*sin(theta1)).^2));
plot(theta1,rs,'b',theta1,rp,'r',theta1,Y0,'b'); %rs&rp曲线
%%%%%%%%%%%%%%%%%%
hold on;
ts = 2*n*cos(theta1)./(cos(theta1)+n*sqrt(1-(n*sin(theta1).^2)));
tp = 2*n*cos(theta1)./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));
plot(theta1,ts,'g',theta1,tp,'b'); %ts&tp曲线
%标注
h = text(0,-0.2,' \leftarrow rs');
set(h,'Fontsize',16);
h = text(0,0.2,' \leftarrow rp');
set(h,'Fontsize',16);
h = text(1,2*n*cos(1)./(cos(1)+n*sqrt(1-(n*sin(1).^2))),' \leftarrow ts');
set(h,'Fontsize',16);
h = text(1,2*n*cos(1)./(n*cos(1)+sqrt(1-(n*sin(1)).^2)),' \leftarrow tp');
set(h,'Fontsize',16);
legend('rs','rp','tp','ts');
axis([0,pi/2,-1,1]); %限制坐标轴的范围
set(gca,'XTick',0:pi/20:pi/2);%%设置标度:设置X轴最小标度为pi/20
set(gca,'YTick',-1:0.2:1);%%设置标度:设置Y轴最小标度为0.4
grid on;
xlabel('theta1');
title('高光作业-从光疏介质射入光密介质');
2、从光密介质射入光疏介质(n1 = 1.5,n2 = 1)
clear;
clc;
%光由光疏介质射入光密介质
n1 = 1.5;
n2 = 1;
n = n1/n2;
theta1 = 0:pi/20:asin(n2/n1); %之后是全反射现象n1sintheta1 = n2sin90
Y0 = 0 * theta1; %参考0轴
hold on;
% theta2 = asin(n1*sin(theta1));%theta1 is a refraction angle
rs = (n*cos(theta1)-sqrt(1-n.^2*(sin(theta1)).^2))./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));
rp = (cos(theta1)-n*sqrt(1-n.^2*(sin(theta1)).^2))./(cos(theta1)+n*sqrt(1-(n*sin(theta1)).^2));
plot(theta1,rs,'b',theta1,rp,'r'); %rs&rp曲线
%%%%%%%%%%%%%%%%%%
hold on;
ts = 2*n*cos(theta1)./(cos(theta1)+n*sqrt(1-(n*sin(theta1).^2)));
tp = 2*n*cos(theta1)./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));
plot(theta1,ts,'g',theta1,tp,'M'); %ts&tp曲线
%标注
h = text(0.45,(n*cos(0.45)-sqrt(1-n.^2*(sin(0.45)).^2))./(n*cos(0.45)+sqrt(1-(n*sin(0.45)).^2)),' \leftarrow rs');
set(h,'Fontsize',16);
h = text(0.5,(cos(0.5)-n*sqrt(1-n.^2*(sin(0.5)).^2))./(cos(0.5)+n*sqrt(1-(n*sin(0.5)).^2)),' \leftarrow rp');
set(h,'Fontsize',16);
h = text(0.45,2*n*cos(0.45)./(cos(0.45)+n*sqrt(1-(n*sin(0.45).^2))),' \leftarrow ts');
set(h,'Fontsize',16);
h = text(0.6,2*n*cos(0.6)./(n*cos(0.6)+sqrt(1-(n*sin(0.6)).^2)),' \leftarrow tp');
set(h,'Fontsize',16);
legend('rs','rp','ts','tp'); %标注
theta = 0:0.3:1.2;
plot(theta,Y0,'black');
axis([0,0.95,-1,2]); %限制坐标轴的范围
set(gca,'XTick',0:pi/20:0.95);%%设置标度:设置X轴最小标度为pi/20
set(gca,'YTick',-1:0.3:2);%%设置标度:设置Y轴最小标度为0.4
grid on;
xlabel('theta1');
title('高光作业-从光密介质射入光疏介质');