PDA

View Full Version : rotate an object



Ziggurat
03-24-2002, 08:56 AM
I am trying to rotate an object in two dimensions but i get the same results with angle = 45 and angle =-45. How can i do for rotate it??? my code is

glRotated(ang,1.0,1.0,0.0);

DFrey
03-24-2002, 09:54 AM
I am afraid you have not given enough information. What you have posted does not relate your problem, since a rotation of 45 degrees is different from one of -45 degrees. There is something else in your code that is wiping out the rotation after it has been done, or preventing the rotation from even occuring.

Jambolo
03-24-2002, 10:52 AM
Nothing wrong with what you posted.

glRotated( 45., 1., 1., 0. )
and
glRotated( -45., 1., 1., 0. )

should rotate differently. It must be something else.

Ziggurat
03-24-2002, 11:10 AM
Im sorry if i was not clear with my question. I am making a work for the college, i must make a class for drawing geometric objects. One of the methods is rotate. I am trying to rotate a point in 2 dimensions. I draw the point like this:

void Punto::dibujar()
{
glPointSize(2.0);
glBegin(GL_POINTS);
glVertex2f(cx,cy);
glEnd();
glFlush();
}

and i try to rotate it like this:

void Punto::rotar(float ang)
{
glRotatef(25.0f,1.0f,1.0f,0.0f);
}

but i cant make the point do a complete round to the center (0,0)

I only can rotate it between 0 and 90 degrees. Thanks and sorry for my english.

Jambolo
03-24-2002, 11:39 AM
I believe you are misunderstanding the parameters of glRotate.

The last three parameters are a vector that the rotation goes around. If you want to rotate in the XY plane, then you should rotate around the Z axis: glrotate(ang,0,0,1)

Ziggurat
03-24-2002, 11:41 AM
Thanks, i will try that.

Ziggurat
03-24-2002, 11:56 AM
Now i am geting a 90 degrees rotation when uses angle = 45. My point original position is (0.5,0.0) and after the rotation with ang = 45 i get the point in (0.0,0.5). Why is that???

Ziggurat
03-24-2002, 11:57 AM
Sorry, problem solved. Thanks for your help.