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

## Recommended Posts

i've searched the articles archive with no luck... can anyone direct me to one about the subject?

##### Share on other sites
Do a search for Euler angles.

##### Share on other sites
Thanks, but still no luck... only aticles about quaternines...

##### Share on other sites
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 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 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).

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.

Regards

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002141
×