It's a fairly simple system, although less simple than the previous ones I've written about. It follows a set of differential equations(I just grabbed these from the Wikipedia page):
dx/dt = σ * (y - x)If we translate these to C (I do all my fractal stuff in C, since it seems to be hopelessly slow in anything else) we get:
dy/dt = x * (ρ - z) - y
dz/dt = x * y - β * z
for (t = 0; t < NUM_ITERATIONS; t++){You'll want some initial conditions, I used x = 0.1, y = 0.0, z = 0.0. You also have a time-step dt, which I set to 0.001. This determines how "smooth" your picture will look.
x1 = x + dt * sigma * (y - z);
y1 = y + dt * (x * (rho - z) - y);
z1 = z + dt * (x * y - beta * z);
x = x1;
y = y1;
z = z1;
// plot point
}
Here's a picture of what it looks like:This is with NUM_ITERATIONS = 100 000. I just used a mostly orthographic projection - the x just maps to x, and y maps to y when you plot it on the screen, and you ignore z. I did a bit of scaling and translating to the x and y so that it fit nicely into an 800x800 window.
The interesting thing is the colours (it may look ugly, but there is some science behind it!). This picture is effectively a trace of a particle moving through time. The more red it is in this picture, the earlier it is in the particle's path, and the more blue, the later (obviously purple ones are in the middle). It's interesting because except for the little red swirls at the beginning there, the red, purple and blue paths are all fairly mixed up (it might look like the blue ones are more clustered, but keep in mind that blue pixels are plotted later, and therefore will overwrite any pixels that might have been there before). This is evidence of something called topological mixing, which as I understand from my brief digging through Wikipedia basically means that the paths taken at different time ranges will inevitably overlap.
Anyway, that's enough about the actual math behind chaos theory. You can probably even take on Jeff Goldblum now! I'll work on other fractals sometime and give you guys more neat pictures.
4 comments:
The fractal egg:
http://tinyurl.com/fractal-egg
The fractal swirl:
http://tinyurl.com/cool-fractal
what makes this fractal?
It has a fractal dimension of roughly 2.06. There is some debate as to whether or not this makes something "a fractal," but since this is not an academic paper I'm accepting the word as a decent approximation ;)
Post a Comment