How to resolve the algorithm Peano curve step by step in the Processing programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Peano curve step by step in the Processing programming language
Table of Contents
Problem Statement
Produce a graphical or ASCII-art representation of a Peano curve of at least order 3.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Peano curve step by step in the Processing programming language
Source code in the processing programming language
//Abhishek Ghosh, 28th June 2022
void Peano(int x, int y, int lg, int i1, int i2) {
if (lg == 1) {
ellipse(x,y,1,1);
return;
}
lg = lg/3;
Peano(x+(2*i1*lg), y+(2*i1*lg), lg, i1, i2);
Peano(x+((i1-i2+1)*lg), y+((i1+i2)*lg), lg, i1, 1-i2);
Peano(x+lg, y+lg, lg, i1, 1-i2);
Peano(x+((i1+i2)*lg), y+((i1-i2+1)*lg), lg, 1-i1, 1-i2);
Peano(x+(2*i2*lg), y+(2*(1-i2)*lg), lg, i1, i2);
Peano(x+((1+i2-i1)*lg), y+((2-i1-i2)*lg), lg, i1, i2);
Peano(x+(2*(1-i1)*lg), y+(2*(1-i1)*lg), lg, i1, i2);
Peano(x+((2-i1-i2)*lg), y+((1+i2-i1)*lg), lg, 1-i1, i2);
Peano(x+(2*(1-i2)*lg), y+(2*i2*lg), lg, 1-i1, i2);
}
void setup(){
size(1000,1000);
Peano(0, 0, 1000, 0, 0);
}
You may also check:How to resolve the algorithm Loops/Foreach step by step in the NewLISP programming language
You may also check:How to resolve the algorithm 9 billion names of God the integer step by step in the D programming language
You may also check:How to resolve the algorithm Identity matrix step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Animation step by step in the Maple programming language
You may also check:How to resolve the algorithm Order by pair comparisons step by step in the J programming language