Beispiel #1
0
        public void GetProjectionPointInFaceTest5()
        {
            Face  target    = new SpaceFace(new Point(1, 1, 0), new Point(1, -1, 0), new Point(0, 0, 0)); // TODO: 初始化为适当的值
            Point viewPoint = new Point(10, 10, -10);                                                     // TODO: 初始化为适当的值
            Point expected  = new Point(10, 10, 0);                                                       // TODO: 初始化为适当的值
            Point actual;

            actual = target.GetProjectionPointInFace(viewPoint);
            Assert.IsTrue(Math.Abs(expected.X - actual.X) < 0.000001 && Math.Abs(expected.Y - actual.Y) < 0.000001 &&
                          Math.Abs(expected.Z - actual.Z) < 0.000001);
        }
Beispiel #2
0
        /// <summary>
        /// 判断射线管是否包含虚拟接收点,将包含的点转化为节点,并将节点存储在list中
        /// </summary>
        /// <param name="currentRayTube">射线管</param>
        /// <param name="virtualRxPoint">接收点</param>
        /// <param name="crossNodeInArea">存储相交节点</param>
        /// <returns></returns>
        private void GetAreaNodeIfRayTubeContainPoint(RayTubeModel currentRayTube, AreaNode virtualRxNode, List <Node> pathNodes)
        {
            SpaceFace    verticalFace = new SpaceFace(virtualRxNode.Position, new SpectVector(0, 0, 1));//作一个态势平面,态势层是平行于xoy的矩形
            List <Point> crossPoints  = new List <Point>();

            for (int i = 0; i < currentRayTube.OneRayModels.Count; i++)//求射线管与该平面的交点
            {
                Point crossPoint = currentRayTube.OneRayModels[i].LaunchRay.GetCrossPointWithFace(verticalFace);
                if (crossPoint != null)
                {
                    crossPoints.Add(crossPoint);
                }
            }
            if (crossPoints.Count != 3)
            {
                LogFileManager.ObjLog.error("判断射线管是否与态势层存在交点时出错");
            }
            else
            {
                Face wavefrontFace = new Triangle(crossPoints[0], crossPoints[1], crossPoints[2]);
                if (wavefrontFace.JudgeIfPointInFace(virtualRxNode.Position))                                         ////判断射线管是否包含当前态势点
                {
                    OneRayModel rayModelToRx = currentRayTube.StructureRayModelToTargetPoint(virtualRxNode.Position); //??
                    if (rayModelToRx == null)
                    {
                        LogFileManager.ObjLog.error("判断点是否在从绕射棱发出的射线管内时,构造到接收机的射线时出错");
                    }
                    else
                    {
                        //当前射线管包含态势点,可以生成路径啦~\(≧▽≦)/~
                        //构造接收节点
                        virtualRxNode.RxNum               = 1;
                        virtualRxNode.NodeStyle           = NodeStyle.Rx;
                        virtualRxNode.DistanceToFrontNode = rayModelToRx.LaunchNode.Position.GetDistance(virtualRxNode.Position);
                        virtualRxNode.RayIn               = rayModelToRx.LaunchRay;
                        virtualRxNode.FatherNode          = rayModelToRx.LaunchNode;
                        for (int i = 0; i < currentRayTube.OneRayModels.Count; i++)
                        {
                            currentRayTube.OneRayModels[i].LaunchNode.ChildNodes.Add(virtualRxNode);
                        }
                        virtualRxNode.FatherNode = currentRayTube.OneRayModels[0].LaunchNode;
                        pathNodes.Add(virtualRxNode);                        //得到从发射节点到态势点的完整的路径节点
                        Path onePath = new Path(new List <Node>(pathNodes)); //生成一条新的路径
                        virtualRxNode.paths.Add(onePath);
                        pathNodes.RemoveAt(pathNodes.Count - 1);
                    }
                }
            }
        }
