stairs Art/Electric
IF-SYSTEMS
programs 1
 
polygons
carpets
koch curve
heighway dragon
gray code dragon
circular fractal
circular sierpinski
 
e-mail
IFS POLYGONS
logical attractor
mouseover for square cantor set

PROGRAM IFSPOLYGON   ! © W.van Duyn May 5th 2004
SET MODE "color"
SET WINDOW 0,1199,0,903
SET BACKGROUND COLOR "white"
CLEAR
CALL init
END

SUB init
PRINT "input: iterations try 1000,000"
INPUT n
PRINT "input: size try 400, number of sides 3 to 8"
INPUT size,ak
CLEAR
SET COLOR 16
FLOOD 1,1
SET COLOR 13
CALL drawPolygon(size,n,ak)
END SUB

SUB drawPolygon(size,n,ak)
OPTION ANGLE degrees
LET b=360/ak
IF ak >8 THEN LET r=2*(1+cos(b/2))
! ??? 9 and above overlaps occur, will need to find r for each case
IF ak>4 AND ak<=8 THEN LET r=2+2*cos(b)
!serpinski polygon
IF ak>3 AND ak<=4 THEN LET r=2+cos(b/2)
!square cantor set
IF ak<=3 THEN LET r=2
!serpinski gasket
LET dx=600
LET dy=400
!almost the center of the screen
LET xr=0
LET yr=0
!arbitrary point to begin
PLOT xr,yr
RANDOMIZE
FOR i=1 to n
LET k=INT(RND*ak)+1
LET a=360*k/ak
LET x= size*SIN(a)   !general coordinates for vertices of any polygon
LET y= size*COS(a)   !
LET xn=(x+xr)/r
LET yn=(y+yr)/r
SET COLOR MIX (col) 1-k/ak,1,k/ak
SET COLOR col
IF i>5 THEN PLOT xn+dx, yn+dy   !wait until it settles down then plot
LET xr=xn
LET yr=yn
NEXT i
END SUB


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