Reputation: 2922
I have a plane and I want to rotate it around the y axis. The planes coordinates are in:
Vec4f(-1,-1, -5, 1),
Vec4f( 1,-1, -5, 1),
Vec4f( 1, 1, -5, 1),
Vec4f(-1, 1, -5, 1),
I just want the plane to rotate, not go around in circles, so I translate it back to origin a then do the rotation:
glTranslatef(0,0,-5);
glRotatef(50.0*t, 0, 1, 0);
draw(plane);
But the plane still makes a circle around the origin. What am I doing wrong?
Upvotes: 1
Views: 464
Reputation: 162317
Transformations apply in the opposite order in which you multiply them, also you might want to translate back to where it came from. So change it like this:
translation = -5;
if(translate_back) glTranslatef(0,0,-translation);
glRotatef(50.0*t, 0, 1, 0);
glTranslatef(0,0,+translation);
Upvotes: 3