[Tex/LaTex] How to translate a set of PSTricks objects and rotate it

pstricks

To illustrate the problem, consider a simple example with which you are familiar: A mechanical system that consists of a block lying on an inclined plane.

I attached a Cartesian coordinate system to the block and also displayed the weight vector.
I want to draw the system easily with minimal calculation and the simplest workflow.

The first step: I draw each part separately as follows:

enter image description here

\documentclass{article}
\usepackage{pstricks-add}

\def\block{%
    \psaxes[ticks=none,labels=none,linestyle=dashed]{->}(0,0)(-2,-2)(2,2)[$x$,0][$y$,90]
    \psframe*[linecolor=gray,opacity=0.5](-1,-0.5)(1,0.5)
    \psdots[linecolor=red](0,-0.5)
    \psline{->}(1.5;-45)
    \uput[-45]{45}(1.5;-45){$\vec{w}$}  
}
\begin{document}

\begin{pspicture}[showgrid=bottom](-3,-9)(6,2)
    \block
    \pspolygon(-1,-2)(5,-8)(-1,-2|5,-8)
    \psdots[linecolor=blue](1,-4)
\end{pspicture}

\end{document}

The next step: I attempted to merge them as follows:

enter image description here

\documentclass{article}
\usepackage{pstricks-add}

\def\block{%
    \psaxes[ticks=none,labels=none,linestyle=dashed]{->}(0,0)(-2,-2)(2,2)[$x$,0][$y$,90]
    \psframe*[linecolor=gray,opacity=0.5](-1,-0.5)(1,0.5)
    \psdots[linecolor=red](0,-0.5)
    \psline{->}(1.5;-45)
    \uput[-45]{45}(1.5;-45){$\vec{w}$}  
}
\begin{document}

\begin{pspicture}[showgrid=bottom](-3,-9)(6,2)
    \rput{-45}(1,-4){\block}
    \pspolygon(-1,-2)(5,-8)(-1,-2|5,-8)
    \psdots[linecolor=blue](1,-4)
\end{pspicture}

\end{document}

Do you see the weird part? Half of the block was submerged into the inclined plane. I want to fix it.

The general question is:
How to translate a system of PSTricks objects such that a certain point (belongs to the system) is coincident with a destination point and rotate the system about the certain point?

Note: If you have another tricky idea but simpler, please let me know.

Best Answer

The following code uses the rotation by \psrotate In this way you can specify the rotation point.

% !TEX program = arara
% !TEX encoding = utf8
% !TEX spellcheck = en_GB
%: Start Header
% arara: latex: {synctex: true}
% arara: dvips
% arara: ps2pdf

\documentclass{article}
\usepackage{pstricks-add}

\def\block{%
    \psaxes[ticks=none,labels=none,linestyle=dashed]{->}(0,0)(-2,-2)(2,2)[$x$,0][$y$,90]
    \psframe*[linecolor=gray,opacity=0.5](-1,-0.5)(1,0.5)
    \psdots[linecolor=red](0,-0.5)
    \psline{->}(1.5;-45)
    \uput[-45]{45}(1.5;-45){$\vec{w}$}  
}
\begin{document}
\begin{pspicture}[showgrid=bottom](-3,-9)(6,2)
 \rput(1,-3.5){\psrotate(0,-.5){-45}{\block}}
 \pspolygon(-1,-2)(5,-8)(-1,-2|5,-8)
  \psdots[linecolor=blue](1,-4)
\end{pspicture}
\end{document}
Related Question