For the two dimensional case we consider two coordinate frames, the original frame A, and a rotated version of that, coordinate frame B. And B is rotated in the positive direction by angle theta with respect to frame A. We then described the new coordinate frame axes in terms of the old coordinate frame axes, and we were able to write these relationships. We then wrote this in matrix form and we ended up with a formulation that allowed us to transform vectors from the new frame to the old frame A. The columns of this rotation matrix are the new X-axis that is the B-axis expressed in terms of the A coordinate frame and the BY-axis in terms of the A coordinate frame. We used some quite complex geometry and diagrams in order to show this.
For three dimensions it's a little complex to do that kind of geometric construction so we're just going to take the big principle from last time. We'll start off in a similar fashion, here's coordinate frame A and we've drawn a point which we can describe in terms of a vector with respect to coordinate frame A. I’m going to introduce a new coordinate frame B which is rotated with respect to coordinate frame A. And we're going to define the point with another vector, vector BP which is the point in respect to a rotated frame B. We're going to pull the same trick as we did for the 2-dimensional case. We're going to describe the axes of coordinate frame B as unit vectors expressed in terms of coordinate frame A and they are the columns of a new rotation matrix. In this case it's a 3x3 rotation matrix. So we're not going to go through the detailed geometric construction, we're going to extrapolate from the 2-dimensional case and just write this expression directly.
This new rotation matrix transforms vectors from the new coordinate frame B to the old coordinate frame A. This 3-dimensional rotation matrix, this 3x3 matrix, has got a lot of similar properties to it's 2x2 counterpart. It is an orthogonal, sometimes called orthonormal, matrix. That means each column in the matrix is a unit length vector. Each column in the matrix is orthogonal to all the other columns so that means if I take the dot product between column 1 and column 2 it will be equal to 0, same for column 1 and column 3, column 2 and column 3. The inverse of this matrix is the same as it's transpose and this is a really useful property because often times when we're computing pose expressions we need to find the inverse of the rotation matrix and computationally it's much simpler to compute the transpose than it is to compute the inverse for a 3x3 matrix. The determinant of this matrix is +1, that means when we multiply a vector by this matrix, its length will be unchanged. A Mathematician would say that a matrix like this belongs to the special orthogonal group of dimension 3 and that'll be written as R being an element of the set SO(3). Three indicating that the matrix is 3x3, it is rotation in 3-dimensional space.
There are some very useful rotation matrices that we can write down, we refer to these as elementary rotation matrices. The first one then is the rotation by theta around the X axis, rotation by theta around the Y axis and finally rotation by theta about the Z axis. And we can multiply these together in various combinations in order to achieve much more complicated rotations; more about that shortly. In the last lecture when we considered 2-dimensional rotations we wrote a rotation matrix that looks like this. In fact this is identical to the top left corner of the elementary rotation matrix for rotation about Z. The reason about this quite intuitive. In the 2 dimensional case we are actually rotating around the unseen Z axis which was sticking up at us out of the screen and was effectively invisible. So there is an equivalence between 2-dimensional rotation and the 3-dimensional rotation around the Z axis.
When we're talking about orientation we consider them in terms of a sequence of elementary rotations, so let's look at rotations around the X-axis. Now this was the positive rotation direction so if I rotate this coordinate frame by 90 degrees around the X-axis it's going to look like this. If I rotate it by minus 90 degrees around the X-axis it's going to look like this. I can rotate it by positive 90 degrees around the Y-axis so that's a rotation that way so positive 90 degrees rotation looks like this and a negative 90 degrees rotation is going to look like this. Now positive rotation around the Z-axis is this way, so if I rotate this frame 90 degrees around the Z-axis it's going to look like this or if I rotate it by minus 90 degrees around the Z-axis it's going to look like this.
Let's have a look at some of these elementary transformation matrices in MATLAB. We can use the function rotx to create a rotation about the X-axis and I'm going to ask for a rotation of 0.2 radians and this is what the rotation matrix looks like. I could have also specified the angle in terms of degrees so in this case what I look for is a rotation of 30 degrees around the X-axis.
Let me put that matrix into a variable which I'm going to call R for rotation it's a 3x3 orthogonal rotation matrix and we'll just test some of the properties we've mentioned earlier about orthogonal rotation matrices. I can look at the determinant of the matrix and we can see that it is equal to 1. I can compute the inverse of that matrix and we can see that it is exactly the same as a transpose of that matrix. And computationally this is particularly convenient instead of having to invert the matrix I can simply transpose it. Computationally much, much cheaper. I can also compute a rotation about a different axis I could ask for a rotation around the Y-axis by 0.2 radians or a rotation around the Z-axis, again by 0.3 radians. The toolbox also contains a function which allows me to graphically depict one of these rotation matrices as a rotated coordinate frame. So I can parse the last result, which is in the automatic variable ans into the function trplot and here we can see the representation of the rotated coordinate frame. The reference coordinate frame is indicated here and the rotated coordinate frame is shown here in blue. The trplot function has got many, many options. We can change the color of the coordinate frame, we can add a label to the frame, we can add arrowheads and so on.
We learn how to describe the orientation of an object by a 3×3 rotation matrix which has some special properties.
This content assumes high school level mathematics and requires an understanding of undergraduate-level mathematics; for example, linear algebra - matrices, vectors, complex numbers, vector calculus and MATLAB programming.