Mandelbrot Approach question

Started by Volker Harun, September 09, 2009, 05:16:36 PM

Previous topic - Next topic

Volker Harun

Hi,

today I had fun following the instructions of this site: http://www.skytopia.com/project/fractal/mandelbrot.html#pandora

I hoped that the way provided there would be faster to render - but I am not able to confirm it, as I have somewhere in my nodes an error that I cannot solve (Attached image). The result is nice, but not a mandelbrot set :(

This is what I thought:
1. I build a sine by dividing X with the length of the vector (which is set to Y=0)
2. From the sine I get by using the ArcSine the radian
3. I multiply the radian with 2
4. With the sine function I can rebuild the new X and with the cosine the new Z by multiplying with the length of scalar again.
5. Adding the old X and Z to the new ones shifts the point to its destination

Thanks,
Volker

cyphyr

Your teasing, I'll never get any sleep now lol
Richard
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

mogn

If you divide a vector [x, 0, z] by its length the new vector become [cos(v), 0, sin(v)] where v is the angle from the x-axis to the point. What you
do in your node-network is measure the angle from the z-axis to the point. Well it does'nt matter.

Volker Harun

@mogn: You are right, I switched those trigs back and forth before, and it did not matter ... ???
What you could not know is, that this 'Scalar = -1'-node was my last addition to the network. And now Sine and Cosine do matter  :D
Thanks  :D :D :D Dude!

One step closer ... the output now shows the mandelbrot set  .... ?twice? ....  :o :o :o

Volker

mogn

Maybe that the reason you get two mandelbrot sets, are that Arccos is not a full circle (the correct function to use is Atan2(x,y) which is not
implemented in TG2.)

Matt

#5
It should be easier than that.

http://www.phys.unsw.edu.au/~mcba/phys2020/notes/mandelbrot.html

(cx,cy): position on the surface being plotted
(zx,zy): initialised to (0,0) before each loop

zx = 0.0;
zy = 0.0;
n = 0;
while ((zx*zx + zy*zy < 4.0) && (n < max_iterations)) {
  new_zx = zx*zx - zy*zy + cx;
  zy = 2.0*zx*zy + cy;
  zx = new_zx;
  n = n + 1;
}

No sines, arcsines etc. needed.
Just because milk is white doesn't mean that clouds are made of milk.

mogn

Execpt that you dont have loops in tg2 (yet).

Volkers transformation is  [x, 0, y] == [R * cos(v), 0, R * sin(v)]  => [R^2 * cos(2v), 0, R^2 * sin(2v)]
Since R^2 * cos(2v)  = R^2 * cos(v)^2 -  R^2 * sin(v)^2 == x^2 - y^2
and  R^2 * sin(2v) = R^2 * 2*cos(v)*sin(v) == 2*x*y

So both ways are the same.

Another transformation based on cos(3v) and sin(3v)  is [x, 0, y] => [4*x^3 - 3*x, 0, 3*y - 4*y^3]

which might be faster since transformation in x and the transformation in y are independent of each other.

What is missing in the julian and mandelbrot transformation shown up til now, is the classical coloring based on the bailout
and the iteration count.

Matt

#7
I know that both are equivalent, mathematically speaking, but Volker is going to extra trouble getting the sines and cosines and recombining them later when it is completely unnecessary and computationally much more expensive. Which way would you prefer to construct in the node network, considering that (cx,cy) is already available but R and v are not? (Well, R is available but it still has to be computed.)

True, loops aren't possible yet - but I assumed Volker would know how to interpret this loop and adapt it to his iterations.
Just because milk is white doesn't mean that clouds are made of milk.

Volker Harun

Hi Matt, thanks for your response.
In fact I used this formula for the Julia Set (aka Mandelbrot) in the file sharing section.

I hoped that using the trigonometric approach would give more interesting shadings inside and outside the mandelbrot set :) as we will have for now a given amount of iterations.

To be honest (at least once), I have gone further exploring some more fancy stuff ;)

Volker

cyphyr

#9
Ok help here needed :)
You guys are talking in code
I've looked at the wiki info on Mandelbrot and Julia sets and I can see some equations, I can even see elementarily what those equations are doing. But I'm having trouble following your notation.

Could someone please show me an equation and a labeled node network showing what corresponds to what, please :)

fc(z)=z2+c

[x, 0, y] => [4*x^3 - 3*x, 0, 3*y - 4*y^3]

(I know they're different formula, its the notation I don't understand)

Also: what dose "R" and "v" stand for in mogn's example? (ah ok I think "v" is "vector" so its the Oh hang on ....)
and what dose == mean?

Once I get my head around the translation process I should be able to tackle and understand more complex, interesting and relevant formula.

Thanks

Richard
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

Volker Harun

Hi Richard,

z and c are complex numbers. They can be described as coordinates x+yi - where i is the 'complex' part.
i is a bit different than any other number as its definition is: i² = -1.

In graphics you ignore the 'i' except for one point: +(yi)² = -y²

fc(z)=z2+c
f = function, c = complex ... function with complex numbers
(z) ... z is the complex number that is going to change, which is variable.

As described above we can write a complex number as coordinates, thus z = x + yi
so our function is f(z) = (x + yi)² + c
this c is another comlex number, which is constant for Julia-sets. In the node network I called it Real (a) and Imag (bi)
write it like c = a + bi (<-- the 'i' again)

Now the equation goes like f(z) = (x + yi)² + a + bi = x² + 2xyi - y² + a +bi 
Let us think of the complex number as coordinates again: x + yi ... the x-axis has no 'i', thy y-axis has an 'i'
So the above equation is split into X = x² -y² + a   and Y = 2xyi + bi

As we are using a planar projection in terragen, we swap y and z, that is all.

In mogn's example R = radius (length to scalar), v is the angle.

Feel free to ask if something is unclear :)

cyphyr

Thanks Volker :)
That's about a weeks worth of homework :)
I'd figured i was complex (I had "i" as the "sq root of -1", irrational)
I had also figured that z and y were swapped.
For now I'm ignoring the y output of the "get" altogether.
Be sure I will have plenty of questions, in maybe a week or so. :)
Richard
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)