A sweep line algorithm for segments intersection, with OpenGL illustrating the result.