Advertisement

Fractal Mathematics

Started by February 13, 2002 05:48 PM
14 comments, last by Xgkkp 23 years ago
About the stack overflow, I have seen it aswell, but I''m no coding guru so I dont know what it is (seems to happen with large arrays)

To change the area that should be rendered you have to change x/y_start/end values, thats right, but you also have to change:

double add = (4.0 / 256.0);

into:

double add = ((x_end - X_start) / 256.0);

assuming the distance between the x values and the y values is the same (ie that you render a square area of the imaginary plane)

If you change the area to for example:

start_x = -0.324017
end_x = -0.348219
start_y = 0.628567
end_y = 0.604365

you should se some nice results (on the mandelbrot)

Typically the nicest patterns occurs in the area where it goes from converging into diverging

And offcourse you can also change it to higher reses like 1024*1024, but remember to change the ''add'' into: ((x_end - X_start) / 1024.0)

if you want to use rectangulare areas you must specify two ''add'' variables, one for x and one for y

As I said, you can also save it as a height map instead of color values, and from that work out some approx normal vectors to generate lighting/3D effects, (maybe also a bool array containing info on wether it converge or diverge and then use a different lighting scheme on those areas to seperate them)


And dont be afraid to try out other recursions like for example:

  switch( fractal ){  case 0:    Z[0] = Z[1]*Z[1] + P // mandelbrot    break;  case 1:    Z[0] = ((Z[1]*Z[2]) + P); // something    break;  case 2:    Z[0] = ((Z[0]*Z[1]*Z[2]) + P); // something2    break;  case 3:    Z[0] = ((Z[1]*Z[1]) + P.inverse()); // mandelbrot inverted?    break;}  


All those will be symmetric about the real axis, to make them un-symmetric you can include the argument of P in the equation


My post up, your post down, my site here

Not really much of a contribution, but i didn't see any mention of James Gleick's book "chaos." it's not a very technical book, but it gives a good history behind chaos theory. I think that it also kind of give you an idea of what it possible... it's usualy easier to do something if you at least have an idea where you're going =)

Edited by - krinkle on February 15, 2002 7:03:58 PM
Advertisement
I have written a Henon Attractor program in QBASIC.
http://thefivelions.tripod.com/etc/henon.zip
It`s a particular kind of chaos equation.
I`m afraid I don`t know much beyond that.
But I`ve included the source with the prog, along w/ a resized screenshot.

For truly erudite knowledge, try mathworld.wolfram.com.

No promises of understanding what they tell you tho.

~V''lion



Bugle4d
~V'lionBugle4d
Thanks Jesper T, I have it working now, but on all the ones on the net I see it really smooth, this seems really 'bitty' with lots of strange pixels around the edge, not smooth, like the applet on:
http://mathforum.org/alejandre/applet.mandlebrot.html

also, why is it so slow? when even small java applets can do it relatively quickly.

also, how can i go onto terrain generation from fractals?

Edited by - Xgkkp on February 18, 2002 6:27:10 PM
AHA!
less iterations, colouring based on number of iterations before left loop. also, i noticed that a couple of the vars were the wrong way around, causing the fractal to be rotated 90 degrees cw.
Thanks all for getting me up and running!

ANy ideas how I can start applying this? I want to eventually use it for landscape generation. (Ideally, I would want to re-write a program like mojoworlds (without the rendering aspect))
quote:
Original post by Xgkkp
whenever i leave this line in
Color result[256][256];
it gives an "Unhandled Exception: Stack overflow"



Allocate that array on the heap rather than the stack. Do it like this:

      color ** result = new color * [256];for(int i = 0; i < 256; i++){      result[i] = new color[256];}  


Of course, then you have to delete it:

        for(int i = 0; i < 256; i++){      delete [] result[i];}delete [] result;  


Instead of dynamically allocating multidimensional arrays you may want to do something simpler like a linear array with x+y*width style access.



Edited by - TerranFury on February 18, 2002 9:17:33 PM

This topic is closed to new replies.

Advertisement