How to automatically draw the images of a point placed between 2 inclined mirrors?

Consider a point X placed between two inclined mirrors as follows.

\documentclass[pstricks,border=20pt,12pt]{standalone}
\usepackage{pst-eucl}

\def\Angle{37}% extreme case in which 360/\Angle-1 is not an integer.
\def\R{5}

\begin{document}
\begin{pspicture}[showgrid](-\R,-\R)(\R,\R)
\pstGeonode[PointSymbol=none,PosAngle={45,-90},PointNameSep=24pt](\R;\Angle){B}(0,0){O}(\R;0){A}
\psframe*[linecolor=lightgray](O|0,-12pt)(A|0,0)
\rput{\Angle}(0,0){\psframe*[linecolor=lightgray](O)(B|0,12pt)}
\psline(B)(O)(A)
\pstMarkAngle[MarkAngleRadius=1.6,LabelSep=.8]{A}{O}{B}{$\theta$}
\pstGeonode(3,1){X}
\end{pspicture}
\end{document}


How can we draw the images of point X for any angle \Angle automatically? Solutions with PSTricks (preferred), Aysmptote, Metapost, TikZ or even raw PostScript are welcome.

Edit

Oh my ghost, the existing answers don't answer because you might misunderstood what my question is, but my question is actually very very clear.

Consider the following sketch for \Angle=60.

Note: The prove of 360/angle-1 is still in progress here.

-
Seriously, I have no idea to prove the formula 360/\Angle-1 is the number of images. –  Please don't touch Feb 10 at 7:35
I don't understand. Are you just interested in placing the X in the middle of the two mirrors? Or what do you mean by "the images for any angle \Angle"? –  Werner Feb 10 at 7:37
@Werner: for any angle \Angle. –  Please don't touch Feb 10 at 7:39
...this remains clear as mud. –  Werner Feb 10 at 7:55
Well, are you absolutely sure it is very, very clear since none of us understood what you meant? (You are indicretly saying that we are all dumb...) –  Svend Tveskæg Feb 10 at 7:55

\documentclass[pstricks,border=20pt,12pt]{standalone}
\usepackage{pst-eucl,pst-plot}
\def\Angle{37}
\def\R{5}

\begin{document}
\begin{pspicture}[showgrid](-\R,-\R)(\R,\R)
\pstGeonode[PointSymbol=none,PosAngle={45,-90},PointNameSep=24pt](\R;\Angle){B}(0,0){O}(\R;0){A}
\pcline[linecolor=lightgray,linewidth=12pt,offset=-6pt,strokeopacity=0.6](O)(A)
\pcline[linecolor=lightgray,linewidth=12pt,offset=6pt,strokeopacity=0.6](O)(B)
\psline(B)(O)(A)
\pstMarkAngle[MarkAngleRadius=1.6,LabelSep=.8]{A}{O}{B}{$\theta$}
\pstGeonode(!3 \Angle\space 2 div PtoC){X}
\pstOrtSym{O}{A}{X}[I_1] \psline[linestyle=dotted](X)(I_1)
\newif\ifA \Afalse
\pstFPDiv\No{360}{\Angle}
\multido{\iA=1+1,\iB=2+1}{\numexpr\No-1}{%
\ifA\pstOrtSym{O}{A}{I_\iA}[I_\iB]\else\pstOrtSym{O}{B}{I_\iA}[I_\iB]\fi
\psline[linestyle=dotted](I_\iA)(I_\iB)
\ifA\Afalse\else\Atrue\fi
}%
\pscircle[linestyle=dotted](O){3}
\end{pspicture}

\end{document}


and with both directions:

\documentclass[pstricks,border=20pt,12pt]{standalone}
\usepackage{pst-eucl,pst-plot}
\def\Angle{37}
\def\R{5}

\begin{document}
\begin{pspicture}[showgrid](-\R,-\R)(\R,\R)
\pstGeonode[PointSymbol=none,PosAngle={45,-90},PointNameSep=24pt](\R;\Angle){B}(0,0){O}(\R;0){A}
\pcline[linecolor=lightgray,linewidth=12pt,offset=-6pt,strokeopacity=0.6](O)(A)
\pcline[linecolor=lightgray,linewidth=12pt,offset=6pt,strokeopacity=0.6](O)(B)
\psline(B)(O)(A)
\pstMarkAngle[MarkAngleRadius=1.6,LabelSep=.8]{A}{O}{B}{$\theta$}
\pstGeonode(!3 \Angle\space 2 div PtoC){X}
\color{blue}\psset{linecolor=blue}%
\pstOrtSym{O}{A}{X}[I_1] \psline[linestyle=dotted](X)(I_1)
\newif\ifA \Afalse
\pstFPDiv\No{360}{\Angle}
\multido{\iA=1+1,\iB=2+1}{\numexpr\No-1}{%
\ifA\pstOrtSym{O}{A}{I_\iA}[I_\iB]\else\pstOrtSym{O}{B}{I_\iA}[I_\iB]\fi
\psline[linestyle=dotted](I_\iA)(I_\iB)
\ifA\Afalse\else\Atrue\fi
}%
\color{red}\psset{linecolor=red}%
\pstOrtSym{O}{B}{X}[I_1] \psline[linestyle=dotted](X)(I_1)
\newif\ifA \Atrue
\pstFPDiv\No{360}{\Angle}
\multido{\iA=1+1,\iB=2+1}{\numexpr\No-1}{%
\ifA\pstOrtSym{O}{A}{I_\iA}[I_\iB]\else\pstOrtSym{O}{B}{I_\iA}[I_\iB]\fi
\psline[linestyle=dotted](I_\iA)(I_\iB)
\ifA\Afalse\else\Atrue\fi
}%
\pscircle[linestyle=dotted](O){3}
\end{pspicture}

