Something interesting happening here

BlitzPlus Forums/BlitzPlus Programming/Something interesting happening here

Oso(Posted 2008) [#1]
What on earth is this simple thing doing mathematically ? Clearly it is plotting a changing chaotic iteration, but the large variety of attractors, some of which have interesting singularities and distinctive forms, intrigues me. Substituting more complicated functions at the various calculations makes it more interesting and unpredictable but does not seem to alter these fundamental types of attractor.

I happened on it by chance but have not developed it. It seems to me to have possibilities for mathematical art but I haven't had time to look further into it.


Graphics 800,600
SetBuffer BackBuffer()
ClsColor 0,0,0
Cls

;Initial values of variables
x#=-100
y#=-100
ix#=-200
ixx#=0.0001

Global zoom#=1

;Main loop
;Escape to finish
While KeyHit(1)=0
ix#=ix#+ixx#
x#=2*ix#+1.7
y#=ix#-0.3
Cls

;Plot 5000 iterations, can use fewer and get a similar, smoother effect
For k=1 To 5000
x1#=calcx#(x#-y#+ix#,x#+3*ix#) ;Can be any function - the more convoluted the better
y1#=calcy#(ix#-y#,(x#+1/x#)) ;Can be any function - the more convoluted the better
x#=x1#
y#=y1#
i=Int(400+400*zoom#*x#)
j=Int(300+300*zoom#*y#)
Color 200,200,0
Plot i,j
Next
Flip
VWait 3

;Reverse (*)
If KeyHit(55) Then
ixx#=-ixx#
EndIf

;Slow down (-)
If KeyHit(74) Then
ixx#=0.5*ixx#
EndIf

;Speed up (+)
If KeyHit(78) Then
ixx#=2*ixx#
EndIf

;Zoom in (Up arrow)
If KeyHit(200) Then
zoom#=1.25*zoom#
EndIf

;Zoom out (Down arrow)
If KeyHit(208) Then
zoom#=0.8*zoom#
EndIf
Wend

;Plotting function
Function ccalc(z#,m)
zp=Int(300+300*zoom#*z#)
Return zp
End Function

;Iterative calculations on x# and y# , can be any functions - the more convoluted the better
Function calcx#(x#,y#)
z#=cosr#(x#)+sinr#(y#)
Return z#
End Function

Function calcy#(x#,y#)
z#=cosr#(2*y#)+sinr#(x#)
Return z#
End Function

;Radian trig functions
Function sinr#(x#)
x#=x#*180/Pi
y#=Sin(x#)
Return y#
End Function

Function cosr#(x#)
x#=x#*180/Pi
y#=Cos(x#)
Return y#
End Function

Function tanr#(x#)
x#=x#*180/Pi
y#=Tan(x#)
Return y#
End Function