コード例 #1
0
 public MeshElement()
 {
     Triangle = null;
     Center   = new Point3D(0, 0, 0);
     Area     = 0;
     Norma    = new DVector(0, 0, 0);
 }
コード例 #2
0
        private void GenerateCosOnStepApperture(CVector i_a, CVector m_a, double delta) //i_a, m_a - двумерные вектора, связанные с плоскостью апертуры)
        {
            CVector[] VectorI  = new CVector[Count];
            CVector[] VectorM  = new CVector[Count];
            Point3D[] Segments = new Point3D[Count];
            double[]  Square   = new double[Count];

            double xlen = XMax - XMin;
            double ylen = YMax - YMin;
            double zlen = ZMax - ZMin;

            double Ra = 0;

            if (xlen >= ylen && xlen >= zlen)
            {
                Ra = xlen / 2;
            }
            else if (ylen >= zlen)
            {
                Ra = ylen / 2;
            }
            else
            {
                Ra = zlen / 2;
            }


            for (int p = 0; p < Count; p++)
            {
                Point3D position = this[p].Center;
                DVector n        = this[p].Norma;

                DVector ran = new DVector(1, 0, 0);
                if (DVector.IsEqual(n, ran, 4) || DVector.IsEqual((-1) * n, ran, 4))
                {
                    ran = new DVector(0, 1, 0);
                }
                //базисные вектора в плоскости апертуры
                DVector e_u = DVector.Cross(n, ran);
                e_u.Normalize();
                DVector e_v = DVector.Cross(n, e_u);
                e_v.Normalize();



                double  c1 = (1 + delta * Math.Cos(Math.PI * Point3D.Distance(position, this.Center) / Ra)) / (1 + delta);
                CVector i  = c1 * (i_a.X * e_u + i_a.Y * e_v);
                CVector m  = c1 * (m_a.X * e_u + m_a.Y * e_v);

                VectorI[p]  = i;
                VectorM[p]  = m;
                Segments[p] = this[p].Center;
                Square[p]   = this[p].Area;
            }

            ApertureCurrent = new Current(VectorI, VectorM, Segments, Square);
            //electricCurrent = new Current(VectorI, Segments);
            //magneticCurrent = new Current(VectorM, Segments);
        }
コード例 #3
0
        public static DVector Cross(DVector v1, DVector v2)
        {
            double x = v1.Y * v2.Z - v1.Z * v2.Y;
            double y = v1.Z * v2.X - v1.X * v2.Z;
            double z = v1.X * v2.Y - v1.Y * v2.X;

            return(new DVector(x, y, z));
        }
コード例 #4
0
        public static CVector Cross(CVector v1, DVector v2)
        {
            Complex x = v1.Y * v2.Z - v1.Z * v2.Y;
            Complex y = v1.Z * v2.X - v1.X * v2.Z;
            Complex z = v1.X * v2.Y - v1.Y * v2.X;

            return(new CVector(x, y, z));
        }
