コード例 #1
0
        public static bool OverlapsBoundary(this LineSegment2D segment, Polygon2D boundary)
        {
            foreach (var edge in boundary.Edges)
            {
                var intersects = segment.CheckForIntersection(edge, out var intersection);

                if (intersects && intersection == null)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Checks for intersections between a line segment and a polygon.  Returns an IEnumerable of the intersection points.
        /// </summary>
        /// <param name="segment">Line segment</param>
        /// <param name="boundary">Polygon boundary</param>
        /// <param name="extend">If set to true, will create an infinite ray along the 'segment' vector and check for intersections between the ray and polygon.  If set to false, will only check the defined line segment.</param>
        /// <returns></returns>
        public static IEnumerable <Point2D> CalculateIntersections(this LineSegment2D segment, Polygon2D boundary,
                                                                   bool extend = false)
        {
            var intersections = new List <Point2D>();

            foreach (var edge in boundary.Edges)
            {
                if (segment.CheckForIntersection(edge, out var intersection, thisEpsilon: 0,
                                                 otherEpsilon: DEFAULTBOUNDARYSEGMENTEXTENSION, extendThisSegment: extend) &&
                    intersection != null)
                {
                    intersections.Add(intersection.Value);
                }
            }

            return(intersections.Distinct());
        }
コード例 #3
0
 public static bool CheckForIntersectionOfExtension(this LineSegment2D segment, LineSegment2D other,
                                                    out Point2D?intersection)
 {
     return(segment.CheckForIntersection(other, out intersection, extendThisSegment: true));
 }