Sunday, December 5, 2010

Fractals!

I recently watched Nova's excellent documentary on fractals. This reminded me of my first programs to render a Julia set, on a 486DX33 running MS-DOS 6.0!

After a few readings in the Internet, I decided to do it again, but this time on my mighty Intel Quad core/2GHz, running Linux Fedora 14.

First hurdle: I never programmed any application whose output is a graphic. So be it, I'll do a small program that will generate a PNG file.

A few attempts later - and discovering that RGB PNG expects you to have 3 bytes per pixel, kind of logical - I did it.

My program is neither smart nor elaborate. But it does the job for Julia sets based on z2+c, where z and c belongs to the set of complex numbers.

The following example is for c=-1.6



And for c=0.256






Going further: if I have a program that can render a Julia set picture for a value of c, I should be able to generate a movie for a path in the set of complex numbers.

Yes. Using the multiple PNGs generated and mencoder (from mplayer), I assembled a couple of animations.


fractal1: from -2 to 2 (works using VLC)

c moves on the line from -2 to 2.

fractal2: sliding a parabola (works using VLC)

c moves along the parabola 2z2-1

No comments:

Post a Comment