Julia set algorithm

1.3k views Asked by At

I have a Mandelbrot set generator:

private int calculateMandel(double positionX, double positionY) {
    int valueOne = 0;
    double complexReal = 0.0;
    double complexImaginery = 0.0;
    double complexRealSquare = 0.0;
    double complexImaginerySquare = 0.0;

    while (valueOne < MAX && complexRealSquare + complexImaginerySquare < 4.0) {
        complexImaginery = 2.0 * complexReal * complexImaginery + positionY;
        complexReal = complexRealSquare - complexImaginerySquare + positionX;
        complexRealSquare = complexReal * complexReal;
        complexImaginerySquare = complexImaginery * complexImaginery;

        valueOne++;
    }

    return valueOne;
}

After modifying complexReal and complexImaginery to certain values at the beginning, somehow I cannot get the Julia set at the values. What am I doing wrong? What would be the correct algorithm for generating Julia Set at a predefined certain point?

1

There are 1 answers

0
MvG On

The iteration for a Julia set depends on two parameters: an initial value z0 and a constant parameter c. Usually, the first is the position of the pixel you want to color, whereas the second is a parameter describing which Julia set you want to plot. So use the pixel position to initialize your complex variable, then add a fixed constant after each squaring. The way I read your question, you used these two the opposite way, with a fixed initialization but a position-dependent addition.