0

So I managed to rotate my object using quaternion around its local coordinate system. This is the order of my code: -I created a unit quaternion -I got the transformation matrix -I used glMultMatrix to perform the rotation -I draw the object -I draw the frame which is the object frame When I set the value of the quaternion on : w=0.7, x=0, y=0.7, z=0, the object rotates around its Y axis, but also the X and Z axis rotate.

The problem I'm facing right now is that when I use glRotated to change the axes direction for example glRotated(-90.0f,0.0f,1.0f,0.0f) before drawing the frame so in this case we have x becomes z and z becomes -x, and then compile and set the value of the quaternion as follows: w=0.7, x=0.7,y=0,z=0, the object is supposed to rotate around the new x axis which direction was changed using glRotated but actually it rotates around the old x axis which has the same direction as the new z axis. It looks like it is rotating around the Z axis. Any idea how to fix that ? I wanted to rotate my object around this new frame but it keeps rotating around, I think, the old one. Also is it possible to make the object rotate with its local coordinate system around a fixed frame or a global coordinate system ?

Rabbid76
  • 177,135
  • 25
  • 101
  • 146
  • that is because in old api OpenGL native notation those functions you use on direct matrices mean global transform and on inverted means local transform and as ModelView combines both direct Model matrix and Inverse View matrix it depends on order which type of transform you got... but you can not switch from one to other so the only way is use inverse of matrix transform and inverse back... see [Understanding 4x4 homogenous transform matrices](https://stackoverflow.com/a/28084380/2521214) ... also beware `glRotated` is not [quaternion](https://en.wikipedia.org/wiki/Quaternion) !!!! – Spektre Mar 08 '22 at 09:06

0 Answers0