# The wrong quarternion

## Recommended Posts

A flight model issue:

The space ship has orientation q1. The flight controls cause yaw y, pitch p and roll r which give q2 = Quaternion.FromYawPitchRoll(y,p,r).

A simple visual test applying just yaw to several randomly oriented spaceships made each space ship rotate around the world y axis regardless of orientation when using Quaternion.Concatenate(q1, q2).

So I've missed something - q2 is relative to world coordinates not the current orientation of the given spaceship.

I need to something to q2 so that it's relative to the space ships current orientation not the world axis, then apply it to q1 to get the new orientation.

Can someone supply the correct line of code or the operations I need to do to q1 and q2, please?

PS. Using XNA4.

##### Share on other sites
Try:
Quaternion.Concatenate(q2, q1).

##### Share on other sites
Several things:

Most importantly, thanks very much, it worked.

Secondly, I can't believe I didn't try that myself when I know the operation isn't commutative.

That'll teach me to code after midnight on a work day - too tired to think.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627714
• Total Posts
2978773

• 9
• 21
• 14
• 12
• 42