How to resolve the algorithm Fibonacci word/fractal step by step in the Processing programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Fibonacci word/fractal step by step in the Processing programming language
Table of Contents
Problem Statement
The Fibonacci word may be represented as a fractal as described here: (Clicking on the above website (hal.archives-ouvertes.fr) will leave a cookie.)
Create and display a fractal similar to Fig 1. (Clicking on the above website (hal.archives-ouvertes.fr) will leave a cookie.)
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Fibonacci word/fractal step by step in the Processing programming language
Source code in the processing programming language
int n = 18;
String f1 = "1";
String f2 = "0";
String f3;
void setup(){
size(600,600);
background(255);
translate(10, 10);
createSeries();
}
void createSeries(){
for(int i=0; i<n; i++){
f3 = f2+f1;
f1 = f2;
f2 = f3;
}
drawFractal();
}
void drawFractal(){
char[] a = f3.toCharArray();
for(int i=0; i<a.length; i++){
if(a[i]=='0'){
if(i%2==0){
rotate(PI/2);
}
else{
rotate(-PI/2);
}
}
line(0,0,2,0);
translate(2,0);
}
}
You may also check:How to resolve the algorithm Entropy step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm Sequence of non-squares step by step in the Scheme programming language
You may also check:How to resolve the algorithm Topswops step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Anagrams step by step in the Ela programming language
You may also check:How to resolve the algorithm Harmonic series step by step in the Forth programming language