Now that we know how to express the translation of our reference frame with the respect to another one
using the translation vector, let's see how to express its orientation using rotation matrices.
In this case, we consider a very simple problem that involves only two reference frames, a global
fixed reference frame called W, and a mobile reference frame that can freely rotate and is oriented
differently from the fixed reference frame of the world.
To simplify the problem, let's assume that these two reference frame have the same origin, the same
center, and therefore the translation vector that connects them is zero.
In this problem, we assume that the translation is zero and therefore the centers of the two reference
frames always overlap.
This way we can focus uniquely on the study of the orientation of the reference frame R that is attached
to the robot with the respect to the global reference frame W.
In other words, we want to find the angular displacement Theta Phi and PSI between the X, y and Z
axis of the two reference frames.
The mathematical tools to solve this problem are complex and are called rotation matrices, but their
derivation is very simple and intuitive, requiring some basic understanding of trigonometry.
It will help you better understand the logic and the manipulation of reference frames.
As always, when faced with a complex problem, let's approach it by breaking it down into simpler and
more easily solvable subproblems.
So let's consider the simple case when we have a fixed reference frame and our mobile reference frame
that is rotated with respect to the Z axis of the fixed reference frame.
In practice.
We are saying that these two reference frame in addition of having the same origin, also have the same
Z axis.
So the Z axis is oriented in the same way.
This is also the rotation axis of the second reference frame.
In other words, we have rotated the second reference frame, the one in red by an angle C with the
respect to the Z axis of the first reference frame.
So the fixed one in black.
If we were to look at these two reference frame from above, we would observe a plane formed by the
X and Y axis of the first reference frame and the Z axis coming out of the plane, so out of the screen.
Consequently the second reference frame.
So the mobile one will be rotated by an angle C with due respect to the first one and therefore the
x first and y first axis of the second reference frame are rotated by an angle C with respect to the
x and Y axis.
Now let's assume that there is a point P on the x y plane of which we project the coordinates along
the x and Y axis.
It will have coordinates, p, x and p y along the axis of the first reference frame.
So the fixed one.
Similarly, we can project the point p onto the second reference frame so the rotated one obtaining
the coordinates p x first and p y first.
Applying some simple trigonometric equations, we know that if we project the vector p x y along the
x axis of the first reference frame.
So the fixed one we obtain that the component of this vector is p x first multiplied by the cosine of
the angle pq.
Similarly, if we project the vector p x first along the y axis of the fixed reference frame, we obtain
that the y component of this vector is p x first multiplied by the sine of the angle PQ.
Similarly, we can project the p first vector along the x and y axis of the fixed reference frame.
So the component along the y axis is given by p y first multiplied by the cosine of the angle C, and
the component along the x axis is given by p y first multiplied by the sine of the angle c.
So far we haven't actually written any kinematic equation, only simple trigonometric derivations.
At this point, knowing these derivations, we ask ourselves what are the values of P, x, P, y,
and Z?
So which are the coordinates of the point?
P with the respect to the fixed reference frame.
So the black one.
Assuming that we know p x first, p, y first and p z first, which are the coordinates of the point
P with the respect to the red reference frame.
So the one that is rotated by an angle C around the Z axis.
Let's start with the easy things.
Let's say that since the Z and Z first axis are equal to each other, so they share the same direction
and origin.
The coordinate of the point P along the Z axis is the same in both reference frames.
Then let's determine the x coordinates of the point.
P.
This is given by the sum of two components.
The first one is p x first, which is the coordinate of the point P along the x first axis multiplied
by the cosine of the angle PC.
The second one is P first, which is the coordinate of the point P along the Y first axis multiplied
by the sine of the angle PC with a minus sign indicating that it has opposite direction.
Finally using the same approach.
We can also determine the y coordinate of the point P.
It is given by p x first, multiplied by the sine of the angle C plus p y, first multiplied by the
cosine of the angle.
C We can express this equation in a matrix form preserving its meaning.
The three coordinates of the point P in the fixed reference frame are given by the product of a certain
matrix by the vector of coordinates of a point P in the second reference frame.
So the mobile one.
In the matrix that connects the coordinate of the point P In the two reference frame, we need to insert
all the components, all the coefficients of the equation.
Since the last row and the last column refer to the components along the Z axis, we can set them to
zero and set the component along the z axis to one.
In practice, we have inserted the first equation into the matrix, which tells us that the coordinate
of P along Z is equal to the coordinate of P along Z.
First, the first row of the matrix consists of the cosine of Z and minus the sign of Z, which corresponds
to the second equation which connects the x coordinate of the point P in the two reference frames.
Finally, the second row consists of the sine of the angle C and the cosine of the angle.
C expressing the relationship between the y coordinate of the point P in the two reference frames.
This matrix is called the rotation matrix.
Specifically an elementary rotation matrix.
It is elementary because we assumed that the two reference frames share their Z axis and therefore they
have a common axis of rotation.
We denote this as R Z of C, which represents an elementary rotation matrix around the Z axis with the
two reference frames rotated by an angle C.
With this tool, we can now freely change the reference frame and express the coordinates of the point
P in the fixed reference frame.
Given the coordinates of the point P in the rotated reference frame and by knowing the rotation angle
between the two reference frames.
This is not the only elementary rotation matrix that we can create.
There are two more.
Let's assume that we have a fixed reference frame still X, Y, and Z in black, and our mobile reference
frame X first, Y first and Z first.
But this time the two reference frame share their y axis.
So the y and y first axis are equal.
They are oriented the same way and they have the same origin.
Then the second reference frame in red is rotated around the y axis by an angle phi.
In this case, if we look at the system from above, imagining ourselves on the perspective of the rotation
axis y, we will see a plane with the X and Z axis and instead the Y axis is coming out of the page
coming out of the screen.
Similarly, we will see the X first and z first axis of the second reference frame rotated by an angle
phi and the Y first axis also coming out of the page.
Again, let's consider describing the coordinates of the point P in both reference frames.
This point will have coordinates, p, z and p x along the z and x axes of the fixed reference frame
and coordinates p, z first and p x first along the z first and x first axes of the rotated reference
frame.
Using some simple trigonometric derivation, we can predict the Z first vector.
Along the Z and x axis of the fixed reference frame and determine the components of the Z first vector
along the Z axis.
And this is given by p z first multiplied by the cosine of the angle phi.
And the component along the x axis is given by p z first multiplied by the sine of the angle phi.
Similarly, we can project the first vector along the x and z axis of the fixed reference frame.
Its component along the Z axis is p x first multiplied by the sine of the angle phi, and the component
along the x axis is p x first multiplied by the cosine of the angle phi.
Once again, we ask ourselves what are the coordinates of the point P in the fixed reference frame?
Specifically, what are P, x, P, y, and Z?
Assuming that we know the coordinates of the point p in the mobile reference frame.
So assuming that we know p x first, p, y first and p z first, we can write a system of three trigonometric
equations to answer this question.
The coordinates of P along the Y axis of the fixed reference frame is equal to the coordinate of P along
the Y first axis.
Since the two y axis are the same.
The coordinate of P along the x axis on the other end is given by the sum of p x first multiplied by
the cosine of P and p, z, first multiplied by the sine of phi.
Similarly, the coordinate of P along the Z axis is given by minus p x first multiplied by the sign
of z plus p, z, first multiplied by the cosine of P.
Once again, we can express this system of equation in a matrix form to connect the coordinates of the
point P in the fixed reference frame to the coordinates of P in the rotated reference frame.
In this matrix since the x axis of the two reference frames are now equal.
The second row and the second column are both zero and one, indicating that the coordinate of P along
the Y axis is equal to the coordinate of P along the Y first axis.
The first row which expressed the relationship between the coordinates of P in x and x first is given
by the cosine of phi zero and the sine of phi.
And finally the last row, which expresses the relationship between the coordinates of P along the Z
and Z.
First axis is given by minus sine of phi and cosine of phi.
This matrix is also called a rotation matrix and in this case an elementary rotation matrix as the two
reference frames share an axis.
So the Y axis.
So we call it our Y of V, which represents an elementary rotation matrix around the Y axis by an angle.
As you may have already realized, there is only one more elementary rotation matrix missing which express
the case when we have two reference frames sharing the x axis.
This means we have a fixed reference frame and a mobile reference frame that share the same x axis and
the mobile frame is rotated around the x axis by an angle theta.
To find the last elementary rotation matrix, we imagine ourselves as an observer located on the x axis.
In this case, we would see a plane with Y first and Z first axis rotated by an angle theta with the
respect to the fixed reference frame.
Once again, let's describe the coordinates of the point P in both reference frame.
This point will have coordinates, P, z and p y along the z and y axis of the fixed reference frame
and coordinates p, z first and p y first along the z first and y first axes of the rotated reference
frame.
Using some simple trigonometric derivations, we can predict the pi first vector along the Y and Z axis
of the fixed reference frame and determine that the component of pi along the y axis is given by pi,
multiplied by the cosine of the angle theta, and the component along the z axis is given by pi, multiplied
with the sine of the angle theta.
Similarly, we can project the first vector along the z and y axis of the fixed reference frame.
Its component along the y axis is p z first multiplied by the cosine of the angle theta.
And the component along the Z axis is p, z, first multiplied by the sine of the angle theta.
Once again, we ask ourselves which are the coordinates of the point p in the fixed reference frame.
So which are P, x, P, y and z.
Assuming that we know the coordinates of the point p in the mobile reference frame.
So p x first, p, y first and p z first, we can write a system of three trigonometric equations to
answer this question.
The coordinate of P along the x axis of the fixed reference frame is equal to the coordinate along the
x first axis since the two x axis are the same.
The coordinate of P along the y axis on the other end is given by the sum of p y first multiplied by
the cosine of theta and minus p z, first multiplied by the sine of the angle theta.
Similarly, the coordinate of P along the z axis is given by p, y first multiplied by the sine of theta
plus p z, first multiplied by the cosine of theta.
Once again, we can express this system of equation in a matrix form to connect the coordinates of the
point P in the fixed reference frame to the coordinate of P in the rotated reference frame.
In this matrix since the x axis of the two reference frames are equal, the first row and the first
column are both zero and one, indicating that the coordinate of P along the x axis is equal to the
coordinate of P along the x first axis.
The second row which expressed the relationship between the coordinates of P in Y and Y.
First is given by zero.
The cosine of theta and minus the sine of theta.
And finally the last row which expresses the relationship between the coordinates of P along Z and Z.
First is given by zero sine of theta and cosine of theta.
Also, this matrix is called a rotation matrix, and this is an elementary rotation matrix as the two
reference frames share their x axis.
So we call it r x of Theta, which represents an elementary rotation matrix around the x axis by an
angle theta.
Together.
These three elementary rotation matrices represents all the possible elementary rotations that a reference
frame can undergo with respect to another.
However, our initial problem was different and more complex.
We wanted to express the arbitrary orientation of one reference frame with respect to another without
necessarily sharing our rotation axis.
It turns out that we can decompose the general problem into three sub problems and determine only the
elementary components of the orientation along the three rotation axis, so X, Y, and Z.
By simply combining, so multiplying the three elementary rotation matrices, we obtain a generic rotation
matrix that allows us to express the orientation of one frame with respect to another in terms of three
angles.
So C around the Z axis, FY, around the Y axis and theta R on the X axis.
These angles are often known as roll pitch and yaw.