stairs Art/Electric
L-SYSTEMS
back to programs
 
koch snowflakes
general von koch
hilbert curve
pythagorean tree
H-H dragon curve
peano-gosper 19
'H' branching curve
plant
sierpinski square
sierpinski arrow
gosper square
sierpinski curve
spirograph circle
sierpinski carpet
sierpinski gasket
peano-gosper 13
peano-gosper 7
peano curve
penrose tiling
snowflake halls
peano octagon
peano hexagon
levy curve
sierpinski pentagon
not sierpinski
peano curve - H
square knot
sierpinski square 2
koch pentagram
fass curve
square cross
cesaro triangle
realistic snowflake
gray code dragon
sierpinski gasket 3
sierpinski sieve
koch square curve
dekking island
koch island
koch ff curve
hexagon spacefill
 
e-mail
KOCH SNOWFLAKE
snowflake
mouseover reveals pentagrammic flake

PROGRAM Koch_Snowflakes_Simulation ! W.van Duyn 2004
SET MODE "color"
SET WINDOW 0,1199,0,903     !tune to suit your monitor
SET BACKGROUND COLOR "white"
CLEAR
CALL init(x,y)
END

SUB init(x,y)
OPTION ANGLE degrees
PRINT "input position try x, 200 and y, 600"
INPUT x,y
PRINT "input size try 400, level try 4, dimension try 6."
INPUT size,level,ak
CLEAR
SET COLOR "blue"
FLOOD 1,1
SET COLOR "white"
LET a=0
LET k=360/ak
LET r= 2*(1+cos(k))
For ii = 1 TO ak STEP 2
CALL shift(level,size,x,y,a,k,r)
NEXT ii
SET COLOR "black"
FLOOD 11,11
END SUB

SUB shift(level,size,x,y,a,k,r)
LET d=size/(r^level)
LET lev=level
CALL move(d,lev,a,x,y,k)
CALL turnRIGHT(a,k)
END SUB

SUB move(d,lev,a,x,y,k)
IF lev=0 THEN
CALL travelON(d,a,x,y)
EXIT IF
ELSE
CALL move(d,lev-1,a,x,y,k)
CALL turnLEFT(a,k)
CALL move(d,lev-1,a,x,y,k)
CALL turnRIGHT(a,k)
CALL move(d,lev-1,a,x,y,k)
CALL turnLEFT(a,k)
CALL move(d,lev-1,a,x,y,k)
END IF
END SUB

SUB travelOn(d,a,x,y)     !move in the current direction
OPTION ANGLE degrees
LET x2=x+d*cos(a)
LET y2=y+d*sin(a)
PLOT x,y;x2,y2
LET x=x2
LET y=y2
END SUB

SUB turnLEFT(a,k)
LET a=a+k
END SUB

SUB turnRIGHT(a,k)
LET a=a-2*k     !try a=a-k
END SUB

!this code can be easily modified to produce
!many different von Koch curves for example
!the triangular Sierpinski gasket and the Peano curve

Website, Text and Some Images Copyright © 2002 tzingaro.com, all rights reserved.