# glTranslate / glScale/glRotate

This topic is 4762 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! I have a model I want to scale/rotate (around itself) and of course, translate. I use the glPushMatrix() and glPopMatrix() around the code to get a new matrix like: glPushMatrix() glLoadIdentity() glTranslate(...) glScale(...) glRotate(...) glBegin(...) ... ... ... glEnd() glPopMatrix() I get different result if I alter the way in which translate/scale/rotate are called. What is the "correct" order to call them in my case?

##### Share on other sites
Translate (to the position), rotate (around the center), scale (the scene).

##### Share on other sites
Matrix multiplications, which glTranslate/glRotate/glWhatever basically are, are not commutative, meaning that order of multiplication does matter. If A and B are matrices, then A*B != B*A.

Which order is correct depends entirely on what result you want. If you want the result as obtained by translating before rotating, then that is, obviously, the ocrrect order. There is no universal correct way of doing it, but there is a way of doing it that gives YOU the desired result for YOUR particular case.

Just remember that scaling and rotating always occur raltive the origin. Meaning, if you translate the object, it is no longer at the origin, and rotation and scaling will not do the "intuitive" thing. So what you're probably after is to scale first, then rotate, and last translate. That is, call them in the following order.
glTranslate(...);glRotate(...);glScale(...);

Hope i got that right [rolleyes].

##### Share on other sites
Well, there are no diffrence where to multiply current matrix by scale matrix. Only rotation/translation order makes sense.

##### Share on other sites
Of course it makes a difference where the scaling is put; it affects translation. It'll affect rotation, too, if it's a non-uniform scaling.

##### Share on other sites
Yes, it matters very much where you scale, just as much where you rotate and translate. If you scale a rotated coordinates system, scaling will occur along the world axes, which may not be the same as the local axes. Just like translation occurs along the world axes, which may, again, not be the same as the local axes.

##### Share on other sites
yah, forgot about non-uniform scaling

##### Share on other sites
It matters for uniform scaling too.

##### Share on other sites
PhiberOptic! this is Aeramor from pyrolight been trying to get in touch with you (sent Private message and an email) let me know whats going on want to catch up with u

##### Share on other sites
Thanks for all replys and hi Areamor! Long time no seen! I sent you a mail! :)

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631782
• Total Posts
3002325
×