# How to distribute a set of circles in polar array?

How can I evenly distribute a set of circles (the red circles in my case) in polar array? The central distance between the big red circle and the white circle is 4.267 cm in case needed. Many thanks for your suggestion in advance!

The code is here,

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{picture}(215,100)(0,0)
\begin{tikzpicture}
\filldraw[color=black](100,50) circle(7cm);
\filldraw[color=white](100,50) circle(1.8cm);
\filldraw[color=red](104.267, 50) circle(0.962cm);
\begin{scope}[shift={(104.267,50)}]
\foreach \x in {60,120,...,360} {\filldraw[color=red](\x:1.633) circle(0.45cm); }
\end{scope}
\end{tikzpicture}
\end{picture}
\end{figure}
\end{document}

• I'm afraid that I don't understand the question. What is a "polar array"? It's not a term that I've heard before. What is it that the code you supply does not do that you want it to do? – Loop Space Jan 18 '11 at 9:30
• I was not too sure what to use to describe the problem here. May I rephrase "radially distribute" as in autocad? Sorry for the confusion – gamahuri Jan 18 '11 at 9:47
• I have no experience with autocad so the phrase "radially distribute" still isn't wholly clear. Can you describe the effect that you would like to achieve, or draw a mock-up? – Loop Space Jan 18 '11 at 9:56
• Do any of the images here help to explain what you want to do? – Juan A. Navarro Jan 18 '11 at 10:01

I assume you want to distribute sets of red circles (consisting of one large and six small circles) evenly around the centre point in a similar fashion to that described on p. 35 of this AutoCAD handout.

Here's my suggestion:

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{picture}(215,100)(0,0)
\begin{tikzpicture}

%These are the parameters from the AutoCAD "Polar Array" dialog:
%"Total number of items"
\def\n{4};

%"Angle to fill"
\def\nangle{360};

%"Rotate items as copied" (1 = yes; 0 = no)
\def\rbool{1};

%Optional angle for the position of the first set
\def\nstart{0};

%Number of small circles
\def\k{6};

\pgftransformshift{ \pgfpoint{100}{50} };
\filldraw[color=black](0,0) circle(7cm);
\filldraw[color=white](0,0) circle(1.8cm);

\foreach \a in {1,...,\n} {
\pgftransformshift{ \pgfpointpolar{(\a-1)*\nangle/\n+\nstart}{4.3cm} }
\pgftransformrotate{ (\a-1)*\nangle/\n*\rbool }
\filldraw[color=red] (0,0) circle(.96cm);
\foreach \x in {1,...,\k} {
\filldraw[color=red,]+(\x*360/\k:1.633) circle(0.43cm);
}
}

\end{tikzpicture}
\end{picture}
\end{figure}
\end{document}


Here's the output:

• Jake, I indented your code (which is how one gets it in to a code block) and added an image of the result - I was curious to see what a "polar array" actually was! Hope that's okay. – Loop Space Jan 18 '11 at 13:02
• Jake, your suggestion is perfectly what I was looking for! Many thanks! – gamahuri Jan 18 '11 at 14:49
• Juan, thanks for your concern. as you can see the problem is solved now, I am sorry that my question was not clear enough. I knew what was a polar array. It was how to do it in tex. – gamahuri Jan 18 '11 at 14:54
• Jake, I was trying to understand your code (all commands are new for me). While doing so, I tried to modify the code to go one step further by adding yet smaller circles. But it is not compiling. Could you please tell me what I missed? Thanks! (I put the new code as answer since I could not figure where to add). – gamahuri Jan 18 '11 at 16:39

A solution with »tikZ« syntax. The iteration should be comprehensible. Just adapt the below example to your needs.

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\fill[black](0,0) circle (7cm);
\fill[white](0,0) circle (2cm);
\foreach \r in {72,144,...,360} {%
\begin{scope}[red,shift={(\r:4.5)}]
\fill (0,0) circle (1cm);
\foreach \x in {72,144,...,360} {%
\begin{scope}[shift={(\x:1.75)}]
\fill (0,0) circle (0.5cm);
\end{scope}
};
\end{scope}
};
\end{tikzpicture}
\end{document}


The pgf/tikZ manual has more details about the involved commands.

• Nice! The scope environment with the shift parameter is much neater to look at. @pban92: The \def statements and the mathematical expressions for defining the number of circles calculating the angles also work in this solution. You can also add a \rotate={<angle>} statement in the optional argument of the first scope environment to get the "Rotate items as copied" effect from AutoCAD. – Jake Jan 18 '11 at 18:43
• Thanks Thorsten! Indeed it looks nice! You guys are so helpful! – gamahuri Jan 19 '11 at 13:46