Beispiel #3
0
        public void ReflectEfieldTest2()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                  // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                               // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 / Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(-1, Math.Sqrt(3), 0));                                                   // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                            // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                 // TODO: 初始化为适当的值
            double      Epara    = 4.1;                                                                                                               // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                 // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                 // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                              // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.0623877164578374, 0.108058694673174),
                                              new Plural(0.0360195648910585, 0.0623877164578365), new Plural(0.0968928150328006, 0.167823278525182)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #4
0
        public void ReflectEfieldTest1()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                      // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                                   // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, -3), new Point(6, -2, 3), new Point(6, 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(-1, 0, 0));                                                                  // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                                // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                     // TODO: 初始化为适当的值
            double      Epara    = 4.1;                                                                                                                   // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                     // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                     // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                                  // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0, 0),
                                              new Plural(-0.0847023107852173, -0.146708705798483), new Plural(-0.0847023107852173, -0.146708705798483));; // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #5
0
        public void ReflectEfieldTest15()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                 // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                              // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 * Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(1, Math.Sqrt(3), 0));                                                   // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                           // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                // TODO: 初始化为适当的值
            double      Epara    = 1 / 80.4;                                                                                                         // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                             // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(-0.221914313088277, -0.37182527838564),
                                              new Plural(0.128122288398547, 0.214673424567456), new Plural(0.49998683666538, -0.00362810713003811)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #6
0
        public void ReflectEfieldTest5()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));               // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                            // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(10, 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(0, 1, 0));                            // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                         // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                              // TODO: 初始化为适当的值
            double      Epara    = 6.2;                                                                            // TODO: 初始化为适当的值
            double      s1       = 1;                                                                              // TODO: 初始化为适当的值
            double      s2       = 1;                                                                              // TODO: 初始化为适当的值
            double      f        = 1000;                                                                           // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.0737128450442626, 0.127674392787113),
                                              new Plural(0, 0), new Plural(0.135750547921789, 0.235126846155848)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #7
0
        public void ReflectEfieldTest13()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                 // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                              // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 / Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(-1, Math.Sqrt(3), 0));                                                  // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                           // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                // TODO: 初始化为适当的值
            double      Epara    = 1 / 80.4;                                                                                                         // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                             // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(-0.232861639196329, -0.365069112622252),
                                              new Plural(-0.134442730073938, -0.210772750445275), new Plural(0.240433653861357, -0.43839669032828)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #8
0
        public void ReflectEfieldTest12()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));              // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                           // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(10, 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(0, 1, 0));                           // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                        // TODO: 初始化为适当的值
            double      Conduct  = 10000000;                                                                      // TODO: 初始化为适当的值
            double      Epara    = 0;                                                                             // TODO: 初始化为适当的值
            double      s1       = 1;                                                                             // TODO: 初始化为适当的值
            double      s2       = 1;                                                                             // TODO: 初始化为适当的值
            double      f        = 1000;                                                                          // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.2500272723013, 0.432910889925977),
                                              new Plural(0, 0), new Plural(0.25001363855995, 0.432961794520133)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #9
0
        public void ReflectEfieldTest11()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                               // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                            // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 / Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(-1, Math.Sqrt(3), 0));                                                // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                         // TODO: 初始化为适当的值
            double      Conduct  = 10000000;                                                                                                       // TODO: 初始化为适当的值
            double      Epara    = 0;                                                                                                              // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                              // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                              // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                           // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.216525636623664, 0.374928007347336),
                                              new Plural(0.125011134591127, 0.216464785968714), new Plural(0.250016703089389, 0.432950353731651)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #10
0
        public void ReflectEfieldTest9()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                  // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                               // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 * Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(1, Math.Sqrt(3), 0));                                                    // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                            // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                 // TODO: 初始化为适当的值
            double      Epara    = 80.4;                                                                                                              // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                 // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                 // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                              // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.137839140789951, 0.238744395119831),
                                              new Plural(-0.0795814650399449, -0.137839140789949), new Plural(0.223473914142364, 0.387068173460853)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #11
