I've implemented the Bentley-Ottmann algorithm and also handled the edge cases mentioned here: http://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm#Special_position_and_numerical_precision_issues.
However, it still doesn't work with all line segments, for example with this one, where only the left intersection is found, but not the second (first 2 lines to the left are inverted in sweep lines dictionary when the first intersection is extracted as event from event priority queue):
Or in a bit complicated case, where still only the first intersection from left is recognized:
What should I add to the algorithm or change it to also take into consideration this kind of a case (and of course maintain its O(n log n) complexity)?
EDIT: Another "dirty" example, this time no intersections are found:
EDIT 2: See algorithm pseudo code and simulation here from page 28 onwards: http://www-ma2.upc.es/vera/wp-content/uploads/2012/10/intersection-of-segments.pdf