title: Algorithm to divide self intersecting polygon
body: <p>First I know there is similar question already asked, but it uses different structure and is in C (<a href="https://stackoverflow.com/questions/4115853/divide-self-intersecting-polygon-c-code?rq=1">Divide self intersecting polygon (C Code)</a>) , my question is a little different.</p>
  
  <p>I have points of self-intersecting polygon, its edges and also I am able to find points where it intersects itself using Bentley–Ottmann algorithm.</p>
  
  <p>I planned to build non-self intersecting polygons by editing edges around intersection points, but problem is when you have two edges that intersect, you don't know which two of the four sides are inside, and which are outside of polygon. </p>
  
  <p>I could use ray crossing algorithm to resolve this, but it is too slow. Its time complexity is  O(n), and I'd have two do it at least two times for every intersection point. So it would be extremely slow with around 200k points of polygon.</p>
  
  <p>So what I'm asking is, is there any faster way to divide self intersecting polygon into non-self intersecting ones.</p>
  
  <p>I need this because I am doing polygon triangulation. I already done sweep-line triangulation algorithm for triangulating non-self intersecting polygons with holes. So I just need tho have array of these polygons as input.</p>