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.

How to pass the abscissa of a node to the first 2 mandatory arguments of \psplot? I have tried \psGetCenterNode but it produced an error in PS interpreting phase.

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

\def\foo{x \psPi\space div 180 mul sin}
\def\goo{x \psPi\space div 180 mul cos}
\def\hoo{x}
\begin{document}
\begin{pspicture}[showgrid=bottom](0,-2)(5,2)
    \psplot[linecolor=red]{0}{4.5}{\foo}
    \psplot[linecolor=blue]{0}{4.5}{\goo}
    \pstInterFF{\foo}{\goo}{0}{A}
    \pstInterFF{\foo}{\goo}{4}{B}
    %\psplot{A.x}{B.x}{\hoo} <== does NOT work!
\end{pspicture}
\end{document}
share|improve this question

2 Answers 2

up vote 3 down vote accepted
\documentclass{article}
\usepackage{pst-plot,pst-eucl}

\def\foo{x RadtoDeg sin}
\def\goo{x RadtoDeg cos}
\def\hoo{x}
\begin{document}
\begin{pspicture}[showgrid=bottom](0,-2)(5,2)
    \psplot[linecolor=red]{0}{4.5}{\foo}
    \psplot[linecolor=blue]{0}{4.5}{\goo}
    \pstInterFF{\foo}{\goo}{0}{A}
    \pstInterFF{\foo}{\goo}{4}{B}
    \psplot{\psGetNodeCenter{A} A.x}{\psGetNodeCenter{B} B.x}{\hoo}
\end{pspicture}

\end{document}

enter image description here

share|improve this answer
    
Sorry. How to make \def\f(#1){#1 1 add} usable in \psline(!0 \f(0))? –  In PSTricks we trust Aug 9 '12 at 13:48
    
The first 2 mandatory arguments of \psplot can accept RPN without !. It is a bit confusing because usually coordinates and angles need ! when they are specified in RPN. –  In PSTricks we trust Aug 11 '12 at 18:28
    
it is not confusing, because they are always real PostScript expressions and nothing else. –  Herbert Aug 11 '12 at 19:48

Just another method.

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

\def\foo{(sin(x))}
\def\goo{(cos(x))}
\def\hoo{(x)}

\pstVerb{/I2P {AlgParser cvx exec} def}
\begin{document}
\begin{pspicture}[showgrid=bottom,algebraic,saveNodeCoors](0,-2)(5,2)
    \psplot[linecolor=red]{0}{4.5}{\foo}
    \psplot[linecolor=blue]{0}{4.5}{\goo}
    \pstInterFF{\foo I2P}{\goo I2P}{0}{A}
    \pstInterFF{\foo I2P}{\goo  I2P}{4}{B}
    \psplot{N-A.x}{N-B.x}{\hoo}
\end{pspicture}
\end{document}
share|improve this answer

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.