コード例 #5
0
        public void Draw(string lable, Point3D center, DVector n, bool include1, Point3D a1p1, Point3D a1p2, double angle1Start, double angle1Finish, double angle1Step, bool include2, Point3D a2p1, Point3D a2p2, double angle2Start, double angle2Finish, double angle2Step, Color color)
        {
            bool           match             = false;
            List <Point3D> scannigPointsList = new List <Point3D>();
            int            numberAngle1      = Convert.ToInt32((angle1Finish - angle1Start) / angle1Step) + 1;
            int            numberAngle2      = Convert.ToInt32((angle2Finish - angle2Start) / angle2Step) + 1;


            for (int i = 0; i < numberAngle1; i++)
            {
                for (int j = 0; j < numberAngle2; j++)
                {
                    Point3D scPoint  = new Point3D(1 * n.X, 1 * n.Y, 1 * n.Z);
                    double  Angle1   = angle1Start + i * angle1Step;
                    double  Angle2   = angle2Start + j * angle2Step;
                    Point3D a2p1_rot = new Point3D(a2p1);
                    Point3D a2p2_rot = new Point3D(a2p2);
                    if (include1)
                    {
                        scPoint = Logic.Instance.RotateElement(scPoint, Angle1, a1p1.X, a1p1.Y, a1p1.Z, a1p2.X, a1p2.Y, a1p2.Z);
                    }
                    if (include2)
                    {
                        if (include1)
                        {
                            a2p1_rot = Logic.Instance.RotateElement(a2p1, Angle1, a1p1.X, a1p1.Y, a1p1.Z, a1p2.X, a1p2.Y, a1p2.Z);
                            a2p2_rot = Logic.Instance.RotateElement(a2p2, Angle1, a1p1.X, a1p1.Y, a1p1.Z, a1p2.X, a1p2.Y, a1p2.Z);
                        }

                        scPoint = Logic.Instance.RotateElement(scPoint, Angle2, a2p1_rot.X, a2p1_rot.Y, a2p1_rot.Z, a2p2_rot.X, a2p2_rot.Y, a2p2_rot.Z);
                    }
                    scannigPointsList.Add(scPoint);
                }
            }

            int count = ScanningPoints.Count;

            for (int i = 0; i < count; i++)
            {
                if (ScanningPoints[i].Title == lable)
                {
                    Scene.Instance.removeRenderObject(ScanningPoints[i]);
                    ScanningPoints[i] = new ScanRegionRender(Logic.Instance.RenderScale, lable, scannigPointsList, color);
                    Scene.Instance.addRenderObject(ScanningPoints[i]);
                    match = true;
                }
            }
            if (!match)
            {
                ScanRegionRender points = new ScanRegionRender(Logic.Instance.RenderScale, lable, scannigPointsList, color);
                ScanningPoints.Add(points);
                Scene.Instance.addRenderObject(points);
            }
        }
コード例 #6
0
        public static bool IsEqual(double nx, double ny, double nz, DVector v2, int precision)
        {
            bool   ans   = false;
            double param = Math.Pow(10, (-1) * precision);

            if (Math.Abs(nx - v2.X) < param && Math.Abs(ny - v2.Y) < param && Math.Abs(nz - v2.Z) < param)
            {
                ans = true;
            }

            return(ans);
        }
コード例 #7
0
        public static bool IsEqual(DVector v1, DVector v2, int precision)
        {
            bool   ans   = false;
            double param = Math.Pow(10, (-1) * precision);

            if (Math.Abs(v1.X - v2.X) < param && Math.Abs(v1.Y - v2.Y) < param && Math.Abs(v1.Z - v2.Z) < param)
            {
                ans = true;
            }

            return(ans);
        }
コード例 #8
0
        public static CVector ChangeLoadedCurrentAnlorithm(CVector v, DVector n, double angle)
        {
            float rangle = (float)(angle / 180 * CV.pi);

            SharpDX.Matrix  m   = SharpDX.Matrix.RotationAxis(new SharpDX.Vector3((float)n.X, (float)n.Y, (float)n.Z), rangle);
            SharpDX.Vector3 reV = new SharpDX.Vector3((float)v.X.Real, (float)v.Y.Real, (float)v.Z.Real);
            SharpDX.Vector3 imV = new SharpDX.Vector3((float)v.X.Imaginary, (float)v.Y.Imaginary, (float)v.Z.Imaginary);

            SharpDX.Vector3 reVrot = SharpDX.Vector3.TransformCoordinate(reV, m);
            SharpDX.Vector3 imVrot = SharpDX.Vector3.TransformCoordinate(imV, m);

            return(new CVector(new Complex(reVrot.X, imVrot.X), new Complex(reVrot.Y, imVrot.Y), new Complex(reVrot.Z, imVrot.Z)));
        }
コード例 #9
0
        public static DVector GetUVector(DVector n)
        {
            DVector ran = new DVector(1, 0, 0);

            if (DVector.IsEqual(n, ran, 4) || DVector.IsEqual((-1) * n, ran, 4))
            {
                ran = new DVector(0, 1, 0);
            }

            DVector e_u = DVector.Cross(n, ran);

            e_u.Normalize();
            return(e_u);
        }
