#### Archived

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

# Moving Objects Per Yaw/Pitch/Roll

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

## Recommended Posts

Hello everyone, This is giving me a headache, I''m hoping someone can clarify. I have a model (A), it tracks Yaw, Pitch and Roll locally in its class. It also has a velocity, which is regularly updated based on speed changes etc. What I would like to know is this: How do I rotate the model based on its Yaw/Pitch/Roll (I can do this easily), BUT, how do I apply the velocity so that it always moves in the right direction in 3D space based on these values? I built a D3D camera class, and so I can fly around freely using the cursor keys and can rotate/yaw/move forward. I took a lot of this code out of the SDK, so the camera velocity, moves the camera forward with the Z value of the velocity vector, regardless of the angle the camera is at. I tried to take this over and do the same with models, so that when I change the Z value of its velocity, it moves through the world space based on its yaw/pitch/roll values? This would be very helpful, its giving me a headache. What am I missing? Warmest Regards to all, Goatie

##### Share on other sites
If you wish to move along the vector derived from your yaw, pitch, roll, then just create a yaw, pitch, roll rotation matrix, apply it to some standard forward vector (<0,0,1> or something similar), take the resulting vector, make sure it''s normalized, and move your object along that.

i.e. (in C#)

float velocity;
Vector3 Position;

Matrix rot = Matrix.RotationYawPitchRoll(yaw, pitch, roll)
Vector3 stdForward = new Vector3(0,0,1);
stdForward.TransformCoordinate(rot);
stdForward.Normalize();
Position += stdForward * velocity;

##### Share on other sites
Superlative! That fills in the blanks perfectly. Many thanks.

~ Goatie

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013740
×