# Yaw rotation.

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

## Recommended Posts

Hey. I have been reading the following article: http://www.gamedev.net/reference/articles/article790.asp and i understand most of it except: x'=z*sin(yaw)+x*cos(yaw) y'=y z'=z*cos(yaw)-x*sin(yaw) x"=x' y"=y'*cos(pitch)-z'*sin(pitch) z"=y'*sin(pitch)+z'*cos(pitch) x"'=y"*sin(roll)+x"*cos(roll) y"'=y"*cos(roll)-x"*sin(roll) z"'=z" I was wondering if somone can explain the concept of rotation of one of the plains. x'=z*sin(yaw)+x*cos(yaw) y'=y z'=z*cos(yaw)-x*sin(yaw) I understand why the y in kept the same but why is x calcualated as it is? I am trying to figure it out with trig but dind;t get far yet. Thx Alot.

##### Share on other sites
To give you a term to research/google, those are 'Euler angle' rotations. I wouldn't recommend thinking of it in terms of rotating in a plane (or whatever), but rather rotating about an axis. The idea with Euler angles is that you rotate about one axis, then about another, and then (often) about a third. Your orientation after this series of rotations is the orientation represented by the Euler angles. The axes about which to rotate are usually the cardinal (world) x, y and z axes, but may occur in a variety of orders.

Euler angles are useful for some things (e.g. FPS movement, user interface), but much less so for others (e.g. objects in a space or physics simulation). So don't assume that Euler angles will always be the best choice when dealing with rotation and orientation in 3d.

##### Share on other sites
thx alot, i found a great explanation when i did a search fr Euler;s angle.

##### Share on other sites
thx alot, i found a great explanation when i did a search fr Euler;s angle.

##### Share on other sites
hey, just a side note question? Is Euler's angle actually developed by Euler? or was it just named after him for some reason or another?
Cuz i read some stuff while i was researchign the method and didn;t see the angle meantioned there but alot of other stuff was....

##### Share on other sites
Quote:
 Original post by rever I understand why the y in kept the same but why is x calcualated as it is?I am trying to figure it out with trig but dind;t get far yet.

