Assuming you are talking about line segments here (otherwise just compare the slopes of the lines: if they have unequal slopes, they intersect).
To find out if there is [one] intersection in a set of two or more line segments, you can use the Chamos-Hoi algorithm.
To find all the intersections in a set of two or more line segments, you can use the Bentley-Ottman algorithm.
Implementation of two and other βscan-basedβ algorithms is available in abundance on the Internet .
Bart kiers
source share