Wednesday 15 May 2013

lua - How can I fix this issue with my Mandelbrot fractal generator? -



lua - How can I fix this issue with my Mandelbrot fractal generator? -

i've been working on project renders mandelbrot fractal. of know, generated iterating through next function c point on complex plane:

function f(c, z) homecoming z^2 + c end

iterating through function produces next fractal (ignore color):

when alter function this, (z raised 3rd power)

function f(c, z) homecoming z^3 + c end

the fractal should render (again, color doesn't matter):

however, when raised z powerfulness of 3, got image extremely similar when raise z powerfulness of 2. how can create fractal render correctly? code iterations done: (the variables real , imaginary scale screen -2 2)

--loop through each pixel, col = column, row = row local real = (col - zoomcol) * 4 / width local imaginary = (row - zoomrow) * 4 / width local z, c, iter = 0, 0, 0 while math.sqrt(z^2 + c^2) <= 2 , iter < maxiter local znew = z^2 - c^2 + real c = 2*z*c + imaginary z = znew iter = iter + 1 end

so decided remake mandelbrot fractal generator, , much more successful effort lastly time, programming skills have increased practice.

i decided generalize mandelbrot function using recursion wants it. so, example, can f(z, c) z^2 + c or f(z, c) z^3 + c

here may need it:

function raise(r, i, cr, ci, pow) if pow == 1 homecoming r + cr, + ci end homecoming raise(r*r-i*i, 2*r*i, cr, ci, pow - 1) end

and it's used this:

r, = raise(r, i, constant_real_part, constant_imag_part, power)

lua iteration fractals mandelbrot

No comments:

Post a Comment