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.

This question arose from trying to answer a different question previously posted by @StiffJokes (aka user:19356) but now deleted.

Each of the following MWE produces different results for the pspicture in a manner I find completely counter-intuitive. The first two examples differ only in how the border for the standalone class has been set. The third example uses the article class.

MWE #1:

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
%% using pgffor just to see what happens at different values
\usepackage{pgffor}
\begin{document}
\begin{pspicture}[showgrid](-1,-1)(3,3)
    \psset{saveNodeCoors=true}
    \pnode (0,0){A}
    \pnode (2,3){B}
    \foreach \myp in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.00}
    {
      \pgfmathparse{1-\myp}
      \edef\myq{\pgfmathresult}
      \nodexn{\myp(A)+\myq(B)}{V}
      \qdisk(V){2pt}
      \pnode(!  N-V.x N-V.y ){D}
      \psline(A)(D)
    }
\end{pspicture}
\end{document}

Resulting in

enter image description here

MWE #2:

\documentclass[pstricks,border=1in]{standalone}
\usepackage{pst-node}
%% using pgffor just to see what happens at different values
\usepackage{pgffor}
\begin{document}
\begin{pspicture}[showgrid](-1,-1)(3,3)
    \psset{saveNodeCoors=true}
    \pnode (0,0){A}
    \pnode (2,3){B}
    \foreach \myp in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.00}
    {
      \pgfmathparse{1-\myp}
      \edef\myq{\pgfmathresult}
      \nodexn{\myp(A)+\myq(B)}{V}
      \qdisk(V){2pt}
      \pnode(!  N-V.x N-V.y ){D}
      \psline(A)(D)
    }
\end{pspicture}
\end{document}

resulting in:

enter image description here

MWE #3:

\documentclass{article}
\usepackage{pstricks,pst-node}
%% using pgffor just to see what happens at different values
\usepackage{pgffor}
\begin{document}
\begin{pspicture}[showgrid](-1,-1)(3,3)
    \psset{saveNodeCoors=true}
    \pnode (0,0){A}
    \pnode (2,3){B}
    \foreach \myp in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.00}
    {
      \pgfmathparse{1-\myp}
      \edef\myq{\pgfmathresult}
      \nodexn{\myp(A)+\myq(B)}{V}
      \qdisk(V){2pt}
      \pnode(!  N-V.x N-V.y ){D}
      \psline(A)(D)
    }
\end{pspicture}
\end{document}

resulting in:

enter image description here

Can anyone explain what's going on here? Why the differences? On one level, the coordinates for V are correct since the points are being plotted where they belong. But as soon as you try to use ! N-V.x N-V.y to grab the coordinates for the center things go haywire.

By changing the coordinates fo points A and B the new coordinates for D can shift dramatically:

MWE #4

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
%% using pgffor just to see what happens at different values
\usepackage{pgffor}
\begin{document}
\begin{pspicture}[showgrid](-1,-1)(3,3)
    \psset{saveNodeCoors=true}
    \pnode (0,0){A}
    \pnode (2,0){B}
    \foreach \myp in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.00}
    {
      \pgfmathparse{1-\myp}
      \edef\myq{\pgfmathresult}
      \nodexn{\myp(A)+\myq(B)}{V}
      \qdisk(V){2pt}
      \pnode(!  N-V.x N-V.y ){D}
      \psline(A)(D)
    }
\end{pspicture}
\end{document}

enter image description here

share|improve this question
    
pgffor is automatically loaded by default so no need to explicitly specify \usepackage{pgffor}. –  stalking is prohibited Dec 30 '13 at 21:46
    
@StiffJokes Never knew that. Do you know why it's loaded by default? Or better yet, where would I go to learn that pgffor is loaded by default? –  A.Ellett Dec 30 '13 at 21:59
    
PSTricks loads pgfutil-common.tex, pgfkeys.code.tex, pgffor.code.tex, and does \let\pgfforeach\foreach. It is "documented" in pstricks.tex. –  stalking is prohibited Dec 30 '13 at 22:17

2 Answers 2

up vote 3 down vote accepted

\nodexn uses internally helper nodes. And when nodes are set by nodes you'll get relative coordinates. Depending to the expression of \nodexn it works only with \psGetNodeCenter{Node}. A "simple" expression is like \nodexn{1,1}{A} (without the ()), then the node values are the same.

And, by the way: writing such questions to the PSTricks mailing list makes more sense.

share|improve this answer
    
Where do I find the PSTricks mailing list? –  A.Ellett Dec 30 '13 at 22:05
    
So are you saying that the expression N-<node_name>.x etc is not supported in conjunction with \nodexn? –  A.Ellett Dec 30 '13 at 22:06
    
PSTricks.tug.org ... –  Herbert Dec 30 '13 at 22:06
    
it is supported, but depends to the expressions. Or in short words: do not use that notation when creating nodes with \nodexn And, of course, for nodes which are a linear combination of other nodes there are simpler macros ... –  Herbert Dec 30 '13 at 22:08
    
(!N-C.x N-C.y) is useful when using \scale{-1 1} because (C) and (!\psGetNodeCenter{C} C.x C.y) cannot be affected by \scale. \nodexn is also useful for creating complicated linear combination of some previously defined nodes. Thus (!N-C.x N-C.y) and \nodexn are both useful to use together, I think. :-) –  stalking is prohibited Dec 30 '13 at 22:25

I strongly believe by inspection that \nodexn does not respect the existence of saveNodeCoors so the variable N-<node_name>.x and N-<node_name>.y are left uninitialized.

The following code create 5 identical pspicture but N-<node_name>.x, and N-<node_name>.y produces different values each.

\documentclass[preview,border=1cm]{standalone}
\usepackage{pst-tools}
\usepackage{pst-node}
\psset{saveNodeCoors}


\begin{document}
\psLoop{5}{%
\begin{pspicture}(3,3)
    \pnode(1,1){A}
    \rput(0,2){\psPrintValue{N-A.x}}
    \rput(0,1){\psPrintValue{N-A.y}}
    %
    \nodexn{(1,1)}{B}
    \rput(2,2){\psPrintValue{N-B.x}}
    \rput(2,1){\psPrintValue{N-B.y}}
\end{pspicture}
\qquad}
\end{document}

enter image description here

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.