LESSON

# Describing rotation and translation in 2D

#### Share

#### Transcript

Now let's bring translation into the picture. Coordinate frame A, Coordinate frame B which is translated and rotated with respect to coordinate frame A and a point P. We can represent the point P by a vector with respect to frame B and that vector can be described in terms of its components along the XB and YB axis.

Now we can rotate that vector into a new frame, coordinate frame V, and coordinate frame V has axis which are parallel to coordinate frame A. We've already talked about how to rotate a vector from one coordinate frame to another using a rotation matrix. And as a sanity check that we've written this expression correctly, we noticed that these two Bs are next to each other. That's a good thing.

Now let's describe the origin of coordinate frame V with respect to coordinate frame A and we do that with a vector. That's a vector from A to V. Now we're allowed to add vectors so we can add this vector ATV to the vector VP to obtain the vector that describes the point P with respect to coordinate frame A. We can do that because these two vectors are described with respect to coordinate frames whose axis are parallel to one another. I can substitute one equation into the other and write this. And again because these two coordinate frames are parallel I can write this.

Let's expand the vectors and matrix in this expression and write them in terms of their elements. Now I can pull a little bit of the trick and now write it like this. If you're unsure about this depth, expand out the matrix and convince yourself that they are exactly the same.

Now this expression has got a two-element vector and a three-element vector over here. Let's make things a little bit more symmetric and write it like this. What we've down now is added some zeros and some ones to the bottom row of the matrix. Previously we had a 2x2 rotation matrix. Now we see that that's embedded into the top left corner of a 3x3 matrix. And our vectors which is to have 2 elements now have three elements. We can write this even more succinctly in this form. The notation, the tilde, above the little p indicates that it is a homogeneous factor. It has got three elements not two, and we'll talk about that in just a moment. The point is described with respect to coordinate frame A by a homogeneous vector which we can obtain from the homogeneous vector of the point with respect to coordinate frame B multiplied by this matrix.

The elements of the matrix include the rotation matrix, which is the function of the orientation; Theta, and the translation between the origin of coordinate frame A and coordinate frame B. We have the familiar representation of a vector in a 2-dimensional plane, two numbers A and B. The homogeneous vector has got three elements in it. It's got A and B and an additional element which is set to 1. This we refer to as a homogeneous transformation. It is a 3x3 matrix. The homogeneous transformation matrix T comprises a rotation matrix which is 2x2 and a translation vector which is a 2x1 matrix padded out with a couple of zeros and a one.

This matrix describes a relative pose. It describes the pose B with respect to the pose of A. All of that is encoded in this single 3x3 matrix. A mathematician would say that homogeneous transformation belongs to the special Euclidian group of dimension 2. Symbolically we would say matrix T belongs to the set SE(2).

Finally it's time to start making these abstract concepts real. Pose is just a matrix. Where we had the symbol ksi before we can substitute this 3x3 homogeneous transformation matrix. When we talk about compounding or joining two poses together using the O+ operator, that is exactly the same as multiplying these two homogeneous transformations. We use the O- operator to indicate the negation of a relative pose, and that is simply the inverse of a homogeneous transformation matrix. I mentioned earlier that the inverse of a rotation matrix is equal to its transpose. That is not the case for a homogeneous transformation matrix. You need to perform a proper matrix inverse: invert a 3x3 matrix.

We introduced a dot operator which transforms a vector from one coordinate frame to another. And that is simply the product of the homogeneous transformation matrix and the vector represented in homogeneous form. Remember that the homogeneous vector is obtained from the original vector P, the two vector and we augment or append a one element to that to form a three element vector.

Here we are in MATLAB and we're going to experiment with these 2-dimensional homogeneous transformation matrices. So what I’m going to do is introduce a function called transl2 which creates a homogeneous transformation representing a pure translation, that is a translation of 1 in the x direction and 2 in the y direction.

