title: Why is cosine used to calculate the x values and sine the y values for an arc?
body: <p>I'm trying to understand the math on this raphael.js demo:</p>
  
  <p><a href="http://raphaeljs.com/pie.js" rel="noreferrer">http://raphaeljs.com/pie.js</a></p>
  
  <p>Checkout the sector method:</p>
  
  <pre><code>function sector(cx, cy, r, startAngle, endAngle, params) {
      var x1 = cx + r * Math.cos(-startAngle * rad),
          x2 = cx + r * Math.cos(-endAngle * rad),
          y1 = cy + r * Math.sin(-startAngle * rad),
          y2 = cy + r * Math.sin(-endAngle * rad);
      return paper.path(["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle &gt; 180), 0, x2, y2, "z"]).attr(params);
  }
  </code></pre>
  
  <p>This is the actual demo:
  <a href="http://raphaeljs.com/pie.html" rel="noreferrer">http://raphaeljs.com/pie.html</a></p>
  
  <p>My math is a little rusty and I'm trying to understand the sector function - given the startAngle and endAngle parameters (each start and end point values between 0 and 360 drawing an arc), why does this function work?</p>