2

私はこのようなものを思いついた:

float MinRe = -2.0f; // real
float MaxRe = 1.0f;
float MinIm = -1.0f; // imaginary
float MaxIm = MinIm + (MaxRe - MinRe) * WindowData.Height / WindowData.Width;

float Re_factor = (MaxRe - MinRe) / (WindowData.Width - 1);
float Im_factor = (MaxIm - MinIm) / (WindowData.Height - 1);

int MaxIterations = 50;
int iter=0;

for (int y = 0; y < WindowData.Height; ++y)
{
    double c_im = MaxIm - y * Im_factor; // complex imaginary
    for (int x = 0; x < WindowData.Width; ++x)
    {
        double c_re = MinRe + x * Re_factor; // complex real

        // calculate mandelbrot set
        double Z_re = c_re, Z_im = c_im; // Set Z = c
        bool isInside = true;

        for (iter=0; iter < MaxIterations; ++iter)
        {
            double Z_re2 = Z_re * Z_re, Z_im2 = Z_im * Z_im;
            if (Z_re2 + Z_im2 > 4)
            {
                isInside = false;
                break;
            }
            Z_im = 2 * Z_re * Z_im + c_im;
            Z_re = Z_re2 - Z_im2 + c_re;
        }

        if(isInside) 
        {
            GL.Color3(0, 0, 0);
            GL.Vertex2(x, y);
        }
    }
}

私はいくつかの方法で試しましたが、ほとんどの場合、セットの周りに単一の色が表示されるか、画面全体が同じ色になります。

色を正しく設定するには?

4

4 に答える 4

1

これを試したとき、外側の色を RGB (値、値、1) に設定しただけです。ここで、値は (あなたの用語では) の 4 番目のルートです(iter / MaxIterations)。それは、白から青への非常に素晴らしいフェードとして出てきます. ダッフィーモほど明るいわけではありませんが、「ストライプ」効果はあまりありません。

于 2012-01-21T17:21:36.727 に答える
1

ソース コードについては、Source Forge リポジトリをチェックしてください。

http://craicpropagation.blogspot.com/2011/03/mandelbrot-set.html

于 2012-01-21T14:27:50.927 に答える