getLineIntersectionHorizontal static method
Finds the intersection point of two line segments whereas the second line segment is horizontal. This is a method which may be faster than the generic one in the case when the first line is above or below the second line.
Implementation
static ILatLong? getLineIntersectionHorizontal(ILatLong line1Start, ILatLong line1End, ILatLong line2Start, ILatLong line2End) {
final y1 = line1Start.latitude;
final y2 = line1End.latitude;
final y3 = line2Start.latitude;
// first lines is below or above the second line
if (y1 > y3 && y2 > y3) return null;
if (y1 < y3 && y2 < y3) return null;
return getLineIntersection(line1Start, line1End, line2Start, line2End);
}