Esempio n. 1
0
        /// <summary>
        /// This specifically checks the borders to see if any of the segments
        /// completely cross over each other.  Touching or overlapping won't
        /// evaluate as true.
        /// </summary>
        /// <param name="Ext">The extents object to compare with.</param>
        /// <returns>Boolean, true if any of the segments from this </returns>
        bool IsCrossedByTheOutlineOf(Extents Ext)
        {
            // the two extents have to intersect for crossing to be possible, which takes longer to check.
            if (IntersectWith(Ext) == false)
            {
                return(false);
            }
            List <Segment> MySegs = ToSegments();
            List <Segment> Segs   = Ext.ToSegments();

            for (int I = 0; I < MySegs.Count; I++)
            {
                for (int J = 0; J < Segs.Count; J++)
                {
                    if (MySegs[I].Crosses(Segs[J]))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Finds the shortest path starting at this extents and ending at the specified one.
        /// </summary>
        /// <param name="Ext">The Topology2D.Extents object to compare to.</param>
        /// <returns>Either a Topology2D.Segment with a startpoint on this object's borders
        /// and an endpoint on the specified extents, or null if the two intersect.</returns>
        public Segment ShortestPathTo(Extents Ext)
        {
            if (IntersectWith(Ext) == true)
            {
                return(null);
            }


            List <Segment> Segs         = Ext.ToSegments();
            double         Dist         = double.PositiveInfinity;
            Segment        ShortestPath = new Segment();

            for (int I = 0; I < Segs.Count; I++)
            {
                Segment path = ShortestPathTo(Segs[I]);
                if (path.Length < Dist)
                {
                    Dist         = path.Length;
                    ShortestPath = path;
                }
            }
            return(ShortestPath);
        }