# How to express a polar coordinate for a macro that only accepts space-separated values?

\psElectricfield only accepts a coordinate in space-separated values as follows. For example, a charge of -0.1 unit at (-1,0) is written as [-0.1 -1 0]. I have attempted to write in PS notation but it still does not work.

\documentclass{article}
\pagestyle{empty}

\usepackage{pst-electricfield,multido}
\def\M{2}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture*}(-\M,-\M)(\M,\M)
\psElectricfield
[
Q={[-0.1 -1 0][-0.1 1 0][0.1 !\i sin 2 mul \i cos 2 mul]}
]
\end{pspicture*}\newpage}
\end{document}


How to express a polar coordinate for a macro that only accepts space-separated values?

-

\documentclass{article}
\pagestyle{empty}\parindent=0pt
\usepackage{pst-electricfield,multido}
\def\M{2}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture*}(-\M,-\M)(\M,\M)
\psElectricfield[Q={
[-0.1 -1 0]
[-0.1 1 0]
[0.1 \i\space sin 2 mul
\i\space cos 2 mul]}]
\end{pspicture*} }
\end{document}


you have to use {\i} or alternatively \i\space otherwise the following space gets lost and you'll get a wrong PostScript entry like 10sin where the space is missing ("eaten" by TeX)

-
+1 Why do we not need ! for PS notation? –  xport Jul 24 '11 at 9:46
there is only PS code possible, nothing else –  Herbert Jul 24 '11 at 9:55

Based on Herbert's solution, I added \pstVerb to it such that the code can be broken into several lines that are often needed when they are posted to a narrow HTML page.

\documentclass{article}
\pagestyle{empty}\parindent=0pt
\usepackage{pst-electricfield,multido}
\def\M{2}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture*}[showgrid](-\M,-\M)(\M,\M)
\pstVerb{/xx \i\space sin 2 mul def}%
\pstVerb{/yy \i\space cos 2 mul def}%
\psElectricfield
[
Q={[-0.1 -1 0][-0.1 1 0][0.1 xx yy]}
]
\end{pspicture*} }
\end{document}

-
or: how can one make things complecated instead of easy ... –  Herbert Jul 24 '11 at 10:11