[Algorithms] Re: D3DXQuaternionRotationYawPitchRoll
Brought to you by:
vexxed72
From: Casey M. <gd...@fu...> - 2003-01-10 21:03:43
|
I don't really understand what all the fuss is about. Matrices and quaternions are interchangable so far as rotation is concerned. So why would anyone be building a matrix of euler angle rotations and then converting it to a quaternion? If you want Yaw * Pitch * Roll, then just build the quaternions and multiply them. This will do the exact same thing as compositing Yaw * Pitch * Roll matrices. Even the order is the same. This is the whole concept behind quaternions for rotation in the first place: they do the same thing as matrices. To be more explicit, you have P = [Sin(Pitch/2), 0, 0, Cos(Pitch/2)] Y = [0, Sin(Yaw/2), 0, Cos(Yaw/2)] R = [0, 0, Sin(Roll/2), Cos(Roll/2)] Q = YPR You can do this on the fly, or you can pre-compute what YPR is algebraicly, and make something that builds the four elements of Q directly from the input angles if you're concerned about the performance. If you want an alternate Euler angle ordering, then just change the order of multiplication. Also note that I have not implied a sign or a handedness or any of that here, and I arbitrarily chose the axes for each quantity to be expressed in (you could freely permute the variables if your axes are different). - Casey |