intersections method
Returns an empty list if there is no intersection If the lines are concurrent it returns one point in the list. If they coincide it returns an empty list as well
Implementation
List<Vector2> intersections(Line otherLine) {
final determinant = a * otherLine.b - otherLine.a * b;
if (determinant == 0) {
//The lines are parallel (potentially coincides) and have no intersection
return [];
}
return [
Vector2(
(otherLine.b * c - b * otherLine.c) / determinant,
(a * otherLine.c - otherLine.a * c) / determinant,
),
];
}