[pstricks] Node Coordinates
Herbert Voss
LaTeX at zedat.fu-berlin.de
Tue Jun 6 15:27:57 CEST 2006
Douglas Reid wrote:
> However, I am still wondering how to recover the original x, y
> coordinates from the node name.
>
> Surely, PSTricks stores the data that defines nodes in a form that is
> accessible to the programme?
The nodes are defined on PostScript side, it is not possible to
get the coordinates back into TeX. But you can write some
special code which does everything in PS.
\documentclass{article}
\usepackage{pst-node,pst-func}
\SpecialCoor
\makeatletter
% #1 text origin
% #2 node A
% #3 node B
\def\printDistance(#1)#2#3{%
\begingroup%
\pst at getcoor{#1}\pst at tempA
\addto at pscode{
tx at NodeDict begin
gsave \psk at PSfont findfont \psk at fontscale scalefont setfont
/N@#2 load GetCenter /yA ED /xA ED
/N@#3 load GetCenter /yB ED /xB ED
\pst at tempA\space moveto
yB yA sub \pst at number\psyunit div
xB xA sub \pst at number\psxunit div Pyth
\psk at valuewidth string cvs show (cm) show grestore
end
}
\use at pscode%
\endgroup%
}
\makeatother
\pagestyle{empty}
\begin{document}
\begin{pspicture}(5,5)
\pnode(0,0){A}\pnode(3,4){B}\psline{|-|}(A)(B)
\printDistance(1.75,2){A}{B}
\end{pspicture}
\end{document}
> I have been spending a lot of time playing about with nodes. There are
> various parameters the use of which is unclear. For example, there is
> Xnodesep and Ynodesep.
they are undocumented and do not work in any case as expected.
Here is another example:
http://tug.org/PSTricks/main.cgi?file=Nodes/nodes#XYNodesep
Herbert
More information about the PSTricks
mailing list