Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am starting to use PSTricks a bit more, and have been looking at the \psVolume command defined in pst-func package. My problem is with Reverse Polish Notation. Is there an interpreter available that will convert infix to RPN?

share|improve this question
    
Do you want the interpreter to be in TeX? Otherwise I think this might be a bit off-topic here. –  Roelof Spijker Mar 13 '12 at 8:45
    
Apologies! It would need to be in Tex. Thanks –  user10082 Mar 13 '12 at 8:55
    
I have just googled your suggestion - it is exactly what I want! Thank you! –  user10082 Mar 13 '12 at 9:07
    
If you are satisfied with my answer, don't forget to check it by clicking the check mark link at the bottom of the down vote arrow. Doing this is important to avoid many open question and also to increase your acceptance percentage. Other people will usually be reluctant to help members with low acceptance percentage. –  I am who I say I am Mar 15 '12 at 0:42
add comment

1 Answer

As \psVolume defined in pst-func cannot accept algebraic option, you need to use infix-RPN package as follows:

Simpler Example

enter image description here

\documentclass{article}

\usepackage{infix-RPN,pst-func}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
\PreviewBorder=10pt\relax

\begin{document}
\begin{pspicture}(-0.5,-2)(5,2.5)
    \psaxes{->}(0,0)(0,-2)(3,2.5)
    \infixtoRPN{x^0.5}%
    \psVolume[fillstyle=solid,fillcolor=magenta!30](0,4){10}{\RPN}
    \psline{->}(4,0)(5,0)
\end{pspicture}
\end{document}

The usage is so simple: invoke \infixtoRPN then use the output \RPN.

WARNING : Trigonometry functions work in degree (not radian) if they are expressed in RPN notation. For example:

  • \psplot{0}{3.1415}{x sin} means you want to plot the sine from 0 degree to 3.1415 degree.
  • \psplot{0}{3.1415}{180 3.1415 div x mul sin} means you plot the sine from 0 degree to about 180 degree.

Simple Example with Trigonometry

enter image description here

\documentclass{article}

\usepackage{infix-RPN,pst-func}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
\PreviewBorder=10pt\relax

\begin{document}
\begin{pspicture}(-0.5,-3)(7,3)  
    \def\f(#1){sin(180/\psPi*#1)+1.2}%
    \infixtoRPN{\f(x)}%
    \psVolume[fillstyle=solid,fillcolor=magenta!30](0,\psPiTwo){15}{\RPN}
    \psaxes[labelFontSize=\scriptscriptstyle]
            {->}(0,0)(0,-2.75)(6.75,2.75)[$x$,0][$y$,90]
    \rput[bl](*{\psPi\space 2 div} {\f(x)+0.2}){$y=sin(x)+1.2$}
\end{pspicture}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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