Serpinski Triangle / Mandlebrot Set
An OpenGL Serpinksi Triangle and Mandlebrot Set fractal viewer.
Written for the Image and Sound class.
January 2006
I spent a couple days on this assignment in OpenGL. It is far from efficient, but does produce nice fractal pictures.
———————————————————————-
This is an interesting fractal based on a very simple algorithm. A fractal is a shape that is “inifinetly complex”, or contains the same design no matter how much you zoom in. Basically it is a great mathematical function to draw these familiar pictures. (Sorry, there is a reason I’m not a mathematician.)
Wikipedia’s decription of the process:
1. Take 3 points in a plane, start at one of the points.
2. Randomly select any point and move half the distance from that point to any of the 3 vertex points. Plot the current position.
3 .Repeat from step 2.
That is all there is too it! You can try it yourself with a pencil and a piece of paper … the only catch is it would take you thousands of pencil dots before you could see the shape. This is where the magic of computers takes over.
Computers are quite horrible at many things, giving you a back rub after a long day for example, but they are good at doing small, repetitive tasks quickly. This is why computing is so powerful.
It took less time for me to write this program then it would to compute the following Serpinski Triangle images by hand, one contains 10000 small points while the other uses 1000 large points.
———————————————————————-
This is the most widely known fractal, publicized by Benoit Mandlebrot and other mathematicians in the late 1970’s early 80’s.
Wikipedia’s description of the process:
The x and y location of each point are used as starting values in a repeating, or iterating calculation (described in detail below). The result of each iteration is used as the starting values for the next. The values are checked during each iteration to see if they have reached a critical ‘escape’ condition. If that condition is reached, the calculation is stopped, the pixel is drawn, and the next x,y point is examined. For some starting values, escape occurs quickly, after only a small number of iterations. For other starting values it may take hundreds or thousands of iterations to escape. And for areas within the Mandelbrot set the values never escapes. The programmer or user must choose how much iteration, or ‘depth’, they wish to examine. The higher the maximum number of iterations, the more detail and subtlety emerge in the final image, but the longer time it will take to calculate the picture.
I implemented a rudimentary selection box, zooming functions, and iteration control so the set could be explored beyond the familiar image. The coloring is based on each points divergence to infinite:, the brighter the point, the fewer number of iterations it requires to “escape” from the equation.
The Mandlebrot Set is so intriguing because it is present all around us in nature. Lightning, cauliflower, leaves: there are many examples of “infinitely complex patterns”.
———————————————————————-
Watch the mandlebrot program in action.
mandlebrot
———————————————————————-
The following pictures represent 2, 6, and 15 iterations.
———————————————————————-
Here are some nice zooms