Ejemplo n.º 1
0
        public void LookAt(Aperture obj)
        {
            double  r        = Logic.Instance.RenderScale * 3;
            Vector3 up       = new Vector3(0, 1, 0);
            float   mmfactor = (float)(1.0 / Logic.Instance.RenderScale);
            Vector3 target   = new Vector3((float)obj.Center.X * mmfactor, (float)obj.Center.Z * mmfactor, (float)obj.Center.Y * mmfactor);
            float   x        = (float)(r * Math.Sin(theta * Math.PI / 180) * Math.Cos(phi * Math.PI / 180));
            float   y        = (float)(r * Math.Sin(theta * Math.PI / 180) * Math.Sin(phi * Math.PI / 180));
            float   z        = (float)(r * Math.Cos(theta * Math.PI / 180));

            Vector3 vect = new Vector3(x, z, y);
            Vector3 eye  = vect;// + target;

            CameraManager.Instance.CameraAt(0);

            CameraManager.Instance.returnCamera(0).eye    = eye;
            CameraManager.Instance.returnCamera(0).target = target;
            CameraManager.Instance.returnCamera(0).up     = up;
            CameraManager.Instance.returnCamera(0).SetView(eye, target, up);

            LastLoadedLook = new Vector3[3] {
                eye, target, up
            };
            //ReScaleGridAndArrows(1f / 2f * (float)obj.DiagonalSize);
            CameraManager.Instance.returnCamera(0).SizeObject = (float)obj.DiagonalSize;
        }
