# TikZ: Get Position/Node of an Arrow Head

Following LaTeX code produces a small image with directions.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{quotes,angles}
\begin{document}

\begin{tikzpicture}[thick]
% X',Y',Z' in black
\draw[->]           (0,0) -- (0,4)  node[right, text width=5em] {$Z'$};
\draw[->]           (0,0) -- (4,0)  node[right, text width=5em] {$Y'$};
\draw[->,rotate=45] (0,0) -- (-4,0) node[right, text width=5em] {$X'$};

% X,Y,Z in red
\draw[->,rotate=20,draw=red](0,0) -- (0,4)  node[right, text width=5em] {$Z$};
\draw[->,rotate=20,draw=red](0,0) -- (4,0)  node[right, text width=5em] {$Y$};
\draw[->,rotate=65,draw=red](0,0) -- (-4,0) node[right, text width=5em] {$X$};

% a and b small
\draw[->]           (0,0) -- (0,2.5)  node[right, text width=5em] (a) {$a$};
\draw[->,rotate=-27.5](0,0) -- (0,2)  node[right, text width=5em] (b) {$b$};
\end{tikzpicture}

\end{document}


However, I would like to draw two lines with an angle down from b. My problem is, I do not know how I can pickup the arrow position/node of b to draw a line straight down. Naturally, I may use coordinates (until I get the correct one), but I think there is a better solution to pickup this point/position/node.

I would like to achieve the following image.

Do you know how I can receive the point of the arrow head of b to draw the remaining lines?

You should use 3d coordinates:

## Code:

\documentclass[border=2pt]{standalone}

\usepackage{tikz}

\newcommand*{\HorizontalAxis}{Y}%
\newcommand*{\VerticalAxis}{Z}%
\newcommand*{\ObliqueAxis}{X}%

\begin{document}
\begin{tikzpicture}[thick]
% X',Y',Z' in black
\draw[-latex] (0,0,0) -- (0,0,4)  node[right, text width=5em] {$\ObliqueAxis'$};
\draw[-latex] (0,0,0) -- (4,0,0)  node[right, text width=5em] {$\HorizontalAxis'$};
\draw[-latex] (0,0,0) -- (0,4,0)  node[right, text width=5em] {$\VerticalAxis'$};

% X,Y,Z in red
\begin{scope}[rotate=20,draw=red]
\draw[->] (0,0,0) -- (0,0,4)  node[right, text width=5em] {$\ObliqueAxis$};
\draw[->] (0,0,0) -- (4,0,0)  node[right, text width=5em] {$\HorizontalAxis$};
\draw[->] (0,0,0) -- (0,4,0)  node[right, text width=5em] {$\VerticalAxis$};
\end{scope}

% a and b small
\draw[->] (0,0,0) -- (0,2.5,0)  node[right, text width=5em] (a) {$a$};
\draw[->] (0,0,0) -- (1,2,1)    node[right, text width=5em] (b) {$b$};

\draw [orange, dotted]
(0,0,0)
-- (1,0,1) node [below, midway] {$u$}
-- (1,2,1);
\end{tikzpicture}
\end{document}


You are trying to solve a problem in 3d geometry using 2d (screen) coordinates. It can't be done. There is no way to determine what plane (b) is supposed to be in just given its screen coordinates.

The following is my best approximation to the mwe using 3d coordinates. My guesses are in blue.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}

\begin{document}
\begin{tikzpicture}[thick]
% X',Y',Z' in black
\draw[->] (0,0,0) -- (0,4,0) node[right, text width=5em] {$Z'$};
\draw[->] (0,0,0) -- (4,0,0) node[right, text width=5em] {$Y'$};
\draw[->] (0,0,0) -- (0,0,4) node[right, text width=5em] {$X'$};

% X,Y,Z in red
\draw[->,rotate=20,draw=red] (0,0,0) -- (0,4,0)  node[right, text width=5em] {$Z$};
\draw[->,rotate=20,draw=red] (0,0,0) -- (4,0,0)  node[right, text width=5em] {$Y$};
\draw[->,rotate=20,draw=red] (0,0,0) -- (0,0,4) node[right, text width=5em] {$X$};

\draw[->,blue] (0,0,0) -- (0,{4*cos(30)},{4*sin(30)*cos(20)})  node[right, text width=5em] {$Z$};
\draw[->,blue] (0,0,0) -- ({4*cos(20)},{4*sin(20)},0)  node[right, text width=5em] {$Y$};
\draw[->,blue] (0,0,0) -- ({4*sin(10)},0,{4*cos(10)})  node[right, text width=5em] {$X$};

% a and b small
\coordinate (a) at (0,2.5,0);
\draw[->] (0,0,0) -- (a)  node[right, text width=5em] {$a$};
\draw[->,rotate=-27.5] (0,0,0) -- (0,2,0) node[right, text width=5em] {$b$};
\coordinate (b) at ({2.5*sin(30)*sin(60)},{2.5*cos(30)},{2.5*sin(30)*cos(60)});
\draw[->,blue] (0,0,0) --  (b) node[right, text width=5em] {$b$};
\draw[->,yellow] (b) -- ({2.5*sin(30)*sin(60)},0,{2.5*sin(30)*cos(60)}) -- (0,0,0);
\end{tikzpicture}

\end{document}

• You don't need to compute the coordinates since you know the x, y and z coordinate of the point you are trying to get to. – Peter Grill Apr 22 '15 at 21:37
• @Peter Grill - I was assuming his axis change was an approximation and that he may have access to the real angles. – John Kormylo Apr 22 '15 at 21:39

For this kind of drawings I usually use the tikz-3dplot package that offers good 3d/perspective capabilities. It makes it easy to draw the projection of a point both in the main reference frame and in the rotated reference frame.

The useful command in this case is \tdplotsetcoord, used as

\tdplotsetcoord{<name>}{<r>}{<theta>}{<phi>}


and which defines a TikZ point named <name> whose polar spherical coordinates are (<r>,<theta>,<phi>). Moreover, this command defines the projection of the point <name> on the reference frame's axes (<name>x, <name>y and <name>z) and on the planes (<name>xy, <name>xz, <name>yz). You can thus access those projections without manually computing their coordinates.

Note: the \tdplotsetmaincoords command sets the perspective through which the 3d is rendered (basically it sets the appearance of the main reference frame). The command \tdplotsetrotatedcoords defines a new reference frame obtained from the main through a precise set of rotations (Euler's angles).

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[tdplot_main_coords]
\coordinate (O) at (0,0,0);
\def\axislength{2.5}
\draw [->] (O) -- (\axislength,0,0) node [left] {$x$};
\draw [->] (O) -- (0,\axislength,0) node [right] {$y$};
\draw [->] (O) -- (0,0,\axislength) node [right] {$z$};
\def\rvec{2}
\def\phivec{60}
\def\thetavec{30}
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}% define a point through its spherical coordinates (r,theta,phi)
\draw [->,dashed] (O) -- (P) node [above] {$P$};
\draw [dashed,black!25] (O) -- (Pxy) -- (P);% access projection of P on the xy-plane though point Pxy defined by \tdplotsetcoord

\tdplotsetrotatedcoords{30}{20}{0}
\begin{scope}[tdplot_rotated_coords,red]% same as before but in the rotated frame
\draw [->] (O) -- (\axislength,0,0) node [left] {$x'$};
\draw [->] (O) -- (0,\axislength,0) node [right] {$y'$};
\draw [->] (O) -- (0,0,\axislength) node [right] {$z'$};
\tdplotsetcoord{Q}{\rvec}{\thetavec}{\phivec}
\draw [->,dashed] (O) -- (Q) node [right] {$Q$};
\draw [dashed,red!25] (O) -- (Qxy) -- (Q);
\end{scope}
\end{tikzpicture}
\end{document}