Code archives/Graphics/Strange Attractor
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Some sample starting conditions are supplied in the init() function. Comment out the init func to generate new shapes. Not all random conditions generate a good shape so you may have to run several times. | |||||
SuperStrict Framework brl.basic Import brl.glmax2d AppTitle="strange attractor" SeedRnd(MilliSecs()) Graphics 800,800 SetBlend alphablend SetAlpha 0.02 glEnable(GL_POINT_SMOOTH) 'disable this for small speedup Global x:Double = 0.1 Global y:Double = 0.1 Global a:Double =Rnd(-3,3) Global b:Double =Rnd(-3,3) Global c:Double =Rnd(-3,3) Global d:Double =Rnd(-3,3) Const STEPS% = 2 Shl 24 init() Print "a= "+a Print "b= "+b Print "c= "+c Print "d= "+d run() Flip Print "Done" WaitKey Function Run() Local nx:Double,ny:Double For Local i% = 0 Until steps nx = _Sin(y*b) + c*_Sin(x*b) ny = _Sin(x*a) + d*_Sin(y*a) x=nx y=ny Plot((x*120)+400,(y*120)+400) Next End Function Function _sin:Double(x:Double) Return Sin(x* 57.2958) End Function Function _cos:Double(x:Double) Return Cos(x* 57.2958) End Function Function init() 'samples 'Rem a= -2.6805439855065067 b= 2.0844768343944953 c= -2.3811550716885534 d= 1.7712752537923500 'EndRem Rem a= 1.9560260499555859 b= 2.4346168219139717 c= 2.0647279581586258 d= -1.1132835321936514 EndRem Rem a= 1.20106173 b= -2.30811906 c= -0.114933334 d= 2.22842979 EndRem Rem a= 1.5688667130811149 b= -1.1898892234416945 c= -2.8606196192568909 d= 0.95424022623010973 EndRem Rem a= 1.2248441387108837 b= -2.7392325587313344 c= -1.7827782443877711 d= -1.3244245968740442 EndRem Rem a= 0.47710959283454901 b= -2.5875993744221732 c= -2.4224025666406996 d= 2.9201404236134216 EndRem Rem a= -0.69950397876281212 b= 1.7563243846226397 c= 2.3431794838379503 d= -2.5740196965902631 EndRem Rem a= 1.9910802873759064 b= -1.8253906252366905 c= -0.87575121512456100 d= -0.31756229735261243 EndRem End Function |
Comments
None.
Code Archives Forum