How to resolve the algorithm Koch curve step by step in the EasyLang programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Koch curve step by step in the EasyLang programming language
Table of Contents
Problem Statement
Draw a Koch curve. See details: Koch curve
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Koch curve step by step in the EasyLang programming language
Source code in the easylang programming language
proc koch x1 y1 x2 y2 iter . .
x3 = (x1 * 2 + x2) / 3
y3 = (y1 * 2 + y2) / 3
x4 = (x1 + x2 * 2) / 3
y4 = (y1 + y2 * 2) / 3
x5 = x3 + (x4 - x3) * cos 60 + (y4 - y3) * sin 60
y5 = y3 - (x4 - x3) * sin 60 + (y4 - y3) * cos 60
if iter > 0
iter -= 1
koch x1 y1 x3 y3 iter
koch x3 y3 x5 y5 iter
koch x5 y5 x4 y4 iter
koch x4 y4 x2 y2 iter
else
line x1 y1
line x3 y3
line x5 y5
line x4 y4
line x2 y2
.
.
linewidth 0.3
x1 = 15
y1 = 30
move x1 y1
for ang = 0 step 120 to 240
x2 = x1 + 70 * cos ang
y2 = y1 + 70 * sin ang
koch x1 y1 x2 y2 4
x1 = x2
y1 = y2
.
You may also check:How to resolve the algorithm Narcissistic decimal number step by step in the Lua programming language
You may also check:How to resolve the algorithm Colour bars/Display step by step in the Scala programming language
You may also check:How to resolve the algorithm Hofstadter Q sequence step by step in the Tailspin programming language
You may also check:How to resolve the algorithm Documentation step by step in the PHP programming language
You may also check:How to resolve the algorithm Interactive programming (repl) step by step in the Bracmat programming language