title: Divide up a rectangle based on pairs of points
body: <p><a href="http://xthlegion.co.uk/images/dividerectangle.png" rel="nofollow noreferrer">Example http://xthlegion.co.uk/images/dividerectangle.png</a>
  <a href="http://xthlegion.co.uk/images/dividerectangle2.png" rel="nofollow noreferrer">Example http://xthlegion.co.uk/images/dividerectangle2.png</a></p>
  
  <p>If you consider the images above, you can see they are comprised of a single large rectangle broken down into smaller rectangles by pairs of user defined coordinates (each pair in the example images are identified with a different color). </p>
  
  <p>What I'm trying to do is obtain the co-ordinates of those rectangles by only defining the joins. Edges are treated as explicit joins. Order doesn't matter.</p>
  
  <p>Does anyone know the name of the algorithm that does this (I'm sure there's one with a fancy name!) or have some example C# code? I've been struggling trying to do this myself for a while now but am having little success. Yet another total math fail!</p>
  
  <p><strong>Update:</strong><br>
  Just thought I'd quickly update this question based on the comments I've received.</p>
  
  <ol>
  <li>Lines must be straight, so each pair of co-ordinates will align on one axis</li>
  <li>Co-ordinates must start from either an edge, or the intersection of another pair. The second co-ordinate must end in a similar fashion. Any "orphan" co-ordinates which don't start/end one another join are illegal and I should ignore them for now, snapping should be possible once I finally get my head in gear.</li>
  <li>Although in this example all the pairs more or less neatly divide the rectangle, this will not be the case in practice and there could be many lines creating rectangles of many sizes.</li>
  </ol>
  
  <p><strong>2nd Update - it works :)</strong><br>
  <a href="http://xthlegion.co.uk/images/dividerectangle3.png" rel="nofollow noreferrer">Example http://xthlegion.co.uk/images/dividerectangle3.png</a></p>