private Complex _get_complex_loc(_2DFractal fractal, int x, int y)
        {
            double real    = fractal.AbcissStart + fractal.AbcissIntervalLength * x;
            double imagine = fractal.OrdinateStart + fractal.OrdinateIntervalLength * y;

            return(new Complex(real, imagine));
        }
 public AbcissOrdinateHandler(_2DFractal Fractal, int horizontal_start, int vertical_start, int horizontal_end, int vertical_end)
 {
     abciss          = horizontal_start;
     ordinate        = vertical_start;
     end_of_abciss   = horizontal_end;
     end_of_ordinate = vertical_end;
     _fractal        = Fractal;
 }
 /*_______________________________________________Статические_методы_класса_____________________________________________________________*/
 #region Static methods
 public static void CopyTo(_2DFractal Source, _2DFractal Destinator)
 {
     Fractal.CopyTo(Source, Destinator);
     Destinator._2df_bottom_edge    = Source._2df_bottom_edge;
     Destinator._2df_imagine_height = Source._2df_imagine_height;
     Destinator._2df_imagine_left   = Source._2df_imagine_left;
     Destinator._2df_imagine_top    = Source._2df_imagine_top;
     Destinator._2df_imagine_width  = Source._2df_imagine_width;
     Destinator._2df_left_edge      = Source._2df_left_edge;
     Destinator._2df_right_edge     = Source._2df_right_edge;
     Destinator._2df_top_edge       = Source._2df_top_edge;
 }
        /*__________________________________________________Перегруженные_методы_______________________________________________________________*/
        #region Overrided methods
        public override bool Equals(object obj)
        {
            if (!(this.GetType().Equals(obj.GetType())))
            {
                return(false);
            }
            _2DFractal f = (_2DFractal)obj;

            return(f._2df_left_edge == this._2df_left_edge && f._2df_imagine_left == this._2df_imagine_left && f._2df_imagine_top == this._2df_imagine_top &&
                   f._2df_imagine_width == this._2df_imagine_width && f._2df_imagine_height == this._2df_imagine_height && f._2df_right_edge == this._2df_right_edge &&
                   f._2df_top_edge == this._2df_top_edge && f._2df_bottom_edge == this._2df_bottom_edge && f.f_iterations_count == this.f_iterations_count);
        }
        private void сохранитьКакШаблонToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FractalDataHandler[] fdh = FractalControler.GetFractalDataHandlers(true);
            if (fdh.Length < 1)
            {
                return;
            }
            OneStringEditor ose = new OneStringEditor("Ведите название сохраняемого шаблона:");

            if (ose.ShowDialog(this) != DialogResult.Yes)
            {
                return;
            }
            _2DFractal fr = (_2DFractal)fdh[0].Fractal.GetClone();

            fr._2df_set_scale(60, 60, 0, 0, fdh[0].Width, fdh[0].Height);
            fractalTemplates.Add(new FractalTemplate(fr, fdh[0].FractalColorMode, ose.Result));
        }
 public JuliaSearcher(IUsingComplex JuliaLike, _2DFractal BackSideFractal, FractalColorMode JuliaMode, FractalColorMode BackSideFractalMode)
     : this(JuliaLike, JuliaMode)
 {
     _mandelbrot = BackSideFractal;
     _m_fcm      = BackSideFractalMode;
 }
 public AbcissOrdinateHandler(_2DFractal Fractal,int horizontal_start,int vertical_start,int horizontal_end,int vertical_end)
 {
     abciss = horizontal_start;
     ordinate = vertical_start;
     end_of_abciss = horizontal_end;
     end_of_ordinate = vertical_end;
     _fractal = Fractal;
 }
 public JuliaSearcher(IUsingComplex JuliaLike, _2DFractal BackSideFractal, FractalColorMode JuliaMode) : this(JuliaLike, JuliaMode)
 {
     //if (!(BackSideFractal is _2DFractal)) throw new ArgumentException("Переданный объект для панели выбора должен быть двухмерным фракталом!");
     _mandelbrot = BackSideFractal;
 }
 public JuliaSearcher(IUsingComplex JuliaLike, _2DFractal BackSideFractal, FractalColorMode JuliaMode,FractalColorMode BackSideFractalMode)
     : this(JuliaLike, JuliaMode)
 {
     _mandelbrot = BackSideFractal;
     _m_fcm = BackSideFractalMode;
 }
        protected override void _m_create_part_of_fractal(_2DFractal.AbcissOrdinateHandler p_aoh, _2DFractal._2DFractalHelper fractal_helper)
        {
            ulong max_iter=f_iterations_count, iterations;
            ulong[][] iter_matrix=fractal_helper.CommonMatrix;
            double[][] Ratio_matrix = fractal_helper.GetRatioMatrix(),radian_matrix=((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            double[] abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double abciss_point, dist, pdist=0D,abciss_start=_2df_get_double_abciss_start(),abciss_interval_length=_2df_get_double_abciss_interval_length(),
            ordinate_start=_2df_get_double_ordinate_start(),ordinate_interval_length=_2df_get_double_ordinate_interval_length();
            FractalCloudPoints fcps = (FractalCloudPoints)fractal_helper.GetUnique();
            FractalCloudPoint[][][] fcp_matrix = fcps.fractalCloudPoint;
            int percent_length = fractal_helper.PercentLength, current_percent_state = percent_length;
            List<FractalCloudPoint> fcp_list=new List<FractalCloudPoint>();
            FractalCloudPoint fcp;
            int fcp_height = ordinate_points.Length / _ordinate_step_length + (ordinate_points.Length % _ordinate_step_length != 0 ? 1 : 0);
            Complex z = new Complex(), z0 = new Complex(),last_valid_z=new Complex();
            for (; p_aoh.abciss < p_aoh.end_of_abciss;p_aoh.abciss++ )
            {
                abciss_point = abciss_points[p_aoh.abciss];
                radian_matrix[p_aoh.abciss] = new double[ordinate_points.Length];
                if (p_aoh.abciss % _abciss_step_length == 0) fcp_matrix[p_aoh.abciss / _abciss_step_length] = new FractalCloudPoint[fcp_height][];
                for(;p_aoh.ordinate<p_aoh.end_of_ordinate;p_aoh.ordinate++)
                {
                    iterations = 0;
                    dist = 0D;

                    z0.Real = abciss_point;
                    z0.Imagine = ordinate_points[p_aoh.ordinate];
                    z.Real = z0.Real;
                    z.Imagine = z0.Imagine;
                    if(((p_aoh.abciss%_abciss_step_length)==0)&&((p_aoh.ordinate%_ordinate_step_length)==0))
                    {
                        fcp_list.Clear();
                        for(;iterations<(ulong)_max_ammount_at_trace&&dist<=4D;iterations++)
                        {
                            pdist = dist;
                            last_valid_z.Real = z.Real;
                            last_valid_z.Imagine = z.Imagine;
                            z.tsqr();
                            z.Real += z0.Real;
                            z.Imagine += z0.Imagine;
                            dist = (z.Real * z.Real + z.Imagine * z.Imagine);
                            fcp.AbcissLocation = (int)((z.Real - abciss_start) / abciss_interval_length);
                            fcp.OrdinateLocation = (int)((z.Imagine - ordinate_start) / ordinate_interval_length);
                            fcp_list.Add(fcp);
                        }
                        fcp_matrix[p_aoh.abciss/_abciss_step_length][p_aoh.ordinate/_ordinate_step_length] = fcp_list.ToArray();
                    }
                    for (; iterations < max_iter && dist <= 4D; iterations++)
                    {
                        pdist = dist;
                        last_valid_z.Real = z.Real;
                        last_valid_z.Imagine = z.Imagine;
                        z.tsqr();
                        z.Real += z0.Real;
                        z.Imagine += z0.Imagine;
                        dist = (z.Real * z.Real + z.Imagine * z.Imagine);
                    }
                    Ratio_matrix[p_aoh.abciss][p_aoh.ordinate] = pdist;
                    iter_matrix[p_aoh.abciss][p_aoh.ordinate] = iterations;
                    radian_matrix[p_aoh.abciss][p_aoh.ordinate] = Math.Atan2(last_valid_z.Imagine,last_valid_z.Real);
                }
                p_aoh.ordinate = 0;
                if((--current_percent_state)==0)
                {
                    current_percent_state = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }
 private Complex _get_complex_loc(_2DFractal fractal,int x,int y)
 {
     double real = fractal.AbcissStart + fractal.AbcissIntervalLength * x;
     double imagine = fractal.OrdinateStart + fractal.OrdinateIntervalLength * y;
     return new Complex(real,imagine);
 }
 public JuliaSearcher(IUsingComplex JuliaLike,_2DFractal BackSideFractal,FractalColorMode JuliaMode)
     : this(JuliaLike,JuliaMode)
 {
     //if (!(BackSideFractal is _2DFractal)) throw new ArgumentException("Переданный объект для панели выбора должен быть двухмерным фракталом!");
     _mandelbrot =BackSideFractal;
 }
 private void JuliaSearcher_Load(object sender, EventArgs e)
 {
     fpb1 = new FractalPictureBox();
     fpb1.SizeMode = PictureBoxSizeMode.AutoSize;
     fpb1.ContextMenuStrip = contextMenuStrip1;
     if(_m_fcm==null)_m_fcm = new Simple2DFractalColorMode();
     panel1.Controls.Add(fpb1);
     fpb1.ToClickMode();
     if(_mandelbrot==null)_mandelbrot = new Mandelbrot();
     _m_fap = _mandelbrot.CreateFractal(panel1.Width, panel1.Height);
     fpb1.Image = _m_fcm.GetDrawnBitmap(_m_fap);
     fpb1.MouseMove += (_sender, _e) => {label1.Text = _get_complex_loc(_mandelbrot,_e.X,_e.Y).ToString(); };
     fpb2 = new FractalPictureBox();
     fpb2.SizeMode = PictureBoxSizeMode.AutoSize;
     panel2.Controls.Add(fpb2);
     fpb1.MouseDown += (_sender, _e) =>
     {
         if (!clickable) return;
         if (_e.Button != MouseButtons.Left) return;
         _using_complex = _get_complex_loc(_mandelbrot, _e.X, _e.Y);
         label2.Text=_using_complex.ToString();
         _julia.SetComplex(_using_complex);
         fpb2.Image = _j_fcm.GetDrawnBitmap(((_2DFractal)_julia).CreateFractal(panel2.Width, panel2.Height));
     };
     fpb2.RectangleSelected += (_sender, rec) =>
     {
         ((_2DFractal)_julia).CreateParallelFractal(panel2.Width, panel2.Height, rec.X, rec.Y, rec.Width, rec.Height, true);
     };
     ((_2DFractal)_julia).ParallelFractalCreatingFinished += (s, fap) =>
     {
     Action<Bitmap> act=(bmp)=>{fpb2.Image=bmp;};
     Invoke(act, _j_fcm.GetDrawnBitmap(fap));
     };
     fpb2.SelectionPen = null;
     fpb1.RectangleSelected += (_s, rec) => {
         _mandelbrot.CreateParallelFractal(panel1.Width, panel1.Height, rec.X, rec.Y, rec.Width, rec.Height,true);
     };
     _mandelbrot.ParallelFractalCreatingFinished += (s, fap) =>
     {
         Action<Bitmap> act = (bmp) => { fpb1.Image = bmp; };
         Invoke(act, _m_fcm.GetDrawnBitmap(fap));
     };
     fpb2.ContextMenuStrip = contextMenuStrip2;
     fpb1.SelectionPen = null;
     clickable = true;
     _fpb1_h_scale = this.Width / (double)panel1.Width;
     _fpb1_v_scale = this.Height / (double)panel1.Height;
     _fpb2_h_scale = this.Width / (double)panel2.Width;
     _fpb2_v_scale = this.Height / (double)panel2.Height;
     oldheight = panel1.Height;
     oldwidth = panel1.Width;
     вРежимВращенияToolStripMenuItem.Visible = вРежимВращенияToolStripMenuItem.Enabled = _mandelbrot is IUsingQuaternion;
 }
 public static void CopyTo(_2DFractal Source,_2DFractal Destinator)
 {
     Fractal.CopyTo(Source, Destinator);
     Destinator._2df_bottom_edge = Source._2df_bottom_edge;
     Destinator._2df_imagine_height = Source._2df_imagine_height;
     Destinator._2df_imagine_left = Source._2df_imagine_left;
     Destinator._2df_imagine_top = Source._2df_imagine_top;
     Destinator._2df_imagine_width = Source._2df_imagine_width;
     Destinator._2df_left_edge = Source._2df_left_edge;
     Destinator._2df_right_edge = Source._2df_right_edge;
     Destinator._2df_top_edge = Source._2df_top_edge;
 }
            public _2DFractalHelper(_2DFractal Fractal, int Width, int Height, bool unsafer = false)
            {
                if (Width < 1 || Height < 1)
                    throw new ArgumentException("Ширина и высота матрицы не могут быть меньше единицы" + (Width < 1 ? ", ошибочная ширина = " + Width : "") + (Height < 1 ? ", ошибочная высота = " + Height : "") + "!");
                _start_time = DateTime.Now;
                _is_process_parallel = Fractal.f_parallel_isbusy;
                _fractal = Fractal;
                _width = Width;
                _height = Height;
                double future_percent_length = _width / (double)_fractal.f_max_percent;
                _curent_percent = _percent_length = (int)(future_percent_length + (future_percent_length % 1d > 0 ? 1 : 0));
                _iterations_count = Fractal.f_iterations_count;
                _abciss_interval_length = Fractal._2df_get_double_abciss_interval_length();
                _ordinate_interval_length = Fractal._2df_get_double_ordinate_interval_length();
                _left_edge = Fractal._2df_get_double_abciss_start();
                _right_edge = _left_edge + (Width - 1) * _abciss_interval_length;
                _top_edge = Fractal._2df_get_double_ordinate_start();
                _bottom_edge = _top_edge + (Height - 1) * _ordinate_interval_length;
                _result_matrix = new ulong[_width][];
                for (int i = 0; i < _width; i++)
                {
                    _result_matrix[i] = new ulong[_height];
                }
                if (unsafer)
                {
                    unsafe
                    {

                        double* limits = stackalloc double[4];
                        *(limits) = _left_edge;
                        *(limits + 1) = _right_edge;
                        *(limits + 2) = _top_edge;
                        *(limits + 3) = _bottom_edge;
                        try { fixed (double** _arg_d_w = &_absciss_real_pointer)
                            fixed (double** _arg_d_h = &_ordina_real_pointer)
                        MakeRealCordsTable(_arg_d_w, _arg_d_h, limits, _width, _height);
                        }
                        catch
                        {
                            unsafer = false;
                        }
                        }
                }
                if (!unsafer)
                {
                    _abciss_real_values_vector = _create_abciss_real_values_vector();
                    _ordinate_real_values_vector = _create_ordinate_real_values_vector();
                }
                _aoh = new AbcissOrdinateHandler();
                if (_is_process_parallel) { _fractal.f_parallel_canceled += _end_creating;
                _fractal.ParallelFractalCreatingFinished += _finish_creating;
                }
                _ratio_matrix=new double[Width][];
                for(int i=0;i<_width;i++)
                {
                    _ratio_matrix[i]=new double[_height];
                }
            }
        public override BigInteger[] FindFirstInserts(BigInteger Width, BigInteger Height, ulong MinIters)
        {
            int        width  = (int)Width;
            int        height = (int)Height;
            _2DFractal temp   = (_2DFractal)this.GetClone();
            FractalAssociationParametrs fap = temp.CreateFractal(width, height);

            BigInteger[] Result = new BigInteger[4];
            bool         con    = true;

            ulong[][] itermatrix = fap.Get2DOriginalIterationsMatrix();
            for (int x = 0; x < width && con; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (itermatrix[x][y] >= MinIters)
                    {
                        con       = false;
                        Result[0] = x;
                        break;
                    }
                }
            }
            if (con)
            {
                Result[0] = -1;
            }
            con = true;
            for (int x = width - 1; x >= 0 && con; x--)
            {
                for (int y = 0; y < height; y++)
                {
                    if (itermatrix[x][y] >= MinIters)
                    {
                        con       = false;
                        Result[1] = x;
                        break;
                    }
                }
            }
            if (con)
            {
                Result[1] = -1;
            }
            con = true;
            for (int y = height - 1; y >= 0 && con; y--)
            {
                for (int x = 0; x < width; x++)
                {
                    if (itermatrix[x][y] >= MinIters)
                    {
                        con       = false;
                        Result[3] = y;
                        break;
                    }
                }
            }
            if (con)
            {
                Result[3] = -1;
            }
            con = true;
            for (int y = 0; y < height && con; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (itermatrix[x][y] >= MinIters)
                    {
                        con       = false;
                        Result[2] = y;
                        break;
                    }
                }
            }
            if (con)
            {
                Result[2] = -1;
            }
            con = true;
            return(Result);
        }
            public _2DFractalHelper(_2DFractal Fractal, int Width, int Height, bool unsafer = false)
            {
                if (Width < 1 || Height < 1)
                {
                    throw new ArgumentException("Ширина и высота матрицы не могут быть меньше единицы" + (Width < 1 ? ", ошибочная ширина = " + Width : "") + (Height < 1 ? ", ошибочная высота = " + Height : "") + "!");
                }
                _start_time          = DateTime.Now;
                _is_process_parallel = Fractal.f_parallel_isbusy;
                _fractal             = Fractal;
                _width  = Width;
                _height = Height;
                double future_percent_length = _width / (double)_fractal.f_max_percent;

                _curent_percent           = _percent_length = (int)(future_percent_length + (future_percent_length % 1d > 0 ? 1 : 0));
                _iterations_count         = Fractal.f_iterations_count;
                _abciss_interval_length   = Fractal._2df_get_double_abciss_interval_length();
                _ordinate_interval_length = Fractal._2df_get_double_ordinate_interval_length();
                _left_edge     = Fractal._2df_get_double_abciss_start();
                _right_edge    = _left_edge + (Width - 1) * _abciss_interval_length;
                _top_edge      = Fractal._2df_get_double_ordinate_start();
                _bottom_edge   = _top_edge + (Height - 1) * _ordinate_interval_length;
                _result_matrix = new ulong[_width][];
                for (int i = 0; i < _width; i++)
                {
                    _result_matrix[i] = new ulong[_height];
                }
                if (unsafer)
                {
                    unsafe
                    {
                        double *limits = stackalloc double[4];
                        *(limits)     = _left_edge;
                        *(limits + 1) = _right_edge;
                        *(limits + 2) = _top_edge;
                        *(limits + 3) = _bottom_edge;
                        try { fixed(double **_arg_d_w = &_absciss_real_pointer)
                              fixed(double **_arg_d_h = &_ordina_real_pointer)
                              MakeRealCordsTable(_arg_d_w, _arg_d_h, limits, _width, _height); }
                        catch
                        {
                            unsafer = false;
                        }
                    }
                }
                if (!unsafer)
                {
                    _abciss_real_values_vector   = _create_abciss_real_values_vector();
                    _ordinate_real_values_vector = _create_ordinate_real_values_vector();
                }
                _aoh = new AbcissOrdinateHandler();
                if (_is_process_parallel)
                {
                    _fractal.f_parallel_canceled             += _end_creating;
                    _fractal.ParallelFractalCreatingFinished += _finish_creating;
                }
                _ratio_matrix = new double[Width][];
                for (int i = 0; i < _width; i++)
                {
                    _ratio_matrix[i] = new double[_height];
                }
            }