/// <summary>
        /// Рисование
        /// </summary>
        private void Draw()
        {
            int Count = 0;

            try
            {
                Count = int.Parse(textBox3.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Число итераций неверное!");
                return;
            }
            Mandelbrot mand   = new Mandelbrot(Count);
            int        radius = panel1.Height / 2;

            for (int i = 1; i < panel1.Height; i++)
            {
                for (int j = 1; j < panel1.Width; j++)
                {
                    double  xCoord  = (i - panel1.Height / 2) / (double)(panel1.Height) * 4;
                    double  yCoord  = (j - panel1.Height / 2) / (double)(panel1.Height) * 4;
                    CNumber complex = new CNumber(xCoord, yCoord);
                    byte    speed   = mand.Speed(complex);
                    DrawPoint(i, panel1.Height - j, speed); //или j  -i?
                }
            }
        }
示例#2
0
        /// <summary>
        /// Умножение комплексных чисел
        /// </summary>
        /// <param name="z">Умножаемое комплексное число</param>
        /// <returns>Возвращает результат умножения</returns>
        public CNumber Umn(CNumber z)
        {
            double x = this.re * z.re - this.im * z.im;
            double y = this.re * z.im + this.im * z.re;

            return(new CNumber(x, y));
        }
示例#3
0
        /// <summary>
        /// Вычитание комплексных чисел
        /// </summary>
        /// <param name="z">вычитаемое комплексное число</param>
        /// <returns>Возвращает результат вычитания</returns>
        public CNumber Minus(CNumber z)
        {
            double x = this.re - z.re;
            double y = this.im - z.im;

            return(new CNumber(x, y));
        }
示例#4
0
        /// <summary>
        /// Сложение комплексных чисел
        /// </summary>
        /// <param name="z">прибавляемое комплексное число</param>
        /// <returns>Возвращает результат сложения</returns>
        public CNumber Plus(CNumber z)
        {
            double x = this.re + z.re;
            double y = this.im + z.im;

            return(new CNumber(x, y));
        }
示例#5
0
        public CNumber Del(CNumber z)
        {
            double u = z.re * z.re + z.im * z.im;
            double x = (this.re * z.re + this.im * z.im) / u;
            double y = (this.re * z.im - this.im * z.re) / u;

            return(new CNumber(x, y));
        }
示例#6
0
        public static CNumber operator ^(CNumber x, byte n)
        {
            if (n == 0)
            {
                return(new CNumber(1, 0));
            }
            CNumber y = x;

            for (int i = 1; i < n; i++)
            {
                y = y * x;
            }
            return(y);
        }
示例#7
0
        /// <summary>
        /// Вычисляет скорость
        /// </summary>
        /// <param name="c">комплексное число</param>
        /// <returns>Возвращает скорость</returns>
        public byte Speed(CNumber c)
        {
            CNumber a      = new CNumber(2, 0);
            CNumber z      = new CNumber(0, 0);
            int     result = 0;

            for (int i = 1; i < Count_Iterations; i++)
            {
                z = c + (z ^ 2);
                if (z.Modul > Radius)
                {
                    result = i;
                    break;
                }
            }
            if (result == 0)
            {
                return(0);
            }
            if (result < 11)
            {
                return(1);
            }
            if (result < 21)
            {
                return(2);
            }
            if (result < 51)
            {
                return(3);
            }
            if (result < 101)
            {
                return(4);
            }
            if (result < 151)
            {
                return(5);
            }
            else
            {
                return(6);
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            double x1, y1;
            byte   n;

            try
            {
                x1 = double.Parse(textBoxRe_1.Text);
                y1 = double.Parse(textBoxIm_1.Text);
                n  = byte.Parse(textBoxStep.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Не все поля заполены!");
                return;
            }
            CNumber x = new CNumber(x1, y1);

            x = x ^ n;
            textBoxRes_Re.Text = x.re.ToString();
            textBoxRes_Im.Text = x.im.ToString();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            double x1, x2, y1, y2;

            try
            {
                x1 = double.Parse(textBoxRe_1.Text);
                x2 = double.Parse(textBoxRe_2.Text);
                y1 = double.Parse(textBoxIm_1.Text);
                y2 = double.Parse(textBoxIm_2.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Не все поля заполены!");
                return;
            }
            CNumber x = new CNumber(x1, y1);
            CNumber y = new CNumber(x2, y2);

            x = x.Del(y);
            textBoxRes_Re.Text = x.re.ToString();
            textBoxRes_Im.Text = x.im.ToString();
        }