title: Computing best-fit polygon from shape given number of target sides (or edges)
body: <p>I have an arbitrary shape, drawn by the user on a canvas, and I would like to compute the best-fit polygon from that shape given the number of sides or edges the output polygon should have. Specifically, I would like a function with the following signature:</p>
  
  <pre><code>polygon computePolygon(Shape shape, int numberOfSides)
   {
    ...
    return polygon; // return polygon with numberOfSides sides
   }
  </code></pre>
  
  <p>For instance, let's say I want to obtain a quadrilateral from the shape drawn by the user (say a GeneralPath), then I would input computePolygon(generalPath, 4).</p>
  
  <p>How would I go about this ?</p>