Light Ray Passing through a Transparent Plate

Manipulate[
(*розрахунок кута між векторами з їх скалярного добутку*)angle[{x1_,y1_},{x0_,y0_},{x2_,y2_}] :=ArcCos[((({x1,y1}-{x0,y0}).({x2,y2}-{x0,y0}))/((Sqrt[(((x1-x0))^2)+(((y1-y0))^2)])(Sqrt[(((x2-x0))^2)+(((y2-y0))^2)])))];
refangle[θ1_,n_]:=If [(1/n)Sin[θ1 ]≥1,π/2,ArcSin[(1/n)Sin[θ1 ]]]//N ;  (*Angle of Refraction at the 1st interface*)
Module[{pleft=-9,pright=9,point1={xpoint1,d},xpoint1,xpoint2,xpoint3,phi0=phi0gr*Degree,phi1},  
 line2[{{x1_,y1_},{x2_,y2_}},{x3_,x4_}]:=Line[{{x3,(y2-y1)/(x2-x1)x3+(x2 y1-x1 y2)/(x2-x1)},{x4,(y2-y1)/(x2-x1)x4+(x2 y1-x1 y2)/(x2-x1)}}];
arrow2[{{x1_,y1_},{x2_,y2_}},{x3_,x4_}]:=Arrow[{{x3,(y2-y1)/(x2-x1)x3+(x2 y1-x1 y2)/(x2-x1)},{x4,(y2-y1)/(x2-x1)x4+(x2 y1-x1 y2)/(x2-x1)}}];(*лінія з початком в т.3, закінченням в т.4  і проходить через точки 1 і 2*)
Graphics[
{(*пластинка*)
{Thick,Line[{{pleft,d},{pright,d}}],Line[{{pleft,0},{pright,0}}],Lighter[Blue,.8/(nred-.13)],Polygon[{{pleft,0},{pleft,d},{pright,d},{pright,0}}]},
(*промінь, що падає на пластину Darker[Red,.4]*)
{Thick,Darker[Red,.4],Arrow[{point1+(11-d){-Sin[phi0],Cos[phi0]},point1}],
(*заломлений промінь*)
Arrow[{point1,{xpoint2=point1[[1]]+d*Tan[phi1=refangle[phi0,nred]],0}}],
arrow2[{{xpoint2,0},{xmax=xpoint2+6*Tan[refangle[angle[point1,{xpoint2,0},{xpoint2,9}],1/nred]],-6}},{xpoint2,If[xmax>9,9,xmax]}]},
(*позначення на малюнку*)
If[pozn,{Thin,Black,Arrowheads[{-.03,.03}],Arrow[{{-8,d},{-8,0}}],Thickness[0.004],Dashed,Line[{{point1[[1]],10},{point1[[1]],-0.1*d}}] , Line[{{xpoint2,0.9*d},{xpoint2,-d}}],Circle[point1,1.7,{π/2,π/2+phi0}],Text[Style["(Subscript[φ, 0])",Medium],point1+2.4{-Sin[phi0/2],Cos[phi0/2]}],Circle[point1,1.7,{3π/2,3π/2+phi1}],Text[Style["(Subscript[φ, 1])",Medium],point1-2.4{-Sin[phi1/2],Cos[phi1/2]}],Text[Style["d",Medium],{-8.5,d/2}],Text[Style["(Subscript[n, 1])",Medium],{-7,d+1}],Text[Style["(Subscript[n, 2])",Medium],{-7,d/2}],Text[Style["(Subscript[n, 1])",Medium],{-7,-1}]} ,{ }] ,
(*продовження променя, що падає на пластину*)
 {Thin,Darker[Red,.4],Dashed,line2[{point1+(10-d){-Sin[phi0],Cos[phi0]},point1},{point1[[1]],10}]},
If[pozn,{Thin,Black,Arrowheads[{-.03,.03}],
If[nred>1,
{Arrow[{{xpoint3=(point1[[1]]+d Tan[phi0]),0},{xpoint3-(h=(xpoint3-xpoint2) Cos[phi0])Cos[phi0],ypoint4=-h Sin[phi0]}}],Text[Style["h",Medium],{xpoint3,.8 ypoint4}]},
{Arrow[{{xpoint2,0},{xpoint2-(h=(xpoint2-(xpoint3=point1[[1]]+d Tan[phi0])) Cos[phi0])Cos[phi0],ypoint4=-h Sin[phi0]}}],Text[Style["h",Medium],{xpoint2-0.5,.8 ypoint4}]}
] } ,{ }]  
},
PlotLabel->If[pozn,Text@TraditionalForm@Style[Row[{(Subscript[n, 2])/(Subscript[n, 1])," = ",Round[nred,.01],", ", (Subscript[φ, 0]) ," = ",Round[phi0/Degree,.1],"°",", ",(Subscript[φ, 1]) ," = ",Round[phi1/Degree,.1],"°","\n",Style["h",Italic], " = ",Style["d",Italic]," ", Cos[(Subscript[φ, 0])],"(",Tan[(Subscript[φ, 0])]-Tan[(Subscript[φ, 1])],")"," = ",Round[h,.1]}],FontWeight->Bold,FontSize->14] ," "],
(*Опції Графіка*)
ImageSize->{425,400},AspectRatio->.85,Axes->koord,PlotRange->{{-9,9},{-6,10}},ImagePadding->{{10,10},{0,40}},Background->GrayLevel[0.9]](*End Graphics*)
],(*End Module*)
(*інструменти для керування*)
Grid[{{Control[{{nred,1.51106,"(Subscript[n, 2])/(Subscript[n, 1]) "},0.8,2.2,Appearance->"Labeled",ImageSize->Small}],
Control[{{d,4,"d "},0.1,8,Appearance->"Labeled",ImageSize->Small}]},
{Control[{{xpoint1,-3,"P"},-7,0,Appearance->"Labeled",ImageSize->Small}],
Control[{{phi0gr,64,"(Subscript[φ, 0])"},0.01,89.9,Appearance->"Labeled",ImageSize->Small}]}}],
Row[{Control[{{pozn,True,"notation"},{True,False}}],
Control[{{koord,False,"  axes"},{True,False}}],Button["initialize",phi0gr=64;nred=1.51106;koord=False;xpoint1=-3;d=4;pozn=True]}],
TrackedSymbols:>Manipulate
]

CAPTION

A light ray passes from medium 1 with index of refraction (Subscript[n, 1]) through a plate with index of refraction (Subscript[n, 2]) and continues back out again into medium 1. The path depends on the ratio (Subscript[n, 2])/(Subscript[n, 1]), the thickness of the plate d, and the angle of incidence (Subscript[ϕ, 0]).

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Light Ray Passing through a Transparent Plate" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/LightRayPassingThroughATransparentPlate/

Contributed by: Volodymyr Holovatsky (Chernivtsi National University, Ukraine)

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »