WEBVTT

00:00.320 --> 00:07.520
Now that we know how to express the translation of our reference frame with the respect to another one

00:07.520 --> 00:15.170
using the translation vector, let's see how to express its orientation using rotation matrices.

00:15.960 --> 00:23.550
In this case, we consider a very simple problem that involves only two reference frames, a global

00:23.550 --> 00:31.290
fixed reference frame called W, and a mobile reference frame that can freely rotate and is oriented

00:31.290 --> 00:34.620
differently from the fixed reference frame of the world.

00:35.290 --> 00:41.710
To simplify the problem, let's assume that these two reference frame have the same origin, the same

00:41.710 --> 00:47.020
center, and therefore the translation vector that connects them is zero.

00:47.620 --> 00:54.190
In this problem, we assume that the translation is zero and therefore the centers of the two reference

00:54.190 --> 00:55.990
frames always overlap.

00:56.350 --> 01:03.100
This way we can focus uniquely on the study of the orientation of the reference frame R that is attached

01:03.100 --> 01:07.450
to the robot with the respect to the global reference frame W.

01:07.480 --> 01:16.540
In other words, we want to find the angular displacement Theta Phi and PSI between the X, y and Z

01:16.570 --> 01:19.300
axis of the two reference frames.

01:19.660 --> 01:26.920
The mathematical tools to solve this problem are complex and are called rotation matrices, but their

01:26.920 --> 01:33.160
derivation is very simple and intuitive, requiring some basic understanding of trigonometry.

01:33.460 --> 01:38.720
It will help you better understand the logic and the manipulation of reference frames.

01:39.910 --> 01:46.870
As always, when faced with a complex problem, let's approach it by breaking it down into simpler and

01:46.870 --> 01:49.040
more easily solvable subproblems.

01:49.060 --> 01:56.740
So let's consider the simple case when we have a fixed reference frame and our mobile reference frame

01:56.740 --> 02:02.500
that is rotated with respect to the Z axis of the fixed reference frame.

02:03.250 --> 02:04.180
In practice.

02:04.180 --> 02:10.930
We are saying that these two reference frame in addition of having the same origin, also have the same

02:10.930 --> 02:11.950
Z axis.

02:11.950 --> 02:15.640
So the Z axis is oriented in the same way.

02:16.250 --> 02:20.260
This is also the rotation axis of the second reference frame.

02:20.270 --> 02:27.460
In other words, we have rotated the second reference frame, the one in red by an angle C with the

02:27.500 --> 02:31.460
respect to the Z axis of the first reference frame.

02:31.460 --> 02:33.560
So the fixed one in black.

02:34.260 --> 02:40.890
If we were to look at these two reference frame from above, we would observe a plane formed by the

02:40.890 --> 02:48.720
X and Y axis of the first reference frame and the Z axis coming out of the plane, so out of the screen.

02:49.360 --> 02:51.790
Consequently the second reference frame.

02:51.790 --> 02:59.140
So the mobile one will be rotated by an angle C with due respect to the first one and therefore the

02:59.140 --> 03:07.540
x first and y first axis of the second reference frame are rotated by an angle C with respect to the

03:07.540 --> 03:09.070
x and Y axis.

03:10.020 --> 03:17.730
Now let's assume that there is a point P on the x y plane of which we project the coordinates along

03:17.730 --> 03:19.410
the x and Y axis.

03:19.890 --> 03:26.940
It will have coordinates, p, x and p y along the axis of the first reference frame.

03:26.940 --> 03:28.380
So the fixed one.

03:29.040 --> 03:36.450
Similarly, we can project the point p onto the second reference frame so the rotated one obtaining

03:36.450 --> 03:40.710
the coordinates p x first and p y first.

03:41.280 --> 03:49.350
Applying some simple trigonometric equations, we know that if we project the vector p x y along the

03:49.350 --> 03:51.810
x axis of the first reference frame.

03:51.810 --> 04:00.930
So the fixed one we obtain that the component of this vector is p x first multiplied by the cosine of

04:00.930 --> 04:01.680
the angle pq.

04:02.580 --> 04:11.670
Similarly, if we project the vector p x first along the y axis of the fixed reference frame, we obtain

04:11.670 --> 04:18.960
that the y component of this vector is p x first multiplied by the sine of the angle PQ.

04:20.160 --> 04:29.490
Similarly, we can project the p first vector along the x and y axis of the fixed reference frame.

04:29.670 --> 04:39.330
So the component along the y axis is given by p y first multiplied by the cosine of the angle C, and

04:39.330 --> 04:47.310
the component along the x axis is given by p y first multiplied by the sine of the angle c.

04:48.400 --> 04:55.600
So far we haven't actually written any kinematic equation, only simple trigonometric derivations.

04:55.960 --> 05:03.760
At this point, knowing these derivations, we ask ourselves what are the values of P, x, P, y,

