Welcome to Fractal Forums

Fractal Art => Fractal Website of the Month => Topic started by: Blue Raven on May 08, 2014, 11:35:26 AM




Title: Classic Fractals Source Codes
Post by: Blue Raven on May 08, 2014, 11:35:26 AM
Hello, I just thought, that for beginners of fractal programming, this website could be useful. There are about 10 well commented fractal source codes (sadly, but only written with C++) and explanations how they are working, but about once a week or two, the new ones are added.
http://www.bio-matic.com/programming-works/science/fractals/


Title: Re: Classic Fractals Source Codes
Post by: cKleinhuis on May 08, 2014, 12:32:33 PM
nice attempt, and hello and welcome to the forums

indeed i do not like the technical description in a c++ program, basic things that you might be familar with, like calculating the length of a vector, are hardcoded in you program, to introduce a technique, i think it is rather more helpful to describe it in what has to be done, and define such things seperately, e.g. in a function, as there are:

length(complexnumber)
add(complexnumber1,complexnumber2)
mul(complexnumber1,complexnumber2)

in such a way the mandelbrot way of calculating is more easily recognisable

e.g.

while(length(z)<bailout)
{
z=mul(z,z);
z=add(z,pixel)
}

in such a way the methods and the inner structure is very easy to see and modify ;)

so, and when you want to drive it further, e.g. calculate higher or non integer powers it would make sense to introduce the polar representation of a complex number, because with that view, the complex exponentiation is as simple as "length^exponent, exponent*angle" which then needs to be
converted back to a polar representation...

:)


Title: Re: Classic Fractals Source Codes
Post by: Blue Raven on May 08, 2014, 04:56:33 PM
Well, I understand what you want to say, but fractal generation using defined functions like pow or etc is several times slower, than using just simple arithmetic operations. For example in C++ pow(x, 2) is about 7x slower than x*x . I have already tested it. Mandelbrot generation with 256 iterations takes less than a second while using arithmetics and about 7 seconds while using default C++ functions like pow. But anyway, thanks for your comments, I will try to perfect the given codes and I am sorry for an anonymic try to promote this website.


Title: Re: Classic Fractals Source Codes
Post by: cKleinhuis on May 08, 2014, 05:20:22 PM
optimizing code is a complete different section ;)

this is a whole lot that can be placed in a "remarks&optimisations" section, as well as the various speed improvements for calculation, like squares of same iteration depth finding and so on ;)




Title: Re: Classic Fractals Source Codes
Post by: top-quark on May 08, 2014, 10:56:39 PM
It's C++. You can declare functions inline and get the best of both worlds - modularity without the call overhead. Just sayin'.

But yes, primitive arithmetic is so much faster than math function calls that it makes sense to do things the hard way.


Title: Re: Classic Fractals Source Codes
Post by: Blue Raven on May 09, 2014, 08:25:40 AM
Good, thanks for your response!