PDA

View Full Version : Circle rotation



saibot
06-10-2010, 11:11 AM
I'm stuck at circular motion
I mean how do I rotate a point like a wheel?
I tried to rotate whit

glRotatef(angle,cos(angle),sin(angle),0.0) but is rotating like an atom and only at the end for 1 sec is rotating like I want to be

I discovered now how

You only need to change angle to 180:
glRotatef(180,cos(angle),sin(angle),0.0)

rewolfer
06-13-2010, 04:03 AM
You seem to be using glRotatef incorrectly. The last three parameters are used to specify the axis around which you rotate. For wheel-like spinning behaviour, this axis should surely not depend on the angle. For a wheel rotating on the horizontal plane, you'd used a vertical axis
glRotatef(angle, .0f, 1.0f, .0f);

Rotating on the x=c plane, you'd use the x-axis
glRotatef(angle, 1.0f, .0f, .0f);

If you had a wheel that could turn left and right with the steering wheel for example, you could perform two rotations: one for the point on the wheel, and one for the axis of the wheel.

glRotatef(wheelTurnAngle, .0f, 1.0f, .0f);
glRotatef(angle, 1.0f, .0f, .0f);
// draw vertex