2 Rotations at the same time

Hi all,

i would like to perform two rotations at the same time. I tried:



Quaternion q = new Quaternion();
q.fromfromAngleAxis((float)Math.toRadians(90), new Vector3f(1, 0, 0));
q.fromfromAngleAxis((float)Math.toRadians(180), new Vector3f(0, 0, 1));

ship.setLocalRotation(q);



but the only rotation that was done was the last.
so I tried this:


Quaternion q = new Quaternion();
Quaternion q2 = new Quaternion();

q.add(q2);

ship.setLocalRotation(q);



but that didn't work either. Any suggestions?

try multiplying.

aaah, but why multiplying? cant we just have a stack of rotations? and every call of fromAngleAxis adds to that stack?



because im currently having to make 2 Quaternions, which is unnecessary and then multiplying them together to get the final quaternion. There must be a better way.



Is there?

aaah, but why multiplying?


Because that's how quaternions work.

cant we just have a stack of rotations? and every call of fromAngleAxis adds to that stack?


no, quaternion is an absolute rotation, not relative. That would make absolutely (heheh) no sense.

because im currently having to make 2 Quaternions, which is unnecessary


It is necessary.

and then multiplying them together to get the final quaternion. There must be a better way.


not if you want smooth rotations there isn't.

multiplying can be pretty tough, but I know you have it in ya! :wink:

hehe, already made a class funnily enough called "QuaternionStack" which adds quaternions to a stack and when you call "getRotation()" it returns all the quaternions in the stack multiplied together.



Thx mojomonk for clearing that mishap in my knowledge up, and thx renanse for the boost!