title: Matlab - Trace contour line between two different points
body: <p>I have a set of points represented as a 2 row by n column matrix.
  These points make up a connected boundary or edge. I require a function that traces this contour from a start point P1 and stop at an end point P2. It also needs to be able trace the contour in a clockwise or anti-clockwise direction. I was wondering if this can be achieved by using some of Matlab's functions.</p>
  
  <p>I have tried to write my own function but this was riddled with bugs and I have also tried using <code>bwtraceboundary</code> and indexing however this has problematic results as the points within the matrix are not in the order that create the contour.</p>
  
  <p>Thank you in advance for any help.</p>
  
  <p>Btw, I have included a link to a plot of the set of points. It is half the outline of a hand.</p>
  
  <p>The function would ideally trace the contour from ether the red star to the green triangle. Returning the points in order of traversal.</p>
  
  <p>EDIT: This is perhaps a work around to a larger problem I am trying to solve but would it be possible to test if a point on the blue boundary edge is connected to the contour that is between either the red stars or green triangular points. </p>
  
  <p>i.e. for a point on the blue boundary, if you were to trace the contour by hand from the left red asterixs to the green triangle the function would return true if the point is on the connected boundary between the two points and false otherwise.</p>
  
  <p><a href="http://img717.imageshack.us/img717/9814/hand1.png" rel="nofollow noreferrer">alt text http://img717.imageshack.us/img717/9814/hand1.png</a></p>