05:03.760 --> 05:04.810
and Z?

05:04.840 --> 05:07.120
So which are the coordinates of the point?

05:07.150 --> 05:10.270
P with the respect to the fixed reference frame.

05:10.270 --> 05:11.440
So the black one.

05:12.340 --> 05:19.930
Assuming that we know p x first, p, y first and p z first, which are the coordinates of the point

05:19.960 --> 05:23.470
P with the respect to the red reference frame.

05:23.470 --> 05:28.390
So the one that is rotated by an angle C around the Z axis.

05:29.140 --> 05:31.150
Let's start with the easy things.

05:31.360 --> 05:38.860
Let's say that since the Z and Z first axis are equal to each other, so they share the same direction

05:38.860 --> 05:39.790
and origin.

05:39.820 --> 05:46.630
The coordinate of the point P along the Z axis is the same in both reference frames.

05:47.340 --> 05:51.720
Then let's determine the x coordinates of the point.

05:51.750 --> 05:52.080
P.

05:52.840 --> 05:55.480
This is given by the sum of two components.

05:55.600 --> 06:04.030
The first one is p x first, which is the coordinate of the point P along the x first axis multiplied

06:04.030 --> 06:06.140
by the cosine of the angle PC.

06:07.100 --> 06:15.980
The second one is P first, which is the coordinate of the point P along the Y first axis multiplied

06:15.980 --> 06:22.550
by the sine of the angle PC with a minus sign indicating that it has opposite direction.

06:23.410 --> 06:25.630
Finally using the same approach.

06:25.630 --> 06:29.080
We can also determine the y coordinate of the point P.

06:29.560 --> 06:39.280
It is given by p x first, multiplied by the sine of the angle C plus p y, first multiplied by the

06:39.280 --> 06:40.690
cosine of the angle.

06:40.780 --> 06:46.990
C We can express this equation in a matrix form preserving its meaning.

06:47.290 --> 06:54.610
The three coordinates of the point P in the fixed reference frame are given by the product of a certain

06:54.610 --> 06:59.620
matrix by the vector of coordinates of a point P in the second reference frame.

06:59.620 --> 07:00.850
So the mobile one.

07:01.420 --> 07:08.290
In the matrix that connects the coordinate of the point P In the two reference frame, we need to insert

07:08.290 --> 07:12.070
all the components, all the coefficients of the equation.

07:12.910 --> 07:19.900
Since the last row and the last column refer to the components along the Z axis, we can set them to

07:19.900 --> 07:24.010
zero and set the component along the z axis to one.

07:24.280 --> 07:31.120
In practice, we have inserted the first equation into the matrix, which tells us that the coordinate

07:31.120 --> 07:35.500
of P along Z is equal to the coordinate of P along Z.

07:35.530 --> 07:45.640
First, the first row of the matrix consists of the cosine of Z and minus the sign of Z, which corresponds

07:45.640 --> 07:52.480
to the second equation which connects the x coordinate of the point P in the two reference frames.

07:53.400 --> 08:00.330
Finally, the second row consists of the sine of the angle C and the cosine of the angle.

08:00.420 --> 08:07.500
C expressing the relationship between the y coordinate of the point P in the two reference frames.

08:07.920 --> 08:11.250
This matrix is called the rotation matrix.

08:11.280 --> 08:14.810
Specifically an elementary rotation matrix.

08:14.850 --> 08:22.200
It is elementary because we assumed that the two reference frames share their Z axis and therefore they

08:22.200 --> 08:24.630
have a common axis of rotation.

08:25.020 --> 08:34.530
We denote this as R Z of C, which represents an elementary rotation matrix around the Z axis with the

08:34.530 --> 08:37.110
two reference frames rotated by an angle C.

08:38.070 --> 08:44.760
With this tool, we can now freely change the reference frame and express the coordinates of the point

08:44.790 --> 08:46.970
P in the fixed reference frame.

08:46.980 --> 08:53.670
Given the coordinates of the point P in the rotated reference frame and by knowing the rotation angle

08:53.670 --> 08:55.500
between the two reference frames.

08:56.310 --> 09:00.510
This is not the only elementary rotation matrix that we can create.

09:00.600 --> 09:02.100
There are two more.

09:02.740 --> 09:09.460
Let's assume that we have a fixed reference frame still X, Y, and Z in black, and our mobile reference

09:09.460 --> 09:12.850
frame X first, Y first and Z first.

09:12.940 --> 09:17.410
But this time the two reference frame share their y axis.

09:17.410 --> 09:21.600
So the y and y first axis are equal.

09:21.610 --> 09:25.390
They are oriented the same way and they have the same origin.

09:25.900 --> 09:33.130
Then the second reference frame in red is rotated around the y axis by an angle phi.

