# How to rotate objects in pstricks without shifting them?

I'm trying to draw an image with pstricks (an experiment schematics) and I'm having a hard time rotating stuff. I'm using psrotate and everytime I rotate something it has its position shifted as well. Is there a way to rotate something with respect to its center? I'm trying to rotate simple objects like squares and rectangles...

thank you very much.

 \documentclass[crop=true]{standalone}
\usepackage{pst-plot}
\usepackage{auto-pst-pdf}

\begin{document}
%
\begin{pspicture}(-0.1,-0.1)(20.1,25.1)

\psframe[linewidth=0.065cm,linecolor=black](0,0)(20,25)
%
\psframe[linewidth=0.065cm,linecolor=black](1,15)(19,24)
\pspolygon[fillstyle=solid, linewidth=0.06cm,linecolor=gray](5,17)(10,22)(15,17)%prisma

\psframe[linewidth=0.065cm,linecolor=black](1,1)(19,14.5)
\pspolygon[linewidth=0.06cm,linecolor=gray](4,2)(10,8)(16,2)%prisma

\pscircle*[linecolor=LTCearthred](7.5,5.5){3pt}
\pscircle*[linecolor=LTCearthred](12.5,5.5){3pt}
\pscircle*[linecolor=LTCearthred](10,2){3pt}

\psline[linestyle=dotted,linecolor=black](5,8)(9,4)
\psline[linestyle=dotted,linecolor=black](11,4)(15,8)

\psline[linewidth=0.05cm,linecolor=black](4,13)(7.5,5.5)
\psline[linewidth=0.05cm,linecolor=black](10,2)(7.5,5.5)

\psline[linewidth=0.05cm,linecolor=red](10,2)(12.5,5.5)
\psline[linewidth=0.05cm,linecolor=red](12.5,5.5)(16,13)

\psrotate(0,0){-20}{\pspolygon*[](-1.95,13.9)(-0.95,14.9)(0.05,13.9)(-0.95,12.9)}

\end{pspicture}
\end{document}


The last object (inside the psrotate, third line from the bottom) is the one giving me headaches. It took so long to put it there and there will be others like it...

• Do you have an example to show? It might be the case there are better approaches to the one you're using. I'm saying this for those who use pstricks. – Alenanno May 15 '16 at 22:01

Use

\psdot[dotsize=1.41,dotstyle=square*,dotangle=70](-0.95,13.9)


instead of the rotated polygon. By the way, there is a package pst-optic with \psprism. See pages 21ff of the documentation.

• (+1) I didn't think of this one :o). However, on compiling I have a small problem: the whole figure is rotated by 90°.Do you know the reason why? – Bernard May 16 '16 at 12:12
• A problem with the conversion. Pass the option -dAutoRotatePages=/None to ghostscript (ps2pdf). See Frequently done errors ... No 6 on tug.org/PSTricks/main.cgi – user2478 May 16 '16 at 12:26

Here is a solution. I kept the original square. The solution is to use the rotatebox command. I simplified the code using the pst-poly package, which defines a \PstSquare command and produces a square not in the same position as yours, so that I had to calculate the resulting rotation.

\documentclass[border = 5pt]{standalone}

\usepackage{pstricks, pst-poly}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{pspicture}(-0.1,-0.1)(20.1,25.1)
\psframe[linewidth=0.065cm,linecolor=black](0,0)(20,25)
%
\psframe[linewidth=0.065cm,linecolor=black](1,15)(19,24)
\pspolygon[fillstyle=solid, linewidth=0.06cm,linecolor=gray](5,17)(10,22)(15,17)%prisma
%
\psframe[linewidth=0.065cm,linecolor=black](1,1)(19,14.5)
\pspolygon[linewidth=0.06cm,linecolor=gray](4,2)(10,8)(16,2)%prisma
%
\pscircle*[linecolor=LTCearthred](7.5,5.5){3pt}
\pscircle*[linecolor=LTCearthred](12.5,5.5){3pt}
\pscircle*[linecolor=LTCearthred](10,2){3pt}
%
\psline[linestyle=dotted,linecolor=black](5,8)(9,4)
\psline[linestyle=dotted,linecolor=black](11,4)(15,8)
%
\psline[linewidth=0.05cm,linecolor=black](4,13)(7.5,5.5)
\psline[linewidth=0.05cm,linecolor=black](10,2)(7.5,5.5)
%
\psline[linewidth=0.05cm,linecolor=red](10,2)(12.5,5.5)
\psline[linewidth=0.05cm,linecolor=red](12.5,5.5)(16,13)
%
{\pspolygon*[](-1.95,13.9)(-0.95,14.9)(0.05,13.9)(-0.95,12.9)}
\rput(-0.95,13.9){\rotatebox{-25}{\PstSquare[linecolor =green]}}%{\pspolygon[linecolor =red](-1,0)(0,1)(1,0)(0,-1)}
%
\end{pspicture}

\end{document}


• \rput{-25}(-0.95,13.9){\PstSquare[linecolor =green]} does the same – user2478 May 16 '16 at 10:57
• @Herbert: That's what I tried first, but as for the O.P., the square moved near the origin. Also tried with PolyRotation= – same result. Does it work on your system? – Bernard May 16 '16 at 11:22
• sure, \rput rotates around the given coordinates, no shift! – user2478 May 16 '16 at 11:36
• Strange… I use MiKTeX. Could there be a difference in the compiler (pdflatex)? – Bernard May 16 '16 at 12:14
• no, that makes no difference – user2478 May 16 '16 at 12:24