Reflections in a Mirrored Corner

Manipulate[
Module[{x0=0,y0=0,y1=0,l=11,pfin={1,0},alf1,y2,phi,line2,fl,koord,x,x1,x2,x3,alf,alf2,alf3},
 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)}}];
phi=φ Degree;fl=True;
alf1=π/2.-ArcTan[(sunloc[[1]]-x10),sunloc[[2]]];koord={sunloc,{x10,y1}};x1=x10;alf="";x3=0;
While[x1>0,
If[alf1==0,x2=x1,
x2=x/.First[Solve[Tan[phi] x-Tan[π/2+alf1](x-x1)==0,x]]];
If[alf1<0&&fl,alf=alf<>"\n";fl=False];alf=alf<>ToString[Round[alf1/Degree,.1]]<>"°, ";
y2=Tan[phi] x2;
If[x2<=0,pfin={x2,y2};Break[],koord=Append[koord,{x2,y2}]];alf2=alf1-phi;
If[alf2<=0&&fl,alf=alf<>"\n";fl=False];alf=alf<>ToString[Round[alf2/Degree,.1]]<>"°, ";
alf3=alf2-phi;
If[alf3==0||alf3==Pi/2,x3=x2,
x3=x/.First[Solve[y2==Tan[π/2-alf3](x2-x),x]]];
If[x3<=0,pfin={x3,0};Break[],koord=Append[koord,{x3,0}]];x1=x3;y1=0;alf1=alf3
];
Graphics[{
Blue,Thick,
Line[{{x0,y0},{l+x0,y0}}],Line[{{x0,y0},{l+x0,l Tan[phi]+y0}}],
Lighter[Blue,.85],Polygon[{{x0-0.2,y0-0.03},{l+x0,y0-0.03},{l+x0,y0-0.5},{x0-.2,y0-0.5}}],
Polygon[{{x0-0.2,y0},{x0,y0+0.03},{l+x0,l Tan[phi]+y0+0.03},{l+x0,l Tan[phi]+y0+.6},{x0-0.2,y0+.6}}],
Thick,Darker[Red,.4],Line[koord],If[pfin[[1]]<=0,line2[{pfin,Last[koord]},{Last[koord][[1]],11}],{}],Black,If[notat,{Text[Style["(Subscript[α, n + 1]) = (Subscript[α, n]) - φ",Large],{5,7.9}],Text[Style["φ="<>ToString[φ]<>"°",Large],{x0+1.,y0+1.4}],Text[Style[alf,Medium],{5.,6.5}]},{}]
},
ImageSize->{550,340},AspectRatio->0.6,Axes->False,PlotRange->{{-0.5`,11},{-0.5`,8}}
](*Graphics*)
],(*Module*)
{{sunloc,{10.373,0.5}},{7,0.01},{11,10},Locator},
Grid[{{Control[{{x10,9,"\!\(\*SubscriptBox[\(х\), \(1\)]\)"},1,11.,Appearance->"Labeled"}],
Control[{{φ,20,"φ "},1,45.,Appearance->"Labeled"}]},
{Control[{{notat,False,"notation"},{True,False}}],
Button["reset (Subscript[x, 1]) and the locator",sunloc={10.5,0.2};notat=False;x10=9]}
}],
TrackedSymbols->True]

CAPTION

This Demonstration shows the reflection of a ray between two flat mirrors that form a corner.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Reflections in a Mirrored Corner" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/ReflectionsInAMirroredCorner/

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 »