/** * Calculates the intersection of slopes of two lines. * * @param lineA First line to use for slope. * @param lineB Second line to use for slope. * @param options Optional IPathIntersectionOptions. * @returns point of intersection of the two slopes, or null if the slopes did not intersect. */ internal static Vector2?FromSlopeIntersection(Line lineA, Line lineB, out bool AreOverlapped, bool excludeTangents = false) { var slopeA = Slope.Of(lineA.P1, lineA.P2); var slopeB = Slope.Of(lineB.P1, lineB.P2); AreOverlapped = false; //see if slope are parallel if (Slope.AreParallel(slopeA, slopeB)) { if (Slope.AreEqual(slopeA, slopeB)) { //check for overlap AreOverlapped = Helper.IsLineOverlapping(lineA, lineB, excludeTangents); } return(null); } Vector2?pointOfIntersection = null; if (!slopeA.HasValue) { pointOfIntersection = verticalIntersectionPoint(lineA, slopeB); } else if (!slopeB.HasValue) { pointOfIntersection = verticalIntersectionPoint(lineB, slopeA); } else { // find intersection by line equation double x = (slopeB.YIntercept - slopeA.YIntercept) / (slopeA.Value - slopeB.Value); double y = slopeA.Value * x + slopeA.YIntercept; pointOfIntersection = new Vector2((double)x, (double)y); } return(pointOfIntersection); }