Jump to content
  • Advertisement
Sign in to follow this  

Working with Yaw-Pitch-Roll

This topic is 4907 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

Just don't do it - work internally with quaternions or 3x3 matrices. If you need to present yaw/pitch/roll to the user, then convert (not difficult).

Share this post

Link to post
Share on other sites
ok, i think i got a little confused :) i don't want to use any angles, except when creating the rotation matrices...
so i need to use quaternions, not euler angles?

Share this post

Link to post
Share on other sites
What you want to to is calculating the composition of three matrices

M_yaw * (M_roll * M_pitch)

the order could be different. And it is how you define yaw, pitch and roll which all correspond to rotations about x,y,z correspondingly.

So how could this be done? I will do the first matrix (yaw) and you can figure out the rest. so lets create M_yaw.

We look at how the basis e_x = (1,0,0)^T, ..., e_z = (0,0,1)^T transforms which is very easy:

M_x * e_x = e_x
M_x * e_y = (cos v * e_y) + (sin v * e_z)
M_x * e_z = (-sin v *e_y) + (cos v * e_z)

(tip: draw a picture..)

But now we know the matrix M_x since M_x * e_x = first column, M_x * e_y = second column and M_x * e_z = third column (very nice way of calculating a matrix if you are not used to it, just find how the standard basis is transformed).

Your M_x is then:
M_x = [1 0 0 0; 0 cosv sinv; 0 -sinv cosv]

(rotation is counter clockwise, just transform v' = -v to get it clockwise)

Doing this also for roll and pitch and finally calculating the composition (given above) gives you the final rotation matirx.

The reason why everyone is talking about quaternions is that they have some advantages in 1) memory efficiency 2) no gimbal lock 3) nice and very fast for doing spherical interpolation.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!