Example #1
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);
        }