Fibonacci Flowers

Andy Long, Spring 2024

disp(“Got this from (and thanks to):  https://math.libretexts.org/Bookshelves/Applied_Mathematics/Mathematical_Biology_(Chasnov)/02%3A_Age-structured_Populations/2.03%3A_The_Fibonacci_Numbers_in_a_Sunflower”);

golden=(1+sqrt(5))/2;
function flower(alpha,size)
% draws points moving radially but rotated an angle 2*pi*num
%    figure
    f = figure;
    angle=2*pi*alpha; 
    v0=1.0; % for higher Fibonacci numbers try v0=0.5, 0.25, etc
    r0=0;
    npts=100/v0;
    theta=(0:npts-1)*angle; % all the angles of the npts
    r = r0*ones(1,npts); % starting radius of the npts
    for i=1:npts % i is the total number of points to be plotted (also time)
        for j=1:i % find coordinates of all i points; j=i is newest point
            r(j)=r(j)+v0; % *(i-j);
            x(j)=r(j)*cos(theta(j)); 
            y(j)=r(j)*sin(theta(j));
        end
        frame = getframe(f);
        scale=size*(i/npts);
        plot(x,y,’.’,’MarkerSize’,5.0*scale);
        axis equal;
        axis([-npts*v0-r0 npts*v0+r0 -npts*v0-r0 npts*v0+r0]);
        pause(0.1);
        % draw a circle at the center
    end
    plot(x,y,’.’,’MarkerSize’,5.0*scale);
    hold on;
    phi=linspace(0,2*pi);
    x=r0*cos(phi);
    y=r0*sin(phi);
    fill(x,y,’r’)
    pause(0.1);
 end
 % flower(golden,2)

golden=GoldenRatio*1.0;

Manipulate[
Module[
{angle=2*Pi*alpha,v0,r0,theta,j,x,y,scale,phi,plot1},(*draws points moving radially but rotated an angle 2*pi*num*)
v0=1.0;(*% for higher Fibonacci numbers try v0=0.5,0.25,*)
r0=0;
theta=(Range[npts]-1)*angle;(*all the angles of the npts*)
x=ConstantArray[0,npts];y=ConstantArray[0,npts];(* % starting radius of the npts *) 
For[j=1,j<=npts,j++ ,
	r0=r0+v0;
	x[[j]]=r0*Cos[theta[[j]]];
	y[[j]]=r0*Sin[theta[[j]]];
	];
 Show[
ParametricPlot[{r0*Cos[u],r0*Sin[u]},{u,0,2Pi}],ListPlot[Transpose[{x,y}],AspectRatio->1,PlotStyle->{PointSize->Large},ColorFunction->Function[{theta},Hue[Cos[theta]]]
]
]
],
{{points,200},100,500,1},
{{npts,34},1,points,1},
{{alpha,golden},0,2Pi,.01}
]