Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotation + Translation problem

Started by MrDoomMaster Oct 17, 2005 at 6:22 PM 5 replies 650+ views
Original Post
MrDoomMaster
MrDoomMaster
I want to first rotate an object and then translate it. This is a problem because once the object is rotated, it becomes horribly difficult to translate the object because not only the OBJECT rotated but the coordinate system has as well. Any way to solve this problem? I want to rotate my object and then translate it without the translation part getting distorted.
Zakwayda
Zakwayda
You probably have your order of operations switched around. Remember that because OpenGL uses column vectors, a rotation followed by a translation is actually:
glTranslate(...);glRotate(...);
MrDoomMaster
MrDoomMaster
That won't work, will it? If you translate first, you move the object. If you rotate after this, the object will then rotate AROUND the origin.

For example,

suppose I translate an object to (3, 0, 0). If I rotate after the translation around the Y axis by 90 degree,s the object will then be at (0, 0, 3).

Correct me if I'm wrong.
Thunder_Hawk
Thunder_Hawk
Quote:
Original post by MrDoomMaster
That won't work, will it? If you translate first, you move the object. If you rotate after this, the object will then rotate AROUND the origin.

For example,

suppose I translate an object to (3, 0, 0). If I rotate after the translation around the Y axis by 90 degree,s the object will then be at (0, 0, 3).

Correct me if I'm wrong.


Translating to (3, 0, 0) esentially makes (3, 0, 0) the origin for any vector. What makes you think that it should do any different for a rotation? Try it, it works...
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Forma
Zakwayda
Zakwayda
Quote:
That won't work, will it? If you translate first, you move the object.
That's just it - you're not translating first, you're rotating first. The sequence:
glTranslate(...);glRotate(...);
First rotates, then translates, which I believe is what you want.
MrDoomMaster
MrDoomMaster
Ah okay thanks guys. I think I'm a bit too used to DirectX.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.