This is an adaptation of a Processing.js example originally written by Jim Bumgardner from his tutorial entitled Circles, Spirals and Sunflowers.
Following code adapts Jim’s example #10.
Credit also goes to TonioElGringo on stackexchange for his help.
Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the
LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de.
En français: TeXnique.fr.
% Phyllotaxy
% Author: David Convent
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\def\nbrcircles {377}
\def\outerradius {30mm}
\def\deviation {.9}
\def\fudge {.62}
\newcounter{cumulArea}
\setcounter{cumulArea}{0}
\begin{document}
\begin{tikzpicture}[scale=.32]
\pgfmathsetmacro {\goldenRatio} {(1+sqrt(5))}
\pgfmathsetmacro {\meanArea}
{pow(\outerradius * 10 / \nbrcircles, 2) * pi}
\pgfmathsetmacro {\minArea} {\meanArea * (1 - \deviation)}
\pgfmathsetmacro {\midArea} {\meanArea * (1 + \deviation) - \minArea}
\foreach \b in {0,...,\nbrcircles}{
% mod() must be used in order to calculate the right angle.
% otherwise, when \b is greater than 28 the angle is greater
% than 16384 and an error is raised ('Dimension too large').
% -- thx Tonio for this one.
\pgfmathsetmacro{\angle}{mod(\goldenRatio * \b, 2) * 180}
\pgfmathsetmacro{\sratio}{\b / \nbrcircles}
\pgfmathsetmacro{\smArea}{\minArea + \sratio * \midArea}
\pgfmathsetmacro{\smRadius}{sqrt(\smArea / pi) / 2 * \fudge}
\addtocounter{cumulArea}{\smArea};
\pgfmathparse{sqrt(\value{cumulArea} / pi) / 2}
\fill[] (\angle:\pgfmathresult) circle [radius=\smRadius] ;
}
\end{tikzpicture}
\end{document}
Comments
Adding comments is currently not enabled.