09:34.350 --> 09:41.250
In this case, if we look at the system from above, imagining ourselves on the perspective of the rotation

09:41.250 --> 09:49.890
axis y, we will see a plane with the X and Z axis and instead the Y axis is coming out of the page

09:49.890 --> 09:51.360
coming out of the screen.

09:51.810 --> 10:01.170
Similarly, we will see the X first and z first axis of the second reference frame rotated by an angle

10:01.200 --> 10:05.730
phi and the Y first axis also coming out of the page.

10:06.470 --> 10:11.960
Again, let's consider describing the coordinates of the point P in both reference frames.

10:11.990 --> 10:22.130
This point will have coordinates, p, z and p x along the z and x axes of the fixed reference frame

10:22.400 --> 10:32.420
and coordinates p, z first and p x first along the z first and x first axes of the rotated reference

10:32.420 --> 10:32.960
frame.

10:33.940 --> 10:40.570
Using some simple trigonometric derivation, we can predict the Z first vector.

10:40.720 --> 10:50.230
Along the Z and x axis of the fixed reference frame and determine the components of the Z first vector

10:50.260 --> 10:52.060
along the Z axis.

10:52.060 --> 10:57.460
And this is given by p z first multiplied by the cosine of the angle phi.

10:58.200 --> 11:05.160
And the component along the x axis is given by p z first multiplied by the sine of the angle phi.

11:06.400 --> 11:14.440
Similarly, we can project the first vector along the x and z axis of the fixed reference frame.

11:15.090 --> 11:23.880
Its component along the Z axis is p x first multiplied by the sine of the angle phi, and the component

11:23.880 --> 11:30.120
along the x axis is p x first multiplied by the cosine of the angle phi.

11:31.040 --> 11:37.880
Once again, we ask ourselves what are the coordinates of the point P in the fixed reference frame?

11:38.030 --> 11:42.500
Specifically, what are P, x, P, y, and Z?

11:43.460 --> 11:48.320
Assuming that we know the coordinates of the point p in the mobile reference frame.

11:48.320 --> 11:56.570
So assuming that we know p x first, p, y first and p z first, we can write a system of three trigonometric

11:56.570 --> 11:58.670
equations to answer this question.

11:59.500 --> 12:06.700
The coordinates of P along the Y axis of the fixed reference frame is equal to the coordinate of P along

12:06.700 --> 12:08.720
the Y first axis.

12:08.740 --> 12:11.800
Since the two y axis are the same.

12:12.760 --> 12:20.200
The coordinate of P along the x axis on the other end is given by the sum of p x first multiplied by

12:20.200 --> 12:25.060
the cosine of P and p, z, first multiplied by the sine of phi.

12:25.720 --> 12:34.270
Similarly, the coordinate of P along the Z axis is given by minus p x first multiplied by the sign

12:34.300 --> 12:39.460
of z plus p, z, first multiplied by the cosine of P.

12:40.480 --> 12:48.130
Once again, we can express this system of equation in a matrix form to connect the coordinates of the

12:48.130 --> 12:54.760
point P in the fixed reference frame to the coordinates of P in the rotated reference frame.

12:55.480 --> 13:00.910
In this matrix since the x axis of the two reference frames are now equal.

13:00.940 --> 13:07.870
The second row and the second column are both zero and one, indicating that the coordinate of P along

13:07.870 --> 13:13.270
the Y axis is equal to the coordinate of P along the Y first axis.

13:14.490 --> 13:22.080
The first row which expressed the relationship between the coordinates of P in x and x first is given

13:22.080 --> 13:26.460
by the cosine of phi zero and the sine of phi.

13:26.880 --> 13:33.060
And finally the last row, which expresses the relationship between the coordinates of P along the Z

13:33.060 --> 13:33.600
and Z.

13:33.600 --> 13:38.970
First axis is given by minus sine of phi and cosine of phi.

13:40.450 --> 13:48.100
This matrix is also called a rotation matrix and in this case an elementary rotation matrix as the two

13:48.100 --> 13:50.080
reference frames share an axis.

13:50.080 --> 13:51.460
So the Y axis.

13:52.280 --> 14:02.190
So we call it our Y of V, which represents an elementary rotation matrix around the Y axis by an angle.

14:03.880 --> 14:10.960
As you may have already realized, there is only one more elementary rotation matrix missing which express

14:10.960 --> 14:15.550
the case when we have two reference frames sharing the x axis.

14:15.970 --> 14:23.590
This means we have a fixed reference frame and a mobile reference frame that share the same x axis and

14:23.590 --> 14:28.480
the mobile frame is rotated around the x axis by an angle theta.

14:29.020 --> 14:36.750
To find the last elementary rotation matrix, we imagine ourselves as an observer located on the x axis.

14:36.760 --> 14:45.070
In this case, we would see a plane with Y first and Z first axis rotated by an angle theta with the

