title: Finding Overlapping Line segments in 2D
body: <pre><code>point a  = [1,0]   
  point b  = [3,0]
  point c  = [3,3]
  point b' = [3,0]
  </code></pre>
  
  <p>Joining these points would give the line path
  <strong>a->b->c&lt;-b'</strong>
  There is an overlap between b to c and back to b` to c.
  I want to find all the overlapping paths.</p>
  
  <p><strong>The problem I'm trying to solve is to identify these overlapping lines and draw them as curve lines so that user can distinguish them.</strong> </p>
  
  <p><strong>case 1</strong></p>
  
  <pre><code>a = [1,0]
  b = [5, 0]
  c = [3, 0]
  </code></pre>
  
  <p>there is an overlap but user can clearly see the overlap, so i ignore this overlap.</p>
  
  <p><strong>case 2</strong></p>
  
  <pre><code>a = [3,0]
  b = [5, 0]
  c = [1, 0]
  </code></pre>
  
  <p>Here if I draw straight line a-b path will be hidden. So in this case draw a curve line.</p>
  
  <p><a href="https://i.stack.imgur.com/SbwE1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SbwE1.png" alt="enter image description here"></a>
  I have implemented the code by considering each N^2 combination of line and comparing their start and end lat long.</p>
  
  <pre><code>line AB = [ [1,0], [3,0]]
  line BC = [ [3,0], [3,3]]
  (AB == BC || AB == flip(BC))
  </code></pre>
  
  <p>Below are the code links</p>
  
  <p><a href="http://jsbin.com/qibarevodi/edit?js,console" rel="nofollow noreferrer">http://jsbin.com/qibarevodi/edit?js,console</a></p>
  
  <p><a href="http://bl.ocks.org/d/d21a0d3e6df2cd4bb08fbe2a6e66ceb8" rel="nofollow noreferrer">http://bl.ocks.org/d/d21a0d3e6df2cd4bb08fbe2a6e66ceb8</a></p>
  
  <p>Is there more efficient way to find the overlapping lines.</p>