November 28, 2020, 11:48:42 AM

### Author Topic: [bmx] Strange Attractor by GW [ 1 month ago ]  (Read 553 times)

#### BlitzBot

• Jr. Member
• Posts: 1
##### [bmx] Strange Attractor by GW [ 1 month ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Strange Attractor
Author : GW
Posted : 1 month ago

Description : 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.

Code :
Code: BlitzMax
1. SuperStrict
2. Framework brl.basic
3. Import brl.glmax2d
4. AppTitle="strange attractor"
5. SeedRnd(MilliSecs())
6.
7. Graphics 800,800
8. SetBlend alphablend
9. SetAlpha 0.02
10. glEnable(GL_POINT_SMOOTH) 'disable this for small speedup
11.
12. Global x:Double = 0.1
13. Global y:Double = 0.1
14. Global a:Double =Rnd(-3,3)
15. Global b:Double =Rnd(-3,3)
16. Global c:Double =Rnd(-3,3)
17. Global d:Double =Rnd(-3,3)
18. Const STEPS% = 2 Shl 24
19.
20. init()
21.
22. Print "a= "+a
23. Print "b= "+b
24. Print "c= "+c
25. Print "d= "+d
26.
27. run()
28. Flip
29. Print "Done"
30. WaitKey
31.
32. Function Run()
33.         Local nx:Double,ny:Double
34.         For Local i% = 0 Until steps
35.                 nx = _Sin(y*b) + c*_Sin(x*b)
36.                 ny = _Sin(x*a) + d*_Sin(y*a)
37.                 x=nx
38.                 y=ny
39.                 Plot((x*120)+400,(y*120)+400)
40.         Next
41. End Function
42.
43. Function _sin:Double(x:Double)
44.         Return Sin(x* 57.2958)
45. End Function
46.
47. Function _cos:Double(x:Double)
48.         Return Cos(x* 57.2958)
49. End Function
50.
51. Function init() 'samples
52.         'Rem
53.         a= -2.6805439855065067
54.         b= 2.0844768343944953
55.         c= -2.3811550716885534
56.         d= 1.7712752537923500
57.         'EndRem
58.
59.         Rem
60.         a= 1.9560260499555859
61.         b= 2.4346168219139717
62.         c= 2.0647279581586258
63.         d= -1.1132835321936514
64.         EndRem
65.
66.         Rem
67.         a= 1.20106173
68.         b= -2.30811906
69.         c= -0.114933334
70.         d= 2.22842979
71.         EndRem
72.
73.         Rem
74.         a= 1.5688667130811149
75.         b= -1.1898892234416945
76.         c= -2.8606196192568909
77.         d= 0.95424022623010973
78.         EndRem
79.
80.         Rem
81.         a= 1.2248441387108837
82.         b= -2.7392325587313344
83.         c= -1.7827782443877711
84.         d= -1.3244245968740442
85.         EndRem
86.
87.         Rem
88.         a= 0.47710959283454901
89.         b= -2.5875993744221732
90.         c= -2.4224025666406996
91.         d= 2.9201404236134216
92.         EndRem
93.
94.         Rem
95.         a= -0.69950397876281212
96.         b= 1.7563243846226397
97.         c= 2.3431794838379503
98.         d= -2.5740196965902631
99.         EndRem
100.
101.         Rem
102.         a= 1.9910802873759064
103.         b= -1.8253906252366905
104.         c= -0.87575121512456100
105.         d= -0.31756229735261243
106.         EndRem
107.
108. End Function