#### Archived

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

# Combining rotations using Quaternions

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

## 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 on other sites
quote:

MultQuaternions2(&tQ2, &tQ1, &endQ);

Just a guess... does MultQuaternions2( &a, &b, &c ) do c = a * b or a = b * c?

##### Share on other sites

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 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.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633345
• Total Posts
3011441
• ### Who's Online (See full list)

There are no registered users currently online

×