Barnsley fern: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,480: | Line 1,480: | ||
=={{header|Scilab}}== |
=={{header|Scilab}}== |
||
{{Works with|Scilab|5.4.0 and above}} |
{{Works with|Scilab|5.4.0 and above}} |
||
This version creates a list of points, defining the fern, and shows them on a plot windows, which can then be saved to a file via the GUI or the console by the user. |
|||
<lang> |
|||
iteractions=1.0d6; |
|||
XY=zeros(2,iteractions+1); |
|||
x=0; |
|||
y=0; |
|||
i=2; |
|||
while i<iteractions+2 |
|||
random_numbers=rand(); |
|||
xp=x; |
|||
if random_numbers(1) < 0.01 then |
|||
x = 0; |
|||
y = 0.16 * y; |
|||
elseif random_numbers(1) >= 0.01 & random_numbers(1) < 0.01+0.85 then |
|||
x = 0.85 * x + 0.04 * y; |
|||
y = -0.04 * xp + 0.85 * y + 1.6; |
|||
elseif random_numbers(1) >= 0.86 & random_numbers(1) < 0.86+0.07 then |
|||
x = 0.2 * x - 0.26 * y; |
|||
y = 0.23 * xp + 0.22 * y + 1.6; |
|||
else |
|||
x = -0.15 * x + 0.28 * y; |
|||
y = 0.26 * xp + 0.24 * y + 0.44; |
|||
end |
|||
XY(1,i)=x; |
|||
XY(2,i)=y; |
|||
i=i+1; |
|||
end |
|||
scf(0); |
|||
clf(); |
|||
xname('Barnsley fern'); |
|||
plot2d(XY(1,:),XY(2,:),-0) |
|||
axes=gca(); |
|||
axes.isoview="on"; |
|||
axes.children.children.mark_foreground=13; |
|||
</lang> |
|||
=={{header|SequenceL}}== |
=={{header|SequenceL}}== |