(I'm sorry if this post is a little out of time)

The formula for the rotation comes from a deeper study of a special case of geometric transformations, called 'isometries'. An isometry f has the property that it preserves the distance of the points it maps. That is: d(f(x1),f(x2)) = d(x1,x2) for all x1,x2 in the plane.

An isometry can be completely defined by its matrix, and it can be proved, that for a matrix to represent an isometry, it has to be orthogonal. That is, each pair of 2 column-vectors must be normal to each other, and have magnitude 1. Thus their matrix will have determinant +1 or -1. The class of isometries with det==+1 are called 'rotations', the class with det==-1 are called 'false-rotations' (or 'reflections')

Let A be a matrix of a 'rotation' isometry, as we called it. It should be an orthogonal matrix with det==1.
A = [ a11  a12 ]  orthogonal <=> { a112 + a212 == 1   (1)    [ a21  a22 ]                 { a122 + a222 == 1   (2)                                 { a11*a12         + a21*a22         == 0   (3)

For each of the members of the matrix, aij, the following has to hold, because the absolute value of a vector's component is clearly smaller than -or equal to- its magnitude.
-1 <= aij <= +1

-1 <= a11 <= +1 <=> There is angle r1, such that a11 == cos(r1)
Similarly, the same holds for another angle, r2, such that a12 == cos(r2)
But then, a212 = 1 - a112 = 1 - cos2(r1) = sin2(r1) <=> a21 = +/-sin(r1)
... and a222 = 1 - a122 = 1 - cos2(r2) = sin2(r2) <=> a22 = +/-sin(r2)

The 2 column vectors must be normal, therefore:
cos(r1)*a12 == -sin(r1)*a22 <=>
a12/a22 = - sin(r1)/cos(r1) = -tan(r1)

Substituting a12 and a22...
cos(r2)/sin(r2) == 1/tan(r2) = -tan(r1) <=>
tan(r1)*tan(r2) = -1
Therefore, the angles r1,r2 are right, which means that r2 = r1 +/- PI/2

For r2=r1+PI/2 this gives:
A = [ cos(r1)  cos(r1+PI/2) ] = [ cos(r1)  -sin(r1) ]    [ sin(r1)  sin(r1+PI/2) ]   [ sin(r1)   cos(r1) ]and for r2=r1-PI/2,A = [ cos(r1)  cos(r1-PI/2) ] = [ cos(r1)    sin(r1) ]    [ sin(r1)  sin(r1-PI/2) ]   [ sin(r1)  -cos(r1) ]

The last matrix has determinant -1, and is therefore rejected.

Although, we arrived at the well-known form of the matrix, we proved nowhere that this angle, 'r1', is actually the angle of rotation. This can be done, by showing that the angle of the vector before and after transformation, is exactly the rotation angle.
Indeed, the dot product of unit vector {x,y}T and A*{x,y}T is 'cos(r1)' which proves that the random vector {x,y} is rotated by angle 'r1' around the origin.

I used to think there's a bunch of ways to prove this, but it gets down that most of them inherently use something that comes from what you wanted to prove in the first place. You can't even use most trigonometric identities as they derive from this result!

E.g. let a point A at angle 'a' with the origin. To get a trigonometric expression of the sine and cosine of the angle (a+b), you can think of sth like this:
The point has to be rotated by 'b' rad in order for it to come to a new angle == a+b. Therefore, the following should hold:
[ cos(a+b) ] = [ cos(b)   -sin(b) ]*{ cos(a) }[ sin(a+b) ]   [ sin(b)    cos(b) ] { sin(a) }

This gives us:
cos(a+b) = cos(b)cos(a) - sin(b)sin(a)
sin(a+b) = sin(b)cos(a) + cos(b)sin(a)

As I said, sorry if this was a little late, I hope it's clear now where this comes from.

##### Share on other sites
well.....just ....WOW.
I got the answer in one of the books i got but this is a much better explanation that the book gave.
Thx.Apriciate it.

##### Share on other sites
hey, i was trying to get this to work on my own but i ran into problems with roll and yaw.....
considering a right hand system(x+ coming out, y pos going right , z positive going up).
I did a rotation between the y and z axis, i got the following
x"=x'
y"=y'*cos(pitch)-z'*sin(pitch)
z"=y'*sin(pitch)+z'*cos(pitch)
which is fine.
then i tried to project the same idea ont the other axis, and it seems to me that
x'=z*sin(yaw)+x*cos(yaw)
y'=y
z'=z*cos(yaw)-x*sin(yaw)
the above equations should be reversed.
the z should be x and vice versa.
The reasoning i am using here is that if we take a look at xz plane, then we can assume Z to be the vertical axis and x the horizontal axis, then the same principle applies as in the one above where z was the verticla axis and y the horizontal...but that measn that cos and sin should be reversed and the sign should be +ve....
Where did i go wronge in my reasoning?

##### Share on other sites
Clearly, if you want to rotate the XZ plane, you should exchange the trig. coefficients, as you say. I don't know where you found this, but this snippet actually reflects points with respect to some horizontal line passing from the origin. The matrix implied, doesn't represent rotation since it has determinant -1.

edit:
ignore the above, I missed something

I didn't notice that the order of appearence of x,z -in the right part of the equations- is reverse.
This is indeed a rotation and its matrix comes from the standard form just by replacing the angle 'a' with '-a'. Cos() remains the same, but Sin() changes sign, therefore the 'minus' moves from position (1,2) to (2,1) in the matrix.
I suppose it just rotates positive angles CW instead of the usual CCW, since it effectively negates the angle.

• 19
• 10
• 19
• 14
• 20