title: Draw a polygon in C
body: <p>i need to draw a polygon of "n" sides given 2 points (the center and 1 of his vertex) just that i suck in math. I have been reading a lot and all this is what i have been able to figure it (i dont know if it is correct):</p>
  
  <p>Ok, i take the distance between the 2 points (radius) with the theorem of Pythagoras:</p>
  
  <pre><code>sqrt(pow(abs(x - xc), 2) + pow(abs(y - yc), 2));
  </code></pre>
  
  <p>And the angle between this 2 points with atan2, like this:</p>
  
  <pre><code>atan2(abs(y - yc), abs(x - xc));
  </code></pre>
  
  <p>Where xc, yc is the center point and x, y is the only vertex know.</p>
  
  <p>And with that data i do:</p>
  
  <pre><code>void polygon(int xc, int yc, int radius, double angle, int sides)
  {
      int i;
      double ang = 360/sides; //Every vertex is about "ang" degrees from each other
      radian = 180/M_PI;
      int points_x[7]; //Here i store the calculated vertexs
      int points_y[7]; //Here i store the calculated vertexs
  
      /*Here i calculate the vertexs of the polygon*/
      for(i=0; i&lt;sides; i++)
      {
          points_x[i] = xc + ceil(radius * cos(angle/radian));
          points_y[i] = yc + ceil(radius * sin(angle/radian));
          angle = angle+ang;
      }
  
      /*Here i draw the polygon with the know vertexs just calculated*/
      for(i=0; i&lt;sides-1; i++)
          line(points_x[i], points_y[i], points_x[i+1], points_y[i+1]);
      line(points_y[i], points_x[i], points_x[0], points_y[0]);
  }
  </code></pre>
  
  <p>The problem is that the program dont work correctly because it draw the lines not like a polygon.</p>
  
  <p>Someone how know enough of math to give a hand? im working in this graphics primitives with C and turbo C.</p>
  
  <hr>
  
  <p>Edit: i dont want to fill the polygon, just draw it.</p>