4

The following code does not compile as I failed to convert the abscissa from infix to postfix.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

% defining an RPN operator that converts Infix Cartesian to Postfix Polar
\pstVerb{/ICtoPP {tx@AlgToPs begin AlgToPs end exch cvx /x ED cvx /y ED y x RadtoDeg PtoC} def }


\begin{document}
\def\Infix#1{(2^(#1/10))}% needs outer parentheses (...)
\begin{pspicture}[showgrid](-3,-3)(3,3)
  \psplot[algebraic,polarplot]{2 Pi mul neg}{2 Pi mul}{\Infix{x}} 
  \qdisk(! (3*Pi/2) \Infix{(3*Pi/2)} ICtoPP){2pt}
\end{pspicture}
\end{document}
3
+100

The procedure AlgToPs converts only a single expression. If both coordinates are given with infix notation, you must invoke it twice. And for convenience, pstricks has a procedure AlgParser which is defined as tx@AlgToPs begin AlgToPs end.

I also had a problem with the parenthesis in the \qdisk node expression. The following works:

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

% defining an RPN operator that converts Infix Cartesian to Postfix Polar
\pstVerb{/ICtoPP {AlgParser cvx exec exch AlgParser cvx exec RadtoDeg PtoC} def }


\begin{document}
\def\Infix#1{(2^(#1/10))}% needs outer parentheses (...)
\begin{pspicture}[showgrid](-3,-3)(3,3)
  \psplot[algebraic,polarplot]{2 Pi mul neg}{2 Pi mul}{\Infix{x}}
  \def\myval{(3*Pi/2) }
  \qdisk(! \myval \Infix{\myval} ICtoPP){2pt}
\end{pspicture}
\end{document}
  • Nice. I also tried that way, however the error thrown by the parenthesis problem was to cryptic for me. I find your solution more elegant. – Adam B. Nov 27 '13 at 8:59
  • Is it safe to rename my operator ICtoPP to IC2PP? – kiss my armpit Nov 27 '13 at 13:39
  • What do you mean by 'safe'? It may overwrite an existing operator with this name, but I don't think it exists. – Christoph Nov 27 '13 at 13:48
  • I meant that is it safe to use numbers inserted between letters when defining an name for PS operators or variables or constants? – kiss my armpit Nov 27 '13 at 19:45
  • Yes, citing from the Redbook: „Any token that consists entirely of regular characters and cannot be interpreted as a number is treated as a name object (more precisely, an executable name). All characters except delimiters and white-space characters can appear in names, including characters ordinarily considered to be punctuation. The following are examples of valid names: abc Offset $$ 23A 13−456 a.b $MyDict @pattern – Christoph Nov 28 '13 at 8:19
3

You could take a look at the infix-RPN package (which is used by the pst-infixplot package), even if that's not exactly a PSTricks operator. The following MWE does the job.

\documentclass[pstricks,border=12pt]{standalone}
%\usepackage{pst-plot}
\usepackage{pst-infixplot}

% defining an RPN operator that converts Infix Cartesian to Postfix Polar
\pstVerb{/ICtoPP {tx@AlgToPs begin AlgToPs end exch cvx /x ED cvx /y ED y x RadtoDeg PtoC} def }

\begin{document}
\def\Infix#1{(2^(#1/10))}% needs outer parentheses (...)
\begin{pspicture}[showgrid](-3,-3)(3,3)
\psplot[algebraic,polarplot,plotpoints=100]{2 Pi mul neg}{2 Pi mul}{\Infix{x}} 
 \def\abscissa{(3*Pi/2)}
 \infixtoRPN{\abscissa}
 \qdisk(! \RPN \Infix{\abscissa} ICtoPP){2pt}
\end{pspicture} 
\end{document}
  • +1 as well even though it is not what I am looking for. :-) – kiss my armpit Nov 27 '13 at 13:10
2
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}
\def\Infix#1{2^(#1/10)}% 
\def\QDisk#1#2{\pnode(+#1,\Infix{#1}){foo}%
  \qdisk(! \psGetNodeCenter{foo} foo.y foo.x RadToDeg PtoC){#2}}

\begin{document}
\begin{pspicture}[showgrid](-3,-3)(3,3)
  \psplot[algebraic,polarplot]{2 Pi mul neg}{2 Pi mul}{\Infix{x}}
  \QDisk{3*Pi/2}{2pt}
\end{pspicture}
\end{document}
  • +1: I chose Christoph's answer as it is more relevant to my question. – kiss my armpit Nov 27 '13 at 13:08

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.