I am writing an Asteroid clone and i got few problems and questions. So i though i would ask here for advices and comments.
Firstly, even if im planning on using quaternion to rotate my objets, im storing their orientation as a matrix. Im doing so since it seems easier to do lots of stuff, like transforming coordinates from world to local or simply getting a forward vector. Any thoughts about this, is this practice common or should i store the orientation as a quaternion?
Secondly, even if all seems to work as they should, i've got some kind of error in my rotation code. Im using this code snippet to turn the ship.
// Orientation is the Ship's Orientation store as a MatrixQuaternion q1 = Quaternion.CreateFromRotationMatrix(Orientation);Quaternion rot = Quaternion.CreateFromAxisAngle(Vector3.Up, 0.2f);Quaternion final = q1 * rot;Orientation = Matrix.CreateFromQuaternion(final);
Question: result seems the same if im swapping quaternion multiplication order (seems odd to me). Is this a normal behavior? From what ive red, no!
// in the above code, either of theses line are giving me the same result.// as if: q1 * rot = rot * q1final = q1 * rot;final2 = rot * q1;
Problem: I got a bug and it's really hard to reproduce it. Very rarely as im moving around the screen and turning the ship around. The ship go out of control and seems to zoom in/out or being tranlated up/down (instead of turning normally). I cant track the problem down, but im sure its has to do with the way im using thoses quaternion to rotate my objects.
Any comments or ideas are welcome...
Thanks you!