0

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 :)

ABIM
  • 322
  • Inside each cirle in that answer https://tex.stackexchange.com/a/256965/140722 you can draw a equilateral triangle using something like \node[regular polygon, regular polygon sides=2, draw,inner sep=0.3535cm] at (\a,\b) {$y_k$}; (see pgfmanual page 792, the library shapes.geometric). Is that what you want? – Black Mild Sep 27 '21 at 10:31

1 Answers1

2

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

Markus G.
  • 2,735
  • I realised re-reading your question, this may not be exactly what you are looking for (as it is still a circle) but it has all the required elements that enable you to turn it into what you are looking for. That will probably also help you making your question a bit more precise (which it currently is actually not) – Markus G. Sep 26 '21 at 20:04
  • Indeed, I was hoping for the ''opposite''; i.e.: a triangle packed with spheres. As opposed to the above (wonderful) sphere packed with triangles.. – ABIM Sep 26 '21 at 20:22