# Tikzpicture - 3D Polyhedron - find points for lines

I am trying to generate a random polygon with tikzpicture and have a question about how to find the corresponding points. E.g. I start with a polygon and then go on to build one side. The problem is now, that I want to have the second polygon closed by the point of the first one. A simple example will demonstrate everything:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
% First polygon (start)
\draw[-] (0,0) -- (72:1cm) -- ++(144:1cm) -- ++(216:1cm) -- ++(288:1cm) -- (0,0);
% Second polygon (start at 0,0 and end 72:1cm but how?)
\draw[-] (0,0) -- (-20:0.5cm) -- ++(70:0.8cm) -- ++(100:0.6cm) -- (0.3,1);
\end{tikzpicture}
\end{figure}
\end{document}


The second line should end at the first polygon point which is (72:1cm). I was trying to do something like that:

\draw[-] (0,0) -- (72:1cm) node (a) {} -- ...;
\draw[-] ... - (a);


but this is not working. Probably I am doing something wrong here because it should be possible to mark the points of the first polygon by (a) or something like that.

Any recommendation is welcomed. Kind regards, Tobias

You don't say what didn't work but your solution was correct, except that it's better to use a coordinate instead of a regular node. A node has some non zero inner sep while a coordinate is just a point.

To better understand these differences, I've replicated the code with a node and with a coordinate:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}

% First polygon (start)
% a is a coordinate
\draw[-] (0,0) -- (72:1cm) coordinate (a) -- ++(144:1cm) -- ++(216:1cm) -- ++(288:1cm) -- (0,0);
% Second polygon (start at 0,0 and end 72:1cm but how?)
\draw[-] (0,0) -- (-20:0.5cm) -- ++(70:0.8cm) -- ++(100:0.6cm) -- (a);

\begin{scope}[xshift=3cm]
% First polygon (start)
% a is a node
\draw[-] (0,0) -- (72:1cm) node[draw=red] (a) {} -- ++(144:1cm) -- ++(216:1cm) -- ++(288:1cm) -- (0,0);
% Second polygon (start at 0,0 and end 72:1cm but how?)
\draw[-] (0,0) -- (-20:0.5cm) -- ++(70:0.8cm) -- ++(100:0.6cm) -- (a);
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document} The right hand figure shows the problem using nodes. Even empty nodes have some area (unless you use option inner sep=0pt) and paths starting or finishing in (a) (just node name) will start or finish at node's border. This is what happens with your initial solution.

As TonioElGringo suggested, you could still use a regular node and obtain desired result if you write (a.center) (explicit selection of a node's anchor).

Left figure uses a coordinate which is just an empty node with no dimensions. In this case a reference to (a) (coordinate name) is equivalent to (a.center) because there is no distance between node's center and border.

• +1 This is right. Alternatively, to show that it was working with the regular node, you can use (a.center) as the target in the second path, yielding the same result. coordinate is the best solution here. May 17, 2017 at 12:37
• Thank you very much for the answer. Well it is funny that I made it correct but I was not aware of the inner sep ... Thanks for clarifying my mistake and sorry that I forgot to mention the problem, that the line was not directly fitted to the point of interest. I added that to the latex code :) but I agree, it would be better to explicitly mention it in the text.
– Tobi
May 18, 2017 at 13:49