2

I wish to produce a regular polygon with circles drawn on each of its sides, at equal distances.

enter image description here

2
\documentclass[tikz,border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}
   \def\n{8}   % no. of sides
   \def\m{3}   % m+1 circles on each side
   \def\R{3}   % polygon's radius
   \def\r{.15} % circles' radii

   \begin{scope}
      [decoration={markings,
        mark=between positions 0 and {1-1/\m} step 1/\m
        with {
          \draw circle (\r);
        }
      }]

   \foreach[remember=\i as \oldi (initially 0)] \i in {0,...,\n} {
     % setting just 'decorate' instead will actually draw polygon
     \draw[postaction={decorate}] ({360/\n*\i}:\R) -- ({360/\n*\oldi}:\R);
   }     
   \end{scope}
\end{tikzpicture}

\end{document}
1

Alternative to your answer but based on it.

\documentclass[tikz,border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.markings,shapes.geometric}

\begin{document}

\begin{tikzpicture}
   \def\n{8}   % no. of sides
   \def\m{3}   % m+1 circles on each side
   \def\R{3}   % polygon's radius
   \def\r{.15} % circles' radii

   \begin{scope}
      [decoration={markings,
        mark=between positions 0 and {1-1/\m} step 1/\m
        with {
          \draw circle (\r);
        }
      },sides/.style={draw,postaction=decorate}]

   \pgfmathsetmacro{\m}{\m*\n}
   \node[regular polygon,regular polygon sides=\n,sides,minimum
   size=2*\R*1cm,rotate=360/16]{};
   \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.