How to resolve the algorithm Peano curve step by step in the XPL0 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Peano curve step by step in the XPL0 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 XPL0 programming language
Source code in the xpl0 programming language
proc Peano(X, Y, Lg, I1, I2);
int X, Y, Lg, I1, I2;
[if Lg = 1 then
[Line(3*X, 3*Y, 11 \cyan\);
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);
];
[SetVid($13);
Peano(0, 0, 3*3*3*3, 0, 0); \start Peano recursion
]
You may also check:How to resolve the algorithm Tokenize a string step by step in the ColdFusion programming language
You may also check:How to resolve the algorithm Hofstadter Q sequence step by step in the Action! programming language
You may also check:How to resolve the algorithm Towers of Hanoi step by step in the 6502 Assembly programming language
You may also check:How to resolve the algorithm Bitmap/Flood fill step by step in the Action! programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean/Calculate Pi step by step in the C++ programming language