Exemple #1
0
 /// <summary>
 ///获取当两侧射线都有交点时的追踪交点
 /// </summary>
 /// <param name="outRay">从射线面发出的射线</param>
 /// <param name="rayCrossNode">射线与交点的dictionary</param>
 /// <param name="ter">地形</param>
 /// <param name="rxBall">接收球</param>
 ///  <param name="buildings">建筑物</param>
 /// <param name="rayBeamAngle">射线束的夹角</param>
 /// <returns></returns>
 private void GetCrossNodeWhenTwoRaysTrue(List <RayInfo> outRay, Dictionary <RayInfo, Node> rayCrossNode, Terrain ter, ReceiveBall rxBall, City buildings, double rayBeamAngle, ref int i)
 {
     //两个交点都是反射点
     if (rayCrossNode[outRay[i]].NodeStyle == NodeStyle.ReflectionNode && rayCrossNode[outRay[i]].NodeStyle == NodeStyle.ReflectionNode)
     {
         //是同一个反射面
         if (rayCrossNode[outRay[i]].ReflectionFace.Equals(rayCrossNode[outRay[i + 1]].ReflectionFace))
         {
             return;
         }
         else
         {
             if (rayCrossNode[outRay[i]].ReflectionFace.FaceStyle == FaceType.Terrian && rayCrossNode[outRay[i + 1]].ReflectionFace.FaceStyle == FaceType.Terrian)
             {
                 if (rayCrossNode[outRay[i]].ReflectionFace.FaceID.JudgeIsSameID(rayCrossNode[outRay[i + 1]].ReflectionFace.FaceID))
                 {
                     AdjacentEdge diffractionEdge  = new AdjacentEdge(rayCrossNode[outRay[i]].ReflectionFace, rayCrossNode[outRay[i + 1]].ReflectionFace);
                     Point        diffractionPoint = new RayInfo(diffractionEdge.StartPoint, diffractionEdge.EndPoint).GetCrossPointWithFace(this.rayFace);
                     if (diffractionEdge.JudgeIfPointInLineRange(diffractionPoint))//若绕射点在棱上
                     {
                         RayInfo inRay           = new RayInfo(this.launchPoint, diffractionPoint);
                         Node    lineNode        = this.GetLineNode(inRay);
                         Node    diffractionNode = this.GetDiffractionNode(lineNode, diffractionPoint, diffractionEdge);
                         rayCrossNode.Add(inRay, diffractionNode);
                         i++;
                     }
                 }
                 else
                 {
                     this.SetNewMiddleRay(outRay, rayCrossNode, ter, rxBall, buildings, rayBeamAngle, ref i);
                 }
             }
             else if (rayCrossNode[outRay[i]].ReflectionFace.FaceStyle == FaceType.Terrian && rayCrossNode[outRay[i + 1]].ReflectionFace.FaceStyle == FaceType.Building)
             {
             }
             else if (rayCrossNode[outRay[i]].ReflectionFace.FaceStyle == FaceType.Building && rayCrossNode[outRay[i + 1]].ReflectionFace.FaceStyle == FaceType.Terrian)
             {
             }
             else
             {
             }
         }
     }
     //一个交点是反射点,一个交点是绕射点
     else if (rayCrossNode[outRay[i]].NodeStyle == NodeStyle.ReflectionNode && rayCrossNode[outRay[i]].NodeStyle == NodeStyle.DiffractionNode)
     {
     }
     //一个交点是反射点,一个交点是绕射点
     else if (rayCrossNode[outRay[i]].NodeStyle == NodeStyle.DiffractionNode && rayCrossNode[outRay[i]].NodeStyle == NodeStyle.ReflectionNode)
     {
     }
     else//两个交点都是绕射点
     {
     }
 }
Exemple #2
0
        /// <summary>
        ///根据绕射点范围和取点距离取多个绕射点
        /// </summary>
        /// <param name="crossPoint">射线与圆柱体的交点</param>
        /// <param name="diffEdge">绕射棱</param>
        /// <returns>在绕射点范围内一定个数的点的list</returns>
        private List <Point> GetDiffractionNodePoistions(Point crossPoint, AdjacentEdge diffEdge)
        {
            Point rightPoint = new RayInfo(crossPoint, diffEdge.EndPoint).GetPointOnRayVector(diffEdge.DiffCylinderRadius);
            Point leftPoint  = new RayInfo(crossPoint, diffEdge.StartPoint).GetPointOnRayVector(diffEdge.DiffCylinderRadius);

            List <Point> diffPoints = new List <Point> {
                crossPoint
            };

            diffPoints.AddRange(this.GetSamplingPointsInRange(crossPoint, rightPoint, 5));
            diffPoints.AddRange(this.GetSamplingPointsInRange(crossPoint, leftPoint, 5));
            for (int i = diffPoints.Count - 1; i >= 0; i--)
            {
                if (!diffEdge.JudgeIfPointInLineRange(diffPoints[i]) || diffPoints[i].equal(diffEdge.StartPoint) || diffPoints[i].equal(diffEdge.EndPoint))
                {
                    diffPoints.RemoveAt(i);
                }
            }
            return(diffPoints);
        }