//--------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// PSI 256 или более сдвигов по строке /// zArrayDescriptor[0] до нагрузки => zArrayDescriptor[3] /// zArrayDescriptor[1] после => zArrayDescriptor[3] /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// public static double[] Razn_faz(double[] res1, double[] res2, int nx, int ny) // Разность двух фаз { int n_sdv = 4; double[] fzrad = new double[n_sdv]; double[,] rezz = new double[nx, n_sdv]; double[] faza = new double[nx]; for (int i = 0; i < n_sdv; i++) { fzrad[i] = Math.PI * Math.PI * 90 * i / 180.0; } for (int k = 0; k < n_sdv; k++) { for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { rezz[i, k] = Math.Cos(res1[i] - res2[i] + fzrad[k]); } } } // MessageBox.Show("PSI 256 "); // psi double[] i_sdv = new double[n_sdv]; double[] k_sin = new double[n_sdv]; double[] k_cos = new double[n_sdv]; for (int i = 0; i < n_sdv; i++) { k_sin[i] = Math.Sin(fzrad[i]); k_cos[i] = Math.Cos(fzrad[i]); } k_sin = ATAN_PSI.Vector_orto(k_sin); k_cos = ATAN_PSI.Vector_orto(k_cos); for (int i = 0; i < nx; i++) { i_sdv[0] = rezz[i, 0]; i_sdv[1] = rezz[i, 1]; i_sdv[2] = rezz[i, 2]; i_sdv[3] = rezz[i, 3]; //double[] v_sdv = ATAN_PSI.Vector_orto(i_sdv); // ------ Формула расшифровки фазы double fz1 = ATAN_PSI.Vector_Mul(i_sdv, k_sin); double fz2 = ATAN_PSI.Vector_Mul(i_sdv, k_cos); faza[i] = Math.Atan2(fz1, fz2); } return(faza); }
/// <summary> /// Быстрое преобразование PSI для четырех сдвигов /// </summary> /// <param name="zArrayPicture"></param> /// <param name="progressBar1"></param> /// <param name="fzz"></param> /// <param name="amplit"></param> /// <returns></returns> public static ZArrayDescriptor ATAN_quick(ZArrayDescriptor[] zArrayDescriptor, ProgressBar progressBar1, double[] fzz, double xmax, double lambda, double d, double amplit) { // 8, 9, 10, 11 -> Complex[1] int w1 = zArrayDescriptor[8].width; int h1 = zArrayDescriptor[8].height; System.Diagnostics.Stopwatch sw = new Stopwatch(); sw.Start(); //MessageBox.Show("width= " + w1 + "height= " + h1); ZComplexDescriptor zComplex_rab = new ZComplexDescriptor(w1, h1); /* * double i_sdv1; //PSI * double i_sdv2; * double i_sdv3; * double i_sdv4; * //double[] i_s = new double[w1]; // Числитель * //double[] i_c = new double[w1]; // Знаменатель * * double k_sin1 = Math.Sin(fzz[0]); * double k_sin2 = Math.Sin(fzz[1]); * double k_sin3 = Math.Sin(fzz[2]); * double k_sin4 = Math.Sin(fzz[3]); * * double k_cos1 = Math.Cos(fzz[0]); * double k_cos2 = Math.Cos(fzz[1]); * double k_cos3 = Math.Cos(fzz[2]); * double k_cos4 = Math.Cos(fzz[3]); * * //double znmt = Math.Abs((k_sin2 - k_sin4) * k_cos1 + (k_sin3 - k_sin1) * k_cos2 + (k_sin4 - k_sin2) * k_cos3 + (k_sin1 - k_sin3) * k_cos4); * double znmt = Math.Abs((k_cos2 - k_cos4) * k_sin1 + (k_cos3 - k_cos1) * k_sin2 + (k_cos4 - k_cos2) * k_sin3 + (k_cos1 - k_cos3) * k_sin4); * znmt = znmt * (2 * amplit); * * progressBar1.Visible = true; * progressBar1.Minimum = 1; * progressBar1.Maximum = w1 - 1; * progressBar1.Value = 1; * progressBar1.Step = 1; * * * * * for (int j = 0; j < h1; j++) * { * for (int i = 0; i < w1; i++) * { * i_sdv1 = zArrayDescriptor[8].array[i, j]; * i_sdv2 = zArrayDescriptor[9].array[i, j]; * i_sdv3 = zArrayDescriptor[10].array[i, j]; * i_sdv4 = zArrayDescriptor[11].array[i, j]; * * double i1 = i_sdv2 - i_sdv4; * double i2 = i_sdv3 - i_sdv1; * double i3 = i_sdv4 - i_sdv2; * double i4 = i_sdv1 - i_sdv3; * * double i_s = i1 * k_sin1 + i2 * k_sin2 + i3 * k_sin3 + i4 * k_sin4; * double i_c = i1 * k_cos1 + i2 * k_sin2 + i3 * k_sin3 + i4 * k_sin4; * * double faza = Math.Atan2(i_c, i_s); // Фаза * //double faza = Math.Atan2(i_s, i_c); * double am = Math.Sqrt(i_s * i_s + i_c * i_c) / znmt; // Амплитуда * * zComplex_rab.array[i, j] = Complex.FromPolarCoordinates(am, faza); * * } * progressBar1.PerformStep(); * } * progressBar1.Value = 1; */ zComplex_rab = ATAN_PSI.ATAN_891011(zArrayDescriptor, progressBar1, fzz, amplit); // PSI //zComplex[1] = zComplex_rab; ZArrayDescriptor zArrayPicture = new ZArrayDescriptor(w1, h1); zComplex_rab = FurieN.FrenelTransformN(zComplex_rab, lambda, d, xmax); // Преобразование Френеля с четным количеством точек for (int i = 0; i < w1; i++) // Амплитуду в главное окно { for (int j = 0; j < h1; j++) { zArrayPicture.array[i, j] = zComplex_rab.array[i, j].Magnitude; } } zArrayPicture = Furie.Invers_Double(zArrayPicture); sw.Stop(); TimeSpan ts = sw.Elapsed; MessageBox.Show("PSI+Frenel Время Минут: " + ts.Minutes + " Время сек: " + ts.Seconds + " Время миллисек: " + ts.Milliseconds); //MessageBox.Show(" Lambda= " + lambda + " d= " + d + " dx= " + xmax); return(zArrayPicture); }