Position a node a certain distance away from another node at a certain angle in TikZ?
Yes, TikZ can use polar coordinates. Not sure exactly what is the best way of defining the second node, here is one way.
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (A) {A};
\path (A) ++(30:2) node (B) [draw,fill=blue!20] {B};
\end{tikzpicture}
\end{document}
In (30:2)
30 is the angle, 2 the distance. 0° is to the right, positive direction is counterclockwise, so node B
will be above and to the right of A
.
TikZ allows you to specify positions and vectors in polar coordinates. Here's an example:
\begin{tikzpicture}
\node at (0,0) (a) {A node};
\node at (120:1cm) (b) {B node};
\path (a) ++(-45:2cm) node (c) {C node};
\end{tikzpicture}
You can shift node position B regarding to another node A from an angle and a radius in the following way:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (A) {A};
\node (B) at ([shift=({240:1 cm})]A) {B};
\end{tikzpicture}
\end{document}