Ejemplo n.º 1
0
 /// <summary>
 /// Any part of this circle overlaps any part of line segment B.
 /// If line B lies within the circle, that counts as overlapping.
 /// </summary>
 public bool Overlaps(LineSegment b)
 {
     Point[] lineIntersectionPoints = GetIntersectionPoints(b.ToLine());
     if (lineIntersectionPoints == null)
     {
         return(false);
     }
     foreach (Point point in lineIntersectionPoints)
     {
         if (b.Overlaps(point))
         {
             return(true);
         }
     }
     if (lineIntersectionPoints.Length == 2)
     {
         //if b lies entirely within the circle
         LineSegment intersectionLine = new LineSegment(lineIntersectionPoints[0], lineIntersectionPoints[1]);
         if (intersectionLine.Length > b.Length && intersectionLine.Overlaps(b))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        public Point[] GetIntersectionPoints(LineSegment lineSegment)
        {
            Point[] lineIntersectionPoints = GetIntersectionPoints(lineSegment.ToLine());
            if (lineIntersectionPoints == null)
            {
                return(null);
            }
            List <Point> segmentIntersectionPoints = new List <Point>();

            foreach (Point point in lineIntersectionPoints)
            {
                if (lineSegment.Overlaps(point))
                {
                    segmentIntersectionPoints.Add(point);
                }
            }
            if (segmentIntersectionPoints.Count == 0)
            {
                return(null);
            }
            return(segmentIntersectionPoints.ToArray());
        }