# Extracting coordinates (of a node), and the one-node-path-trick

If one has nodes (vector0) and (vector1), one method to get the first and second coordinate of

       ($(vector1)-(vector0)$)


is to write

      \path ($(vector1)-(vector0)$);
\pgfgetlastxy{\XCoord}{\YCoord};


This method appears, for example, in this thread

where one finds

\path (A); \pgfgetlastxy{\xA}{\yA}; % Extract the coordinates of A

Or, more precisely, the method I descibed above consists of replacing "A" with $(vector0)-(vector1)$.

where one finds

\path (z) node[below] {$z$}; \pgfgetlastxy{\XCoord}{\YCoord};

Question.

Briefly: how should one do this?

In more detail:

• what noteworthy methods are there to, if one at some point of a TikZ program has nodes (vector0) and (vector1), get the first and second coordinate of ($(vector1)-(vector0)$) ?
• Which of these methods should one use and when? In particular, should one avoid this one-node-path-trick?
• In particular, how to do this more quickly, in more or less one line, e.g. by writing something like

 \node (tempnode) at ($(vector1)-(vector0)$)[]{};
\pgfgetlastxy {      code involving (tempnode)   } { another code involving (tempnode) };


?

• what noteworthy methods are there to, if one at some point of a TikZ program has nodes (vector0) and (vector1), get the first and second coordinate of ($(vector1)-(vector0)$) ?

There is the let operation.

• Which of these methods should one use and when? In particular, should one avoid this one-node-path-trick?

You should only use the let operation because it's the only high-level method.

• In particular, how to do this quicker, in more or less one line, e.g. by writing something like

The let operation is part of the path and therefore one line, see also example below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
\node[draw,fill,circle,label={above:vector 0}] (vector0) at (1,2) {};
\node[draw,fill,circle,label={above:vector 1}] (vector1) at (3,1) {};
\draw let \p1=($(vector1)-(vector0)$) in
(vector0) -- +(\x1,0) -- +(\x1,\y1);
\end{tikzpicture}

\end{document}