Previously we saw how to create a 2-dimensional rotation matrix, for instance a rotation of 30 degrees is created like this. We see that this rotation matrix is only 2x2 compared to the 3x3 homogeneous transformation matrix. So I can create a homogeneous transformation matrix equivalent of this rotation by prefixing with the letter T. This function returns a 3x3 homogeneous transformation matrix. We can see the rotation matrix part up in the top left corner. We can see that the translation part of this matrix is equal to zero. This homogeneous transformation matrix represents a pure rotation. Now we can multiply these two together. transl2, multiply it by the rotation part - 30 degrees. And now what I have is a homogeneous transformation which represents a pose. It's got a rotational component and it's got a translational component. Now the toolbox has got a shorthand function to achieve this. I parse in the x and y translational parts; the rotational part and the option to say that that angle is specified in units of degrees. We have exactly the same matrix here.

Now let's plot this particular pose and see what it looks like. And to do that I'm going to create an axis in which to plot, and x is going to vary from 0-5 and y is going to vary from 0-5. I need to set the aspect ratio so that everything looks reasonable, so I'm going to set the axis so that the aspect ratio is square. I'm going to put a hold on because I'm going to plot a few poses. The first pose I'm going to plot I'm going to put into workspace variable T1 and it is the pose that I looked at just a moment ago: 1 in the x direction, 2 in the y direction and the rotation of 30 degrees. There is a homogeneous transformation matrix. Now I'm going to plot that.

To plot that I use the function trplot2. The 2 suffix means that it's for 2-dimensional poses. Parse in the pose represented by the homogeneous transformation. I'm going to plot it as a frame named 1, and I'm going to plot it in the color blue. There are quite a few options there. And there we see the pose plotted. We can see that it does indeed have a translational component; 1 in the x direction, 2 in the y direction. And it is rotated with respect to the world coordinate frame.

I can create another pose quite easily. I can create a pose that has got an offset of 2 in the x direction. 1 in the y direction and no rotation. That's what the homogeneous transformation looks like. Now I'm going to plot that. I'm going to use the function trplot2 again, parse in the homogeneous transformation matrix, and I’m going to plot it as a frame labeled 2. To be different I'm going to plot it as a red colored frame, and here we see the second pose. It's got no rotation. It has got a translational component.

Now I can compose 2 of these poses. I’m going to say pose 3 is equal to pose 1 compounded with pose 2. That's what the transformation matrix look like. I can plot that. I'm going to plot that one, trplot2, parse in the matrix, there's going to be a frame, called 3 and I'm going to color that one green. So if I compound those 2 poses I end up with the pose shown here as 3. The way we can think about this is we moved from the world frame 2 from frame 1 which is rotated, and then in frame 1 we then moved 2 in the x direction and 1 in the y direction. But X and Y direction are frame 1, not on the world frame, and that gets us to the frame labeled as frame 3.

I could compound the poses in the opposite order. I'm going to create a new pose T4 and it's going to be pose 2 compounded with pose 1. We can see that's what the homogeneous transformation matrix looks like and it's different to T3. I can plot this. I can parse in T4. I can plot it as a frame labeled 4 and I'm going to plot it into color cyan. Here we can see the frame 4 which has resulted from compounding pose 2 with post 1. Now I'm going to introduce a point into the plot. I'm going to introduce a point at a coordinate 3, 2. I need to transpose that so that it becomes a column vector. There it is. I can plot that. Plot point P, and I'm going to plot is an asterisk. There we see it in our figure. If I want to determine the coordinate of the point with respect to frame 1 then what I need to do is to use the inverse of the relative pose 1, which is that, and multiply it by the points coordinate in homogeneous form. I'll take point P and I'm going to append a 1 to it. What I have now is the homogeneous coordinate of the asterisk with respect to the coordinate frame 1.

We learn how to describe the 2D pose of an object by a 3×3 homogeneous transformation matrix which has a special structure.

### Skill level

Undergraduate mathematics

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.

### Rate this lesson

## Check your understanding

## Discussion

## Leave a comment

Please Sign In to leave a comment.

Hiya, at around 3:53 Peter starts talking about going from “Abstract to Real”. Can someone point me to some references so I can prove to myself that pose composition is equivalent to matrix multiplication? Or am I heading down a rabbit hole of 3 years of linear algebra by wanting to know this? I mean I can take it at face value if i have to but I would rather know WHY just for personal satisfaction. This video is overall very very good, information dense too, had to stop and pause it many times to understand what was being said.

Thanks in advance.

Actually I think I may get WHY… the whole video was about WHY… I just have to multiply it out without matrices and with matrices and see if theyre equal