Beispiel #1
0
        /// <summary>
        ///获得正二十面体的20个初始射线管
        /// </summary>
        ///  <param name="tx">发射机</param>
        /// <returns></returns>
        private List <RayTubeModel> GetOriginUnitsOfIcosahedron()
        {
            //求正二十面体顶点坐标的方法参考论文:单纯形射线追踪法计算室内场强-王文华
            //注意论文中的XY坐标与我们使用的相反,所以要把x,y的公式反过来
            double thi = 63.4349488229220 * Math.PI / 180;
            double fi  = 72 * Math.PI / 180;

            Point[] icosahedronVetices = new Point[12];
            icosahedronVetices[0] = new Point(this.tx.Position.X, this.tx.Position.Y, this.tx.Position.Z + 1); //顶点1
            for (int i = 1; i < 6; i++)                                                                        //求顶点2-6的坐标
            {
                icosahedronVetices[i] = new Point(this.tx.Position.X + Math.Sin(thi) * Math.Cos(fi * (i - 1)),
                                                  this.tx.Position.Y + Math.Sin(thi) * Math.Sin(fi * (i - 1)), this.tx.Position.Z + Math.Cos(thi));
            }
            for (int j = 6; j < 11; j++)//求顶点7-11的坐标
            {
                icosahedronVetices[j] = new Point(this.tx.Position.X + Math.Sin(thi) * Math.Cos(fi * (j - 6) + Math.PI / 5),
                                                  this.tx.Position.Y + Math.Sin(thi) * Math.Sin(fi * (j - 6) + Math.PI / 5), this.tx.Position.Z - Math.Cos(thi));
            }
            icosahedronVetices[11] = new Point(this.tx.Position.X, this.tx.Position.Y, this.tx.Position.Z - 1);//顶点12
            //生产单射线模型
            OneRayModel[] originRayModels = new OneRayModel[12];
            for (int n = 0; n < originRayModels.Length; n++)
            {
                originRayModels[n] = new OneRayModel(this.tx, new RayInfo(this.tx.Position, icosahedronVetices[n]));
            }
            List <RayTubeModel> rayTubeModels = this.GetOriginIcosahedronRayTubeModes(originRayModels);

            return(rayTubeModels);
        }
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);
                    }
                }
            }
        }