# Why is my beam trace skewed?

I am using the pst-optexp package to configure a optical setup. after drawing the beam path, it appears to be skewed on its return path after it hits a beam splitter.

MWE:

\documentclass[margin=36pt]{standalone} % remove margin for compact diagram
\usepackage{pst-optexp}
\usepackage{amsmath}

\begin{document}
\begin{pspicture}[showgrid](0, 0)(11, 8) % (bottom left)(upper right)
\pnodes(0,5){S}(1,5){LS}(2,5){A}(3,5){BS1}(5,5){DM1}(5,7){DM2}(6,7){L2}(7,7){L3}(9,7){DM3}(9,5){L4}(9,4.75){M1}(9,4.75){B}(3,5){C}(3,3){L5}(3,2){BS2}(3,1){CCD}(2,2){P2}(1,2){PD}

\optbox[abspos = 0.5, optboxsize=1 0.5, labeloffset = 0](S)(LS){Laser}
\lens[compname=L0, abspos = 0.2, n=2,thicklens = false](LS)(A){L0}
\pinhole[compname = P1, labeloffset = -0.7](LS)(A){P1}
\lens[compname=L1, abspos = 1.2, n=1, thicklens = false](LS)(A){L1}

\psset{mirrortype=extended, mirrordepth=0.2}
\beamsplitter[bsstyle=plate, compname=BS1,label = 0.8 -90](B)(BS1)(BS2){BS1}
\mirror[compname=DM1,labeloffset = 1](BS1)(DM1)(DM2){DM1}
\mirror[compname=DM2,labeloffset = 1](DM1)(DM2)(DM3){DM2}
\lens[compname=L2, abspos = 1, n=1, thicklens = false](DM2)(L3){L2}
\lens[compname=L3, abspos = 1, n=1, thicklens = false](L2)(DM3){L3}
\mirror[compname=DM3,labeloffset = 1](L3)(DM3)(M1){DM3}
\lens[compname=L4, abspos = 1, n=1, thicklens = false](DM3)(L4){L4}
\optbox[compname=S1,abspos = 0, optboxsize=0.5 0.5, label = 1.0 -180](L4)(M1){Sample}
\mirror[compname=M1,labeloffset = 0.5](L4)(M1)(DM3){Test Arm}

%%
\lens[compname=L5, abspos = 1.5, n=1, thicklens = false](C)(L5){L5}
\beamsplitter[bsstyle=plate, compname=BS2,label = 0.8 -45](C)(BS2)(PD){BS2}
\pinhole[compname = P2, labeloffset = -0.7](BS2)(PD){P2}
\optdetector[compname=PD, angle=-180, dettype=diode](P2)(PD){PD}
\optbox[compname=CCD, abspos = 1.5, optboxsize=0.5 0.5, label = 1.0 -180](BS2)(CCD){CCD}

\addtopsstyle{Beam}{beamwidth=0.2, fillstyle=solid, linecolor = red, fillcolor=red, opacity = 0.2}

\drawwidebeam[raytrace=false](LS){L0}{L1}{BS1}{DM1}{DM2}{L2}{L3}{DM3}{L4}{M1}{L4}{DM3}{L3}{L2}{DM2}{DM1}{BS1}{L5}{BS2}{CCD}
\drawwidebeam[raytrace=false](LS){L0}{L1}{BS1}{DM1}{DM2}{L2}{L3}{DM3}{L4}{M1}{L4}{DM3}{L3}{L2}{DM2}{DM1}{BS1}{L5}{BS2}{PD}

\end{pspicture}
\end{document}


MWE OUTPUT:

• I don't get any warnings or errors at all. I am compiling it using Latex and not pdfLatex. – Rene Duchamp May 14 '18 at 2:25
• I use ShareLaTeX to compile all my projects. It doesn't show any errors at all. Plus I went through my code for any obvious errors, looks Okay to me. – Rene Duchamp May 14 '18 at 15:43
• Solved it by changing the source position which hits BS1 to DM1 instead of M1: \beamsplitter[bsstyle=plate, compname=BS1,label = 0.8 -90](DM1)(BS1)(BS2){BS1} I use ShareLaTeX to compile all my projects. It din't show any errors at all. Plus I went through my code for any obvious errors, looked Okay to me. Changed source of BS1 to DM1 instead of M1 and it resolved itself. – Rene Duchamp May 14 '18 at 16:27
• @marmot Unfortunately, pst-optexp doesn't work with xelatex. – Christoph May 14 '18 at 18:25
• @Christoph I see. I didn't know that. Thanks! (It nevertheless produced the output of the OP.) – user121799 May 14 '18 at 18:26

\beamsplitter[bsstyle=plate, compname=BS1,label = 0.8 -90](DM1)(BS1)(BS2){BS1}