Rotation around him, but around the axis world

Hi, i’m back with my rotation problem

I would like to know, using glrotated and gltransled, how to make a cube, rotating on itself, but using the world axis, wich is not moving.

I tried a lot of thing, and i am desparate, ao help will be gratifuly welcome.

Assuming the cube is in model coordinates (centered around 0,0,0), then try the following:

glTranslatef(position in world space);
glRotatef(angle, axis);
<draw the cube>

Tanks for your help.

But this will not do exactly what i want.

Maybe i do not explain myself well.

Hum, my cube is at 10,10,10. I want it to rotate around itself (rotation point 10,10,10) but around the World Axis.

Umm, it sounds like you’re trying to rotate around two distinct and completely different coordinate systems.

Now, try to explain better:

Are you trying to rotate the cube around it’s center of gravity (so it spins), or are you trying to rotate the cube around the world’s center (so it rotates in an orbit)?

If you’re trying to do the former, you do what was said above by Korval. If you’re trying to do the latter, you leave out the glTranslate call.

Now, if I understand you right, it seems like you want to “spin” the cube about its center of gravity on an axis parallel to a given axis in the world. If this is the case, you do what Korval said above, substituting in the world’s axis for the rotation axis.

Those are the three possible things I can glean from what you are trying to say. I don’t know which one you mean exactly, so I hope I’ve covered all the cases. If not, please be more detailed.


Originally posted by sicklab:
Hum, my cube is at 10,10,10. I want it to rotate around itself (rotation point 10,10,10) but around the World Axis.

Yeah, after a bit of further thought, what was said above is correct for this statement.

glTranslatef(10, 10, -10);
glRotatef(angle, axisX, axisY, axisZ);

Just substitute the components of whatever you’re using for your “World Axis” in the axis components of the glRotatef call.

That should be what you want.


Ok, here we are

I made a WEB page, to let you visualize the problem. What is on my side, is calculated like the way you said, using something like that:

glTranslated(m_c3dOrg.x, m_c3dOrg.y, m_c3dOrg.z);

glRotated(m_nXRot, 1.0, 0.0, 0.0);
glRotated(m_nYRot, 0.0, 1.0, 0.0);
glRotated(m_nZRot, 0.0, 0.0, 1.0);

Loot at

And you’ll see very well what i means This is the difference beetwen my Own Software, and 3DS Max

Tanks again

Oh, this is a Euler-axis rotation problem. I think you’ll need to generate your rotations via quaternions. I don’t know much about them yet, but I’m pretty sure you can find all the information you need here if you do a search on quaternions.

I already do a search with the word “Rotation” with no luck.

I’ll try “quaternions” like you said

Maybe it will be better,


Umm, skip quats alltogether.

Just use matrix math. There’s several examples on this at You can do everything via simple linear algebra that quats do, only easier.


Maybe it’s a stupid question… but I’ll ask it anyway

Do you know that 3DStudioMAX and OpenGL uses different coordinate systems? the first is right-handed, with Z pointing backwards (out of the monitor)… well, maybe this is very basic stuff and you already know that, but it seems that in your page (the last 2 pictures) ‘your own’ box is rotating around the X axis… when the 3DS’s box do that in Z…

I hope this helps.

  • Royconejo.

[This message has been edited by royconejo (edited 03-24-2001).]

Yes you’r right.

This is just an error in my WEB page.

Tanks for the advice

I tried to use Quaternion as some of you told me. I pick up some fonction on GameDev to help me doing so.

First, i convert my Euler to a Quaternion.
Second, i convert my Quaternion, to a Matrix.
Tirth, i load this Matrix in OpenGL to make my transformation.

And it’s still not working.

I use those 2 function:

EulerToQuat(float roll, float pitch, float yaw, QUAT * quat)

QuatToMatrix(QUAT * quat, float m[4][4])

But no luck i guess. Whan am i doing wrong? it seems that no one really know how to do that kind of rotation like this one:

It’s driving me crazy.