\end{document}


-
(You probably know more maths than me) While this works. If 360/angle is not an integer, then the number of images is not finite. If you try with an integer you will see that “both directions” give you the same images. It would be cool if (in case of 360/angle is an integer) it will draw the 360/angle - 1 = n points and then write instead of $X$ -> $X = X_n$. –  Manuel Feb 10 at 10:10
We have physics here: You can have only 2*(int(360/angle) - 1) virtual points. In the above example the I_10 would be real point which is not possible. –  Herbert Feb 10 at 10:34
the position of X is not important. –  Herbert Feb 10 at 10:54
@Manuel: it depends to what you want and what variables are given. (3,1) is far different from using polar coordinates. –  Herbert Feb 10 at 12:35
English correction: "It depends to..." should be written as "It depends on". :-) –  Please don't touch Feb 11 at 17:35

Another attempt with MetaPost, strongly modified. if k-1=floor(360/theta), it checks if the "k"th image is equal to the original point X, and in that case prints "Success!" besides this point. Else it prints "failed!". Possibility to make any number of attempts one likes, it suffices to modify the "theta" parameter. Thus it is easy to check that if 360/theta is an integer, the number of images is indeed 360/theta - 1. But I'm still not sure if it is what was wanted…

input latexmp;
setupLaTeXMP(options = "12pt",
mode = rerun,
textextlabel = enable,
multicolor=enable,
packages="SIunits");

u:=1.5cm; % for scaling
% Angle
numeric theta; theta = 30;
% Supposed number of images
hypothesis := 360/theta-1;
number_of_images := floor(hypothesis);
% mirrors
numeric eps; eps = 0.4*u; % mirrors thickness
pair A, B, X;
path mirror[];
A := (5u, 0);
mirror1 = origin -- A -- A-(0, eps) -- (0, -eps) -- cycle;
mirror2 = mirror1 reflectedabout(origin, A) rotated theta;
B:= point 1 of mirror2;

beginfig(0);
% Grid and labels
drawoptions(dashed withdots);
for i = -5 upto 5:
draw (-5, i)*u -- (5, i)*u;
draw (i, -5)*u -- (i, 5)*u;
label.bot("$" & decimal(i) & "$", (i*u, -5*u));
label.lft("$" & decimal(i) & "$", (-5u, i*u));
endfor;
% mirrors drawing
drawoptions();
draw mirror1 ; fill mirror1 withcolor 0.8white ; draw origin -- A;
draw mirror2 ; fill mirror2 withcolor 0.8white; draw origin--B;
label.rt("$A$", A); label.rt("$B$", B);
% The angle drawing and its label
draw anglebetween(origin--A, origin--B, "$\theta =" & decimal(theta) & "\degree$");
% X
pair X[]; X0 = (3, 1)*u; freedotlabel("$X$", X0, origin);
draw X0 withpen pencircle scaled 3bp;
% Placement of floor(360/theta-1) images of X
drawoptions(dashed evenly);
k:=1;
forever:
exitunless k <= number_of_images;
if (k = round(k/2)*2): A else: B fi);
draw X[k-1]--X[k];
draw X[k] withpen pencircle scaled 3bp;
freedotlabel("$X_{" & decimal(k) & "}$", X[k], origin);
k := k+1;
endfor;
% Success or no success?
X[k]= X[k-1] reflectedabout(origin, if (k = round(k/2)*2): A else: B fi);
if (abs(X[k]-X0)< 1e-12):
draw X[k-1] -- X0;
freedotlabel("$X$\ \textcolor{red}{Success!}", X0, origin)
else:
draw X[k-1] -- X[k];
freedotlabel("$X$", X0, origin);
freedotlabel("\textcolor{red}{Failed!}", X[k], origin)
fi;
% The circle
draw fullcircle scaled (2*abs(X1)) dashed withdots;
endfig;
end.


-

My try with MetaPost, for what it's worth: it's been done in a bit of a hurry, and I'm not sure I've correctly understood what you want.

EDIT: As Herbert did, I added the circle where the images are located.

To be processed with the MetaFun format and the floating-point arithmetics:

mpost --mem=metafun --numbersystem=double angles.mp

input latexmp;
setupLaTeXMP(options = "12pt",  mode = rerun, textextlabel = enable);
u:=1cm; % for scaling
numeric my_angle;
my_angle = 37;
numeric eps; eps = 0.4*u; % mirror thickness
pair A, B, X;
path mirror[];
A := (5u, 0);
mirror1 = origin -- A -- A-(0, eps) -- (0, -eps) -- cycle;
mirror2 = mirror1 reflectedabout(origin, A) rotated my_angle;
B:= point 1 of mirror2;

beginfig(0);
% Grid and labels
drawoptions(dashed withdots);
for i = -5 upto 5:
draw (-5, i)*u -- (5, i)*u;
draw (i, -5)*u -- (i, 5)*u;
label.bot("$" & decimal(i) & "$", (i*u, -5*u));
label.lft("$" & decimal(i) & "$", (-5u, i*u));
endfor;
% mirrors drawing
drawoptions();
draw mirror1 ; fill mirror1 withcolor 0.8white ; draw origin -- A;
draw mirror2 ; fill mirror2 withcolor 0.8white; draw origin--B;
% The angle drawing and its label
draw anglebetween(origin--A, origin--B, textext("$\theta$"));
% The images
pair X[]; X0 = (3, 1)*u; label.rt("$X$", X0);
draw X0 withpen pencircle scaled 3bp;
for k= 0 upto 360/my_angle:
label.rt("$X_{" & decimal(k+1) & "}$", X[k+1]);