コード例 #10
0
        public static double Scal(DVector v1, DVector v2)
        {
            double ans = 0;

            if (DVector.IsEqual(v1, v2, 9))
            {
                ans = 1;
            }
            else
            {
                ans = v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z;
            }
            return(ans);
        }
コード例 #11
0
        public static double Scal(double ax, double ay, double az, double bx, double by, double bz)
        {
            double ans = 0;

            if (DVector.IsEqual(ax, ay, az, bx, by, bz, 9))
            {
                ans = 1;
            }
            else
            {
                ans = ax * bx + ay * by + az * bz;
            }
            return(ans);
        }
コード例 #12
0
        private void SquareCalc()
        {
            //double a = Math.Sqrt(Math.Pow(V2.X - V1.X, 2) + Math.Pow(V2.Y - V1.Y, 2) + Math.Pow(V2.Z - V1.Z, 2));
            //double b = Math.Sqrt(Math.Pow(V3.X - V2.X, 2) + Math.Pow(V3.Y - V2.Y, 2) + Math.Pow(V3.Z - V2.Z, 2));
            //double c = Math.Sqrt(Math.Pow(V1.X - V3.X, 2) + Math.Pow(V1.Y - V3.Y, 2) + Math.Pow(V1.Z - V3.Z, 2));
            //double p = (a + b + c) / 2;

            DVector ab = new DVector(V2.X - V1.X, V2.Y - V1.Y, V2.Z - V1.Z);
            DVector ac = new DVector(V3.X - V1.X, V3.Y - V1.Y, V3.Z - V1.Z);

            //DVector val =
            Square = 0.5d * DVector.Cross(ab, ac).Module;
            //Square = Math.Sqrt((p - a) * (p - b) * (p - c) * p);
            //double diff = Square - sq;
            //MessageBox.Show("" + diff);
        }
コード例 #13
0
        /// <summary>
        /// Формат: координаты/площади/вектор нормали
        /// </summary>
        /// <param name="antennaFileName"></param>
        /// <returns></returns>
        public static Mesh ReadingMeshTxt(string antennaFileName)
        {
            StreamReader sr = new StreamReader(antennaFileName);

            int count = 0;

            while (!sr.EndOfStream)
            {
                sr.ReadLine();
                count++;
            }

            sr.DiscardBufferedData();
            sr.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);

            string line    = "";
            int    columns = 4;

            double[,] datastream = new double[count, columns];
            for (int i = 0; i < count; i++)
            {
                line = sr.ReadLine();

                for (int k = 0; k < columns; k++)
                {
                    float x = Single.Parse(line.Substring(15 * k, 15).Replace(".", ","));
                    datastream[i, k] = x;
                }
            }
            sr.Close();

            Point3D[] points  = new Point3D[count];
            double[]  squares = new double[count];
            DVector[] norma   = new DVector[count];

            for (int n = 0; n < count; n++)
            {
                points[n]  = new Point3D(datastream[n, 0], datastream[n, 1], datastream[n, 2]);
                squares[n] = datastream[n, 3];
                //norma[n] = new DVector(datastream[n, 4], datastream[n, 5], datastream[n, 6]);
                norma[n] = new DVector(0, 1, 0);
            }
            Form1.Instance.textBox1.AppendText("Внимание, не считывается вектор нормали. По умолчанию n = [0, 1, 0]" + Environment.NewLine);
            return(new Mesh(points, squares, norma));
        }
