N-dependent Radius?

Can anyone find the error?

I’ve been trying to make a function that draws a spiral based on the following parameter:

void spiral(int N, float radius, flat step);

The problem I’m having is that I want to be able to control the size of the spiral by mean of the radius. At this moment I can’t see why the figure gets bigger as I increment the N.

void spiral(int N, float radius, flat step){
float currRad = step;
float angle = 360.0 / N;
float currAngle = 0.0;
float prevX = currRad, prevY = 0;
float currX = 0, currY = 0;
glBegin(GL_LINES);
for(; currRad < rad; currRad += step){
currAngle += angle;
currX = prevX + currRadcos( PIcurrAngle / 180.0);
currY = prevY + currRadsin( PIcurrAngle / 180.0);
glVertex2f(prevX, prevY);
glVertex2f(currX, currY);
prevX = currX;
prevY = currY;
}
glEnd();
}

Ok what is the part of the math I’m missing here?

A larger N value means that a circle needs more steps to complete, at same time the radius increases with a constant value each step. Thus, larger N = more steps = larger radius.

Leif…

The points on a circle are defined in polar coordinates, r = radius, theta = angle. and in rectangular coordinates <radiuscos(angle), radiussin(angle)>.

A parametric polar definition of a spiral, in terms of t, is r = sizet, theta = phaset. And converting to rectangular coordinates we get <sizetcos(phaset), sizetsin(phaset)> for exact coordinates.


void DrawSpiral(int subdivision, float size, float phase)
{
  glBegin(GL_LINE_STRIP);
  while(subdivision--)
  {
    glVertex2f( size * sudivision * cos(phase * subdivision), size * sudivision * sin(phase * sudivision));
  }
  glEnd();
}