Jump to content

mandelbrot set


Recommended Posts

it looks like this particular forum hasn't had many posts in general, which i think is a shame considering that the topic of it (fractals and chaos theory) is such an interesting and diverse topic.

 

so, i decided to write my own mandelbrot set generator, even though there are hundreds around i suppose, and i've included the source code which is available here. you'll need a linux machine to compile and run the program, but a Makefile is included. You'll also the need the png and gd libraries and header files for gd.

 

program usage: ./mandelbrot x1 x2 y1 y2 width iterations/pixel

 

it's a fairly simple program to use. the mandelbrot set is defined in the complex plane, so the first four values you can input are the x and y co-ordinates on the plane for which you want to generate the image. the point (x1, y1) is measured from the top left hand corner. so the co-ordinates -2, 1, 1, -1 would generate the familiar picture of the mandelbrot set.

 

the other two parameters speak for themselves; the width of the image you want (the height will be automatically calculated) and the iterations/pixel. it takes ~30 seconds to generate a 600x400 png with 1000 iterations/pixel on my Pentium II 400MHz. output file is mandelbrot.png.

 

bugs/other stuff

 

the colour is a bit crappy atm, i haven't worked out a decent way of doing a palette.

if the mandelbrot.png file exists already, then it can cause problems when trying to generate another image, and it might segfault. just delete the old image file.

 

happy mandelbrot set generating.

Link to comment
Share on other sites

"This file is hosted by Tripod, a Lycos®Network Site, and is not available for download. Please check out Tripod's Help system for more information about Remote Loading and our Remote Loading policy. "

Link to comment
Share on other sites

well, i finished, so since you offered to host it here (cheers), i've included it as an attachment (it's only 3k or so).

 

this "version" is a lot different. it has a config file (mandelbrot.conf) which details all of the things that you can do with it. it's set up to give a fairly nice initial image :)

 

there's also the ability to save it as a jpeg or a png. this means youll have to have the jpeg library installed as well.

 

have fun :)

mandelbrot.tar.gz

Link to comment
Share on other sites

  • 1 year later...

I was thinking of adapting this program to use different fractal algorithms, if anyone would be interested in seeing them. If you would, then please suggest some nice algorithms below (or point me in the general direction), as to be fair, I don't have a lot of experience when it comes to things like fractals :) Cheers.

Link to comment
Share on other sites

I didn't; I made it myself from the ground up. If you want to get started with programming in general, you need to either find a book, or an online tutorial. If you're talking about programming fractals, then it's not all that hard, you just need to get your program to cope with large amounts of iteration, complex numbers and writing to image files. That program took me about a day to write, so it's not all that complex - I daresay it's a pretty inefficient program as well.

Link to comment
Share on other sites

Indeed; the fractal generation part of my code is only 1 function long, and it's about 5 lines long. The problem is you have to do all the extraneous stuff like code image output, configuration file input, colour coding, etc. If you have some interesting ones, feel free to post them and I'll see if I can put them into the program.

 

(btw, any mods I do to the program won't be for a while yet as I've got exams, but as soon as my 3 month vacation comes along, I'm going to be bored a lot, so I'm planning to do it then.)

Link to comment
Share on other sites

I didn't; I made it myself from the ground up. If you want to get started with programming in general, you need to either find a book, or an online tutorial.

 

whoops; i mean what programming language/compiler, unless you used straight-up machine language?

 

I've done spots of html, VB, Basic, and C, but no in-depth programming.

I think i should though. Programming is so important in Engineering & the Sciences.

Link to comment
Share on other sites

Mine was programmed in C++.

 

You'll find that if you do engineering, things like MATLAB and Mathematica get used a lot, because they're moreorless tailor made for modelling environments (which is what most engineers do, unless, ofc, they want to be electronic engineers :)).

Link to comment
Share on other sites

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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.