コード例 #14
0
        private void ShowMScanningPoints(string templateLable)
        {
            if (CheckConvertToDoubleAll())
            {
                double axis1x1 = Convert.ToDouble(textBoxRotAxis1X1.Text);
                double axis1y1 = Convert.ToDouble(textBoxRotAxis1Y1.Text);
                double axis1z1 = Convert.ToDouble(textBoxRotAxis1Z1.Text);

                double axis1x2 = Convert.ToDouble(textBoxRotAxis1X2.Text);
                double axis1y2 = Convert.ToDouble(textBoxRotAxis1Y2.Text);
                double axis1z2 = Convert.ToDouble(textBoxRotAxis1Z2.Text);

                double axis2x1 = Convert.ToDouble(textBoxRotAxis2X1.Text);
                double axis2y1 = Convert.ToDouble(textBoxRotAxis2Y1.Text);
                double axis2z1 = Convert.ToDouble(textBoxRotAxis2Z1.Text);

                double axis2x2 = Convert.ToDouble(textBoxRotAxis2X2.Text);
                double axis2y2 = Convert.ToDouble(textBoxRotAxis2Y2.Text);
                double axis2z2 = Convert.ToDouble(textBoxRotAxis2Z2.Text);

                double scanMPhiStart  = Convert.ToDouble(textBoxMAngle2Start.Text);
                double scanMPhiFinish = Convert.ToDouble(textBoxMAngle2Finish.Text);
                double scanMPhiStep   = Convert.ToDouble(textBoxMAngle2Step.Text);

                double scanMThetaStart  = Convert.ToDouble(textBoxMAngle1Start.Text);
                double scanMThetaFinish = Convert.ToDouble(textBoxMAngle1Finish.Text);
                double scanMThetaStep   = Convert.ToDouble(textBoxMAngle1Step.Text);

                bool include1 = false;
                if (comboBoxAxis1.SelectedIndex == 1)
                {
                    include1 = true;
                }
                bool include2 = false;
                if (comboBoxAxis2.SelectedIndex == 1)
                {
                    include2 = true;
                }
                DVector n      = Logic.Instance.Antenna.elements[0].Norma;
                Point3D center = Logic.Instance.Antenna.Center;


                if (scanMThetaStart <= scanMThetaFinish && scanMThetaStep != 0 || !include1)
                {
                    if (scanMPhiStart <= scanMPhiFinish && scanMPhiStep != 0 || !include2)
                    {
                        Color   xCol = new Color(255, 0, 128);
                        Point3D p1a1 = new Point3D(axis1x1, axis1y1, axis1z1);
                        Point3D p2a1 = new Point3D(axis1x2, axis1y2, axis1z2);
                        Point3D p1a2 = new Point3D(axis2x1, axis2y1, axis2z1);
                        Point3D p2a2 = new Point3D(axis2x2, axis2y2, axis2z2);

                        parent.renderControl1.Draw(templateLable, center, n, include1, p1a1, p2a1, scanMThetaStart, scanMThetaFinish, scanMThetaStep, include2, p1a2, p2a2, scanMPhiStart, scanMPhiFinish, scanMPhiStep, xCol);
                    }
                }
                else
                {
                    RemoveScanningRegion(templateLable);
                }
            }
            else
            {
                RemoveScanningRegion(templateLable);
            }
        }
コード例 #15
0
 public static double ScalSimple(DVector v1, DVector v2)
 {
     return(v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z);
 }
