Click to See Complete Forum and Search --> : rotation in OpenGL?


himageofxidian
June 10th, 2004, 05:59 AM
Hi guys:
In OpenGL, I can rotate using the function glRotate(angle,x,y,z),
but the vector or line (x,y,z) is from the origin. How can i rotate around
arbitrary axis(or line, e,g some line parallels x axis).

himageofxidian

wien
June 11th, 2004, 04:28 PM
First translate to the position you shoud rotate around, and then rotate:
glTranslatef(-3.0f, 0.0f, 0.0f);
glRotate(45.0f, 1.0f, 0.0f, 0.0f);

himageofxidian
June 12th, 2004, 11:04 PM
Thank you Wien, but if I don't translate the coordinates ,How can I do this :confused: :confused:

wien
June 14th, 2004, 07:56 PM
That's the whole point.. You can't. To rotate around anything else than [0,0,0], you need to translate first.