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.

Introduction

I am writing a tutorial on a short introduction to PSTricks for newbies. I got obstacles to explain how a node A (for example), \rput, (!\psGetNodeCenter{A} A.x A.y) and (!N-A.x N-A.y) work by design.

I have read the pst-node documentation as shown below.

enter image description here

enter image description here

And the following is taken from page 35-36:

enter image description here

The manual says:

  • The transformation matrix will be reset by \psGetNodeCenter.
  • (!N-A.x N-A.y) is not affected by \rput.

Even though I read it many times, I still get confused. The statements are too short.

Problem

Please consider the following figure for the remaining discussion.

enter image description here

  • Case 1

    A node A is defined outside \rput and a dot is translated by \rput.

    • with (!\psGetNodeCenter{A} A.x A.y)

      \pnode(2,2){A}
      \rput(1,1){\psdots(!\psGetNodeCenter{A} A.x A.y)}
      
    • with (!N-A.x N-A.y)

      \pnode(2,2){A}
      \rput(1,1){\psdots(!N-A.x N-A.y)}
      

    The results are different. \rput only affects (!N-A.x N-A.y).

  • Case 2

    A node A is defined inside \rput and a dot is translated by \rput.

    • with (!\psGetNodeCenter{A} A.x A.y)

      \rput(1,1){\pnode(2,2){A}\psdots(!\psGetNodeCenter{A} A.x A.y)}
      
    • with (!N-A.x N-A.y)

      \rput(1,1){\pnode(2,2){A}\psdots(!N-A.x N-A.y)}
      

    The results are identical. \rput affects both.

  • Case 3

    A node A is defined inside \rput and a dot is defined outside \rput.

    • with (!\psGetNodeCenter{A} A.x A.y)

       \rput(1,1){\pnode(2,2){A}}
       \psdots(!\psGetNodeCenter{A} A.x A.y)
      
    • with (!N-A.x N-A.y)

       \rput(1,1){\pnode(2,2){A}}
       \psdots(!N-A.x N-A.y)
      

    The results are different. \rput only affects (!\psGetNodeCenter{A} A.x A.y).

The MWE is given as follows.

\documentclass[margin=12pt]{standalone}
\usepackage{pst-node}
\addtopsstyle{gridstyle}{gridlabels=5pt}
\psset{saveNodeCoors,linecolor=red}
\everypsbox{\color{blue}}
\begin{document}

\begin{psmatrix}
\begin{pspicture}[showgrid=bottom](3,3)
    \rput(1,1){Case 1-A}
    \pnode(2,2){A}
    \rput(1,1){\psdots(!\psGetNodeCenter{A} A.x A.y)}
\end{pspicture}
&
\begin{pspicture}[showgrid=bottom](3,3)
    \rput(1,1){Case 1-B}
    \pnode(2,2){A}
    \rput(1,1){\psdots(!N-A.x N-A.y)}
\end{pspicture}
\\
% case 2
\begin{pspicture}[showgrid=bottom](3,3)
    \rput(1,1){Case 2-A}
    \rput(1,1){\pnode(2,2){A}\psdots(!\psGetNodeCenter{A} A.x A.y)}
\end{pspicture}
&
\begin{pspicture}[showgrid=bottom](3,3)
    \rput(1,1){Case 2-B}
    \rput(1,1){\pnode(2,2){A}\psdots(!N-A.x N-A.y)}
\end{pspicture}
\\
% case 3
\begin{pspicture}[showgrid=bottom](3,3)
    \rput(1,1){Case 3-A}
    \rput(1,1){\pnode(2,2){A}}
    \psdots(!\psGetNodeCenter{A} A.x A.y)
\end{pspicture}
&
\begin{pspicture}[showgrid=bottom](3,3)
    \rput(1,1){Case 3-B}
    \rput(1,1){\pnode(2,2){A}}
    \psdots(!N-A.x N-A.y)
\end{pspicture}
\end{psmatrix}
\end{document}

Question

How do I have to explain their behaviors to the newbies as the statements in the documentation seem to be unclear?

Note: As (!\psGetNodeCenter{A} A.x A.y) is identical to (A), (A) will not be discussed here.

If you are a teacher, how do you explain it to your students?

share|improve this question
1  
although i cannot comment on pstricks being a newbie to pstricks. I am very happy to hear that your are writing short intro to pstricks. It would be very interesting. all the best. –  texenthusiast Mar 17 '13 at 6:17
    
@Herbert, where are you? :-) –  Daniel Mar 20 '13 at 20:05
add comment

1 Answer

up vote 2 down vote accepted

The crucial point is understanding the difference between a node (A), which is created by \pnode, and a pair of coordinates (x,y):

  • A coordinate pair, e.g. (1,1) specifies a relative point. Its position depends on the current environment, whether its surrounded by \psdot(1,1) text, or shifted with \rput(2,2){\psdot(1,1)} etc.

  • A node (A) refers to an absolute, fixed point on the page. This is independent of the environment.

The following example resumes this.

\documentclass[pstricks, margin=12pt]{standalone}
\usepackage{pst-node}
\begin{document}
\begin{pspicture}[showgrid](2,2)
    \rput(1,1){%
        \pnode(1,1){A}}
    \psdot(A)
    \pnode(1,1){B}
    \rput(1,1){%
        \psdot[linecolor=red](B)}
    \end{pspicture}
  \end{document}

The black dot is placed at (2,2), because \rput shifts the coordinate pair (1,1), which is used to define node A. The red dots remains at (1,1) because \rput has no effect on (B) after its definition:

enter image description here

That's the essence of all node-stuff.

Concerning \psGetNodeCenter, you are right: in this respect using (!\psGetNodeCenter{A} A.x A.y) is equivalent to (A).

The parameter saveNodeCoors saves the relative coordinates at the time of the node definition. I.e. adding dots at (!N-A.x N-A.y) and (!N-B.x N-B.y) in the above example places two dots at (1,1), which are the coordinate pairs used to define both nodes A and B:

\documentclass[pstricks, margin=12pt]{standalone}
\usepackage{pst-node}\SpecialCoor
\begin{document}
\begin{pspicture}[showgrid, saveNodeCoors](2,2)
    \rput(1,1){%
        \pnode(1,1){A}}
    \psdot(A)
    \pnode(1,1){B}
    \rput(1,1){%
        \psdot[linecolor=red](B)}
    %
    \psdot[dotstyle=+, dotscale=2](!N-A.x N-A.y)
    \psdot[dotstyle=x, dotscale=2](!N-B.x N-B.y)
    \end{pspicture}
  \end{document}

enter image description here

Resuming this:

  • Coordinate pairs like (1, 1) or node expressions with ! N-A.x N-A.y are relative and are subject to scaling and translation like with \rput, \scale, \translate and such.

  • Nodes (A) and node expressions with \psGetNodeCenter are fixed, "immutable" points.

share|improve this answer
add comment

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.