## Rotations: figuring out what a rotation does

I want to write a short emphatic post making one major point. I’ve made it before, but I think it needs to be hammered home.

In addition to the links in this post, you could use the Tag Cloud to find related posts.

I mentioned in this happenings post, near the end, that I had found a nice introductory book on the control of aircraft (Thomas Yechout et al., “Introduction to Aircraft Flight Mechanics…”, AIAA 2003, ISBN 1-56347-4344).

I looked at it yesterday morning. I was planning to spend the day working on the next regression post … and I did … but I figured I’d turn my kid loose first, and he wanted to play in that book.

I still think it’s a nice book… but two of their drawings for rotations are mighty confusing… at first glance, they appear to be wrong. It turns out they are right, but the display is unusual.

I’ve talked about this out before, but let me put it in a post all by itself. (This post seemed essential when I thought they had made a mistake; it is merely desirable once I saw that the reader had to take a careful look at their drawings.)

Suppose we are given the following rotation matrix…

$Rz[\theta] = \left(\begin{array}{ccc} \cos (\theta ) & \sin (\theta ) & 0 \\ -\sin (\theta ) & \cos (\theta ) & 0 \\ 0 & 0 & 1\end{array}\right)$

It should look like a rotation to you (about the z-axis), but if you’re not sure, just compute the determinant: it’s a rotation if and only if the determinant is +1.

The key question is: what does that rotation do?

The answer is crucial: it is either

1. a CCW (counter-clockwise) rotation of the x and y axes thru an angle $\theta\$;
2. or a CW (clockwise) rotation of a vector thru an angle $\theta\$.

The ambiguity is in whether we view the matrix as an active transformation moving the vector, or a passive transformation moving the coordinate system. Either interpretation is possible.

But as soon as someone says, “This is a rotation of the coordinate system”, it’s all settled: it’s a CCW rotation of the coordinate system. Or, if someone says, “It’s a linear transformation applied to a vector”, it’s settled the other way: it’s a CW rotation of the vector.

A safe choice for verifying this is a vector at 45° in the xy-plane…

v = {1, 1, 0}

and take $\theta\$ = 45° in the matrix. Then the matrix becomes

$\left(\begin{array}{ccc} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\ 0 & 0 & 1\end{array}\right)$

… and when we apply that to the vector v, we get

v2 = {$\sqrt{2}$, 0, 0}

which unambiguously lies on the x-axis. Good.

But there were two different ways to accomplish that. We start with

We might have rotated the x and y axes 45° CCW (new axes in blue):

Or we might have rotated the vector 45° CW:

DWG 3

Either way, the vector v2 = Rv lies on the x-axis.

If we view that matrix as a coordinate transformation, then it is unambigously a CCW rotation (thru $\theta\$, about the z axis).

If that was “a safe choice”, what’s a dangerous choice for checking it out?

Suppose we study the effect of that matrix on a different vector. Let’s take the unit vector along the x-axis, and a 90° rotation.

v3 = {1, 0, 0}

$\left(\begin{array}{ccc} 0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1\end{array}\right)$

Then we get

v4 = R v3 = {0,-1,0}

which says that we now have a vector which points along the negative y axis.

That is, we started with…

We might have rotated the coordinate system 90° CCW:

Or we might have rotated the vector 90° CW:

It may seem weird, but what that matrix does to the x-axis is not the same as what it does to a unit vector on the x-axis. It either rotates the x-axis CCW or it rotates the unit vector i CW.

And that weirdness is why I strongly suggest that you investigate it using the safe choice: a 45° angle and a vector at 45° between the relevant axes. And yes, all of this works out just fine for the other two coordinate axis rotation matrices:

$Ry[\theta] = \left(\begin{array}{ccc} \cos (\theta ) & 0 & -\sin (\theta ) \\ 0 & 1 & 0 \\ \sin (\theta ) & 0 & \cos (\theta )\end{array}\right)$

$Rx[\theta] = \left(\begin{array}{ccc} 1 & 0 & 0 \\ 0 & \cos (\theta ) & \sin (\theta ) \\ 0 & -\sin (\theta ) & \cos (\theta )\end{array}\right)$

Back to the book.

I originally thought the authors got confused, that they drew that rotation as though rotating the unit vector CW meant that they were rotating the coordinate system CW. But they got the related drawing right for a rotation about the y-axis. So something else was going on.

The aerospace coordinate system for the earth is usually taken to have the x axis pointing north, y pointing east, and z pointing down. (That’s a perfectly fine right-handed coordinate system.) For the rotation about the z-axis, the book draws the x-axis vertically (“north”) and the y-axis going to the right (“east”). From that perspective, the rotation appears to be CW… and if you miss the labels on the axes — me raises hand — you’ll get the wrong idea.

(Viewed from above the North Pole, the Earth appears to be rotating CCW; but viewed from below the South Pole, the Earth appears to be rotating CW. OK, we have to be looking at a rotation “in the usual way” in order to call it CW or CCW.)

But if you know how to work it out, you can be confidant that the matrices they gave us are, in fact, CCW rotations of the coordinate system about various axes. Then you know you are supposed to look at the text again and ask, “Why did they draw it clockwise?”

(Conversely, we could have been given the transposes of those matrices. Fine, we can verify that the transposes of those matrices are CW rotations of the coordinate systems. And as I said here, for some purposes, we want the transposes of those matrices: after all, the convention we’re using here says that a CCW rotation of a vector is a negative angle. If we use the thumb of our right hand for an axis and our fingers curled in the direction of the rotation, our hand is describing a rotation thru a negative angle, and maybe we don’t want that angle to be negative.)

Let me close with one other discussion: transition matrix and attitude matrix. There’s a lot more detail here.

We construct an attitude matrix explicitly anytime we specify, “I want our new x axis basis vector (i) to be this.” (And our new j and k basis vectors.) Lay them out as rows of a matrix, and we have just gotten the attitude matrix which describes the new coordinate system.

We know — OK, I certainly know — that we are specifying an attitude matrix implicitly when we say, “Rotate the initial coordinate system as follows”. And that’s what people do when they write out the aerospace Euler angle sequence: first rotate about the z-axis, then about the (new) y-axis, and finally about the (new) x-axis. They are giving us a sequence of attitude matrices.

In other words, our given matrix

$\left(\begin{array}{ccc} \cos (\theta ) & \sin (\theta ) & 0 \\ -\sin (\theta ) & \cos (\theta ) & 0 \\ 0 & 0 & 1\end{array}\right)$

was presented implicitly as an attitude matrix for a rotation of the coordinate system.

We can confirm that. What is the new x-axis, i.e. the new unit vector i, in terms of the original basis? It’s the first row of that matrix: cos $\theta\$ i + sin $\theta\$ j. And the new unit j vector is the second row… and the new unit k vector is the same as the original one.

OK, but what about the transition matrix? There are two essential facts:

• the transition matrix is the transpose attitude matrix;
• the transition matrix maps new components to old ones.

But wait a minute! We figured out what our rotation was doing by applying it to a vector, namely to the old components of a vector, not to the new ones.

What’s up?

Well, for a rotation, the transpose is the inverse, so the attitude matrix is not only the transpose transition matrix, but it is also the inverse transition matrix.

And it is the inverse transition matrix that maps old components to new. For a rotation, that’s the original matrix. In a sense, we weren’t “really” applying the original matrix to the vector v, we were applying its inverse transpose to v… but for a rotation, the inverse transpose is the original matrix, and it all works out nicely.