Archived

This topic is now archived and is closed to further replies.

Combining rotations using Quaternions

This topic is 5308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am trying to combine two individual rotations into a single quaternion. The first rotation is the user''s pitch, and the second is the user''s yaw. The pitch is locked, but the yaw changes depending on the user''s input. I convert the pitch and yaw into quaternions and then combine them through multiplication, as shown here: tVector tVec1, tVec2; tQuaternion tQ1, tQ2, endQ; tVec1.x = 90; tVec1.y = 0; tVec1.z = 0; tVec2.x = 0; tVec2.y = heading; tVec2.z = 0; EulerToQuaternion(&tVec1, &tQ1); EulerToQuaternion(&tVec2, &tQ2); MultQuaternions2(&tQ2, &tQ1, &endQ); The resulting quaternion gives me the correct pitch, but the yaw has no effect, as if it is being totally ignored. I know this isn''t much information to go on, but does anybody have any ideas what''s going on? Thanks in advance.

Share this post


Link to post
Share on other sites
Thanks for replying!

MultQuaternions2( &a, &b, &c ) does c = b * a

I''ve played around with changing the order of a and b. I should really try and figure out what is going on rather than just using trial and error.

Am I on the right track at all though? My understanding is:

Step 1: Setup vectors a and b
Step 2: Convert to quaternions
Step 3: Multiply to combine rotations
Step 4: Convert back to matrix, euler angles whatever...

Share this post


Link to post
Share on other sites
Since you state the problem as "the yaw has no effect, as if it is being totally ignored", there are very few possibilities. Here are all that I can think of. If none of these are the problem, then perhaps this code is working correctly and the problem is somewhere else.

1. The angles should be in radians, not degrees.
2. The value for "heading" is not changing.
2. The parameters for EulerToQuaternion are in the wrong order.
3. EulerToQuaternion is broken or doesn''t work the way you think it does.
4. The parameters for MultQuaternions2 are in the wrong order.
5. MultQuaternions2 is broken or doesn''t work the way you think it does.

Share this post


Link to post
Share on other sites