How to resolve the algorithm Barnsley fern step by step in the ZX Spectrum Basic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Barnsley fern step by step in the ZX Spectrum Basic programming language
Table of Contents
Problem Statement
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS).
Create this fractal fern, using the following transformations: Starting position: x = 0, y = 0
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Barnsley fern step by step in the ZX Spectrum Basic programming language
Source code in the zx programming language
10 REM Fractal Fern
20 PAPER 7: BORDER 7: BRIGHT 1: INK 4: CLS
30 LET maxpoints=20000: LET x=0: LET y=0
40 FOR n=1 TO maxpoints
50 LET p=RND*100
60 IF p<=1 THEN LET nx=0: LET ny=0.16*y: GO TO 100
70 IF p<=8 THEN LET nx=0.2*x-0.26*y: LET ny=0.23*x+0.22*y+1.6: GO TO 100
80 IF p<=15 THEN LET nx=-0.15*x+0.28*y: LET ny=0.26*x+0.24*y+0.44: GO TO 100
90 LET nx=0.85*x+0.04*y: LET ny=-0.04*x+0.85*y+1.6
100 LET x=nx: LET y=ny
110 PLOT x*17+127,y*17
120 NEXT n
You may also check:How to resolve the algorithm Solve a Hidato puzzle step by step in the Wren programming language
You may also check:How to resolve the algorithm Roots of unity step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Joystick position step by step in the Phix programming language
You may also check:How to resolve the algorithm Long multiplication step by step in the Crystal programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the PowerShell programming language