Just sharing in case anybody needs it. The code shows four plates with different configurations. May need a bit texkeeping (is there any such word at all?) Thank you all once again for your kind help!

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{picture}(215,20)(0,0)
\begin{tikzpicture}
\pgftransformshift{\pgfpoint{100}{0}}; % shift of (0,0) coordinate
\filldraw[scale=0.2,color=black](0,0) circle(7cm); % plate
\filldraw[scale=0.2,color=white](0,0) circle(0.6505cm); % 1stlevelcircle
\foreach \x in {60,120,...,360} {\filldraw[scale=0.2,color=white](\x:1.9) circle(0.6505cm);
\foreach \x in {30,60,...,360} {\filldraw[scale=0.2,color=white](\x:3.8) circle(0.6505cm);
\foreach \x in {18,36,...,360} {\filldraw[scale=0.2,color=white](\x:5.7) circle(0.6505cm);
}
}
}
%F0F0F0F0F0
\pgftransformshift{\pgfpoint{90}{0}};
\filldraw[scale=0.2,color=black](0,0) circle(7cm);
\filldraw[scale=0.2,color=white](0,0) circle(2.5cm);
\foreach \x in {60,120,...,360}{\filldraw[scale=0.2,color=white](\x:4.755) circle(1.28cm); }
%F1F1F1F1F1
\def\n{6}; %"Total number of items"
\def\nangle{360}; %"Angle to fill"
\def\rbool{1}; %"Rotate items as copied" (1 = yes; 0 = no)
\def\nstart{0} ;%Optional angle for the position of the first set
\def\k{6}; %Number of small circles
\pgftransformshift{\pgfpoint{90}{0}};
\filldraw[scale=0.2,color=black](0,0) circle(7cm);
\filldraw[scale=0.2,color=white](0,0) circle(1.8cm);
\foreach \a in {1,...,\n} {
\pgftransformshift{\pgfpointpolar{(\a-1)*\nangle/\n+\nstart}{0.86cm}}
\pgftransformrotate{(\a-1)*\nangle/\n*\rbool}
\filldraw[scale=0.2,color=white](0,0) circle(.96cm); %4.3*0.2=0.86
\foreach \x in {1,...,\k} {
\filldraw[scale=0.2,color=white]+(\x*360/\k:1.633) circle(0.43cm);
}
}
%%F2F2F2F2F2
\pgftransformshift{\pgfpoint{90}{0}}; % shift of (0,0) coordinate
\filldraw[scale=0.2,color=black](0,0) circle(7cm);   % plate
\filldraw[scale=0.2,color=white](0,0) circle(1.4cm);  % 1stlevelcircle
\foreach \m in {1,...,\n} {\filldraw[scale=0.2,color=white,]+(\m*360/\k+27:6.130) circle(0.15cm); }
\foreach \m in {1,...,\n} {\filldraw[scale=0.2,color=white,]+(\m*360/\k+32:6.130) circle(0.15cm); }
\foreach \a in {1,...,\n} {
\pgftransformshift{\pgfpointpolar{(\a-1)*\nangle/\n+\nstart}{0.8146cm}}
\pgftransformrotate{(\a-1)*\nangle/\n*\rbool}  %rotation degree and %4.073*0.2=0.8146
\filldraw[scale=0.2,color=white] (0,0) circle(.736cm);  % 2ndlevelcircle
\foreach \i in {1,...,\n} {
\pgftransformshift{\pgfpointpolar{(\i-1)*\nangle/\n+\nstart}{0.297cm}}
\pgftransformrotate{(\i-1)*\nangle/\n*\rbool}  %rotation degree and %1.485*0.2=0.297
\filldraw[scale=0.2,color=white] (0,0) circle(.4cm);  % 3rdlevelcircle
\foreach \x in {1,...,\k} {
\filldraw[scale=0.2,color=white]+(\x*360/\k+30:.63) circle(0.15cm); % 4thlevelcircle
}
}
}
\end{tikzpicture}
\end{picture}
\end{figure}
\end{document}

• Out of sheer curiosity: What do these shapes represent? – Jake Jan 18 '11 at 21:53
• Jake, they are flow conditioners (FCs). The first one is the classical one and the remaining three are fractal FC up to second level iteration, (N = 0~2). See google.co.uk/… for more fractals. – gamahuri Jan 19 '11 at 13:33