Esempio n. 1
0
        public void Iterate(int iterations = 10)
        {
            //calculate viewport so, on zoom 1, shown rectangle is in [(-2,-2)..(2,2)]
            var zoom_ratio = 4 / (double)Math.Min(PlaneWidth, PlaneHeight) / Zoom;
            var o_prime    = VectorFlyWeight.GetVector(
                Center.X - (PlaneWidth / 2) * zoom_ratio,
                Center.Y - (PlaneHeight / 2) * zoom_ratio
                );

            Parallel.For(0, PlaneWidth,
                         new ParallelOptions()
            {
                MaxDegreeOfParallelism = 3
            },
                         i =>
            {
                for (var y = 0; y < PlaneHeight; y++)
                {
                    var result =
                        new Zeta(
                            new Point(i, y),
                            VectorFlyWeight.GetVector(
                                i * zoom_ratio + o_prime.X,
                                y * zoom_ratio + o_prime.Y
                                ));
                    Zetas[i, y] = result;
                    result.ZSquaredPlusC(iterations);
                }
            });
            IterationsDone = iterations;
        }
Esempio n. 2
0
        public Vector2d ImageSpaceToZetaSpace(int x, int y)
        {
            var zoom_ratio = 4 / (double)Math.Min(PlaneWidth, PlaneHeight) / Zoom;

            return(VectorFlyWeight.GetVector(
                       Center.X - (PlaneWidth / 2 - x) * zoom_ratio,
                       Center.Y - (PlaneHeight / 2 - y) * zoom_ratio
                       ));
        }
Esempio n. 3
0
 public Mandelbrot(int width, int height,
                   double zoom     = 1,
                   Vector2d center = null
                   )
 {
     PlaneWidth  = width;
     PlaneHeight = height;
     Zoom        = zoom;
     Center      = (center ?? VectorFlyWeight.GetVector());
     Zetas       = new Zeta[width, height];
 }
Esempio n. 4
0
 public void Dispose()
 {
     VectorFlyWeight.RecycleVector(Z);
     VectorFlyWeight.RecycleVector(Z_n);
 }
Esempio n. 5
0
 public void ChangeCenter(Vector2d vec)
 {
     VectorFlyWeight.RecycleVector(Center);
     Center = vec;
 }