[pstricks] How can I get the x and y coordinates of a node?
Henrik Bengtsson
hb at maths.lth.se
Tue Oct 23 19:26:06 CEST 2001
Dear PSTricks coders, is it possible to get the x and y coordinates
of a node? I would like to get this to be able to calculate new
coordinates that are relative to a certain node coordinates.
For example, I would like to calculate the midpoint between two nodes A
and B:
\usepackage{pst-all} \usepackage{calc}
\newlength{\newx} \newlength{\newy} \psset{xunit=10mm,yunit=10mm}
\begin{pspicture}(0,0)(5,5)
\rput(2,4){\circlenode{A}{A}}
\rput(4,4){\circlenode{B}{B}}
\ncline{A}{B}
\setlength{\newx}{(\getxcoord{A} + \getxcoord{B}) / 2}
\setlength{\newy}{(\getycoord{A} + \getycoord{B}) / 2}
% Midpoint between A and B
\pnode(\newx,\newy){AB}
% Line to a node 2 yunits below the midpoint
\psaddtolength{\newy}{-2}
\rput(\newx,\newy){\circlenode{C}{C}}})
\ncline{AB}{C} \end{pspicture}
Is there a "\getxcoord" and a "\getycoord" or something similar?
FYI: My knowledge of "low-level" TeX is very ad hoc.
Thanks
Henrik Bengtsson
Lund University, Sweden
More information about the PSTricks
mailing list