【问题标题】:Mandelbrot Set outputting a single pointMandelbrot Set 输出单点
【发布时间】:2013-10-19 08:53:53
【问题描述】:

我整天都在为此苦恼。我觉得这真的应该工作!无论我做什么来调整它,它都会输出一个点。任何帮助将不胜感激!

double x_init, y_init;  //These will be the real and imaginary aspects of C 
double x_temp, y_temp;  //We gotta hold values while we update the new x, y since they are based recursively on previous values;
double arg; // This will be our square root test



for (double y = - 1.6; y < 1.6; y += .002)
{
    for (double x = -1.5; x < 0.6; x += .004)
    {
        x_init = x;
        y_init = y;

        int iter = 0;
        arg = 0;
        while(iter < 50 && arg < 2)
        {
            x_temp = x;
            y_temp = y;
            x = (x_temp * x_temp) - (y_temp * y_temp) + x_init;
            y = 2 * x_temp * y_temp + y_init;
            arg = sqrt(x*x + y*y);
            iter++;
        }
        if (iter > 40)
        {
            drawBlack(x_init, y_init);

        }


    }
}

【问题讨论】:

    标签: c++ mandelbrot


    【解决方案1】:

    有2个问题:

    1) 您已将最大迭代次数设置为 50,但随后您使用最大迭代次数 40 来确定是否绘制黑色。

    2) 您正在使用方程的 x 和 y 坐标进行绘制。您需要在绘图时保留一个单独的 x 和 y 像素坐标。

    【讨论】:

    • 可能(未提供)drawBlack 例程扩展到屏幕。
    猜你喜欢
    • 1970-01-01
    • 2019-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 2022-06-30
    相关资源
    最近更新 更多