So this is the result of me working 3 weeks to make this algorithm to work, just to discover that it is only more efficient than the bruteforce method after 200 random generated segment lines are used and sometimes even worst.
https://en.wikipedia.org/wiki/Bentley...
The Bentley-Ottmann algorithm finds intersection by sweeping the lines and finding its starting points and ending points and analyzing the neighbour's segments to see if there are intersections.
For this particular setup, there are 50 lines, 213 intersections found, and 313 events occurred (startpoint|endpoints|intersections).
The implementation is pretty general and can be used with Java stand alone, but not to spoil anything, this implementation is also defective and cannot handle very dense payloads of segments. More details on GitHub.
Song: Avant Jazz, Disco Ultralounge - Kevin MacLeod
Done in processing and available on GitHub:
Source code: https://github.com/volfegan/Geometric...