Exemplo n.º 1
0
        static void RenderPart(FractalConfig conf, int x, int y, int wth, int hth, IDensityMatrix data, Complex pert)
        {
            //http://www.physics.emory.edu/faculty/weeks/software/mandel.c

            Complex z, c;

            InitZC(conf, x, y, wth, hth, pert, out z, out c);
            Complex[] points     = new Complex[conf.IterMax];
            int       escapeiter = FillOrbit(points, conf.IterMax, z, c, conf.Escape, out bool didesc);
            bool      hide       = conf.HideEscaped && didesc || conf.HideContained && !didesc;

            if (hide)
            {
                return;
            }

            for (int iter = 0; iter < escapeiter; iter++)
            {
                Complex f  = points[iter];
                int     bx = WorldToWin(f.Real, conf.Resolution, wth, conf.OffsetX);
                int     by = WorldToWin(f.Imaginary, conf.Resolution, hth, conf.OffsetY);
                if (bx >= 0 && bx < wth && by >= 0 && by < hth)
                {
                    data.Touch(bx, by);
                }
            }
        }
Exemplo n.º 2
0
        static void InitZC(FractalConfig conf, int x, int y, int wth, int hth, Complex pert, out Complex z, out Complex c)
        {
            double cx = WinToWorld(x, conf.Resolution, wth, conf.OffsetX);
            double cy = WinToWorld(y, conf.Resolution, hth, conf.OffsetY);

            switch (conf.Plane)
            {
            case Planes.XY:
            default:
                c = new Complex(cx, cy) + pert;
                z = new Complex(conf.X, conf.Y); break;

            case Planes.XW:
                c = new Complex(conf.W, cy);
                z = new Complex(conf.X, cx); break;

            case Planes.XZ:
                c = new Complex(cx, conf.Z);
                z = new Complex(conf.X, cy); break;

            case Planes.YW:
                c = new Complex(conf.W, cx);
                z = new Complex(cy, conf.Y); break;

            case Planes.YZ:
                c = new Complex(cx, conf.Z);
                z = new Complex(cy, conf.Y); break;

            case Planes.WZ:
                c = new Complex(conf.W, conf.Z);
                z = new Complex(cx, cy); break;
            }
        }
Exemplo n.º 3
0
        static DensityMatrix DoCreateMatrix(FractalConfig conf, string name = null)
        {
            DensityMatrix matrix  = new DensityMatrix(Options.Width, Options.Height);
            var           builder = new FractalBuilder(matrix, conf);
            string        n       = EnsureEndsWith(name ?? Options.FileName, ".dm");

            Logger.PrintInfo("building matrix [" + n + "]");
            builder.Build();
            Logger.PrintInfo("saving matrix file [" + n + "]");
            matrix.SaveToFile(n);
            return(matrix);
        }
Exemplo n.º 4
0
        static FractalConfig GetNormalFractalConfig()
        {
            var conf = new FractalConfig {
                Escape          = Options.FractalEscape,
                Plane           = Planes.XY,
                Resolution      = Options.Resolution,
                X               = 0.0, Y = 0.0, W = 0.0, Z = 0.0,
                IterMax         = Options.FractalMaxIter,
                OffsetX         = 0.0,
                OffsetY         = 0.0,
                HideEscaped     = Options.HideEscaped,
                HideContained   = Options.HideContained,
                SamplesPerPoint = Options.FractalSamples
            };

            return(conf);
        }
Exemplo n.º 5
0
 public FractalBuilder(IDensityMatrix matrix, FractalConfig config = null)
 {
     Matrix      = matrix;
     this.config = config ?? FractalConfig.Default;
 }