由于我无法将横坐标从中缀转换为后缀,因此以下代码无法编译。
\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}
答案1
该过程AlgToPs
仅转换单个表达式。如果两个坐标都以中缀表示法给出,则必须调用它两次。为方便起见,pstricks 有一个AlgParser
定义为的过程tx@AlgToPs begin AlgToPs end
。
节点表达式中的括号也存在问题\qdisk
。以下方法有效:
\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}
答案2
您可以查看该infix-RPN
包(由该包使用pst-infixplot
),即使它不完全是 PSTricks 运算符。以下 MWE 可以完成这项工作。
\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}
答案3
\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}