コード例 #16
0
        public static Tuple <CVector, CVector> GetPolarizationCurrents(string changedPolarizatioin, string distribution)
        {
            //polarization detection
            //var d = DictionaryLibrary.PolarizationNames;
            //int polarization = d.FirstOrDefault(x => x.Value == changedPolarizatioin).Key;

            //set currents
            CVector electricCurrent = null;
            CVector magneticCurrent = null;

            if (distribution == "Постоянное поле" || distribution == "Косинус на пьедестале")
            {
                //ortogonal and parallel vectors detection
                double xlength = Logic.Instance.Antenna.XMax - Logic.Instance.Antenna.XMin;
                double ylength = Logic.Instance.Antenna.YMax - Logic.Instance.Antenna.YMin;
                double zlength = Logic.Instance.Antenna.ZMax - Logic.Instance.Antenna.ZMin;

                DVector probeVector;
                if (xlength > ylength)
                {
                    if (xlength > zlength)
                    {
                        probeVector = new DVector(1, 0, 0);
                    }
                    else
                    {
                        probeVector = new DVector(0, 0, 1);
                    }
                }
                else
                {
                    if (ylength > zlength)
                    {
                        probeVector = new DVector(0, 1, 0);
                    }
                    else
                    {
                        probeVector = new DVector(0, 0, 1);
                    }
                }

                DVector normaVector     = Logic.Instance.Antenna[0].Norma;
                DVector ortogonalVector = DVector.Cross(probeVector, normaVector);
                ortogonalVector.Normalize();
                DVector parallelVector = DVector.Cross(ortogonalVector, normaVector);
                parallelVector.Normalize();



                if (changedPolarizatioin == "Поляризация А")
                {
                    electricCurrent = new CVector(new Complex(parallelVector.X, 0), new Complex(parallelVector.Y, 0), new Complex(parallelVector.Z, 0));
                    magneticCurrent = CV.Z_0 * new CVector(new Complex(ortogonalVector.X, 0), new Complex(ortogonalVector.Y, 0), new Complex(ortogonalVector.Z, 0));
                }
                else if (changedPolarizatioin == "Поляризация Б")
                {
                    electricCurrent = new CVector(new Complex(-ortogonalVector.X, 0), new Complex(-ortogonalVector.Y, 0), new Complex(-ortogonalVector.Z, 0));
                    magneticCurrent = CV.Z_0 * new CVector(new Complex(parallelVector.X, 0), new Complex(parallelVector.Y, 0), new Complex(parallelVector.Z, 0));
                }
                else if (changedPolarizatioin == "Круговая поляризация А")
                {
                    //!!!! запланировано, не работает
                    electricCurrent = new CVector(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));
                    magneticCurrent = CV.Z_0 * new CVector(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));
                }
                else if (changedPolarizatioin == "Круговая поляризация Б")
                {
                    //!!!!запланировано, не работает
                    electricCurrent = new CVector(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));
                    magneticCurrent = CV.Z_0 * new CVector(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));
                }
                else if (changedPolarizatioin == "Пользовательская")
                {
                    //!!!!запланировано, не работает
                    electricCurrent = new CVector(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));
                    magneticCurrent = CV.Z_0 * new CVector(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));
                }
            }
            else if (distribution == "Загрузить из файла")
            {
                int    count    = I.Length;
                double max      = I[0].Modulus;
                int    maxIndex = 0;
                for (int i = 1; i < count; i++)
                {
                    if (I[i].Modulus > max)
                    {
                        maxIndex = i;
                        max      = I[i].Modulus;
                    }
                }


                if (changedPolarizatioin == "Поляризация А")
                {
                    electricCurrent = I[maxIndex];
                    magneticCurrent = M[maxIndex];
                }
                else if (changedPolarizatioin == "Поляризация Б")
                {
                    electricCurrent = I[maxIndex];
                    magneticCurrent = M[maxIndex];

                    electricCurrent = Current.ChangeLoadedCurrentAnlorithm(electricCurrent, Logic.Instance.Antenna[maxIndex].Norma, 90);
                    magneticCurrent = Current.ChangeLoadedCurrentAnlorithm(magneticCurrent, Logic.Instance.Antenna[maxIndex].Norma, 90);
                }
            }
            return(new Tuple <CVector, CVector>(electricCurrent, magneticCurrent));
        }
コード例 #17
0
 //Методы класса Triangle
 public void Move(DVector vector)
 {
     V1.Move(vector);
     V2.Move(vector);
     V3.Move(vector);
 }
コード例 #18
0
 public static Complex Scal(CVector v1, DVector v2)
 {
     return(v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z);
 }
コード例 #19
0
 public void Move(DVector vector)
 {
     this.X += vector.X;
     this.Y += vector.Y;
     this.Z += vector.Z;
 }
コード例 #20
0
 public DVector(DVector vector)
 {
     X = vector.X;
     Y = vector.Y;
     Z = vector.Z;
 }
コード例 #21
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);
        }