Exemple #1
0
        private void Refresh3D_1(double[,] a)
        {
            for (int i = 0; i < nx1; i++)
            {
                for (int j = 0; j < ny1; j++)
                {
                    zArray2D.array[i, j] = 0;
                }
            }

            arr = Ini3D();
            arr = Scale(arr, sx, sx);
            arr = Sdv(arr, dx, dy);

            double dx1 = nx1 / 2;
            double dy1 = ny1 / 2;

            arr = Sdv(arr, -dx1, -dy1);
            arr = Rot(arr, fi);
            arr = Sdv(arr, dx1, dy1);


            double[,] a0 = new double[3, 3];
            a0           = matr_obr(a);

            for (int i = 0; i < nx1; i++)
            {
                for (int j = 0; j < ny1; j++)
                {
                    int x = (int)(i * a0[0, 0] + j * a0[1, 0] + a0[2, 0]);
                    int y = (int)(i * a0[0, 1] + j * a0[1, 1] + a0[2, 1]);
                    if (x < nx && y < ny && x > 0 && y > 0)
                    {
                        zArray2D.array[i, j] = zArrayPicture.array[x, y];
                    }
                }
            }


            Vizual.Vizual_Picture(zArray2D, picture3D);
        }
Exemple #2
0
        private void Gr3D()
        {
            ns = Convert.ToInt32(textBox1.Text);
            ZArrayDescriptor zArray3D = new ZArrayDescriptor(nx1, ny1);

            int[] arr_max    = new int[nx1];
            int[] arr_tmp    = new int[nx1];
            int[] arr_tmp_gr = new int[nx1];

            //for (int i = 0; i < nx1; i++)
            //{
            //    arr_max[i] = 0;
            //arr_tmp[i] = -1000;
            // }


            int ys = 2;

            int y0 = 250;  //  Сдвиг снизу для красоты
                           //int ns1 = ns;

            double max = SumClass.getMax(zArray2D);
            double min = SumClass.getMin(zArray2D);

            int k = 0;

            for (int j = 0; j < ny1; j += ns, k++)
            {
                for (int i = 0; i < nx1; i++)
                {
                    int ix = i - k;
                    if (ix < nx1 && ix > 0)
                    {
                        arr_tmp[i] = (int)((zArray2D.array[ix, j] - min) * 128 / (max - min)) + ys * k;
                    }
                }

                for (int i = 0; i < nx1; i++)
                {
                    if (arr_tmp[i] > arr_max[i])
                    {
                        arr_max[i] = arr_tmp[i];
                    }
                }

                int x1 = 0;
                int y1 = (int)(arr_max[0]);
                for (int i = 1; i < nx1 - 100 + k; i++)
                {
                    if (i >= nx1)
                    {
                        break;
                    }
                    int x2 = i;
                    int y2 = (int)(arr_max[i]);
                    lineDDA(x1, y1, x2, y2, y0, zArray3D);
                    y1 = y2;
                    x1 = x2;
                }
            }
            Vizual.Vizual_Picture(zArray3D, picture3D);
        }