Mandelbrot Set Fractal Code

眉间皱痕 提交于 2019-12-04 15:55:13

I think in the function squared you need to use the absolute value:

 public Complex square() {
    double newreal;
    double newimaginary;

    newreal = ((real * real) - (imaginary * imaginary));
    newimaginary = 2 * abs(imaginary * real);

    return new Complex(newreal, newimaginary);
}

Now, to square a complex number, I expand this equation: (Zx + Zyi)2 = Zx × Zx + Zx × Zy +Zx × Zy - Zy×Zy = Zx2-Zy2 + 2(Zx×Zy) The real part is Zx2-Zy2. It is quicker to multiply them together (the ZxZx part) than use a function for raising a number to another. The imaginary part is 2(Zx×Zy). It is quicker to set a variable n = ZxZy then set n = n + n to avoid multiplying by two (adding is quicker than multiplying). Zy is a floating point number so I cannot do a bit shift left to multiply by two. Now the part that is different to the Mandelbrot set is this: Zy=Math.abs(Zx*Zy);

[¹]http://spanishplus.tripod.com/maths/FractalBurningShip.htm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!