Q:

Rotating in glutIdleFunc within a specified range

Let's say I have this glutIdleFunc going in the background of an OpenGL scene containing a little creature with multiple, radially arranged legs that "pulsate":
 void PulsateLegs(void)
 {
   lowerLegsRot = (lowerLegsRot + 1)%360;
   glutPostRedisplay();
 }

...where the lowerLegsRot value is used like this in the display function:
 glRotatef((GLfloat)lowerLegsRot, 1.0, 0.0, 0.0);

It's hard to visualize without seeing what the little fellow actually looks like, but it's clear that this function is making the legs spin all the way around repeatedly. I want to limit this spin to a certain range (say, -15 to 50 degrees), and, furthermore, to make the legs go back and forth within the range, like a pendulum. 
Since I'm going for a 65 degree swath, I tried just changing "%360" to "%65" as a first step. But this made the legs go way too fast, and I cannot use a lower increment value if I want to use modulus, which only works on ints. 
Is there another way to achieve the desired first-step behavior? More importantly, how can I make the legs go back and forth? It's kind of hard to conceptualize with a function that is getting called multiple times (vs. just using a loop structure that takes care of everything, which I tried before I realized this!) 

A:

and I cannot use a lower increment value if I want to use modulus, which only works on ints.

The % operator is broken anyway. You should not use integers, but floats, and use the fmod (double) or fmodf (float) function.

