Sign in to follow this  

Fractals

This topic is 4308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lately, after having watched several episodes of Stargate SG1 involving hyperspace, it dawned on me how similiar to a fractal their hyperspace backgrounds are. I've been thinking of investigating using fractals for the hyperspace background textures in the game I'm building (OpenGL). Does anyone know of a good beginner's resource for learning more about fractals and how to plot them, use them, etc? I'd rather not buy a book, though. I'm more interested in resources on the net. Thank you, -Richard Lewis

Share this post


Link to post
Share on other sites
From what I remember the big idea with plotting a fractal is roughly like this:

You consider that your screen maps to a rectangular piece of the complex numbers. e.g. x1<x<x2, y1<y<y2.

Find the values z0 = x0+i*y0 to which a pixel corresponds, from x0 = x1+(x2-x1)*(pixelX/ResX)
and y0 = y1 + (y2-y1)*(pixelY/ResY). ResX,ResY are the resolution of the monitor e.g. 800,600

Consider a z0 = x0+i*y0. Don't be scared by the complex numbers, you can consider them as an ordered pair that transform via certain rules. It's not difficult...

Choose a recursive formula (the fractal itsself), and plug the initial z0 = x0+i*y0 into it. Let z1 = x1+i*y1 be the new value you'll get, plug it in again to get another pair (x2,y2) and so on... until

1st) The abs.value of (xn, yn) which is sqrt(x2+y2) becomes greater than 2. (Or -of course- x2+y2 > 4)
or
2nd) You've reached a maximum number of iterations and (1) has not yet been satisfied... Given the formula, there may be some points for which (1) may never become true.

If (1) was satisfied, use the index 'n' where the iteration stopped, and set the pixel to a color corresponding uniquely to that 'n'.

If (2) was satisfied, set the pixel to black.

Continue with the next pixel...

This is the big idea, I don't know if there are other ways too; This one is used for the most famous fractals like the Mandelbrot and Julia sets.

E.g., typical values for the Mandelbrot, are roughly x0=-2,x1=1, y1=-1, y2=1. Its recursive formula is zn+1 = zn2 + z0, where z0 = x0 + i*y0 that I described above.
I guess you'll only need to look for the transformation rules of the complex numbers to implement their required math...

Share this post


Link to post
Share on other sites
Quote:
Original post by someusername
1st) The abs.value of (xn, yn) which is sqrt(x2+y2) becomes greater than 2. (Or -of course- x2+y2 > 4)

Good explanation of the Escape-time fractals! There's just one small thing I'd like to correct you on: the value "2" is a parameter, not a constant - different fractals need different values of this parameter to make sense.

Quote:
Original post by someusername
This is the big idea, I don't know if there are other ways too; This one is used for the most famous fractals like the Mandelbrot and Julia sets.

While it's true that Escape-time fractals (like Mandelbrot and Julia sets) are the most famous, they are by no means the only ones. Some other well know fractal types are:

- L-systems (link; this includes the famous Koch Snowflake),
- IFS (link, link; this includes the well known Sierpinski Gasket and the Barnsley Fern),
- Plasma fractals (link, link; this type of fractal can be used to generate realistic landscapes and cluds, and was reportedly used for special effects in Star Trek),
- Strange Attractors (link; this includes the famous Lorenz Attractor, Hénon Map and Logistic Map and is of special interest to physics and Chaos Theory),
- etc...


To the OP:

To learn more about fractals and their construction it might be instructive to play around with them a bit in Ultra Fractal or FractInt (draw a few fractals, examine the functions used to create them, try your hand at modifying an existing fractal or writting a new one on your own...).


PS: I also found the following two sites: A Beginner's Guide to Chaos (also includes a section on fractals) and Fractal Programming (!).

[Edited by - Devilogic on March 1, 2006 11:07:12 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Devilogic
Quote:
Original post by someusername
1st) The abs.value of (xn, yn) which is sqrt(x2+y2) becomes greater than 2. (Or -of course- x2+y2 > 4)

Good explanation of the Escape-time fractals fractals! There's just one small thing I'd like to correct you on: the value "2" is a parameter, not a constant - different fractals need different values of this parameter to make sense.

Thanks for clarifying this. I didn't know. Actually I thought it might come from some theorem or sth. (!) Anyway, it's been more than 4 years since I've done any fractals, I'm glad I still remember these.
I'm off to check your links.

Share this post


Link to post
Share on other sites

This topic is 4308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this