0
        public void ReflectEfieldTest8()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));              // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                           // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(10, 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(0, 1, 0));                           // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                        // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                             // TODO: 初始化为适当的值
            double      Epara    = 80.4;                                                                          // TODO: 初始化为适当的值
            double      s1       = 1;                                                                             // TODO: 初始化为适当的值
            double      s2       = 1;                                                                             // TODO: 初始化为适当的值
            double      f        = 1000;                                                                          // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.182066642851485, 0.315348675782264),
                                              new Plural(0, 0), new Plural(0.213346339815971, 0.36952670017011)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #12
0
        public void ReflectEfieldTest7()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                             // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 / Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(-1, Math.Sqrt(3), 0));                                                 // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                          // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                               // TODO: 初始化为适当的值
            double      Epara    = 80.4;                                                                                                            // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                               // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                               // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                            // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.167173715239667, 0.289553368485151),
                                              new Plural(0.0965177894950518, 0.167173715239665), new Plural(0.205899086049201, 0.356627678269207)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #13
0
        public void ReflectEfieldTest6()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                  // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                               // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 * Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(1, Math.Sqrt(3), 0));                                                    // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                            // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                 // TODO: 初始化为适当的值
            double      Epara    = 6.2;                                                                                                               // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                 // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                 // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                              // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.0304958700190565, 0.0528203962940216),
                                              new Plural(-0.0176067987646741, -0.0304958700190561), new Plural(0.161801754519918, 0.28024885958228)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #14
0
        /// <summary>
        ///根据绕射棱两侧的绕射射线生成绕射追踪模型
        /// </summary>
        /// <param name="fatherPoint">父节点</param>
        /// <param name="leftRays">左侧的绕射射线</param>
        /// <param name="rightRays">右侧的绕射射线</param>
        /// <returns>绕射追踪模型</returns>
        private List <IRayTracing> GetDiffractionRayFaces(Point diffractionPoint, AdjacentEdge diffractionEdge)
        {
            //绕射范围两个端点的位置
            Point rightPoint = new RayInfo(diffractionPoint, diffractionEdge.EndPoint).GetPointOnRayVector(diffractionEdge.DiffCylinderRadius);
            Point leftPoint  = new RayInfo(diffractionPoint, diffractionEdge.StartPoint).GetPointOnRayVector(diffractionEdge.DiffCylinderRadius);
            //将点转成节点
            Node leftNode  = this.GetDiffractionChildNode(this.fatherNode, leftPoint, diffractionEdge);
            Node rightNode = this.GetDiffractionChildNode(this.fatherNode, rightPoint, diffractionEdge);
            //求出左侧节点的绕射射线
            List <RayInfo>     leftRays = Rays.GetDiffractionRays(this.fatherNode.Position, leftPoint, diffractionEdge, 24);
            List <IRayTracing> rayFaces = new List <IRayTracing>();

            //根据左侧绕射射线生成射线模型
            for (int i = 0; i < leftRays.Count; i++)
            {
                Point   fatherFacePoint   = new SpaceFace(diffractionEdge.StartPoint, leftRays[i].RayVector.CrossMultiplied(diffractionEdge.LineVector)).GetSubPointInFace(this.fatherNode.Position);
                Point   fatherMirrorPoint = new RayInfo(rightPoint, fatherFacePoint).GetPointOnRayVector(diffractionEdge.DiffCylinderRadius);
                RayInfo rightRay          = new RayInfo(rightPoint, new SpectVector(fatherMirrorPoint, rightPoint));
                rayFaces.Add(new FaceRay(leftNode, rightNode, leftRays[i], rightRay));
            }
            return(rayFaces);
        }
