Sunflower fractal: Difference between revisions
m
→{{header|Fōrmulæ}}
(→{{header|Julia}}: move png) |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 270:
End
</syntaxhighlight>
=={{header|Fōrmulæ}}==
{{FormulaeEntry|page=https://formulae.org/?script=examples/Sunflower_model}}
'''Solution'''
The method consists in drawing points on a spriral, an archimedean spiral, where two contiguous points are separated (in angle) by the golden angle.
Because the points tend to agglomerate in the center, they are smaller there.
[[File:Fōrmulæ - Sunflower model 02.png]]
[[File:Fōrmulæ - Sunflower model 03.png]]
'''Improvement'''
Last result is not natural. Florets in a sunflower are all equal size.
H. Vogel proposed to use a Fermat spiral, in such a case, the florets are equally spaced, and we can use now circles with the same size:
[[File:Fōrmulæ - Sunflower model 04.png]]
[[File:Fōrmulæ - Sunflower model 05.png]]
[[File:Fōrmulæ - Sunflower model 06.png]]
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
window 1, @"Sunflower Fractal", ( 0, 0, 400, 400 )
WindowSetBackgroundColor( 1, fn ColorBlack )
void local fn SunflowerFractal
NSUinteger seeds = 4000
double c, i, angle, x, y, r
pen 2.0, fn ColorWithRGB( 0.997, 0.838, 0.038, 1.0 )
c = ( sqr(5) + 1 ) / 2
for i = 0 to seeds
r = (i ^ c) / seeds
angle = 2 * pi * c * i
x = r * sin(angle) + 200
y = r * cos(angle) + 200
oval ( x, y, i / seeds * 5, i / seeds * 5 )
next
end fn
fn SunflowerFractal
HandleEvents
</syntaxhighlight>
[[file:Sunflower_Fractal.png]]
=={{header|Go}}==
Line 477 ⟶ 532:
sunflowerplot()
</syntaxhighlight>
▲[[File:Sunflower-julia.png|left|thumb]]
{{output}}
[[File:Sunflower-julia.png|center|thumb]]
=={{header|Liberty BASIC}}==
Line 1,008 ⟶ 1,067:
{{trans|Go}}
{{libheader|DOME}}
<syntaxhighlight lang="
import "dome" for Window
|