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.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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}
share|improve this answer
    
I just realized this several minutes ago by accident. Oh my ghost! –  Oh my ghost Apr 12 '13 at 8:22

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.