Skip to main content
1 of 5

How do I optimize this algorithm further?

float escapesmooth(double real, double imag){ // Optimized Escape Time Algorithm + smooth colors + perodicity checks
    double r0=real;
    double i0=imag;
    float iter=0.0;
    double tempreal,io,ro;
    while(iter<maxIter&&real*real+imag*imag<=16){
        tempreal=real*real-imag*imag+r0;
        imag=2*real*imag+i0;
        real=tempreal;
        iter++;
        if(real==ro&&imag==io){
            iter=maxIter;
            break;
        }
        //interesting effect
        if(biomorph){
            if(abs(real)>3&&abs(imag)>3){
                iter-=real+imag;
                break;
            }
        }
        period++;
        if(period>20){
            period=0;
            ro=real;
            io=imag;
        }
    }
    if(iter<maxIter){
        float log_zn=log((real*real)+(imag*imag))/2;
        float nu=log(log_zn/log(2))/log(2);
        iter=iter+1.0-nu;
    }
    return iter;
}

This is my Mandelbrot set algorithm - it includes Smooth Coloring, perodicity checks, and my approach to biomorphs.

I know of Edge Detection, but I couldn't find a simple explanation that I can understand. Any help appreciated!