Exemplo n.º 1
0
        /// <summary>
        /// This function will find the closest node from a geographical position in space.
        /// </summary><seealso cref="ClosestNode(double,double,double,out double,bool)"/>
        /// <param name="P">point from which you want the closest node</param>
        /// <param name="Distance">The distance to the closest node.</param>
        /// <param name="IgnorePassableProperty">if 'false', then nodes whose property Passable is set to false will not be taken into account.</param>
        /// <returns></returns>
        public Node ClosestNode(Point3D P, out double Distance, bool IgnorePassableProperty)
        {
            Node   NodeMin     = null;
            double DistanceMin = -1;

            foreach (Node N in LN)
            {
                if (IgnorePassableProperty && N.Passable == false)
                {
                    continue;
                }
                double DistanceTemp = Point3D.DistanceBetween(N.Position, P);
                if (DistanceMin == -1 || DistanceMin > DistanceTemp)
                {
                    DistanceMin = DistanceTemp;
                    NodeMin     = N;
                }
            }
            Distance = DistanceMin;
            return(NodeMin);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function will find the closest arc from a geographical position in space using projection.
        /// </summary>
        /// <param name="P">point from which you want the closest arc.</param>
        /// <param name="Distance">The distance to the closest arc.</param>
        /// <param name="IgnorePassableProperty">if 'false', then arcs whose property Passable is set to false will not be taken into account.</param>
        /// <returns>The closest arc that has been found.</returns>
        public Arc ClosestArc(Point3D P, out double Distance, bool IgnorePassableProperty)
        {
            Arc    ArcMin      = null;
            double DistanceMin = -1;

            foreach (Arc A in LA)
            {
                if (IgnorePassableProperty && A.Passable == false)
                {
                    continue;
                }
                Point3D Projection   = Point3D.ProjectOnLine(P, A.StartNode.Position, A.EndNode.Position);
                double  DistanceTemp = Point3D.DistanceBetween(P, Projection);
                if (DistanceMin == -1 || DistanceMin > DistanceTemp)
                {
                    DistanceMin = DistanceTemp;
                    ArcMin      = A;
                }
            }
            Distance = DistanceMin;
            return(ArcMin);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Performs the calculous that returns the arc's length
 /// Can be overriden for derived types of arcs that are not linear.
 /// </summary>
 /// <returns></returns>
 virtual protected double CalculateLength()
 {
     return(Point3D.DistanceBetween(_StartNode.Position, _EndNode.Position));
 }