How to find whether two lines intersect