private void CreateJuliaGpu(Bitmap2D tex2D)
        {
            int[] iterArray = new int[width * height];
            GpuRef.ComputeJulia(iterArray, width, height, min.Value.x, min.Value.y, rangeX, rangeY, customConstant.Value[0], customConstant.Value[1]);
            float colorToUse;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    colorToUse = iterArray[y * width + x] / maxIterations;
                    tex2D.SetPixel(x, y, new color(colorToUse, colorToUse, colorToUse)); //depending on the number of iterations, color a pixel.
                }
            }
        }
예제 #2
0
        private void CreateNewton(Bitmap2D tex2D)
        {
            Complex coords;
            int     iterations;
            Complex epsilon;
            float   colorToUse;
            double  magSquared;

            const double cutoff = 0.00000000001;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    coords     = ConvertPixToCoords(x, y);
                    iterations = 0;

                    do
                    {
                        epsilon = -(F(coords) / dFdx(coords));
                        coords += epsilon;
                        iterations++;
                        magSquared = Math.Pow(Complex.Abs(epsilon), 2);
                    }while (magSquared > cutoff && iterations < maxIterations);

                    if (iterations < maxIterations)
                    {
                        colorToUse = 0;
                        if (Math.Abs(coords.Real + .5) < .001 && Math.Abs(coords.Imaginary + .866) < .001)
                        {
                            colorToUse = 0;
                        }
                        else if (Math.Abs(coords.Real - 1) < .001 && Math.Abs(coords.Imaginary) < .001)
                        {
                            colorToUse = .5f;
                        }
                        else if (Math.Abs(coords.Real + .5) < .001 && Math.Abs(coords.Imaginary - .866) < .001)
                        {
                            colorToUse = 1;
                        }
                        tex2D.SetPixel(x, y, new color(colorToUse, colorToUse, colorToUse)); //depending on the number of iterations, color a pixel.
                    }
                }
            }
        }
        private void CreateJulia(Bitmap2D tex2D)
        {
            double2 coords;
            int     iterations;
            double  realZ  = 0;
            double  imagZ  = 0;
            double  realZ2 = 0;
            double  imagZ2 = 0;
            double  realC  = customConstant.Value[0];
            double  imagC  = customConstant.Value[1];
            float   colorToUse;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    coords = ConvertPixToCoords(x, y);
                    realZ  = coords[0] + realC;
                    imagZ  = coords[1] + imagC;

                    iterations = 0;
                    while (iterations < maxIterations)
                    {
                        iterations++;
                        realZ2 = realZ * realZ;
                        imagZ2 = imagZ * imagZ;
                        if (realZ2 + imagZ2 > 4)
                        {
                            break;
                        }
                        imagZ = 2 * realZ * imagZ + imagC;
                        realZ = realZ2 - imagZ2 + realC;
                    }
                    colorToUse = iterations / maxIterations;
                    tex2D.SetPixel(x, y, new color(1 - colorToUse, 1 - colorToUse, 1 - colorToUse)); //depending on the number of iterations, color a pixel.
                }
            }
        }