$1$ big circle formed by $27$ smaller circles I have $27$ small circles of radius $40$ pixels. I want to form $1$ big circle from these. 
How can I find the positions of each?
I also want to have a small gap between each small circle.
 A: I assume that you are trying to arrange your circle centers like this:

The points drawn here form a regular 27-gon. They are spaced at regular angles, i.e. the angle $AOB$ (marked yellow) is $\frac{360°}{27}$. The point $C$ is the midpoint between $A$ and $B$. The line $OC$ is perpendicular to $AB$. So $OAC$ is a right triangle. $OA$ is its hypothenuse, and $\frac{180°}{27}$ is its angle at $O$. Call the length of the hypothenuse $r$, since this is also the radious of the circumcircle. Then you get
$$\lvert A,C\rvert = r\sin\frac{180°}{27}$$
If you want your circles to touch one another, then you'd want the distance $\lvert A,C\rvert$ to be equal to the radius of your circles, i.e. 40 pixels. If you want to have “a small gap” between them, then add half that gap to the distance $\lvert A,C\rvert$. In the result, the distance $\lvert A,B\rvert$ between neighbouring circle centers will be twice the radius plus the desired gap. Once you know your ideal $\lvert A,C\rvert$, you can solve the above equation for $r$.
Once you know $r$, you can choose your circle centers by computing angles at regular intervals, and converting from polar coordinates to Cartesian ones.
\begin{align*}
 \varphi_i &= \frac{i}{27}\cdot360° \quad( + \theta ) \\
 x_i &= r\cos\varphi_i \quad( + x_C ) \\
 y_i &= r\sin\varphi_i \quad( + y_C )\\
\end{align*}
The optional addition of $\theta$ to all angles simply rotates the setup as a whole. Similarly, the offsets $x_C$ and $y_C$ can be used to shift the center of the whole setup to an arbitrary location.
