public static bool IntersectionFactor (Vector2 start1, Vector2 dir1, Vector2 start2, Vector2 dir2, out float factor) {
float den = dir2.y*dir1.x - dir2.x * dir1.y;
// Parallel
if (den == 0) {
factor = 0;
return false;
}
float nom = dir2.x*(start1.y-start2.y)- dir2.y*(start1.x-start2.x);
factor = nom/den;
return true;
}
}