14:45.070 --> 14:47.380
respect to the fixed reference frame.

14:48.300 --> 14:54.000
Once again, let's describe the coordinates of the point P in both reference frame.

14:54.360 --> 15:01.860
This point will have coordinates, P, z and p y along the z and y axis of the fixed reference frame

15:01.860 --> 15:10.740
and coordinates p, z first and p y first along the z first and y first axes of the rotated reference

15:10.740 --> 15:11.160
frame.

15:12.040 --> 15:20.410
Using some simple trigonometric derivations, we can predict the pi first vector along the Y and Z axis

15:20.440 --> 15:28.300
of the fixed reference frame and determine that the component of pi along the y axis is given by pi,

15:28.330 --> 15:35.350
multiplied by the cosine of the angle theta, and the component along the z axis is given by pi, multiplied

15:35.350 --> 15:37.180
with the sine of the angle theta.

15:38.300 --> 15:46.130
Similarly, we can project the first vector along the z and y axis of the fixed reference frame.

15:46.740 --> 15:54.000
Its component along the y axis is p z first multiplied by the cosine of the angle theta.

15:54.720 --> 16:01.800
And the component along the Z axis is p, z, first multiplied by the sine of the angle theta.

16:02.590 --> 16:09.460
Once again, we ask ourselves which are the coordinates of the point p in the fixed reference frame.

16:09.460 --> 16:13.200
So which are P, x, P, y and z.

16:14.290 --> 16:19.030
Assuming that we know the coordinates of the point p in the mobile reference frame.

16:19.030 --> 16:26.980
So p x first, p, y first and p z first, we can write a system of three trigonometric equations to

16:26.980 --> 16:28.240
answer this question.

16:28.600 --> 16:35.020
The coordinate of P along the x axis of the fixed reference frame is equal to the coordinate along the

16:35.020 --> 16:39.370
x first axis since the two x axis are the same.

16:39.850 --> 16:47.170
The coordinate of P along the y axis on the other end is given by the sum of p y first multiplied by

16:47.170 --> 16:53.350
the cosine of theta and minus p z, first multiplied by the sine of the angle theta.

16:53.830 --> 17:01.420
Similarly, the coordinate of P along the z axis is given by p, y first multiplied by the sine of theta

17:01.450 --> 17:05.470
plus p z, first multiplied by the cosine of theta.

17:06.170 --> 17:12.410
Once again, we can express this system of equation in a matrix form to connect the coordinates of the

17:12.410 --> 17:18.260
point P in the fixed reference frame to the coordinate of P in the rotated reference frame.

17:18.850 --> 17:25.480
In this matrix since the x axis of the two reference frames are equal, the first row and the first

17:25.480 --> 17:32.530
column are both zero and one, indicating that the coordinate of P along the x axis is equal to the

17:32.530 --> 17:35.800
coordinate of P along the x first axis.

17:37.410 --> 17:43.350
The second row which expressed the relationship between the coordinates of P in Y and Y.

17:43.380 --> 17:45.630
First is given by zero.

17:45.660 --> 17:49.350
The cosine of theta and minus the sine of theta.

17:49.710 --> 17:56.220
And finally the last row which expresses the relationship between the coordinates of P along Z and Z.

17:56.250 --> 18:01.230
First is given by zero sine of theta and cosine of theta.

18:02.430 --> 18:09.180
Also, this matrix is called a rotation matrix, and this is an elementary rotation matrix as the two

18:09.180 --> 18:12.270
reference frames share their x axis.

18:12.750 --> 18:19.980
So we call it r x of Theta, which represents an elementary rotation matrix around the x axis by an

18:19.980 --> 18:20.640
angle theta.

18:21.820 --> 18:22.690
Together.

18:22.690 --> 18:29.740
These three elementary rotation matrices represents all the possible elementary rotations that a reference

18:29.740 --> 18:32.860
frame can undergo with respect to another.

18:33.250 --> 18:37.210
However, our initial problem was different and more complex.

18:37.420 --> 18:44.530
We wanted to express the arbitrary orientation of one reference frame with respect to another without

18:44.530 --> 18:47.050
necessarily sharing our rotation axis.

18:47.880 --> 18:54.180
It turns out that we can decompose the general problem into three sub problems and determine only the

18:54.180 --> 19:00.360
elementary components of the orientation along the three rotation axis, so X, Y, and Z.

19:00.570 --> 19:07.950
By simply combining, so multiplying the three elementary rotation matrices, we obtain a generic rotation

19:07.950 --> 19:15.450
matrix that allows us to express the orientation of one frame with respect to another in terms of three

19:15.450 --> 19:16.110
angles.

19:16.110 --> 19:23.370
So C around the Z axis, FY, around the Y axis and theta R on the X axis.

19:23.670 --> 19:28.170
These angles are often known as roll pitch and yaw.
