H.Vogel’s pattern for sunflower forets.
import Diagrams.Backend.SVG.CmdLine
A representation of Vogel’s model for the floret pattern of a sunflower head. Vogel, H (1979). “A better way to construct the sunflower head”. Mathematical Biosciences 44 (44): 179–189. doi:10.1016/0025-5564(79)90080-4.
{-# LANGUAGE NoMonomorphismRestriction #-}
import Diagrams.Prelude
import Data.Colour.Palette.BrewerSet
The n florets of the sunflower are positioned at radii proportional to the square root of n and rotated by a factor 2.4 radians in accordance with Vogel’s model.
mkCoords :: Int -> [P2 Double]
=[coord (fromIntegral i) | i <- [1..n]]
mkCoords n where
= p2 $ fromPolar (sqrt m) (2.4 * m)
coord m = (r * cos theta, r * sin theta) fromPolar r theta
The color of each floret is based on it’s radius.
floret :: Double -> Diagram B
= circle 0.6 # lw none # fc (colors !! n)
floret r where
= floor (1.4 * sqrt r) `mod` 10
n = black : (reverse $ brewerSet YlOrBr 9) colors
sunflower :: Int -> Diagram B
= frame 4 $ position $ zip (mkCoords n) (florets n)
sunflower n where
= [floret (sqrt (fromIntegral i)) | i <- [1..m]] florets m
example :: Diagram B
= frame 4 $ sunflower 2000 # bg black example
= mainWith (example :: Diagram B) main