7

I am currently trying to draw Fibonacci Flower with Tikz. Everything works fine for small values of \i but if I go higher than 45 the angle becomes too large for rotate (I had something like 6000 in mind for the maximal value :) ).

\documentclass{minimal}
\usepackage{tikz}
\usepackage{calc}
\begin{document}

\begin{center}
\begin{tikzpicture}[scale=0.05]
\foreach \i in {45,...,1}{
\draw[rotate={\i*360*(1-1/(0.5*(1+sqrt(5))))},fill=white] ({(sqrt(\i))},0) ellipse ({(sqrt(\i))} and {0.3*(sqrt(\i))});
}

\end{tikzpicture}
\end{center}
\end{document}

My best fix so far is to use the \intcalcMod from the intcalc package but than I can use only integers as input hence the error becomes too large. Here is the best I could get so far (as you see the spirals vanish in the outer regions, I think this is due to the rounding error and should not happen if we use the exact angle):

enter image description here

Would appreciate any help for this fun project :)

Solved:

Thanks to percusse here is the version with 10000 paddles. I counted 144 clockwise and 89 anticlockwise spirals (so consecutive Fibonacci numbers, as it should be). Math is so awesome :)

enter image description here

5
  • 3
    Oh my eyes!! Nice picture. First time I have seen it.
    – Sigur
    Commented Dec 6, 2017 at 20:40
  • Search \pgfmathmod in the manual.
    – Symbol 1
    Commented Dec 6, 2017 at 21:02
  • Ah, I did not know that exists, thank you. I tried it but unfortunately it gives the same "Dimension too large" error as rotate.
    – Florian
    Commented Dec 6, 2017 at 21:10
  • whoa how did you count them?
    – percusse
    Commented Dec 7, 2017 at 15:20
  • 1
    I printed it out and counted the spirals while drawing them (always starting from the outside). It took some time :)
    – Florian
    Commented Dec 8, 2017 at 18:24

1 Answer 1

4

Instead of a direct multiplication if you can accept an iterative solution then following works. The value 283.10562 is just done offline but it doesn't matter since it just defines an initial angle. It can also be iterated starting from 0 defining an extra rotation.

Note that I've used dimensions in the coordinates and ellipse specs. This is a safer way to avoid scaling issues.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\myfact{(1-2/(1+sqrt(5)))*360}
\foreach \i[evaluate={\t=Mod(\lastt-\myfact,360);},
           remember=\t as \lastt (initially 283.10562)] in {1200,...,1}{
\draw[rotate={\t},fill=white] 
      ({(sqrt(\i))*1pt},0) ellipse ({(sqrt(\i))*1pt} and {(sqrt(\i))*0.3pt});
}

\end{tikzpicture}
\end{document}

Here is for 1200

enter image description here

and 5000

enter image description here

1
  • If you switch to LuaLaTeX engine, 10000 also compiles.
    – percusse
    Commented Dec 6, 2017 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .