Exemplo n.º 1
0
            public AbcissOrdinateHandler[] CreateDataForParallelWork(int CountOfThread)
            {
                AbcissOrdinateHandler[] result = new AbcissOrdinateHandler[CountOfThread];
                int unit_size = _width / CountOfThread, h_s = 0;

                --CountOfThread;

                if (_fractal.f_parallel_isbusy)
                {
                    for (int i = 0; i < CountOfThread; i++, h_s += unit_size)
                    {
                        result[i] = new AbcissOrdinateHandler(_fractal, h_s, 0, h_s + unit_size, _height);
                        result[i].Connect();
                    }
                    result[CountOfThread] = new AbcissOrdinateHandler(_fractal, h_s, 0, _width, _height);
                    result[CountOfThread].Connect();
                }
                else
                {
                    for (int i = 0; i < CountOfThread; i++, h_s += unit_size)
                    {
                        result[i] = new AbcissOrdinateHandler(_fractal, h_s, 0, h_s + unit_size, _height);
                    }
                    result[CountOfThread] = new AbcissOrdinateHandler(_fractal, h_s, 0, _width, _height);
                }
                return(result);
            }
        protected virtual void inc_create_part_of_fractal(AbcissOrdinateHandler p_aoh, _2DFractalHelper fractal_helper)
        {
            ulong iter_count = f_iterations_count, iteration;

            ulong[][] matrix = fractal_helper.CommonMatrix;
            double[]  abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double    abciss_point, dist, pdist = 0D;

            double[][] Ratio_matrix = (double[][])fractal_helper.GetRatioMatrix();
            int        percent_length = fractal_helper.PercentLength, current_percent = percent_length;

            double[][] Radian_matrix = ((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            int        height = ordinate_points.Length;
            double     cosrad = Math.Cos(inc_rotater.Radian), sinrad = Math.Sin(inc_rotater.Radian);
            Triplex    z = new Triplex(), z0 = new Triplex(), last_valid_z = new Triplex();

            //new Complex(-0.8D, 0.156D));
            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[height];
                for (; p_aoh.ordinate < p_aoh.end_of_ordinate; ++p_aoh.ordinate)
                {
                    z0.x = abciss_point;                    //-0.8D;
                    z0.y = ordinate_points[p_aoh.ordinate]; //0.156D;//
                    z0.z = 0D;
                    inc_rotater.Rotate(z0);
                    z.x  = z0.x;
                    z.y  = z0.y;
                    z.z  = z0.z;
                    dist = 0D;
                    for (iteration = 0; iteration < iter_count && dist < 4D; iteration++)
                    {
                        pdist          = dist;
                        last_valid_z.x = z.x;
                        last_valid_z.y = z.y;
                        last_valid_z.z = z.z;
                        z.tsqr();
                        z.tadd(z0);
                        dist = (z.x * z.x + z.y * z.y + z.z * z.z);
                    }
                    Ratio_matrix[p_aoh.abciss][p_aoh.ordinate]  = pdist;
                    matrix[p_aoh.abciss][p_aoh.ordinate]        = iteration;
                    Radian_matrix[p_aoh.abciss][p_aoh.ordinate] = Math.Atan2(last_valid_z.y, last_valid_z.x) * cosrad + sinrad * Math.Atan2(last_valid_z.z, last_valid_z.x);
                }
                p_aoh.ordinate = 0;
                if ((--current_percent) == 0)
                {
                    current_percent = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }
Exemplo n.º 3
0
        protected virtual void _m_create_part_of_fractal(AbcissOrdinateHandler p_aoh, _2DFractalHelper fractal_helper)
        {
            ulong iter_count = f_iterations_count, iteration;

            ulong[][] matrix = fractal_helper.CommonMatrix;
            double[]  abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double    abciss_point, dist, pdist = 0D;

            double[][] Ratio_matrix = (double[][])fractal_helper.GetRatioMatrix();
            int        percent_length = fractal_helper.PercentLength, current_percent = percent_length;
            Complex    z = new Complex(), z0 = new Complex(), last_valid_z = new Complex();

            double[][] Radian_matrix = ((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            int        height        = ordinate_points.Length;

            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[height];
                for (; p_aoh.ordinate < p_aoh.end_of_ordinate; ++p_aoh.ordinate)
                {
                    z0.Real    = abciss_point;
                    z0.Imagine = ordinate_points[p_aoh.ordinate];
                    z.Real     = z0.Real;
                    z.Imagine  = z0.Imagine;
                    dist       = 0D;
                    for (iteration = 0; iteration < iter_count && dist < 4D; iteration++)
                    {
                        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;
                    matrix[p_aoh.abciss][p_aoh.ordinate]        = iteration;
                    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) == 0)
                {
                    current_percent = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }
Exemplo n.º 4
0
        protected virtual void _j_create_part_of_fractal(AbcissOrdinateHandler p_aoh, _2DFractalHelper fractal_helper)
        {
            ulong max_iterations = f_iterations_count, iterations;

            ulong[][] result_matrix = fractal_helper.CommonMatrix;
            int       percent_length = fractal_helper.PercentLength, percent_counter = percent_length, height;

            double[] abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double   abciss_point, dist, pdist = 0D, sqr;

            double[][] ratio_matrix = (double[][])fractal_helper.GetRatioMatrix();
            Complex    complex_iterator = new Complex(), last_valid_complex = new Complex();

            double[][] radiad_matrix = ((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            height = ordinate_points.Length;
            for (; p_aoh.abciss < p_aoh.end_of_abciss; ++p_aoh.abciss)
            {
                abciss_point = abciss_points[p_aoh.abciss];
                radiad_matrix[p_aoh.abciss] = new double[height];
                for (; p_aoh.ordinate < p_aoh.end_of_ordinate; ++p_aoh.ordinate)
                {
                    complex_iterator.Real    = abciss_point;
                    complex_iterator.Imagine = ordinate_points[p_aoh.ordinate];
                    dist = 0D;
                    for (iterations = 0; dist < 4D && iterations < max_iterations; ++iterations)
                    {
                        pdist = dist;
                        last_valid_complex.Real    = complex_iterator.Real;
                        last_valid_complex.Imagine = complex_iterator.Imagine;
                        sqr = complex_iterator.Real * 2;
                        complex_iterator.Real     = complex_iterator.Real * complex_iterator.Real - complex_iterator.Imagine * complex_iterator.Imagine;
                        complex_iterator.Imagine *= sqr;
                        complex_iterator.Real    += j_complex_const.Real;
                        complex_iterator.Imagine += j_complex_const.Imagine;
                        dist = (complex_iterator.Real * complex_iterator.Real + complex_iterator.Imagine * complex_iterator.Imagine);
                    }
                    result_matrix[p_aoh.abciss][p_aoh.ordinate] = iterations;
                    ratio_matrix[p_aoh.abciss][p_aoh.ordinate]  = pdist;
                    radiad_matrix[p_aoh.abciss][p_aoh.ordinate] = Math.Atan2(last_valid_complex.Imagine, last_valid_complex.Real);
                }
                p_aoh.ordinate = 0;
                if ((--percent_counter) == 0)
                {
                    percent_counter = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }
Exemplo n.º 5
0
        /*________________________________________________________Частные_методы_для_реализации_класса____________________________________________________________*/
        #region Private methods for realizations
        protected virtual _2DFractalHelper _create_fractal_double_version(int Width, int Height)
        {
            ulong            iterations_count = f_iterations_count, iteration;
            _2DFractalHelper fractal_helper = new _2DFractalHelper(this, Width, Height);

            ulong[][]             matrix = fractal_helper.CommonMatrix;
            double[]              abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double                abciss_point, p, _2d3d = 2d / 3d;
            int                   percent_length = fractal_helper.PercentLength, _current_percent = percent_length;
            AbcissOrdinateHandler aoh = fractal_helper.AOH;
            Complex               z = new Complex(), t = new Complex(), d = new Complex();

            for (; aoh.abciss < Width; aoh.abciss++)
            {
                abciss_point = abciss_points[aoh.abciss];
                for (aoh.ordinate = 0; aoh.ordinate < Height; aoh.ordinate++)
                {
                    z.Real    = abciss_point;
                    z.Imagine = ordinate_points[aoh.ordinate];
                    d.Real    = z.Real;
                    d.Imagine = z.Imagine;
                    for (iteration = 0; iteration <= iterations_count && (z.Real * z.Real + z.Imagine * z.Imagine <= 1000000) && (d.Real * d.Real + d.Imagine * d.Imagine > 0.000001); iteration++)
                    {
                        t.Real    = z.Real;
                        t.Imagine = z.Imagine;
                        p         = Math.Pow(t.Real * t.Real + t.Imagine + t.Imagine, 2);
                        z.Real    = _2d3d * t.Real + (t.Real * t.Real - t.Imagine * t.Imagine) / (3 * p);
                        z.Imagine = _2d3d * t.Imagine * (1 - t.Real / p);
                        d.Real    = Math.Abs(z.Real - t.Real);
                        d.Imagine = Math.Abs(z.Imagine - t.Imagine);
                    }
                    matrix[aoh.abciss][aoh.ordinate] = iteration;
                }
                if ((--_current_percent) == 0)
                {
                    _current_percent = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
            return(fractal_helper);
        }
Exemplo n.º 6
0
        //protected override Fractal.fractal_resume_data get_resume_data()
        //{
        //   return new julia_resume_data(_2df_imagine_left, _2df_imagine_top,j_complex_const);
        //}
        #endregion /Realization of abstract methods

        /*___________________________________________________________Частные_методы_класса____________________________________________________________*/
        #region Private methods for realization
        protected virtual _2DFractalHelper _j_parallel_create_fractal_double_version(int width, int height)
        {
            ulong                 max_iterations = f_iterations_count, iterations;
            _2DFractalHelper      fractal_helper = new _2DFractalHelper(this, width, height);
            AbcissOrdinateHandler aoh            = fractal_helper.AOH;

            ulong[][] result_matrix = fractal_helper.CommonMatrix;
            int       percent_length = fractal_helper.PercentLength, percent_counter = percent_length;

            double[] abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double   abciss_point;
            Complex  complex_iterator = new Complex();

            for (; aoh.abciss < width; ++aoh.abciss)
            {
                abciss_point = abciss_points[aoh.abciss];
                for (; aoh.ordinate < height; ++aoh.ordinate)
                {
                    complex_iterator.Real    = abciss_point;
                    complex_iterator.Imagine = ordinate_points[aoh.ordinate];
                    for (iterations = 0; (complex_iterator.Real * complex_iterator.Real + complex_iterator.Imagine * complex_iterator.Imagine) < 4D && iterations < max_iterations; ++iterations)
                    {
                        complex_iterator.tsqr();
                        complex_iterator.Real    += j_complex_const.Real;
                        complex_iterator.Imagine += j_complex_const.Imagine;
                    }
                    result_matrix[aoh.abciss][aoh.ordinate] = iterations;
                }
                aoh.ordinate = 0;
                if ((--percent_counter) == 0)
                {
                    percent_counter = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
            fractal_helper.GiveUnique(j_complex_const);
            return(fractal_helper);
        }
Exemplo n.º 7
0
        /*__________________________________________________________Защищённые_методы_для_реализации___________________________________________________________*/
        #region Protected methods for realization
        protected virtual _2DFractalHelper m_old_create_fractal_double_version(int width, int height)
        {
            ulong                 iter_count = f_iterations_count, iteration;
            _2DFractalHelper      fractal_helper = new _2DFractalHelper(this, width, height);
            AbcissOrdinateHandler aoh            = fractal_helper.AOH;

            ulong[][] matrix        = fractal_helper.CommonMatrix;
            double[]  abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double    abciss_point;
            int       percent_length = fractal_helper.PercentLength, current_percent = percent_length;
            Complex   z = new Complex(), z0 = new Complex();

            for (; aoh.abciss < width; aoh.abciss++)
            {
                abciss_point = abciss_points[aoh.abciss];
                for (aoh.ordinate = 0; aoh.ordinate < height; aoh.ordinate++)
                {
                    z0.Real    = abciss_point;
                    z0.Imagine = ordinate_points[aoh.ordinate];
                    z.Real     = z0.Real;
                    z.Imagine  = z0.Imagine;
                    for (iteration = 0; iteration < iter_count && (z.Real * z.Real + z.Imagine * z.Imagine) < 4D; iteration++)
                    {
                        z.tsqr();
                        z.Real    += z0.Real;
                        z.Imagine += z0.Imagine;
                    }
                    matrix[aoh.abciss][aoh.ordinate] = iteration;
                    if ((--current_percent) == 0)
                    {
                        current_percent = percent_length;
                        f_new_percent_in_parallel_activate();
                    }
                }
            }
            return(fractal_helper);
        }
        protected unsafe override void _j_create_part_of_fractal(AbcissOrdinateHandler p_aoh, _2DFractalHelper fractal_helper)
        {
            ulong max_iterations = f_iterations_count, iterations;
            ulong[][] result_matrix = fractal_helper.CommonMatrix;
            int percent_length = fractal_helper.PercentLength, percent_counter = percent_length, height;
            double  dist, pdist = 0D, sqr,abciss_interval_length=_2df_get_double_abciss_interval_length(),
                   ordinate_interval_length=_2df_get_double_ordinate_interval_length(),abciss_start=_2df_get_double_abciss_start(),
                   ordinate_start=_2df_get_double_ordinate_start();
            double[][] ratio_matrix = fractal_helper.GetRatioMatrix();
            Complex complex_iterator = new Complex(), last_valid_complex = new Complex();
            double[][] radiad_matrix = ((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            height = fractal_helper.Height;
            int fcp_height=height / _ordinate_step_length + (height % _ordinate_step_length != 0 ? 1 : 0);
            FractalCloudPoint[][][] fcp_matrix = ((FractalCloudPoints)fractal_helper.GetUnique(typeof(FractalCloudPoints))).fractalCloudPoint;
            List<FractalCloudPoint> fcp_list = new List<FractalCloudPoint>();
            FractalCloudPoint fcp;
            double* abciss_point,ordinate_point= fractal_helper.OrdinateRealPointer;
            abciss_point = fractal_helper.AbscissPointer + (p_aoh.abciss - 1);

            for (; p_aoh.abciss < p_aoh.end_of_abciss; ++p_aoh.abciss)
            {
                ++abciss_point;
                radiad_matrix[p_aoh.abciss] = new double[height];
                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)
                {
                    complex_iterator.Real = *abciss_point;
                    complex_iterator.Imagine = *(ordinate_point++);
                    dist = 0D;
                    iterations = 0;
                    if (((p_aoh.abciss % _abciss_step_length) == 0) && ((p_aoh.ordinate % _ordinate_step_length) == 0))
                    {
                        fcp_list.Clear();
                        for (; dist < 4D && iterations <= (ulong)_max_ammount_at_trace; ++iterations)
                        {
                            pdist = dist;
                            last_valid_complex.Real = complex_iterator.Real;
                            last_valid_complex.Imagine = complex_iterator.Imagine;
                            sqr = complex_iterator.Real * 2;
                            complex_iterator.Real = complex_iterator.Real * complex_iterator.Real - complex_iterator.Imagine * complex_iterator.Imagine;
                            complex_iterator.Imagine *= sqr;
                            complex_iterator.Real += j_complex_const.Real;
                            complex_iterator.Imagine += j_complex_const.Imagine;
                            dist = (complex_iterator.Real * complex_iterator.Real + complex_iterator.Imagine * complex_iterator.Imagine);
                            fcp.AbcissLocation=(int)((complex_iterator.Real-abciss_start)/abciss_interval_length);
                            fcp.OrdinateLocation = (int)((complex_iterator.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 (; dist < 4D && iterations < max_iterations; ++iterations)
                    {
                        pdist = dist;
                        last_valid_complex.Real = complex_iterator.Real;
                        last_valid_complex.Imagine = complex_iterator.Imagine;
                        sqr = complex_iterator.Real * 2;
                        complex_iterator.Real = complex_iterator.Real * complex_iterator.Real - complex_iterator.Imagine * complex_iterator.Imagine;
                        complex_iterator.Imagine *= sqr;
                        complex_iterator.Real += j_complex_const.Real;
                        complex_iterator.Imagine += j_complex_const.Imagine;
                        dist = (complex_iterator.Real * complex_iterator.Real + complex_iterator.Imagine * complex_iterator.Imagine);
                    }
                    result_matrix[p_aoh.abciss][p_aoh.ordinate] = iterations;
                    ratio_matrix[p_aoh.abciss][p_aoh.ordinate] = pdist;
                    radiad_matrix[p_aoh.abciss][p_aoh.ordinate] = Math.Atan2(last_valid_complex.Imagine, last_valid_complex.Real);
                }
                ordinate_point -= height;
                p_aoh.ordinate = 0;
                if ((--percent_counter) == 0)
                {
                    percent_counter = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }
Exemplo n.º 9
0
        /*_______________________________________________Перегруженные_методы_класса________________________________________________________________*/
        #region Override methods
        protected override _2DFractalHelper m_old_create_fractal_double_version(int width, int height)
        {
            ulong                 iter_count = f_iterations_count, iteration;
            _2DFractalHelper      fractal_helper = new _2DFractalHelper(this, width, height);
            AbcissOrdinateHandler aoh            = fractal_helper.AOH;

            ulong[][] matrix = fractal_helper.CommonMatrix;
            double[]  abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double    abciss_point, abciss_interval_length = _2df_get_double_abciss_interval_length(), ordinate_interval_length = _2df_get_double_ordinate_interval_length(),
                      abciss_start = _2df_get_double_abciss_start(), ordinate_start = _2df_get_double_ordinate_start();
            int     percent_length = fractal_helper.PercentLength, current_percent = percent_length;
            Complex z = new Complex(), z0 = new Complex();
            int     fcp_width = width / _abciss_step_length + (width % _abciss_step_length != 0?1:0), fcp_height = height / _ordinate_step_length + (height % _ordinate_step_length != 0?1:0);

            FractalCloudPoint[][][]  fcp      = new FractalCloudPoint[fcp_width][][];
            List <FractalCloudPoint> fcp_list = new List <FractalCloudPoint>();
            FractalCloudPoint        cfcp;

            for (; aoh.abciss < width; aoh.abciss++)
            {
                abciss_point = abciss_points[aoh.abciss];
                if ((aoh.abciss % _abciss_step_length) == 0)
                {
                    fcp[aoh.abciss / _abciss_step_length] = new FractalCloudPoint[fcp_height][];
                }
                for (aoh.ordinate = 0; aoh.ordinate < height; aoh.ordinate++)
                {
                    z0.Real    = abciss_point;
                    z0.Imagine = ordinate_points[aoh.ordinate];
                    z.Real     = z0.Real;
                    z.Imagine  = z0.Imagine;
                    iteration  = 0;
                    if ((aoh.abciss % _abciss_step_length) == 0 && (aoh.ordinate % _ordinate_step_length) == 0)
                    {
                        fcp_list.Clear();
                        for (; iteration < (ulong)_max_ammount_at_trace && (z.Real * z.Real + z.Imagine * z.Imagine) < _max_sqr_radius; iteration++)
                        {
                            z.tsqr();
                            z.Real               += z0.Real;
                            z.Imagine            += z0.Imagine;
                            cfcp                  = new FractalCloudPoint();
                            cfcp.AbcissLocation   = (int)((z.Real - abciss_start) / abciss_interval_length);
                            cfcp.OrdinateLocation = (int)((z.Imagine - ordinate_start) / ordinate_interval_length);
                            fcp_list.Add(cfcp);
                        }
                        fcp[aoh.abciss / _abciss_step_length][aoh.ordinate / _ordinate_step_length] = fcp_list.ToArray();
                    }

                    for (; iteration < iter_count && (z.Real * z.Real + z.Imagine * z.Imagine) < 4D; iteration++)
                    {
                        z.tsqr();
                        z.Real    += z0.Real;
                        z.Imagine += z0.Imagine;
                    }
                    matrix[aoh.abciss][aoh.ordinate] = iteration;
                }
                if ((--current_percent) == 0)
                {
                    current_percent = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
            fractal_helper.GiveUnique(new FractalCloudPoints(_max_ammount_at_trace, fcp));
            return(fractal_helper);
        }
        protected virtual void inc_create_part_of_fractal(AbcissOrdinateHandler p_aoh,_2DFractalHelper fractal_helper)
        {
            ulong iter_count = f_iterations_count, iteration;
            ulong[][] matrix = fractal_helper.CommonMatrix;
            double[] abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double abciss_point, dist, pdist = 0D;
            double[][] Ratio_matrix = (double[][])fractal_helper.GetRatioMatrix();
            int percent_length = fractal_helper.PercentLength, current_percent = percent_length;
            double[][] Radian_matrix = ((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            int height = ordinate_points.Length;
            double cosrad = Math.Cos(inc_rotater.Radian),sinrad=Math.Sin(inc_rotater.Radian);
            Triplex z=new Triplex(), z0=(Triplex)inc_const.Clone(),last_valid_z=new Triplex();
            inc_rotater.Rotate(z0);
            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[height];
                for (; p_aoh.ordinate < p_aoh.end_of_ordinate; ++p_aoh.ordinate)
                {
                    z.x = abciss_point;
                    z.y = ordinate_points[p_aoh.ordinate];
                    z.z =0;
                    inc_rotater.Rotate(z);
                    dist = 0D;
                    for (iteration = 0; iteration < iter_count && dist < 4D; iteration++)
                    {
                        pdist = dist;
                        last_valid_z.x = z.x;
                        last_valid_z.y = z.y;
                        last_valid_z.z = z.z;
                        z.tsqr();
                        z.tadd(z0);
                        dist = (z.x * z.x + z.y * z.y + z.z * z.z);
                    }
                    Ratio_matrix[p_aoh.abciss][p_aoh.ordinate] = pdist;
                    matrix[p_aoh.abciss][p_aoh.ordinate] = iteration;
                    Radian_matrix[p_aoh.abciss][p_aoh.ordinate] = Math.Atan2(last_valid_z.y, last_valid_z.x) * cosrad + sinrad * Math.Atan2(last_valid_z.z, last_valid_z.x);
                }
                    p_aoh.ordinate = 0;
                    if ((--current_percent) == 0)
                    {
                        current_percent = percent_length;
                        f_new_percent_in_parallel_activate();
                    }

            }
        }
Exemplo n.º 11
0
            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];
                }
            }
Exemplo n.º 12
0
        unsafe protected override void _j_create_part_of_fractal(AbcissOrdinateHandler p_aoh, _2DFractalHelper fractal_helper)
        {
            ulong max_iterations = f_iterations_count, iterations;

            ulong[][] result_matrix = fractal_helper.CommonMatrix;
            int       percent_length = fractal_helper.PercentLength, percent_counter = percent_length, height;
            double    dist, pdist = 0D, sqr, abciss_interval_length = _2df_get_double_abciss_interval_length(),
                      ordinate_interval_length = _2df_get_double_ordinate_interval_length(), abciss_start = _2df_get_double_abciss_start(),
                      ordinate_start = _2df_get_double_ordinate_start();

            double[][] ratio_matrix = fractal_helper.GetRatioMatrix();
            Complex    complex_iterator = new Complex(), last_valid_complex = new Complex();

            double[][] radiad_matrix = ((RadianMatrix)fractal_helper.GetUnique(typeof(RadianMatrix))).Matrix;
            height = fractal_helper.Height;
            int fcp_height = height / _ordinate_step_length + (height % _ordinate_step_length != 0 ? 1 : 0);

            FractalCloudPoint[][][]  fcp_matrix = ((FractalCloudPoints)fractal_helper.GetUnique(typeof(FractalCloudPoints))).fractalCloudPoint;
            List <FractalCloudPoint> fcp_list   = new List <FractalCloudPoint>();
            FractalCloudPoint        fcp;
            double *abciss_point, ordinate_point = fractal_helper.OrdinateRealPointer;

            abciss_point = fractal_helper.AbscissPointer + (p_aoh.abciss - 1);

            for (; p_aoh.abciss < p_aoh.end_of_abciss; ++p_aoh.abciss)
            {
                ++abciss_point;
                radiad_matrix[p_aoh.abciss] = new double[height];
                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)
                {
                    complex_iterator.Real    = *abciss_point;
                    complex_iterator.Imagine = *(ordinate_point++);
                    dist       = 0D;
                    iterations = 0;
                    if (((p_aoh.abciss % _abciss_step_length) == 0) && ((p_aoh.ordinate % _ordinate_step_length) == 0))
                    {
                        fcp_list.Clear();
                        for (; dist < 4D && iterations <= (ulong)_max_ammount_at_trace; ++iterations)
                        {
                            pdist = dist;
                            last_valid_complex.Real    = complex_iterator.Real;
                            last_valid_complex.Imagine = complex_iterator.Imagine;
                            sqr = complex_iterator.Real * 2;
                            complex_iterator.Real     = complex_iterator.Real * complex_iterator.Real - complex_iterator.Imagine * complex_iterator.Imagine;
                            complex_iterator.Imagine *= sqr;
                            complex_iterator.Real    += j_complex_const.Real;
                            complex_iterator.Imagine += j_complex_const.Imagine;
                            dist = (complex_iterator.Real * complex_iterator.Real + complex_iterator.Imagine * complex_iterator.Imagine);
                            fcp.AbcissLocation   = (int)((complex_iterator.Real - abciss_start) / abciss_interval_length);
                            fcp.OrdinateLocation = (int)((complex_iterator.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 (; dist < 4D && iterations < max_iterations; ++iterations)
                    {
                        pdist = dist;
                        last_valid_complex.Real    = complex_iterator.Real;
                        last_valid_complex.Imagine = complex_iterator.Imagine;
                        sqr = complex_iterator.Real * 2;
                        complex_iterator.Real     = complex_iterator.Real * complex_iterator.Real - complex_iterator.Imagine * complex_iterator.Imagine;
                        complex_iterator.Imagine *= sqr;
                        complex_iterator.Real    += j_complex_const.Real;
                        complex_iterator.Imagine += j_complex_const.Imagine;
                        dist = (complex_iterator.Real * complex_iterator.Real + complex_iterator.Imagine * complex_iterator.Imagine);
                    }
                    result_matrix[p_aoh.abciss][p_aoh.ordinate] = iterations;
                    ratio_matrix[p_aoh.abciss][p_aoh.ordinate]  = pdist;
                    radiad_matrix[p_aoh.abciss][p_aoh.ordinate] = Math.Atan2(last_valid_complex.Imagine, last_valid_complex.Real);
                }
                ordinate_point -= height;
                p_aoh.ordinate  = 0;
                if ((--percent_counter) == 0)
                {
                    percent_counter = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }
Exemplo n.º 13
0
            public AbcissOrdinateHandler[] CreateDataForParallelWork(int CountOfThread)
            {
                AbcissOrdinateHandler[] result = new AbcissOrdinateHandler[CountOfThread];
                int unit_size = _width / CountOfThread,h_s=0;
                --CountOfThread;

                if(_fractal.f_parallel_isbusy)
                {
                    for(int i=0;i<CountOfThread;i++,h_s+=unit_size)
                    {
                    result[i] = new AbcissOrdinateHandler(_fractal,h_s, 0, h_s + unit_size, _height);
                    result[i].Connect();
                    }
                result[CountOfThread]=new AbcissOrdinateHandler(_fractal,h_s,0,_width,_height);
                result[CountOfThread].Connect();
                }
                else
                {
                    for (int i = 0; i < CountOfThread; i++, h_s += unit_size)
                    {
                        result[i] = new AbcissOrdinateHandler(_fractal, h_s, 0, h_s + unit_size, _height);
                    }
                    result[CountOfThread] = new AbcissOrdinateHandler(_fractal, h_s, 0, _width, _height);
                }
                return result;
            }
Exemplo n.º 14
0
            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];
                }
            }
Exemplo n.º 15
0
        private void Create_part_of_fractal(_2DFractalHelper fractal_helper,AbcissOrdinateHandler p_aoh)
        {
            ulong iterations;
            int percent_length=fractal_helper.PercentLength, current_percent=percent_length,trio_height;
            ulong[][] iter_matrix = fractal_helper.CommonMatrix;
            double[] abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double abciss_point,ratio,lratio;
            double[][] Ratio_matrix = fractal_helper.GetRatioMatrix();
            double[][][] trio_matrix = (double[][][])fractal_helper.GetUnique(typeof(double[][][]));
            double  v1, v2, v3, v1total, v2total, v3total, v1min, v1max, v2min, v2max, v3min, v3max;
            Complex value=new Complex(), z=new Complex();
            trio_height=Ratio_matrix[0].Length;
            for(;p_aoh.abciss<p_aoh.end_of_abciss;p_aoh.abciss++)
            {
                abciss_point = abciss_points[p_aoh.abciss];
                trio_matrix[p_aoh.abciss] = new double[trio_height][];
                for(;p_aoh.ordinate<p_aoh.end_of_ordinate;p_aoh.ordinate++)
                {
                    z.Real=abciss_point;
                    z.Imagine = ordinate_points[p_aoh.ordinate];
                    //z0 = z.getclone();
                    v1 = v2 = v3 = v1total = v1max = v1min = v2total = v2max = v2min = v3total = v3max = v3min = 0D;
                    ratio = (z.Real * z.Real + z.Imagine * z.Imagine);
                    lratio = 0;
                    for(iterations=0;iterations<f_iterations_count&&ratio<400D;iterations++)
                    {
                        lratio = ratio;
                        z = Complex.SSin(z);
                        z.Real += _P.Real;
                        z.Imagine += _P.Imagine;
                        value = Complex.Sec(z);
                        ratio = z.Real*z.Real+z.Imagine*z.Imagine;
                        if (double.IsNaN(value.Real) || double.IsNaN(value.Imagine)) {
                            v1 = v2 = v3 = 0;
                        }
                        else{v1 = value.abs;
                        v2 = value.sqr().abs;
                        v3 = value.Pow(3).abs;
                        v1total += v1;
                        v2total += v2;
                        v3total += v3;
                        if (v1 < v1min) v1min = v1;
                        else if (v1 > v1max) v1max = v1;
                        if (v2 < v2min) v2min = v2;
                        else if (v2 > v2max) v2max = v2;
                        if (v3 < v3min) v3min = v3;
                        else if (v3 > v3max) v3max = v3;}
                    }
                    //$r = (($v1total / $count) - $v1min) / ($v1max - $v1min);
                    Ratio_matrix[p_aoh.abciss][p_aoh.ordinate] = lratio;
                    if (iterations > 0)
                    {
                        trio_matrix[p_aoh.abciss][p_aoh.ordinate] = new double[] {((v1total/(double)iterations)-v1min)/(v1max-v1min),
                        ((v2total/(double)iterations)-v2min)/(v2max-v2min),
                        ((v3total/(double)iterations)-v3min)/(v3max-v3min)};
                    }
                    else trio_matrix[p_aoh.abciss][p_aoh.ordinate] = new double[3];
                    iter_matrix[p_aoh.abciss][p_aoh.ordinate] = iterations;
                }
                p_aoh.ordinate = 0;
                if((--current_percent)==0)
                {
                    current_percent = percent_length;
                    f_new_percent_in_parallel_activate();
                }

            }
        }
Exemplo n.º 16
0
        private void Create_part_of_fractal(_2DFractalHelper fractal_helper, AbcissOrdinateHandler p_aoh)
        {
            ulong iterations;
            int   percent_length = fractal_helper.PercentLength, current_percent = percent_length, trio_height;

            ulong[][] iter_matrix = fractal_helper.CommonMatrix;
            double[]  abciss_points = fractal_helper.AbcissRealValues, ordinate_points = fractal_helper.OrdinateRealValues;
            double    abciss_point, ratio, lratio;

            double[][]   Ratio_matrix = fractal_helper.GetRatioMatrix();
            double[][][] trio_matrix = (double[][][])fractal_helper.GetUnique(typeof(double[][][]));
            double       v1, v2, v3, v1total, v2total, v3total, v1min, v1max, v2min, v2max, v3min, v3max;
            Complex      value = new Complex(), z = new Complex();

            trio_height = Ratio_matrix[0].Length;
            for (; p_aoh.abciss < p_aoh.end_of_abciss; p_aoh.abciss++)
            {
                abciss_point = abciss_points[p_aoh.abciss];
                trio_matrix[p_aoh.abciss] = new double[trio_height][];
                for (; p_aoh.ordinate < p_aoh.end_of_ordinate; p_aoh.ordinate++)
                {
                    z.Real    = abciss_point;
                    z.Imagine = ordinate_points[p_aoh.ordinate];
                    //z0 = z.getclone();
                    v1     = v2 = v3 = v1total = v1max = v1min = v2total = v2max = v2min = v3total = v3max = v3min = 0D;
                    ratio  = (z.Real * z.Real + z.Imagine * z.Imagine);
                    lratio = 0;
                    for (iterations = 0; iterations < f_iterations_count && ratio < 400D; iterations++)
                    {
                        lratio     = ratio;
                        z          = Complex.SSin(z);
                        z.Real    += _P.Real;
                        z.Imagine += _P.Imagine;
                        value      = Complex.Sec(z);
                        ratio      = z.Real * z.Real + z.Imagine * z.Imagine;
                        if (double.IsNaN(value.Real) || double.IsNaN(value.Imagine))
                        {
                            v1 = v2 = v3 = 0;
                        }
                        else
                        {
                            v1       = value.abs;
                            v2       = value.sqr().abs;
                            v3       = value.Pow(3).abs;
                            v1total += v1;
                            v2total += v2;
                            v3total += v3;
                            if (v1 < v1min)
                            {
                                v1min = v1;
                            }
                            else if (v1 > v1max)
                            {
                                v1max = v1;
                            }
                            if (v2 < v2min)
                            {
                                v2min = v2;
                            }
                            else if (v2 > v2max)
                            {
                                v2max = v2;
                            }
                            if (v3 < v3min)
                            {
                                v3min = v3;
                            }
                            else if (v3 > v3max)
                            {
                                v3max = v3;
                            }
                        }
                    }
                    //$r = (($v1total / $count) - $v1min) / ($v1max - $v1min);
                    Ratio_matrix[p_aoh.abciss][p_aoh.ordinate] = lratio;
                    if (iterations > 0)
                    {
                        trio_matrix[p_aoh.abciss][p_aoh.ordinate] = new double[] { ((v1total / (double)iterations) - v1min) / (v1max - v1min),
                                                                                   ((v2total / (double)iterations) - v2min) / (v2max - v2min),
                                                                                   ((v3total / (double)iterations) - v3min) / (v3max - v3min) };
                    }
                    else
                    {
                        trio_matrix[p_aoh.abciss][p_aoh.ordinate] = new double[3];
                    }
                    iter_matrix[p_aoh.abciss][p_aoh.ordinate] = iterations;
                }
                p_aoh.ordinate = 0;
                if ((--current_percent) == 0)
                {
                    current_percent = percent_length;
                    f_new_percent_in_parallel_activate();
                }
            }
        }