Exemplo n.º 1
0
        /// <summary>
        ///进行射线追踪
        /// </summary>
        public List <Node> GetCrossNodes(Terrain ter, ReceiveBall rxBall, City buildings, double rayBeamAngle)
        {
            List <Rectangle> shadowRect        = ter.lineRect(this.inRay);                                                                                    //记录射线在俯视图投影经过的矩形
            Node             crossWithTer      = this.inRay.GetCrossNodeWithTerrainRects(shadowRect);                                                         //记录射线与地形交点、与源点距离、所在面
            Node             CrossWithReceive  = rxBall.GetCrossNodeWithRxBall(this.inRay);                                                                   //记录射线与接收球交点
            Node             CrossWithTerEdge  = this.inRay.GetCrossNodeWithTerDiffractionEdge(shadowRect, this.fatherNode.RayTracingDistance, rayBeamAngle); //记录射线与地形绕射边的交点,绕射等信息
            Node             crossWithCity     = buildings.GetReflectionNodeWithCity(this.inRay);                                                             //记录射线与建筑物交点、与源点距离、所在面
            Node             CrossWithCityEdge = buildings.GetDiffractionNodeWithBuildings(this.inRay, this.fatherNode.RayTracingDistance, rayBeamAngle);     //记录射线与建筑物绕射边的交点,绕射等信息

            //把所有交点放到一个list中
            if (crossWithTer != null)
            {
                this.crossNodes.Add(crossWithTer);
            }
            if (CrossWithReceive != null)
            {
                this.crossNodes.Add(CrossWithReceive);
            }
            if (crossWithCity != null)
            {
                this.crossNodes.Add(crossWithCity);
            }
            if (CrossWithTerEdge != null)
            {
                this.crossNodes.Add(CrossWithTerEdge);
            }
            if (CrossWithCityEdge != null)
            {
                this.crossNodes.Add(CrossWithCityEdge);
            }
            if (crossNodes.Count == 0)
            {
                return(crossNodes);
            }
            else if (crossNodes.Count == 1)
            {
                return(new List <Node> {
                    this.crossNodes[0]
                });
            }
            else
            {
                //若交点大于两个,排序
                for (int i = 0; i < this.crossNodes.Count - 1; i++)
                {
                    for (int j = i + 1; j < this.crossNodes.Count; j++)
                    {
                        if (this.crossNodes[j].DistanceToFrontNode > this.crossNodes[j + 1].DistanceToFrontNode)
                        {
                            Node param = this.crossNodes[j];
                            this.crossNodes[j]     = this.crossNodes[j + 1];
                            this.crossNodes[j + 1] = param;
                        }
                    }
                }
                return(new List <Node> {
                    this.crossNodes[0]
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///求射线与地形,接收球,建筑物的交点,并将交点按照与源点距离进行排序
        /// </summary>
        /// <param name="oneRay">射线</param>
        /// <param name="rxBall">接收球</param>
        /// <param name="ter">地形</param>
        ///  <param name="cityBuilding">建筑物</param>
        ///  <param name="TxFrequencyBand">发射机频段信息</param>
        ///  <param name="multiple">绕射圆柱体半径倍数</param>
        /// <returns>返回交点</returns>
        private List <Node> GetCrossPointsWithEnvironment(ReceiveBall rxBall, Terrain ter, City cityBuilding, List <FrequencyBand> txFrequencyBand, double multiple)
        {
            Node        crossWithTer      = this.inRay.GetCrossNodeWithTerrainRects(this.terShadowRects);                   //记录射线与地形交点、与源点距离、所在面
            Node        CrossWithReceive  = rxBall.GetCrossNodeWithRxBall(this.inRay);                                      //记录射线与接收球交点
            List <Node> CrossWithTerEdge  = this.GetCrossNodeWithTerDiffractionEdge(txFrequencyBand, multiple);             //记录射线与地形绕射边的交点,绕射等信息
            Node        crossWithCity     = cityBuilding.GetReflectionNodeWithCity(this.inRay);                             //记录射线与建筑物交点、与源点距离、所在面
            List <Node> CrossWithCityEdge = cityBuilding.GetDiffractionNodeWithCity(this.inRay, txFrequencyBand, multiple); //记录射线与建筑物绕射边的交点,绕射等信息
            //把所有交点放到一个list中
            List <Node> crossNodes = new List <Node> ();

            if (crossWithTer != null)
            {
                crossNodes.Add(crossWithTer);
            }
            if (CrossWithReceive != null)
            {
                crossNodes.Add(CrossWithReceive);
            }
            if (crossWithCity != null)
            {
                crossNodes.Add(crossWithCity);
            }
            if (CrossWithTerEdge.Count != 0)
            {
                crossNodes.AddRange(CrossWithTerEdge);
            }
            if (CrossWithCityEdge.Count != 0)
            {
                crossNodes.AddRange(CrossWithCityEdge);
            }
            //
            if (crossNodes.Count > 1)//若交点个数大于2,进行排序
            {
                for (int i = 0; i < crossNodes.Count - 1; i++)
                {
                    for (int j = 0; j < crossNodes.Count - i - 1; j++)
                    {
                        if (crossNodes[j].DistanceToFrontNode > crossNodes[j + 1].DistanceToFrontNode)
                        {
                            Node param = crossNodes[j];
                            crossNodes[j]     = crossNodes[j + 1];
                            crossNodes[j + 1] = param;
                        }
                    }
                }
            }
            //        this.DeleteSameNode(crossNodes);
            return(crossNodes);
        }