[chaoscope] Re: Ive developed an atractor

  • From: Alan <alan2here@xxxxxxxxx>
  • To: chaoscope@xxxxxxxxxxxxx
  • Date: Mon, 22 Aug 2005 22:12:01 +0100

Nearly all comenations of parimerters make stable atractors so its just 
random
 basic4gl (NOT c++, sorry) soruce code.
 'START OF CODE
 
const width = 1024 ' Must be a power of 2
const height = 768 ' Must be a power of 2
dim a1#(height-1)(width-1)
dim n#, x, y, x#, y#, z#
dim v#(17)
gosub redo
glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
gluOrtho2D (0, 1, 0, 1)
glMatrixMode (GL_MODELVIEW)

dim tex
glEnable (GL_TEXTURE_2D)
tex = glGenTexture ()
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)

sleep(1000)

here:
for n# = 1 to 10000
x# = sin(((x# * v#(0)) + v#(1)) + ((y# * v#(2)) + v#(3)) + ((z# * v#(4)) + 
v#(5)))
y# = sin(((x# * v#(6)) + v#(7)) + ((y# * v#(8)) + v#(9)) + ((z# * v#(10)) + 
v#(11)))
z# = sin(((x# * v#(12)) + v#(13)) + ((y# * v#(14)) + v#(15)) + ((z# * 
v#(16)) + v#(17)))
x = (y# + 1) * ((width * .5) - 1)
y = (x# + 1) * ((height * .5) - 1)
x = ((x - (width * .5)) / (z# + 2)) + (width * .5)
y = ((y - (height * .5)) / (z# + 2)) + (height * .5)
a1#(y)(x) = a1#(y)(x) + .01
next
glTexImage2D (GL_TEXTURE_2D, 0, 1, width, height, 0, GL_LUMINANCE, GL_FLOAT, 
a1#)
glClearColor (0, 0, 0, 0)
glDisable (GL_DEPTH_TEST)
glEnable (GL_TEXTURE_2D)
glEnable (GL_BLEND)
glBlendFunc (GL_SRC_ALPHA, GL_ONE)
glClear (GL_COLOR_BUFFER_BIT)
glColor3f (1, 1, 1)
glBegin (GL_QUADS)
glTexCoord2f (0, 1): glVertex2f (0, 0)
glTexCoord2f (1, 1): glVertex2f (1, 0)
glTexCoord2f (1, 0): glVertex2f (1, 1)
glTexCoord2f (0, 0): glVertex2f (0, 1)
glEnd ()
SwapBuffers ()
if keydown(" ") then gosub redo endif
goto here:

redo:
for x = 0 to width - 1
for y = 0 to height - 1
a1#(y)(x) = 0
next
next
for n# = 0 to 17
v#(n#) = (((rnd() % 40) - 20) * .2)
next
return

'END OF CODE

Explanation I posted erlier, repost'ed
 x = sin(((x * v(0)) + v(1)) + ((y * v(2)) + v(3)) + ((z * v(4)) + v(5)))
y = sin(((x * v(6)) + v(7)) + ((y * v(8)) + v(9)) + ((z * v(10)) + v(11)))
z = sin(((x * v(12)) + v(13)) + ((y * v(14)) + v(15)) + ((z * v(16)) + 
v(17))) 
 v(0 to 17) are random numbers between -4 and 4
 x is x (left, right) coordinate, Its a floating (not integer) number
y is y (up, down) coordinate, Its a floating (not integer) number
z is z (distance into screen) coordinate, Its a floating (not integer) 
number
* means times by
sin as in trigonometry.
 So I repeat the process Meany times, each time increasing the brightness of 
the pixel it lands on.

Other related posts: