How to resolve the algorithm Koch curve step by step in the BASIC256 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Koch curve step by step in the BASIC256 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 BASIC256 programming language
Source code in the basic256 programming language
global RtoD, DtoR
RtoD = 180 / Pi
DtoR = Pi / 180
global posX, posY, angulo
posX = 170 : posY = 100 : angulo = 0
global ancho, alto
ancho = 650 : alto = 650
graphsize ancho, alto
subroutine kochLado(longitud, fondo)
if fondo = 0 then
dx = cos(angulo*DtoR) * longitud
dy = sin(angulo*DtoR) * longitud
color rgb(5,100,24)
line (posX, posY, posX+dx, posY+dy)
posX += dx
posY += dy
else
call kochLado(longitud/3.0, fondo-1)
angulo += 60
call kochLado(longitud/3.0, fondo-1)
angulo -= 120
call kochLado(longitud/3.0, fondo-1)
angulo += 60
call kochLado(longitud/3.0, fondo-1)
end if
end subroutine
subroutine CopoNieveKoch(longitud, recursionfondo)
for i = 1 to 6
call kochLado(longitud,recursionfondo)
angulo -= 300
next i
end subroutine
for n = 0 To 7
clg
fastgraphics
text 3,4, "Copo de nieve de Koch"
text 4,16, "Iteración número: " & n
call CopoNieveKoch(280, n)
pause 0.8
refresh
next n
imgsave "Koch_curve.jpg", "jpg"
end
You may also check:How to resolve the algorithm Extreme floating point values step by step in the Tcl programming language
You may also check:How to resolve the algorithm Longest common substring step by step in the Modula-2 programming language
You may also check:How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the Ela programming language
You may also check:How to resolve the algorithm Tokenize a string step by step in the PL/M programming language
You may also check:How to resolve the algorithm Runtime evaluation step by step in the Ursa programming language