Ejemplo n.º 2
0
        public void LookAt(Aperture Aperture, Radome Radome)
        {
            double r = Radome.DiagonalSize * 3;

            Vector3 up     = new Vector3(0, 1, 0);
            Vector3 target = new Vector3((float)Aperture.Center.X, (float)Aperture.Center.Z, (float)Aperture.Center.Y);

            float x = (float)(r * Math.Sin(theta * Math.PI / 180) * Math.Cos(phi * Math.PI / 180));
            float y = (float)(r * Math.Sin(theta * Math.PI / 180) * Math.Sin(phi * Math.PI / 180));
            float z = (float)(r * Math.Cos(theta * Math.PI / 180));

            Vector3 vect = new Vector3(x, y, z);
            Vector3 eye  = vect + target;

            CameraManager.Instance.CameraAt(0);

            CameraManager.Instance.returnCamera(0).eye    = eye;
            CameraManager.Instance.returnCamera(0).target = target;
            CameraManager.Instance.returnCamera(0).up     = up;
            CameraManager.Instance.returnCamera(0).SetView(eye, target, up);

            //ReScaleGridAndArrows(1f / 2f * (float)Radome.DiagonalSize);
            LastLoadedLook = new Vector3[3] {
                eye, target, up
            };
            CameraManager.Instance.returnCamera(0).SizeObject = (float)Radome.DiagonalSize;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Отрисовка геометрии антенны
        /// </summary>
        /// <param name="surfaceGeometry"></param>
        public void Draw(Aperture surfaceGeometry)
        {
            List <double> vertexX = surfaceGeometry.ListX;
            List <double> vertexY = surfaceGeometry.ListY;
            List <double> vertexZ = surfaceGeometry.ListZ;



            Point3D[] points = new Point3D[surfaceGeometry.Count];

            for (int i = 0; i < surfaceGeometry.Count; i++)
            {
                points[i] = surfaceGeometry[i].Center;
            }

            //if (ScaleFactor < surfaceGeometry.DiagonalSize)
            //{
            //    ScaleFactor = (float)surfaceGeometry.DiagonalSize;
            //}

            if (Antenna != null)
            {
                removingAntenna();
            }
            Color color = new Color(50, 100, 100);

            Antenna = new AntennaMesh("", points, color);
            Scene.Instance.addRenderObject(Antenna);
        }
Ejemplo n.º 4
0
        public void Add(string title, FarFieldC farField, Aperture ap, string Component, string Type)
        {
            int count = farField.Count;

            double[] x   = new double[count];
            double[] y   = new double[count];
            double   val = 0;

            for (int j = 0; j < count; j++)
            {
                if (Form1.Instance.radioButtonX1.Checked)
                {
                    x[j] = farField[j].LocalTheta;
                }
                else
                {
                    x[j] = farField[j].LocalPhi;
                }

                if (Type == "Модуль")
                {
                    switch (Component)
                    {
                    case "Total":
                        val = farField[j].Etotal;
                        break;

                    case "Theta":
                        val = farField[j].EdirectMagnitude(ap);
                        break;

                    case "Phi":
                        val = farField[j].EcrossMagnitude(ap);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (Component)
                    {
                    case "Theta":
                        val = farField[j].EdirectPhase(ap);
                        break;

                    case "Phi":
                        val = farField[j].EcrossPhase(ap);
                        break;

                    default:
                        break;
                    }
                }

                y[j] = val;
            }
            //ListPointPairs.Add(new PointPairList(x, y));
            PointPairList ppl = new PointPairList(x, y);
            //Random rnd = new Random();
            Color color = FindUniqueColor();

            Curves.Add(new GraphData(title, x, y, Component, Type, color));
            //if (key != 0)
            //{
            //    int stop = 0;
            //    CurveItem ci = myPane.CurveList.Find(v => v.Label.Text == CurveNames[key-1]);
            //    Color b = ci.Color;

            //    while ((a.R - b.R) * (a.R - b.R) + (a.G - b.G) * (a.G - b.G) + (a.B - b.B) * (a.B - b.B) < 0.25 * 3 * 255 * 255)
            //    {
            //        a = uniqueColors[rnd.Next(0, 57)];
            //        stop++;
            //        if (stop > 100)
            //        {
            //            break;
            //        }
            //    }
            //}

            LineItem curve = myPane.AddCurve(title, ppl, color, SymbolType.None);

            curve.Line.Width  = 2F;
            curve.Symbol.Size = 2F;

            AxisChange();
            Refresh();
        }
Ejemplo n.º 5
0
        //Расчёт ближнего поля, возбуждаемого токами на апертуре
        unsafe public static NearFieldC SurfaceCurToGeometryCpp(Aperture app, Radome geom, double freq, float dim, int proc)
        {
            int ApSize = app.ApertureCurrent.Count;

            double[] ApX = new double[ApSize];
            double[] ApY = new double[ApSize];
            double[] ApZ = new double[ApSize];
            double[] ApS = new double[ApSize];

            for (int i = 0; i < ApSize; i++)
            {
                ApX[i] = app.ApertureCurrent[i].P.X;
                ApY[i] = app.ApertureCurrent[i].P.Y;
                ApZ[i] = app.ApertureCurrent[i].P.Z;
                ApS[i] = app.ApertureCurrent[i].S;
            }


            Complex[] Ix = new Complex[ApSize];
            Complex[] Iy = new Complex[ApSize];
            Complex[] Iz = new Complex[ApSize];

            Complex[] Mx = new Complex[ApSize];
            Complex[] My = new Complex[ApSize];
            Complex[] Mz = new Complex[ApSize];

            for (int j = 0; j < ApSize; j++)
            {
                Ix[j] = app.ApertureCurrent[j].I.X;
                Iy[j] = app.ApertureCurrent[j].I.Y;
                Iz[j] = app.ApertureCurrent[j].I.Z;

                Mx[j] = app.ApertureCurrent[j].M.X;
                My[j] = app.ApertureCurrent[j].M.Y;
                Mz[j] = app.ApertureCurrent[j].M.Z;
            }

            int GeoSize = geom.CountElements;

            double[] GeoX = new double[GeoSize];
            double[] GeoY = new double[GeoSize];
            double[] GeoZ = new double[GeoSize];

            int h = 0;

            for (int r = 0; r < geom.Count; r++)
            {
                RadomeElement finalGeom = geom[r];

                for (int k = 0; k < finalGeom.Count; k++)
                {
                    GeoX[h] = finalGeom[k].Center.X;
                    GeoY[h] = finalGeom[k].Center.Y;
                    GeoZ[h] = finalGeom[k].Center.Z;
                    h++;
                }
            }



            CComplex *sol = SurfaceCurrentToGeometry(ApX, ApY, ApZ, ApS, Ix, Iy, Iz, Mx, My, Mz, GeoX, GeoY, GeoZ, freq, ApSize, GeoSize, ref proc);

            NearFieldC ans = new NearFieldC(GeoSize);

            for (int i = 0; i < GeoSize; i++)
            {
                ans[i].E     = new CVector(new Complex(sol[i * 6 + 0].re, sol[i * 6 + 0].im), new Complex(sol[i * 6 + 1].re, sol[i * 6 + 1].im), new Complex(sol[i * 6 + 2].re, sol[i * 6 + 2].im));
                ans[i].H     = new CVector(new Complex(sol[i * 6 + 3].re, sol[i * 6 + 3].im), new Complex(sol[i * 6 + 4].re, sol[i * 6 + 4].im), new Complex(sol[i * 6 + 5].re, sol[i * 6 + 5].im));
                ans[i].Place = new Point3D(GeoX[i], GeoY[i], GeoZ[i]);
            }

            return(ans);
        }
Ejemplo n.º 6
0
        public static NearFieldC SurfaceCurToGeometryCs(Aperture app, Radome geom, double freq, float dim, int proc)
        {
            Complex imOneMin = new Complex(0, -1);      // минус мнимая единица
            double  pi       = CV.pi;
            Complex imOne    = new Complex(0, 1);


            double  Lambda  = CV.c_0 / freq;
            double  Omega   = 2 * pi * freq;
            double  K_0     = 2 * pi / Lambda; // волновое число 2pi/lambda
            double  K2      = K_0 * K_0;
            Complex iomega  = imOne * Omega;
            Complex Ekoeff  = (-1.0) / (iomega * CV.E_0);         // 1/i*omega*E_0
            Complex Mukoeff = (-1.0) / (iomega * CV.Mu_0);        // -1/i*omega*Mu_0

            int ApSize = app.Count;

            double[] ApX  = new double[ApSize];
            double[] ApY  = new double[ApSize];
            double[] ApZ  = new double[ApSize];
            double[] ApS  = new double[ApSize];
            float    dim2 = dim * dim;

            for (int i = 0; i < ApSize; i++)
            {
                ApX[i] = dim * app[i].Center.X;
                ApY[i] = dim * app[i].Center.Y;
                ApZ[i] = dim * app[i].Center.Z;
                ApS[i] = dim2 * app[i].Area;
            }


            Complex[] Ix = new Complex[ApSize];
            Complex[] Iy = new Complex[ApSize];
            Complex[] Iz = new Complex[ApSize];

            Complex[] Mx = new Complex[ApSize];
            Complex[] My = new Complex[ApSize];
            Complex[] Mz = new Complex[ApSize];

            for (int j = 0; j < ApSize; j++)
            {
                Ix[j] = app.ApertureCurrent[j].I.X;
                Iy[j] = app.ApertureCurrent[j].I.Y;
                Iz[j] = app.ApertureCurrent[j].I.Z;

                Mx[j] = app.ApertureCurrent[j].M.X;
                My[j] = app.ApertureCurrent[j].M.Y;
                Mz[j] = app.ApertureCurrent[j].M.Z;
            }

            int GeoSize = geom.CountElements;

            double[] GeoX = new double[GeoSize];
            double[] GeoY = new double[GeoSize];
            double[] GeoZ = new double[GeoSize];

            int h = 0;

            for (int r = 0; r < geom.Count; r++)
            {
                RadomeElement finalGeom = geom[r];

                for (int k = 0; k < finalGeom.Count; k++)
                {
                    GeoX[h] = finalGeom[h].Center.X * dim;
                    GeoY[h] = finalGeom[h].Center.Y * dim;
                    GeoZ[h] = finalGeom[h].Center.Z * dim;
                    h++;
                }
            }


            Complex    ex, ey, ez, hx, hy, hz;
            NearFieldC outField = new NearFieldC(GeoSize);


            for (int j = 0; j < GeoSize; j++)
            {
                //st.Start();
                ex = new System.Numerics.Complex(0, 0);
                ey = new System.Numerics.Complex(0, 0);
                ez = new System.Numerics.Complex(0, 0);

                hx = new System.Numerics.Complex(0, 0);
                hy = new System.Numerics.Complex(0, 0);
                hz = new System.Numerics.Complex(0, 0);

                float xsecond = Convert.ToSingle(GeoX[j] * dim);
                float ysecond = Convert.ToSingle(GeoY[j] * dim);
                float zsecond = Convert.ToSingle(GeoZ[j] * dim);

                Point3D pointsecond = new Point3D(xsecond, ysecond, zsecond);


                for (int p = 0; p < ApSize; p++)
                {
                    //
                    //	Координаты
                    //
                    float xprime = Convert.ToSingle(ApX[p] * dim);
                    float yprime = Convert.ToSingle(ApY[p] * dim);
                    float zprime = Convert.ToSingle(ApZ[p] * dim);

                    Point3D pointprime = new Point3D(xprime, yprime, zprime);

                    CVector i      = new CVector(Ix[p], Iy[p], Iz[p]);
                    CVector m      = new CVector(Mx[p], My[p], Mz[p]);
                    float   square = Convert.ToSingle(ApS[p] * dim2);

                    //Field FieldC = ElementFieldCalcP(icur, mcur, pointprime, pointsecond, square);

                    //
                    //  Переменные
                    //
                    double x_x0 = xprime - xsecond;
                    double y_y0 = yprime - ysecond;
                    double z_z0 = zprime - zsecond;
                    double x2   = x_x0 * x_x0;
                    double y2   = y_y0 * y_y0;
                    double z2   = z_z0 * z_z0;

                    double  r       = Math.Sqrt(x2 + y2 + z2);
                    Complex exp_ikr = new Complex(Math.Cos(K_0 * r), -Math.Sin(K_0 * r));
                    //Complex exp_ikr = Complex.Exp(imOneMin * K_0 * r);

                    Complex funG = exp_ikr / (4 * pi * r);
                    double  r2   = r * r;
                    double  r4   = r2 * r2;

                    //
                    //НАЧАЛО КОСТИНЫ ФОРМУЛЫ
                    //
                    Complex coeffA = imOneMin * K_0 / r - 1.0 / r2;
                    Complex coeffB = (3.0 + 3.0 * imOne * K_0 * r - K2 * r2) / r4;

                    Complex dx = x_x0 * coeffA * funG;
                    Complex dy = y_y0 * coeffA * funG;
                    Complex dz = z_z0 * coeffA * funG;

                    Complex dxx = (x2 * coeffB + coeffA) * funG;
                    Complex dyy = (y2 * coeffB + coeffA) * funG;
                    Complex dzz = (z2 * coeffB + coeffA) * funG;

                    Complex dxy = (x_x0 * y_y0 * coeffB) * funG;
                    Complex dxz = (x_x0 * z_z0 * coeffB) * funG;
                    Complex dyz = (y_y0 * z_z0 * coeffB) * funG;
                    //
                    // КОНЕЦ
                    //

                    ex += (-1) * (Ekoeff * (K2 * i.X * funG + i.X * dxx + i.Y * dxy + i.Z * dxz) * square - (m.Z * dy - m.Y * dz) * square);  //-
                    ey += (-1) * (Ekoeff * (K2 * i.Y * funG + i.Y * dyy + i.Z * dyz + i.X * dxy) * square - (m.X * dz - m.Z * dx) * square);  //-
                    ez += (-1) * (Ekoeff * (K2 * i.Z * funG + i.Z * dzz + i.X * dxz + i.Y * dyz) * square - (m.Y * dx - m.X * dy) * square);  //-

                    hx += (-1) * (Mukoeff * (K2 * m.X * funG + m.X * dxx + m.Y * dxy + m.Z * dxz) * square + (i.Z * dy - i.Y * dz) * square); //+
                    hy += (-1) * (Mukoeff * (K2 * m.Y * funG + m.X * dxy + m.Y * dyy + m.Z * dyz) * square + (i.X * dz - i.Z * dx) * square); //+
                    hz += (-1) * (Mukoeff * (K2 * m.Z * funG + m.X * dxz + m.Y * dyz + m.Z * dzz) * square + (i.Y * dx - i.X * dy) * square); //+
                }
                outField[j].E     = new CVector(ex, ey, ez);
                outField[j].H     = new CVector(hx, hy, hz);
                outField[j].Place = new Point3D(GeoX[j], GeoY[j], GeoZ[j]);
            }
            return(outField);
        }
Ejemplo n.º 7
0
        public DVector GetPolarization(double thetaG, double phiG)
        {
            double x = Math.Sin(thetaG * Math.PI / 180) * Math.Cos(phiG * Math.PI / 180);
            double y = Math.Sin(thetaG * Math.PI / 180) * Math.Sin(phiG * Math.PI / 180);
            double z = Math.Cos(thetaG * Math.PI / 180);

            DVector J = new DVector(x - Center.X, y - Center.Y, z - Center.Z);

            J.Normalize();
            DVector n = new DVector(this[0].Norma);

            n.Normalize();

            DVector e_u = Aperture.GetUVector(n);
            DVector e_v = Aperture.GetVVector(n);

            Complex i_u = CVector.Scal(ApertureCurrent.I[0].CVector, e_u);
            Complex i_v = CVector.Scal(ApertureCurrent.I[0].CVector, e_v);

            DVector e_y = i_v.Magnitude * e_v + i_u.Magnitude * e_u;
            DVector e_x = DVector.Cross(e_y, n);

            e_x.Normalize();
            e_y.Normalize();

            double J_zLoc = DVector.Scal(J, n);

            if (J_zLoc > 1)
            {
                J_zLoc = 1;
            }
            if (J_zLoc < -1)
            {
                J_zLoc = -1;
            }

            double thetaLoc = Math.Acos(J_zLoc);               // угол theta в локальной системе координат, в радианах

            double J_xLoc = DVector.Scal(e_x, J);

            if (J_xLoc > 1)
            {
                J_xLoc = 1;
            }
            double J_yLoc = DVector.Scal(e_y, J);

            if (J_yLoc > 1)
            {
                J_yLoc = 1;
            }

            double phiLoc = Math.Atan2(J_yLoc, J_xLoc);

            DVector e_phiLoc = DVector.Cross(n, J_xLoc * e_x + J_yLoc * e_y);

            e_phiLoc.Normalize();
            DVector e_thetaLoc = DVector.Cross(e_phiLoc, J);

            e_thetaLoc.Normalize();

            DVector p = (Math.Cos(thetaLoc) + 1) * Math.Sin(phiLoc) * e_thetaLoc + (1 + Math.Cos(thetaLoc)) * Math.Cos(phiLoc) * e_phiLoc;

            p.Normalize();
            return(p);
        }