rotating object

Show 40 post(s) from this thread on one page
Page 2 of 2 First 12
• 07-18-2013, 06:38 AM
GClements
Quote:

Originally Posted by pbivens
so how do I adjust the angle variable.

Have keys for "rotate right" and "rotate left". Pressing one causes the angle to increase at a fixed rate, pressing the other causes it to decrease at a fixed rate.
• 07-18-2013, 06:25 PM
pbivens
here is the code I am using
Code :

```void ship_left_two() { angle+=2.5f; }   void ship_right_two() { angle-=2.5f; }```
here is the drawing code
Code :

```void DrawShip(GLfloat position_X,GLfloat position_Y, GLfloat position_Z, GLfloat rotation,GLfloat color) { glPushMatrix(); double magnitude = sqrt(position_X * position_X + position_Y * position_Y); double angle = atan2(position_Y,position_X); position_X = magnitude * cos(angle); position_Y = magnitude * sin(angle); // double acceleration = sqrt(position_X * position_X + position_Y * position_Y); // double angle = atan2(position_Y,position_X); // position_X = acceleration * cos(angle); // position_Y = acceleration * sin(angle); // position_X = speed_X; // position_Y = speed_Y; // glRotatef(rotation,0.0f,0.0f,1.0f); glTranslatef(position_X, position_Y, position_Z); glColor3f(color,0.0f,0.0f); glBegin(GL_LINE_LOOP); glVertex3f(0.0f,-0.25f,0.0f); glVertex3f(-0.25f,-0.5f,0.0f); glVertex3f(-0.5f,-0.5f,0.0f); glVertex3f(0.0f,0.5f,0.0f); glVertex3f(0.5f,-0.5f,0.0f); glVertex3f(0.25f,-0.5f,0.0f); glVertex3f(0.0f,-0.25f,0.0f); glEnd(); glPopMatrix(); }```
I am still a little confused
• 07-19-2013, 03:03 AM
GClements
Quote:

Originally Posted by pbivens
here is the drawing code
Code :

``` double magnitude = sqrt(position_X * position_X + position_Y * position_Y); double angle = atan2(position_Y,position_X); position_X = magnitude * cos(angle); position_Y = magnitude * sin(angle);```

This doesn't belong here. The drawing code in your first post was fine.

The issue is how you obtain the position which you pass to the drawing function.
• 07-19-2013, 12:35 PM
pbivens