home *** CD-ROM | disk | FTP | other *** search
- { The Lorenz Attractor }
-
- const xscreen=640,yscreen=400
- const delta=0.01
-
- single x,y,z
- single xf,yf
- longint lt,rt,top,bottom
-
- sub draw_universal_line(xw,yw)
- shared xf,yf
- shared lt,rt,top,bottom
- xs = ((xw*xf-lt) * xscreen / (rt-lt)) + xscreen/2
- ys = (yw*yf-bottom) * yscreen / (top-bottom)
- color int(rnd*2)+1
- line step (xs,ys)
- end sub
-
- sub universal_x&(xw)
- shared xf
- shared lt,rt
- universal_x& = ((xw*xf-lt) * xscreen / (rt-lt)) + xscreen/2
- end sub
-
- sub universal_y&(yw)
- shared yf
- shared top,bottom
- universal_y& = (yw*yf-bottom) * yscreen / (top-bottom)
- end sub
-
- sub calc
- shared x,y,z
- dx = 10.0*(y-x)
- dy = x*(28.0-z)-y
- dz = x*y - (8.0/3.0)*z
- x = x + delta*dx
- y = y + delta*dy
- z = z + delta*dz
- end sub
-
- sub LorenzAttractor
- shared x,y,z
- x=1 : y=1 : z=1
- calc
- penup
- setxy universal_x&(x),universal_y&(z)
- repeat
- calc
- draw_universal_line(x,z)
- until mouse(0)
- end sub
-
- { ** main ** }
- screen 1,xscreen,yscreen,2,4
-
- palette 0,0,0,0 '..black
- palette 1,1,1,1 '..white
- palette 2,0,1,0 '..green
-
- lt=0 '..window dimensions
- rt=xscreen
- top=0
- bottom=yscreen
-
- xf=14.0 '..scale up x and y
- yf=7.0
-
- color 1,0
- cls
-
- locate 2,50
- prints "press left mouse button..."
-
- LorenzAttractor
-
- color 1,0
- locate 2,50
- prints " hit a key..."
-
- while inkey$="":wend
-
- screen close 1
-