If two segments do not intersect, the minimum distance between them is at least one endpoint of the segment. Because of this, in your case it is enough to check if a pair of segments intersect or if any endpoint of a segment is next to another segment.
The first test is standard in the Bentley-Ottman algorithm, the second part can be performed by adding and removing a segment from the scan line. When a segment is added to SL (left endpoint), than enough to test segments on SL that are near the left endpoint and segments that end at a given distance from SL to left. Similarly, when a segment is removed from SL.
I think that because of the symmetry, this is enough to check only one side, for example. Adding a segment to SL.
Since endpoints are sorted, this search should be quick. If there is a certain guarantee that the segments are not dense relative to the tolerance, then this change does not change the time n log n original algorithm.
source share