Beispiel #15
0
        public void ReflectEfieldTest14()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));               // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                            // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(10, 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(0, 1, 0));                            // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                         // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                              // TODO: 初始化为适当的值
            double      Epara    = 1 / 80.4;                                                                       // TODO: 初始化为适当的值
            double      s1       = 1;                                                                              // TODO: 初始化为适当的值
            double      s2       = 1;                                                                              // TODO: 初始化为适当的值
            double      f        = 1000;                                                                           // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(-0.26082694568263, -0.426578602845795),
                                              new Plural(0, 0), new Plural(0.429829743600304, -0.25543373214299)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #16
0
        public void ReflectEfieldTest3()
        {
            EField      e        = new EField(new Plural(0, 0), new Plural(1, 0), new Plural(1, 0));                                                    // TODO: 初始化为适当的值
            RayInfo     rayIn    = new RayInfo(new Point(0, 0, 0), new Point(1, 0, 0));                                                                 // TODO: 初始化为适当的值
            Face        face     = new SpaceFace(new Point(6, -2, 3), new Point(6, -2, -3), new Point(6 + 4 * Math.Sqrt(3), 2, 0));
            RayInfo     rayOut   = new RayInfo(new Point(0, 0, 0), new Point(1, Math.Sqrt(3), 0));                                                      // TODO: 初始化为适当的值
            SpectVector l        = face.GetNormalVector();                                                                                              // TODO: 初始化为适当的值
            double      Conduct  = 0;                                                                                                                   // TODO: 初始化为适当的值
            double      Epara    = 4.1;                                                                                                                 // TODO: 初始化为适当的值
            double      s1       = 1;                                                                                                                   // TODO: 初始化为适当的值
            double      s2       = 1;                                                                                                                   // TODO: 初始化为适当的值
            double      f        = 1000;                                                                                                                // TODO: 初始化为适当的值
            EField      expected = new EField(new Plural(0.0122584145400459, 0.0212321968036003),
                                              new Plural(-0.00707739893453353, -0.0122584145400457), new Plural(0.142717699857073, 0.247194307291812)); // TODO: 初始化为适当的值
            EField actual = new EField();

            actual = ReflectEfieldCal.ReflectEfield(e, rayIn, rayOut, l, Conduct, Epara, s1, s2, f);
            Assert.IsTrue(Math.Abs(actual.X.Re - expected.X.Re) < 0.0000001 && Math.Abs(actual.X.Im - expected.X.Im) < 0.0000001 &&
                          Math.Abs(actual.Y.Re - expected.Y.Re) < 0.0000001 && Math.Abs(actual.Y.Im - expected.Y.Im) < 0.0000001 &&
                          Math.Abs(actual.Z.Re - expected.Z.Re) < 0.0000001 && Math.Abs(actual.Z.Im - expected.Z.Im) < 0.0000001);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #17
0
        /// <summary>
        /// 求圆与三角面的交点
        /// </summary>
        /// <param name="terTri">三角面</param>
        /// <param name="centerPoint">圆心</param>
        /// <param name="radius">圆的半径</param>
        /// <param name="vectorU">圆所在平面的一个向量U,其与平面的法向量垂直</param>
        /// <param name="vectorV">圆所在平面的一个向量V,其与U及平面法向量相互垂直</param>
        /// <param name="triPoint">三角面除了绕射棱两个端点外的另一个点</param>
        /// <returns>返回圆与三角面的交点</returns>
        private static Point GetCrossPointOfCircleWithTer(SpaceFace terTri, Point centerPoint, double radius, SpectVector vectorU, SpectVector vectorV, Point triPoint)
        {
            //将空间圆的参数方程带入到平面方程Ax+By+Cz+D=0中可推导得下列式子
            //空间圆周参数方程参考 http://wenku.baidu.com/link?url=gsI3WsqXqjVOcLsNrLT76erK8g3XD828DxlehCvgBsFcKzLPw0hjQSZjxocv-gYOTtKtYcFOOOMKa4KQ215wCTkNWTApqk3c0mPU_XvkR7q

            //求圆与三角面所在平面的交点
            List <Point> crossPoints = new List <Point>();

            if (radius < 1)//半径太小导致判断有误差,所以设置半径不小于1
            {
                radius = 1;
            }
            SpectVector triVector = terTri.NormalVector.GetNormalizationVector();//获取三角面的法向量
            double      D         = -(triVector.a * terTri.Vertices[0].X + triVector.b * terTri.Vertices[0].Y + triVector.c * terTri.Vertices[0].Z);
            double      M         = radius * (triVector.a * vectorU.a + triVector.b * vectorU.b + triVector.c * vectorU.c);
            double      N         = radius * (triVector.a * vectorV.a + triVector.b * vectorV.b + triVector.c * vectorV.c);

            double[] sint = new double[2];
            sint[0] = Math.Round(Math.Sqrt(Math.Pow(N, 2) / (Math.Pow(M, 2) + Math.Pow(N, 2))), 10);
            sint[1] = Math.Round(-Math.Sqrt(Math.Pow(N, 2) / (Math.Pow(M, 2) + Math.Pow(N, 2))), 10);
            for (int i = 0; i < 2; i++)                //由于分辨不清角度t的范围,所以将cost用1-sint^2开根的方法求,并得到4个点,其中两个不在平面内
            {
                if ((-1 <= sint[i]) && (sint[i] <= 1)) //解的范围在-1到1之间时
                {
                    Point    crossPoint1 = new Point();
                    double[] cost        = new double[2];
                    cost[0]       = Math.Sqrt(1 - Math.Pow(sint[i], 2));
                    cost[1]       = -Math.Sqrt(1 - Math.Pow(sint[i], 2));
                    crossPoint1.X = centerPoint.X + radius * (vectorU.a * sint[i] + vectorV.a * cost[0]);
                    crossPoint1.Y = centerPoint.Y + radius * (vectorU.b * sint[i] + vectorV.b * cost[0]);
                    crossPoint1.Z = centerPoint.Z + radius * (vectorU.c * sint[i] + vectorV.c * cost[0]);
                    crossPoints.Add(crossPoint1);
                    Point crossPoint2 = new Point();
                    crossPoint2.X = centerPoint.X + radius * (vectorU.a * sint[i] + vectorV.a * cost[1]);
                    crossPoint2.Y = centerPoint.Y + radius * (vectorU.b * sint[i] + vectorV.b * cost[1]);
                    crossPoint2.Z = centerPoint.Z + radius * (vectorU.c * sint[i] + vectorV.c * cost[1]);
                    crossPoints.Add(crossPoint2);
                }
                else
                {
                    LogFileManager.ObjLog.debug("生成绕射射线时,在求园与三角面交点时求sint出错");
                    return(new Point());
                }
            }
            //删除不在三角面平面上的交点
            for (int i = crossPoints.Count - 1; i >= 0; i--)//排除不在平面的点
            {
                if (!terTri.JudgeIfPointInFace(crossPoints[i]))
                {
                    crossPoints.RemoveAt(i);
                }
            }
            //由于当thi角为90度时,求得的点中有两个是重复的点,故要将其删除
            if (crossPoints.Count == 4)
            {
                for (int m = crossPoints.Count - 1; m > 0; m--)
                {
                    for (int n = m - 1; n >= 0; n--)
                    {
                        if (Math.Abs(crossPoints[m].X - crossPoints[n].X) < 0.00001 &&
                            Math.Abs(crossPoints[m].Y - crossPoints[n].Y) < 0.00001 &&
                            Math.Abs(crossPoints[m].Z - crossPoints[n].Z) < 0.00001)
                        {
                            crossPoints.RemoveAt(m);
                            break;
                        }
                    }
                }
            }
            //圆与三角面或者在其一侧的交点
            if (crossPoints.Count == 2)
            {
                if (triPoint.GetDistance(crossPoints[0]) < triPoint.GetDistance(crossPoints[1]))
                {
                    return(crossPoints[0]);
                }
                else
                {
                    return(crossPoints[1]);
                }
            }
            else
            {
                LogFileManager.ObjLog.debug("生成绕射射线时,在筛选园与三角面交点时出错");
                return(new Point());
            }
        }
Beispiel #18
0
        /// <summary>
        ///求启发式绕射系数,文档公式3,5
        /// </summary>
        private static Plural GetDiffractionFactor(RayInfo ray, Face diffractionFace1, Face diffractionFace2, AdjacentEdge sameEdge, Point diffractionPoint, Point viewPoint, double waveLength, bool judgeVerticallyPolarizedWave)
        {
            Plural D = new Plural();
            //求a1,a2
            Face rayFace            = new SpaceFace(sameEdge.StartPoint, sameEdge.EndPoint, ray.Origin);
            Face diffractionRayFace = new SpaceFace(sameEdge.StartPoint, sameEdge.EndPoint, viewPoint);
            Face frontFace          = GetTheFrontFace(diffractionFace1, diffractionFace2, rayFace, sameEdge);//先与射线相交的三角面
            Face laterFace          = diffractionFace2;

            if (frontFace != diffractionFace1)
            {
                laterFace = diffractionFace1;//后相交的三角面
            }
            double a1 = GetAngleOfTwoTers(frontFace, rayFace, sameEdge) * Math.PI / 180;
            double a2;

            if (ray.Origin.JudgeIsConcaveOrConvexToViewPoint(frontFace, diffractionRayFace))//若两个三角面的形状是凸的
            {
                double angleWithFront = GetAngleOfTwoTers(frontFace, diffractionRayFace, sameEdge);
                double angleWithLater = GetAngleOfTwoTers(laterFace, diffractionRayFace, sameEdge);
                if (angleWithFront < angleWithLater)
                {
                    a2 = angleWithFront * Math.PI / 180;
                }
                else
                {
                    a2 = (360 - angleWithFront) * Math.PI / 180;
                }
            }
            else//若两个三角面的形状是凹的
            {
                a2 = GetAngleOfTwoTers(frontFace, diffractionRayFace, sameEdge) * Math.PI / 180;
            }
            //求n
            double angleOfTwoTers = GetAngleOfTwoTers(diffractionFace1, diffractionFace2, sameEdge);
            double n = 2 - (angleOfTwoTers / 180);//n=2-a/pi,其中a为两个三角面的夹角

            //求ri
            double[] r = new double[4];
            r[0] = (Math.PI - (a2 - a1)) / (2 * n);
            r[1] = (Math.PI + (a2 - a1)) / (2 * n);
            r[2] = (Math.PI - (a2 + a1)) / (2 * n);
            r[3] = (Math.PI + (a2 + a1)) / (2 * n);
            //求k
            double k = 2 * Math.PI / waveLength;//波矢量
            //求L
            double L = GetDistanceParameter(ray.Origin, diffractionPoint, sameEdge, viewPoint, waveLength);

            //求Di
            Plural[] Di        = new Plural[4];
            Plural   minusepi4 = new Plural(-Math.Sqrt(2) / 2, Math.Sqrt(2) / 2);

            for (int i = 0; i < 4; i++)
            {
                Di[i] = Plural.PluralMultiplyDouble(minusepi4 * GetTransitionFunction(2 * k * L * Math.Pow(n, 2) * Math.Pow(Math.Sin(r[i]), 2)), 1 / (Math.Tan(r[i]) * (2 * n * Math.Sqrt(2 * k * Math.PI))));
            }
            //求反射系数R
            RayInfo diffractionRay = new RayInfo(diffractionPoint, viewPoint);

            Plural Ro = GetReflectionCoefficient(ray, frontFace, a1, waveLength, judgeVerticallyPolarizedWave);
            Plural Rn = GetReflectionCoefficient(diffractionRay, laterFace, n * Math.PI - a2, waveLength, judgeVerticallyPolarizedWave);

            D = Di[0] + Di[1] * Ro * Rn + Di[2] * Ro + Di[3] * Rn;
            return(D);
        }