How can I simplify some positioning with some foreach loops
or some own styles
? Here is the original picture:
And here is my MWE:
\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[every node/.style={font=\tiny},scale=1.5,xscale=1.2]
\coordinate (a) at (0:1.5);
\coordinate (b) at (60:1);
\coordinate (c) at (120:1);
\coordinate (d) at (180:1.5);
\coordinate (e) at (240:1);
\coordinate (f) at (300:1);
\draw[dashed] (a) -- (b) -- (c) -- (d);
\draw (d) -- (e) -- (f) -- (a);
\draw (a) -- (0,3);
\draw (0,3) -- ($(b)!.5!(0,3)$);
\draw[dashed] (c) -- ($(c)!.5!(0,3)$);
\draw ($(c)!.5!(0,3)$) -- (0,3);
\draw[dashed] (b) -- ($(b)!.5!(0,3)$);
\draw (0,3) -- (d);
\draw (0,3) -- (e);
\draw (0,3) -- (f);
\draw ($(a)!.5!(0,3)$) -- ($(b)!.5!(0,3)$) -- ($(c)!.5!(0,3)$) -- ($(d)!.5!(0,3)$) -- ($(e)!.5!(0,3)$) -- ($(f)!.5!(0,3)$) -- cycle;
\fill[black,opacity=.3] ($(a)!.5!(0,3)$) -- ($(b)!.5!(0,3)$) -- ($(c)!.5!(0,3)$) -- ($(d)!.5!(0,3)$) -- ($(e)!.5!(0,3)$) -- ($(f)!.5!(0,3)$) -- cycle;
\fill[gray,opacity=.3] ($(a)!.5!(0,3)$) -- ($(b)!.5!(0,3)$) -- (b) -- (a) -- cycle;
\fill[gray,opacity=.3] ($(b)!.5!(0,3)$) -- ($(c)!.5!(0,3)$) -- (c) -- (b) -- cycle;
\fill[gray,opacity=.3] ($(d)!.5!(0,3)$) -- ($(e)!.5!(0,3)$) -- (e) -- (d) -- cycle;
\fill[gray,opacity=.3] ($(c)!.5!(0,3)$) -- ($(d)!.5!(0,3)$) -- (d) -- (c) -- cycle;
\fill[gray,opacity=.3] ($(e)!.5!(0,3)$) -- ($(f)!.5!(0,3)$) -- (f) -- (e) -- cycle;
\fill[black,opacity=.3] ($(f)!.5!(0,3)$) -- ($(a)!.5!(0,3)$) -- (a) -- (f) -- cycle;
\draw[dashed] ([xshift=-.75cm]$(a)!.5!(0,3)$) -- (0,0);
\draw[fill=white,radius=.1em] (0,0) circle node[right] {$O_1$};
\draw ([xshift=-.75cm]$(a)!.5!(0,3)$) -- (0,3);
\draw[fill=white,radius=.1em] ([xshift=-.75cm]$(a)!.5!(0,3)$) circle node[above right=-3.5] {$O_1'$};
\node[above right=-2] at (b) {$A_i$};
\node[above left=-2] at (b) {$A_2'$};
\node[above right=-2] at (c) {$A_1'$};
\draw[fill=white,radius=.1em] (b) circle;
\draw[fill=white,radius=.1em] (c) circle;
\node[left] at (d) {$A_n$};
\node[below] at (e) {$A_1$};
\node[below] at (f) {$A_2$};
\draw[fill=white,radius=.1em] (0,3) circle node[above] {$O$};
\node[above left=-2] at ($(d)!.5!(0,3)$) {$A_n'$};
\node[above right=-4] at ($(b)!.5!(0,3)$) {$A_i'$};
\draw[fill=white,radius=.1em] ($(a)!.5!(0,3)$) circle;
\draw[fill=white,radius=.1em] ($(b)!.5!(0,3)$) circle;
\draw[fill=white,radius=.1em] ($(c)!.5!(0,3)$) circle;
\draw[fill=white,radius=.1em] ($(d)!.5!(0,3)$) circle;
\draw[fill=white,radius=.1em] ($(e)!.5!(0,3)$) circle;
\draw[fill=white,radius=.1em] ($(f)!.5!(0,3)$) circle;
\end{tikzpicture}
\end{document}
Here is the ouput, too:
BONUS: How can in generally be the code cleaned up?
\foreach \X in {a,...,f} {\draw[fill=white,radius=.1em] ($(\X)!.5!(0,3)$) circle;}
and so on...