Julia Set Visualisation
About
The Julia set is a chaotic set of fractals defined by iterating on a function , where:
and are complex parameters.
The colour of a given pixel is defined by how many recursive iterations of it takes, until the magnitude of the returned value is greater than some .
Pseudo-code
def julia(z):
i = 0
while len(z) < R && i < LIMIT:
z = (z * z) + c
i = i + 1
return i
for (x, y) in pixels:
zx = map(x, 0, width, -R, R)
zy = map(y, 0, height, -R, R)
z = complex(zx, zy)
value = julia(z)
pixels[x, y] = grey(value)
Parameters For The Above Sketch
By default the demonstration above uses a value where:
is animated over the range with a period of seconds.
In-case you haven't worked with complex numbers for a while, the above definition of is in the form:
This, in practice, is a representation of a polar coordinate, where is magnitude and is the angle (radians).
To represent this in code, you can do the following (pseudo-code):
cx = A * cos(theta)
cy = A * sin(theta)
c = complex(cx, cy)