I have a regular polygon using TikZ like this:
\begin{tikzpicture}
\node[regular polygon, regular polygon sides=5, shape border rotate=-18, fill=blue!20, minimum size=5cm, thick, draw] (Funfeck) {};
\coordinate (P1) at (Funfeck.corner 1);
\coordinate (P2) at (Funfeck.corner 2);
\coordinate (P3) at (Funfeck.corner 3);
\coordinate (P4) at (Funfeck.corner 4);
\coordinate (P5) at (Funfeck.corner 5);
...
\end{tikzpicture}
In another place, I want to have a triangle with the points P5, P1 and P2.
It should look like this:
,
so the part in the document in which these polygons are, should look like this:
The Code would be something like this:
\draw (P5) -- (P1) -- (P2) -- (P5) -- cycle;
But, as this code is at an entirely different place, this code is in a different tikzpicture and I can't access the coordinates.
Now, I have four solution proposals:
First: (My favourite) I get these coordinates without drawing the pentagon. The advantage would be, that I needn't to draw the figure somewhere else if I have the same problem another time.
Something like this:
\coordinate (P1) at (\node[regular polygon, regular polygon sides=5, shape border rotate=-18, minimum size=5cm].corner 1);
\coordinate (P2) at (\node[regular polygon, regular polygon sides=5, shape border rotate=-18, minimum size=5cm].corner 1);
\coordinate (P5) at (\node[regular polygon, regular polygon sides=5, shape border rotate=-18, minimum size=5cm].corner 1);
\draw (P5) -- (P1) -- (P2) -- (P5) -- cycle;
Second: Another possibility would be to get the coordinates out of the other tikzpicture.
I mean something like this:
\coordinate (P1) at (tikzpicture[0].coordinate.P1);
\coordinate (P2) at (tikzpicture[0].coordinate.P2);
\coordinate (P5) at (tikzpicture[0].coordinate.P5);
\draw (P5) -- (P1) -- (P2) -- (P5) -- cycle;
Third: Another solution, I have fought about was to draw the polygon, get the coordinates and then I remove the polygon. In fact, I can make the node without draw and without fill=blue!20, but then, there is still a whitespace.
I mean something like this:
\node[regular polygon, regular polygon sides=5, shape border rotate=-18, minimum size=5cm, draw] (Funfeck) {};
\coordinate (P1) at (Funfeck.corner 1);
\coordinate (P2) at (Funfeck.corner 2);
\coordinate (P3) at (Funfeck.corner 3);
\coordinate (P4) at (Funfeck.corner 4);
\coordinate (P5) at (Funfeck.corner 5);
\remove {Funfeck}
\draw (P5) -- (P1) -- (P2) -- (P5) -- cycle;
Fourth: If nothing of the other methods is possible, the worst solution is to print the Coordinates and insert them3 manually. But I haven't even found a way to do this:
My Pseudo-Code would be:
\begin{tikzpicture}
\node[regular polygon, regular polygon sides=5, shape border rotate=-18, fill=blue!20, minimum size=5cm, thick, draw] (Funfeck) {};
\coordinate (P1) at (Funfeck.corner 1);
\coordinate (P2) at (Funfeck.corner 2);
\coordinate (P3) at (Funfeck.corner 3);
\print("P1, x: "+P1.X+" .P1, y: "+P1.Y);
\print("P2, x: "+P2.X+" .P2, y: "+P2.Y);
\print("P3, x: "+P3.X+" .P3, y: "+P3.Y);
...
\end{tikzpicture}
...
\coordinate (P1) at (manually inserted, manually inserted);
\coordinate (P2) at (manually inserted, manually inserted);
\coordinate (P3) at (manually inserted, manually inserted);
Can anybody give me a solution how to solve this problem?
Thank you very much :).

\documentclassand ending with\end{document}. - Does access a coordinate in a nested \tikzpicture help? – Bobyandbob Oct 30 '17 at 11:48remember pictureandoverlay. If the latter, just draw the same points -- for regular polygons just use polar coordinates. – Oct 30 '17 at 12:01