# Overriding the (0,0) Default When Using Pstricks Polar Coordinates

Consider the code

\documentclass[12pt]{book}
\usepackage{pstricks,xcolor,graphicx}

\begin{document}
\thispagestyle{empty}

\begin{pspicture}(-5,-5)(5,12)%
\psframe[fillcolor=yellow!35!brown,fillstyle=solid](-5,-5)(5,12)
\psframe[linecolor=yellow!35!brown](-5,-5)(5,12)

\SpecialCoor % Provides for polar coordinates (r;t) ; r = length (cm); t = angle (degrees)
\psgrid
\rput(4;0){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;15){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;30){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;45){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;60){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;75){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;90){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;105){\includegraphics[width=1.4em]{example-image-a}}
\end{pspicture}%
\end{document}

which produces the output

The \rput command is always relative to the Cartesian (i.e., (x,y)) point (0,0). I WOULD LIKE TO CHANGE THAT IF POSSIBLE.

Currently, \rput(4;0) will plot the associated image at the position 0 degrees and 4 units away from (0,0).

\rput(4;15) will plot the associated image at the position 15 degrees and 4 units away from (0,0).

etc.

QUESTION: How may I override the (0,0) default to plot my images, say, relative to the Cartesian point (0,6)? The code is compiled with xelatex and I am looking for an answer that modifies the MWE and can be compiled with xelatex.

REMARK: Indeed, the effect is a simple translation of the scattering of images (in this case) 6 units up. However, in the document I need this for, there are quite a few images and it would be most convenient to change the reference point from (0,0) to something else, lest the translated images interfere with the other existing ones. Thus, the objective of this post is to override the (0,0) default to (0,6) as the point of reference.

Thank you.

• Based on your quote "The more simple you are, the more good you will do.", I provide you with a simpler solution. See my answer. Commented May 24, 2022 at 23:50

You can use a node and then specify the polar coordinates relative to this node:

\documentclass[12pt]{book}
\usepackage{pstricks,pst-node,xcolor,graphicx}

\begin{document}
\thispagestyle{empty}

\begin{pspicture}(-5,-5)(5,12)%
\psframe[fillcolor=yellow!35!brown,fillstyle=solid](-5,-5)(5,12)
\psframe[linecolor=yellow!35!brown](-5,-5)(5,12)

\SpecialCoor % Provides for polar coordinates (r;t) ; r = length (cm); t = angle (degrees)
\psgrid
\pnode(0,6){center}
\rput([nodesep=4,angle=0]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=15]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=30]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=45]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=60]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=75]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=90]center){\includegraphics[width=1.4em]{example-image-a}}
\rput([nodesep=4,angle=105]center){\includegraphics[width=1.4em]{example-image-a}}
\end{pspicture}%
\end{document}

If you don't want to change the syntax, you can also patch the internal macro \polar@coor used for applying polar coordinates to move the resulting point afterwards:

\documentclass[12pt]{book}
\usepackage{pstricks,xcolor,graphicx}

\makeatletter
\let \original@polar@coor \polar@coor
\newcommand \polar@transform@code{}
\renewcommand \polar@coor[2] {%
\original@polar@coor {#1}{#2}%
\edef\pst@coor{%
\pst@coor
\polar@transform@code
}%
}
\def \MovePolarBase(#1){%
\pst@@getcoor{#1}%
\edef \polar@transform@code {%
stack exch \pst@coor 3 1 roll add 3 1 roll add stack
}%
\show\polar@transform@code
}
\makeatother

\begin{document}
\thispagestyle{empty}

\begin{pspicture}(-5,-5)(5,12)%
\psframe[fillcolor=yellow!35!brown,fillstyle=solid](-5,-5)(5,12)
\psframe[linecolor=yellow!35!brown](-5,-5)(5,12)

\SpecialCoor % Provides for polar coordinates (r;t) ; r = length (cm); t = angle (degrees)
\psgrid
\MovePolarBase(0,6)
\rput(4;0){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;15){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;30){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;45){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;60){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;75){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;90){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;105){\includegraphics[width=1.4em]{example-image-a}}
\end{pspicture}%
\end{document}

Both lead to the same result:

– DDS
Commented May 21, 2022 at 2:07

The following redefines \rput@iv, which is one of the internal macros used for handling the coordinate specification. It transforms the polar coordinates to cartesian (using radius*cos(angle) and radius*sin(angle) for x and y respectively), adds a specified cartesian coordiate, and then calls the next macro \rput@v with the new cartesian coordinate. The calculations are performed using xfp, which has built-in functions cosd and sind for cosine and sine on degrees.

Of course if you still want to use the original definition for other plots or other points then you can store the definition first (using \let) and restore it when needed.

MWE:

\documentclass[12pt]{book}
\usepackage{pstricks,xcolor,graphicx}
\usepackage{xfp}

\begin{document}
\thispagestyle{empty}
\def\xtranslation{0}
\def\ytranslation{6}
\makeatletter
\def\rput@iv(#1;#2){%
\edef\xtranslated{\fpeval{#1*cosd(#2)+\xtranslation}}%
\edef\ytranslated{\fpeval{#1*sind(#2)+\ytranslation}}%
\message{print #1;#2 at \xtranslated,\ytranslated}
\pst@killglue \pst@makebox {\rput@v {\xtranslated,\ytranslated}}%
}
\makeatother
\begin{pspicture}(-5,-5)(5,12)%
\psframe[fillcolor=yellow!35!brown,fillstyle=solid](-5,-5)(5,12)
\psframe[linecolor=yellow!35!brown](-5,-5)(5,12)

\SpecialCoor % Provides for polar coordinates (r;t) ; r = length (cm); t = angle (degrees)
\psgrid
\rput(4;0){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;15){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;30){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;45){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;60){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;75){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;90){\includegraphics[width=1.4em]{example-image-a}}
\rput(4;105){\includegraphics[width=1.4em]{example-image-a}}
\end{pspicture}%
\end{document}

Result:

A PSTricks solution only for either fun or comparison purposes.

\documentclass[pstricks,border=\dimexpr355mm/113]{standalone}
\usepackage{pst-plot}
\usepackage{graphicx}
\begin{document}

\def\N{16 } % the trailing space is needed!
\def\a{4}
\def\b{3}
\def\x{6}
\def\y{0}

\begin{pspicture}[showgrid](-1,-4)(11,4)
\degrees[\N]