title: Testing whether a polygon is simple or complex
body: <p>For a polygon defined as a sequence of (x,y) points, how can I detect whether it is complex or not?  A complex polygon has intersections with itself, as shown:</p>
  
  <p><img src="https://i.stack.imgur.com/cZkiX.png" alt="example complex polygon image"></p>
  
  <p>Is there a better solution than checking every pair which would have a time complexity of O(N<sup>2</sup>)?</p>