public static bool LinepieceIntersectWithLine(Linepiece l1, Line l2, out Vector2 intersection) { intersection = Vector2.zero; if (LinesIntersect(l1, l2, out intersection)) { return(l1.ContainsPoint(intersection)); } return(false); }
public static bool LinepiecesIntersect(Linepiece l1, Linepiece l2, out Vector2 intersection) { intersection = Vector2.zero; // There is one (unlikely) edge case: two equidirectional linepieces that overlap // LinesIntersect will return a random point on either line as the intersection point // This point might not lie on both linepieces // This could result in a false evaluation, while the linepieces do overlap if (LinesIntersect(l1, l2, out intersection)) { return(l1.ContainsPoint(intersection) && l2.ContainsPoint(intersection)); } return(false); }