/// <summary> /// Calculate the intersection points when a line across many segments. /// </summary> /// <param name="sEqs">The segment equations.</param> /// <param name="lEq">The line equation.</param> /// <returns>Returns the intersection points.</returns> public static List <Point> GetIntersection(IEnumerable <SegmentEquation> sEqs, LinearEquation lEq) { var pts = new List <Point>(); foreach (var sEq in sEqs) { var pt = SegmentEquation.GetIntersection(sEq, lEq); if (null != pt && sEq.IsPointInRange(pt)) { pts.Add(pt); } } return(pts); }
/// <summary> /// Calculate the intersection point between the segment and line (Special). /// </summary> /// <param name="sEq">The segment equation.</param> /// <param name="lEq">The line equation.</param> /// <returns>Returns the intersection points.</returns> public static Point GetIntersectionSp(SegmentEquation sEq, LinearEquation lEq) { var pt = SegmentEquation.GetIntersection(sEq, lEq); if (pt == sEq.endpoint1) { if (pt.Y <= sEq.endpoint2.Y) { pt = null; } } else if (pt == sEq.endpoint2) { if (pt.Y <= sEq.endpoint1.Y) { pt = null; } } return(pt); }