Draw circle covering of a triangle with Tikz

graphicstikz-pgftikz-styles

I want to modify the answer to this post in two ways:

  • Pack a triangle
  • Put a point at the center of each circle with label y_1,y_2,…

How can this be done? Thanks in advance 🙂

Best Answer

An approach could be replacing the drawn circles by nodes. Here is an example of how to do this, but I'll leave some of the kinks of the solution for you to work out, including the optimal orientation of the triangles and sizes and such, which highly depend on your use case.

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric,fit}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{document}

\begin{tikzpicture}[x=3cm,y=3cm]
    \pgfmathsetmacro\rad{1.1}
    \begin{scope}[every node/.style={regular polygon,regular polygon sides=3,inner sep=0cm,minimum width=1.3cm}]
        \node[fill=blue!40!red,inner sep=.12cm] at (0,0) {};
        \foreach \i in {0,...,6}
            \node[fill=blue!30!red] at (60*\i:.30*\rad) {y$_\i$};
        \foreach \n [count=\i] in {7,...,18}
            \node[fill=blue!20!red] at  ({15+30*\i}:0.57*\rad) {y$_{\n}$};
        \foreach \n [count=\i] in {19,...,36}
            \node[fill=blue!10!red] (outer\i) at ({10+20*\i}:0.86*\rad) {y$_{\n}$};
    \end{scope}

    \begin{pgfonlayer}{background}
        \node[fit=(outer1) (outer10),circle,fill=red!40,minimum width=\rad,inner sep=0cm]{};    
    \end{pgfonlayer}
\end{tikzpicture}
\end{document}

enter image description here