# What makes the green line unable to reach the corresponding vertex of the polygon?

What makes the green line unable to reach the corresponding vertex of the polygon?

\documentclass[pstricks]{standalone}
\usepackage{pst-node,pst-plot}

\begin{document}
\pstVerb{realtime srand}%
\psLoop{10}{%
\begin{pspicture}[saveNodeCoors](-2,-2)(2,2)
\psnpolygon(0,\numexpr\Pnodecount-1){P}
\curvepnodes[plotpoints=50]{0}{N-P3.x N-P3.y Pyth}{t N-P3.y N-P3.x atan PtoC}{Q}
\psnline[linecolor=green](0,\Qnodecount){Q}
\end{pspicture}}
\end{document}


# Edit

The problem gone if I buffer the node P3 as follows.

\documentclass[pstricks]{standalone}
\usepackage{pst-node,pst-plot}

\begin{document}
\pstVerb{realtime srand}%
\psLoop{10}{%
\begin{pspicture}[saveNodeCoors](-2,-2)(2,2)
\psnpolygon(0,\numexpr\Pnodecount-1){P}
\pnode(P3){T}
\curvepnodes[plotpoints=50]{0}{N-T.x N-T.y Pyth}{t N-T.y N-T.x atan PtoC}{Q}
\psnline[linecolor=green](0,\Qnodecount){Q}
\end{pspicture}}
\end{document}

• My guess is that there are two different random number at work: one when you draw the vertex and one when you draw the green line. That is, Rand gets evaluated twice. – Schrödinger's cat Sep 15 at 19:01
• @Schrödinger'scat: It is counter intuitive. :-) – Money Oriented Programmer Sep 15 at 19:05
• At least in TikZ this happens and is a standard pit fall. It is also the reason why declare function={rr=1.5*(1+0.1*rnd);} in this post works. – Schrödinger's cat Sep 15 at 19:07
• the saved nodes are global, so you overwrite the P3 with the next run. With \pnode(P3){T} you save the global node P3 into the local one T – user187802 Sep 16 at 7:25
• @user187802: Thank you. It is a nice feature. :-) – Money Oriented Programmer Sep 16 at 9:03

\documentclass[pstricks]{standalone}
\usepackage{pst-node,pst-plot}
\begin{document}
\pstVerb{realtime srand}
\psLoop{10}{%
\begin{pspicture}(-2,-2)(2,2)
\edef\COOR{}\multido{\iA=0+36,\iB=0+1}{10}{%