9

I'm almost happy with my golden spiral in golden rectangles:

    \documentclass[a4paper,class=article,border=5pt,tikz]{standalone}
    \usepackage{fp}
    \usetikzlibrary{fixedpointarithmetic}

    \begin{document}
    \begin{tikzpicture}[thick, scale=4]
        \pgfmathsetmacro{\w}{1}
        \pgfmathsetmacro{\h}{\w*(2/(1+sqrt(5)))}
        \pgfmathsetmacro{\dx}{(-(\h/(\h-\w))*\w)/((\h/\w)-(\h/(\h-\w)))}
        \pgfmathsetmacro{\dy}{(\h/\w)*\dx}

        \draw (0,0) rectangle (\w,\h);
        \draw (\h,0) -- (\h,\h); 
        \draw (\h,{\w-\h}) -- (\w,{\w-\h});        
        \draw ({2*\w-2*\h)},{\w-\h}) -- ({2*\w-2*\h},\h);      
        \draw (\h,{4*\h-2*\w}) -- ({2*\w-2*\h)},{4*\h-2*\w});
        \draw ({6*\h-3*\w},{4*\h-2*\w}) -- ({6*\h-3*\w},{\w-\h});
        \draw ({6*\h-3*\w},{6*\w-9*\h}) -- ({2*\w-2*\h},{6*\w-9*\h});
        \draw ({2*\w-2*\h-13*\h+8*\w},{4*\h-2*\w}) -- ({2*\w-2*\h-13*\h+8*\w},{4*\h-2*\w-13*\h+8*\w});

        \pgfmathsetmacro{\a}{(-2/pi)*ln((1+sqrt(5))/2)}
        \pgfmathsetmacro{\d}{sqrt(pow(\dx,2) + pow((\dy-\h), 2))}

        \draw[red, rotate around={{-atan((2*\h-\w)/\w)}:(\dx,\dy)}, domain=0:6*pi, variable=\t, samples=300] plot[fixed point arithmetic] ({\dx-\d*exp(\a*\t)*cos(deg(\t))}, {\dy-\d*exp(\a*\t)*sin(deg(\t))});

    \end{tikzpicture}
    \end{document}

enter image description here

But even with 5000 samples and very thin lines there is a small problem:

enter image description here

The logarithmic spiral should stay inside the box, but it doesn't. The spirals here have the same problem as mine. Is there a way to fix this?

The line width is not the problem. It's getting even worse with thinner lines of same width:

enter image description here

11
  • 3
    Is that from the double line width (0.2mm spiral, 0.1mm grid)? Does it vanish if you set the spiral to 0.1mm? Commented Nov 27, 2015 at 1:20
  • 1
    Please post complete code! Completing your code in the most obvious way, I just get gazillions of errors.
    – cfr
    Commented Nov 27, 2015 at 3:03
  • No, the line width is not the problem. Commented Nov 27, 2015 at 5:45
  • 4
    I believe this is the correct result: The golden spiral passes through the points that divide the golden rectangles, but it's not tangent to the rectangle borders at these points. Take a look at Fig. 34 in Spirals and the Golden Section or see Golden Rectangle on Wolfram MathWorld
    – Jake
    Commented Nov 27, 2015 at 9:41
  • @Jake An answer? (Or is this off-topic as it's about maths, or ...?
    – Joseph Wright
    Commented Dec 17, 2015 at 11:12

0

Browse other questions tagged .