JimCamel
10-03-2003, 02:01 AM
Who loves fractals? YOU DO!
As I'm sure you all know, Fractals are images which have recursive nature, that the same shape is repeated no matter how far you zoom in. For example, a simple line is made up of smaller lines which are made up of smaller lines, and so on till infinity.
Typically these fractals are generated by recursion, creating the image by creating all the sub images.However, as we all know, recursion can be costly.
The method demonstrated in this code example uses another method, known as a Random Iteration Algorithm. The idea is that we start with a single point, and some Affine Maps, which are essentially 2D Transformation matrix.
We assign each Affine Map a probability, and choose a random map based on these probabilities. We then apply this transfomation on our point, and redraw it. This continues on for a specified number of points.
This approach has certain mathematical properties. Because of these maps and The probabilites we assign to them, we get what is known as an "Attractor", which is the fractal. All these points will converge to form our fractal, even though they are generated by random numbers. Any point within our attractor, when transformed using one of these Affine Maps will also be in an attractor. As my graphics lecturer said, these attractors are in some ways similar to black holes, in that all the points converge within them.
If you've read all of that, congratulations. If you understood any of it, you're a genius :p .
But anyways, here's some code I wrote which demonstrates how to create these Randomly Iterated Fractals. If you come with any cool Affine Maps, I'd love to see them.
As I'm sure you all know, Fractals are images which have recursive nature, that the same shape is repeated no matter how far you zoom in. For example, a simple line is made up of smaller lines which are made up of smaller lines, and so on till infinity.
Typically these fractals are generated by recursion, creating the image by creating all the sub images.However, as we all know, recursion can be costly.
The method demonstrated in this code example uses another method, known as a Random Iteration Algorithm. The idea is that we start with a single point, and some Affine Maps, which are essentially 2D Transformation matrix.
We assign each Affine Map a probability, and choose a random map based on these probabilities. We then apply this transfomation on our point, and redraw it. This continues on for a specified number of points.
This approach has certain mathematical properties. Because of these maps and The probabilites we assign to them, we get what is known as an "Attractor", which is the fractal. All these points will converge to form our fractal, even though they are generated by random numbers. Any point within our attractor, when transformed using one of these Affine Maps will also be in an attractor. As my graphics lecturer said, these attractors are in some ways similar to black holes, in that all the points converge within them.
If you've read all of that, congratulations. If you understood any of it, you're a genius :p .
But anyways, here's some code I wrote which demonstrates how to create these Randomly Iterated Fractals. If you come with any cool Affine Maps, I'd love to see them.