1

In the following MWE, only the combination of \pstTranslation and angle calculated via N-P.y N-P.x atan 90 sub produces error.

How to solve it?

MWE

\documentclass[pstricks,margin=1cm]{standalone}
\usepackage{pst-eucl}
\psset{saveNodeCoors,PointName=none,PointSymbol=none}

\def\Pic#1#2#3{%
\begin{pspicture}[showgrid](4,5)
% node type switch
\ifnum#1=0\relax
    \pnode(0,0){O}
    \pnode(2,1){A}
    \pnode(1,4){B}
\else
    \pstGeonode
        (0,0){O}
        (2,1){A}
        (1,4){B}
\fi
% transformation switch
\ifnum#2=0\relax
    \nodexn{(B)-(A)}{P}
\else   
    \pstTranslation{A}{B}{O}[P]
\fi
%
    \pcline(A)(B)
    \pscircle(A){1}
% angle calculation switch
\ifnum#3=0\relax
    \uput{1}[(P)]{!\psGetNodeCenter{P}P.y P.x atan 90 sub}(>A){\psline[linecolor=red]{->}(0,1)}
\else
    \uput{1}[(P)]{!N-P.y N-P.x atan 90 sub}(>A){\psline[linecolor=red]{->}(0,1)}
\fi
\end{pspicture}}


\begin{document}
\Pic{1}{0}{1}
\Pic{1}{0}{0}
%\Pic{1}{1}{1}
\Pic{1}{1}{0}
\Pic{0}{0}{1}
\Pic{0}{0}{0}
%\Pic{0}{1}{1}
\Pic{0}{1}{0}
\end{document}
Display Name
  • 46,933

2 Answers2

1

{!\psGetNodeCenter{P}P.y P.x atan 90 sub ... can only be used with default PSTricks nodes but not with one defined by \pstGeonode. Use something like

[...]
\pnode(P){P1}
\uput{1}[(P)]{!\psGetNodeCenter{P1} P1.y P1.x atan 90 sub}(>A){%
  \psline[linecolor=red]{->}(0,1)}
[...]
  • But my question has no problem with \psGetNodeCenter{P}P.y P.x atan 90 sub. – Display Name Dec 14 '17 at 18:35
  • You use \uput{1}[(P)]{!N-P.y N-P.x... P ist defined by \pstGeonode. All nodes defined by pst-eucl are special and not saved by saveNodeCoors. See edited answer for a fix –  Dec 14 '17 at 21:35
  • I think your last comment is not 100% correct. This issue is not specific to \pstGeonode but it is about a node created inside \rput. For more details, please see my answer. – Display Name Dec 15 '17 at 18:46
0

Based on Christoph's explanation, I can summarize as follows:

If B is a node created by a node creating macro (either \pnode or \pstGeonode) inside a transforming macro (\rput, \uput or others) then the point (!N-B.y N-B.x) provided by saveNodeCoors=true will not be the same as (!\psGetNodeCenter{B} B.y B.x) or (B). Buffering B via either \pnode(B){C} or \pstGeonode(B){C} is a way to make them behave the same.

In the following examples,

  • the red dots represents dots created with (!N-B.x N-B.y).
  • the green dots represents dots created with (!N-C.x N-C.y).
  • the blue dots represents dots created with (B) or (!\psGetNodeCenter{B} B.y B.x). As (B) behaves the same as (!\psGetNodeCenter{B} B.y B.x), only the usage of (B) is given.

The green (!N-C.x N-C.y) and blue (B) dots are placed at the same location but not for the red (!N-B.x N-B.y) dots.

Case 1: Node creation with literal (x,y)

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{pst-node}

\begin{document}

\begin{pspicture}[saveNodeCoors,showgrid](4,6)
    \rput(1,2){\pnode(3,4){B}}
    \pnode(B){C}
    \pscircle*[linecolor=red](!N-B.x N-B.y){4pt}
    \pscircle*[linecolor=green](!N-C.x N-C.y){3pt}
    \pscircle*[linecolor=blue](B){2pt}
\end{pspicture}    
\end{document}

enter image description here

Remarks:

\rput(1,2){\pnode(3,4){B}}
\pnode(B){C}

produces the following result.

  • (B)=(1+3,2+4) <--- Effect of translation
  • N-B.y=4 and N-B.x=3 <--- No effect of translation
  • (C)=(B)=(1+3,2+4)

Case 2: Node creation with another node

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{pst-node}

\begin{document}    
\begin{pspicture}[saveNodeCoors,showgrid](4,6)
    \pnode(3,4){A}
    \rput(1,2){\pnode(A){B}}
    \pnode(B){C}
    \pscircle*[linecolor=red](!N-B.x N-B.y){4pt}
    \pscircle*[linecolor=green](!N-C.x N-C.y){3pt}
    \pscircle*[linecolor=blue](B){2pt}
\end{pspicture}    
\end{document}

enter image description here

Remarks:

\pnode(3,4){A}
\rput(1,2){\pnode(A){B}}
\pnode(B){C}

produces the following result.

  • (B)=(A)=(3,4) <--- No effect of translation
  • N-B.y=4-2 and N-B.x=3-1 <--- Effect of translation, but it is reversed. Is it strange?
  • (C)=(B)=(3,4)

Recommendation

As the behavior of N-B.y and N-B.x is different from B or (!\psGetNodeCenter{B} B.y B.x), it is better to avoid using N-B.y and N-B.x. They are confusing!

Display Name
  • 46,933