title: Offsets to create n-sided shape around starting point in Javascript
body: <p>I would like to find an function where, given a starting point (x, y) P, a radius r, and an integer n, I can generate offsets from P to create n well-placed points to create a shape (within a circle of radius r) around P.</p>
  
  <p>For example:</p>
  
  <pre class="lang-js prettyprint-override"><code>For P = {x: 0, y: 0}, r = 25.
  Where "offsets" is the return value of the desired function...
  Let n = 0:
      offsets = [];
  Let n = 1:
      // Note 25 here is simply P.x + r, where P.x = 0 for simplicity's sake.
      // So x: 25 is actually x: P.x + 25
      // And y: 0 is actually y: P.y + 0
      // I've kept the simplified notation here and below for readability.
      offsets = [{x: 25, y: 0}];
  Let n = 2: // Line
      offsets = [{x: 25, y: 0}, {x: -25, y: 0}];
  Let n = 3: // Triangle
      offsets = [{x: 25, y: 0}, {x: -25, y: 0}, {x: 0, y: 25}];
  Let n = 4: // Square
      offsets = [
        {x: 25, y: 0},
        {x: -25, y: 0},
        {x: 0, y: 25},
        {x: 0, y: -25}
      ];
  Let n = 5: // Pentagon
      offsets = [
        {x: 25, y: 0},
        {x: -25, y: 0},
        {x: 0, y: 25},
        {x: -12.5, y: -25},
        {x: 12.5, y: -25}
      ];
  </code></pre>
  
  <p>.... and so on.</p>