# XNA quanternion multiple axis

This is a discussion on XNA quanternion multiple axis within the C# Programming forums, part of the General Programming Boards category; Hey all, I'm working on a static camera class (for my own use, if I ever complete it and have ...

1. ## XNA quanternion multiple axis

Hey all, I'm working on a static camera class (for my own use, if I ever complete it and have it working ill post here) in XNA.

I made a working version using absolute vextors being rotated by matrices and keeping relative vecotrs for translations. What I didnt like is that I HAVE TO use the standard XYZ axis for rotation.

What I decided to do was use quanternions to store current rotation,cthen buffer rotations each time some were done and add it up.

The way I see it, it should look somewhat like this:
(in the UpdateRotation part, plz dont mind any typos i make, this isnt the actual current code. Also on a small note I use dictionaries, so dont be surprised xD)
Code:
```RelativeVectors["Up"] = Vector3.Transform(AbsoluteVectors["Up"], (Quanterion)CurrentRotation);
//repeat for Look and Right relative vectors
Quanternion Yaw = Quanternion.CreateFromAxisAngle(RelativeVectors["Up"], RotationBuffer["Yaw"]);
//repeat for roll and pitch
CurrentRotation = Quanternion.Contancate(CurrentRotation,(Yaw*Pitch*Roll));
//clear the rotation buffer```
Whats happening right now tho, is that doing this exactly doesnt actually do anything, so I have to use standard axis anyway. If you need I can copy the whole class into here, but that may not be necessary xD, i hope.

2. Ok all, I managed to find the answer myself!
Seems that quaternion multiplications work differently then Matrix ones. So I did the combining in matrices then retransformed it. Here is the final content of the UpdateRotation() function:
Code:
```Quaternion Yaw;
Quaternion Pitch;
Quaternion Roll;
RelativeVectors["Look"] = Vector3.Transform(AbsoluteVectors["Look"], Matrix.CreateFromQuaternion(CameraRotation));
RelativeVectors["Up"] = Vector3.Transform(AbsoluteVectors["Up"], Matrix.CreateFromQuaternion(CameraRotation));
RelativeVectors["Right"] = Vector3.Transform(AbsoluteVectors["Right"], Matrix.CreateFromQuaternion(CameraRotation));