# Yaw + Pitch Object Rotations

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

## Recommended Posts

I'm having trouble getting the correct rotations out of my object. I have a yaw and a pitch for the object. When the user presses up, down, left, and right, the object is supposed to rotate about its current local axis. The pitch is always correct, but the object rotates about its initial yaw axis... which I don't want to do. How do I solve this? I'm using two calculations: One, on input, the yaw and pitch are set in vectors: yaw +/- (.1,0,0) pitch +/- (0,0.1) Then I use a directX (I've also tried manually using axes, to no avail) yaw/pitch/roll matrix function (ignore the pitch to roll thing...): D3DXMatrixRawPitchRoll( yaw, 0, pitch); Again, any help would be much appreciated. Thanks.

##### Share on other sites
Save the current yaw/pitch in a Matrix, and constantly multiply a new YawPitch matrix by it.

Ex.

D3DXMatrix m_RotationMatrix...yaw +/- (.1,0,0)pitch +/- (0,0.1)D3DXMatrix rot = D3DXMatrixYawPitchRoll( yaw, pitch, 0 );m_RotationMatrix = m_RotationMatrix * rot;...D3DSetWorldMatrix( &m_RotationMatrix );

The functions might not all be correct, but you get the idea.

I think that's what you're looking for. If not, i tried :).

##### Share on other sites
No, that's not quite what I'm looking for.

Let me see if I can explain this more clearly. What I want is a rotation about the y axis followed by a rotation about the NEW z axis. That is:

If rotation by theta about the y axis results in the new coordinate system i,j,k, then I want to rotate the object by theta degrees about y, followed by iota degrees about k.

What I'm currently getting is a rotation about y followed by a rotation about z.

Here's an image of my problem:

[Edited by - RealmRPGer on November 19, 2006 12:04:22 AM]

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013555
×