2

Please consider \pstVerb{/#2 \csname#2\endcsname\space def} in the following code snippet.

\newcommand\const[3][3]{%
    \edef\next{round(#3}%
        \expandafter\FPeval\csname#2\expandafter\endcsname
        \expandafter{\next:#1)}%
    \pstVerb{/#2 \csname#2\endcsname\space def}%
}

Its purpose is to define a constant for expressions written in RPN notation.

My complete code below

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

\newcommand\const[3][3]{%
    \edef\next{round(#3}%
        \expandafter\FPeval\csname#2\expandafter\endcsname
        \expandafter{\next:#1)}%
    \pstVerb{/#2 \csname#2\endcsname\space def}%
}


\const{Vox}{2}
\const{Xo}{1}

\const{Voy}{4}
\const{Yo}{10}

\const{G}{10}

\def\X(#1){Xo+Vox*#1}
\def\Y(#1){Yo+Voy*#1-0.5*G*#1^2}

\const{Tp}{Voy/G}
\const{Toffset}{0.5}


\const{Tf}{2*Tp+Toffset}

\const{Xp}{\X(Tp)}
\const{Yp}{\Y(Tp)}
\const{Xf}{\X(Tf)}
\const{Yf}{\Y(Tf)}

\usepackage{fourier}
\begin{document}
\begin{pspicture}(0,\Yp)(\Xf,\Yf)
    \psframe*[linecolor=lightgray](0,\Yf)(\Xo,\Yo)
    \psparametricplot[algebraic,linecolor=red,linestyle=dashed]{0}{\Tf}{\X(t)|\Y(t)}
    \rput[B]{45}(\Xp,\Yp){\bomb}
\end{pspicture}
\end{document}

use \psparametricplot[algebraic,linecolor=red,linestyle=dashed]{0}{\Tf}{\X(t)|\Y(t)} with algebraic option. As you can see there is no expressions written in RPN notation.

However, if I disable \pstVerb{/#2 \csname#2\endcsname\space def} (by commenting it with %), the compilation successes in latex and dvips phases but fails in ps2pdf phase with

Error: /undefined in Xo
... <other errors go here but omitted for brevity> ....

I am using algebraic option but why must I specify some constants that are only needed for expressions written in RPN?

0

1 Answer 1

1

No need to define constants in PS world if I change the parametric function with constants from TeX world.

\def\X(#1){\Xo+\Vox*#1}
\def\Y(#1){\Yo+\Voy*#1-0.5*\G*#1^2}
1
  • I just realized this several minutes ago by accident. Oh my ghost! Apr 12, 2013 at 8:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .