4

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.

4

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}
  • The same should hold for \rput[<refpoint>]{<angle>}(x,y){<stuff>}. – Werner May 19 '12 at 14:19
  • 1
    @Werner: I tried: \rput[0,-.5]{-45}(1,-3.5){\block} but it fails – Marco Daniel May 19 '12 at 14:28
  • @MarcoDaniel: <refpoint> should be t, b, l, r or similar, rather than a coordinate. Tried is as well and it didn't work. Don't know why...? – Werner May 19 '12 at 14:43
  • @Forgiver: I've added an answer the differs slightly from @_MarcoDaniel's; using \rput inside \rput to adjust vertically before placement. – Werner May 19 '12 at 14:51
5

Adding an extra vertical adjustment inside the existing \rput takes care of the proper baseline alignment:

enter image description here

\documentclass{article}
\usepackage{pstricks-add}% http://ctan.org/pkg/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)
  \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){\rput{0}(0,0.5){\block}}% Modified code
  \pspolygon(-1,-2)(5,-8)(-1,-2|5,-8)
  \psdots[linecolor=blue](1,-4)
\end{pspicture}

\end{document}
  • Even though I accepted Marco's answer, I used your answer in the production. Yours is simpler than Marco's. – kiss my armpit May 19 '12 at 15:03
1
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}% http://ctan.org/pkg/pstricks-add

\def\block{%
  \psaxes[ticks=none,labels=none,linestyle=dashed,linecolor=red]{->}(0,0)(-2,-2)(2,2)[$x$,90][$y$,90]%
  \psframe*[linecolor=gray,opacity=0.5](-1,-0.5)(1,0.5)%
    \rput{*0}(0,0){\psline[linecolor=blue]{->}(0,-1.2)\uput[-90](0,-1.2){$\vec{w}$}}%
}
\begin{document}
\multido{\n=.0+.1}{11}{%
\begin{pspicture}[dimen=m](-1,-1)(8,9)
  \pspolygon(0,7)(0,0)(6,0)
    \pcline[linestyle=none,offset=0](0,7)(6,0)\naput[labelsep=-\pslinewidth,nrot=:U,npos=\n]{\rput(0,.5){\block}}
\end{pspicture}}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.