• Advertisement

# glRotatef()

This topic is 3180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(90.0, 0.0, 0.0, 0.5); I use the above lines before I draw my object and it gets my object into the right position, but isn't it possible to do this with one line? I tried using glRotatef(90.0, 1.0, 0.0, 0.5) , but did not get the right result..

#### Share this post

##### Share on other sites
Advertisement
Yes, any combination of rotations can be expressed as a single axis-angle rotation. What you have is Euler angles, and what you want is an axis-angle pair. So search for "euler to axis angle" or something.

#### Share this post

##### Share on other sites
okay.. I'll look into that..

Just to be sure I'm on the right track here; I'm trying to build a hexagonal container.. first I draw a hexagon polygon then drawing the walls and rotating them into place.. is this the right approach? (just got the bottom and right wall for now, but wanted to be sure on the right track before I continue)
    glPushMatrix();        //bottom of the container        glColor3f(0.0,1.0,0.0);        glRotatef(90.0, 1.0, 0.0, 0.0);        glRotatef(90.0, 0.0, 0.0, 0.5);        glBegin(GL_POLYGON);            int i;            for(i = 0; i < 6; ++i)            {                glVertex2d(2*sin(i/6.0*2*PI),2*cos(i/6.0*2*PI));            }        glEnd();    glPopMatrix();    //back wall    glPushMatrix();        glColor3f(0.0,0.0,1.0);        glTranslatef(0.0, 1.0, -2.73);        glRotatef(90.0, 1.0, 0.0, 0.0);        glBegin(GL_POLYGON);            glVertex3f( 1.0, 1.0,-2.0);            glVertex3f(-1.0, 1.0,-2.0);            glVertex3f(-1.0, 1.0, 1.0);            glVertex3f( 1.0, 1.0, 1.0);        glEnd();    glPopMatrix();

#### Share this post

##### Share on other sites
You're not rotating walls... You're just setting the polygon vertex into right position... I'm not sure if you can do rotation with a single line...I know, that you can you matrix for that, but if you achieve in putting two rotations(along two different axes) into one, can it be done with three also?

#### Share this post

##### Share on other sites
Quote:
 Original post by CTPAX..., but if you achieve in putting two rotations(along two different axes) into one, can it be done with three also?

As stated; any combination of rotations can be expressed as a single axis-angle rotation.

#### Share this post

##### Share on other sites

• Advertisement