Let's continue with our practical lesson.
So in this lesson, we will try to apply what we have learned about different representations of rotations
like Roll Pitch Your Aler Angles quarter and use angle and angle vector representations into practice.
So let's start with aero angles.
OK.
Uh, angles.
OK.
First of all, let's take a rotation matrix, which is, as you know, we have assumed in our tutorial,
the angles as that.
Why is it so sequence?
So rotation about it, then rotation about why then rotation about zip.
OK.
So as you know, this was the these were about the current axis, not the fixed axis.
So be careful here.
So that's why we will multiply.
Uh, excuse me, multiply these rotations mattresses post multiply because they are about the current,
uh, rotation error, current frame, not about the fixed frame.
So then rotation z rotation y zero point one and then rotation Z again zero point three.
So this is our rotation matrix uh, z y z rotation mattress.
OK, then let's uh, see, first of all, this result of this press f nine and you can see the rotation
matrix here.
OK, then let's do try to do the same with that function, which is, uh, easier, which converts from
eyler angles to rotation matrix.
So what are our angles?
Zero point five, zero point one and zero point three?
OK.
No, let's do from eyler to rotation matrix.
OK, let's run this also.
OK.
If mine and OK, it is so rotation matrix.
As you can see, they are the same.
We can check this in this way or one or two.
This is not equality, OK?
This is just for comparing if the indices of R1 is equal to indices of R2.
Let's check if all of them are equal.
We will have to see one matrix.
As you can see, we have seen matrix of one.
Uh, so every indices of R1 is equal to R2.
So metrics are one is equal to R2, which is, uh, which have to be like that.
So let's see now our let's see, first of all, KLC in order to clean our workspace.
OK.
And let's see our, uh, rotation matrix again.
OK, this is our rotation method.
So I would like to remind you that, uh, now we will try to first of all, this right here what we
are trying to do.
Uh, we we try to find aler angles, angles from rotation matrix.
OK.
So as you remember what we have said, first of all, there was two cases.
If our rotation matrix are one, three and R2, three indices are not zero, then we have to separate,
uh, solutions.
So, OK, let's try to find this error angles.
Because the T R2 L, which converts from rotation matrix to our um LRA, uh, angular representation.
OK.
No.
Let's see if mine, these are our angles.
As you can see, they are the same zero point five zero point one zero point three.
We got our error angles.
OK.
But what's interesting is L or angles equals thirty or two.
And let's do the same with this one like that.
But now we will take the T to as minus, because what we have said, we have said that if our rotation
matrix R1 and R2 three are not zero, then we have two different solutions.
This was because of the sine difference of TITA.
In this case, we have taken Theta as a plus.
As you can see, this is a plus.
No negative.
Now we will try to do the same, but with negative.
So, OK, let's copy it.
Then this one, uh and uh, we will just make it minus.
OK, let's see the rotation mattress press f nine.
This is not our rotation matrix.
As you can see, it's different from the first one.
OK, let's try to.
Find our angles or let's see what we get.
OK.
Press nine, as you can see, we got Twitter plus, however, our Twitter was minus and also we got
completely different angles from the original one.
However, what's interesting if we try to again find our Aler angles from every angles, from our rotation,
so, uh, our angles, so we try to convert.
We we got our angles and we will try to convert these angles.
Rotation matrix again.
What is interesting is that we got the same rotation matrix as you can see.
What does it mean while we have quite different angles?
We when we convert to the rotation matrix, we got the same rotation mattress.
This means that different angles correspond to the same rotation matrix.
So mapping from rotation matrix to angles is not unique.
OK, so we can get different angles which are mapping to a unique rotation matrix.
OK, let's continue.
And this is not surprising because we have seen this.
So let's come to the second, um case where are one three and our two three indices of our rotation?
Matrix is zero.
So let's case two.
If Twitter is zero and R1 three because it is zero R1 three and are two or three because of sine, these
contain sine of T to sign of zero equals to zero.
So that's why R1 Street and R2 three will be zero.
We have seen all of these in the last lesson.
So if you cannot remember, please refer to these, uh, lessons again and repeat and come back.
OK, R2 three of rotation matrix matrix becomes zero.
OK.
So let's do that.
You were alerted to a rotation matrix, OK?
Zero point five.
Now, as you can see, we gave it a zero.
So we have to get our once we are two three in zero, let's check if we will get as you can see, your
star wants to be and R2 three zero.
What we have said in our last this is we have said that every R1 three and R2 three equals to zero.
Then we have infinite solutions for the angles.
I mean, V and C angles.
OK, let's check that.
First of all, let's ride that.
So when finding a hole or angles or angles?
So, OK, a angles, there are infinitely many solutions.
OK.
So these are two hailer.
So what we are doing, we are converting from rotation matrix to angles.
OK, now see what we will get.
OK.
As you can see, we get it as zero, which is expected and we get zero and zero point eight.
So, uh, the library, the petrol caucus library and also in robotics.
It is by conversion.
What is done is accepted as zero.
Because we have infinitely many solutions, we can accept anything.
So we accept features as zero and find see based on this one.
OK, let's try this one.
Also by convention angle fee is zero.
OK, now let's come to roll up your roll pitch, your pitch, your representation of rotation.
OK.
What we will do first of all.
First, let's try to roll pitch yaw to convert it from roll pitch rotation metrics.
So roll pitch your two rotation matrix.
The default in our caucus library is default is zit y x sequence.
So the first angle is about Z.
The second is about why the third is about, uh, x uh, axis.
And be careful, enroll pitch.
Yo, we the subsequent rotations were about not the current frame.
Fixed frame.
So, OK, but you can change this sequence.
Let's first.
OK, let's do.
Uh, I will show how you can change.
First of all, it's from RPI, from RPI to rotation matrix.
This all function.
0.5 0.1.
So this is about it.
This is about why this is about actually zero point three.
So let's check our rotation matrix F9.
As you can see, this is our rotation matrix.
The in rotation matrix and let's ride help or roll pitch, you know, two rotation and as you can see
we can from options we can override.
Let's make it bigger, OK?
We can override the sequence x y z z y x y exit.
OK, so let's continue.
OK.
So what what?
We will try find angles from rotation matrix.
OK, what we will do.
We will transform from a rotation matrix tool or p y role feature from our rotation methods.
Let's check F9 Chris.
If man, as you can see, we get the same role, pick your angles so we can even visualize it to visualize.
We can visualize, uh, roll pitch.
Yo, um, we can.
Write this comment, and we will we we can animate road picture, which is in order to understand them
better.
As you can see, this is about z axis y axis x axis.
OK, first of all, for example, this our plane, uh, we try to rotate it about that axis.
As you can see, we are rotating now about z axis.
OK, let's rotated about y axis.
And, OK, let's rotated about x axis.
OK.
As you can see, now, we are rotating about x axis.
You can play with it and try to understand better, you can change your sequence from here.
OK, so let's come to axis angle representation, axis angle representation.
OK, so what we can do, first of all, let's try to define our rotation metrics from every angle,
so rotation zero point five, zero point one and zero point three.
So let's run this one.
This our rotation matrix that we got from al angles.
So as you as we have said before, every rotation can be represented as a rotation about some axis and
with specific angle theta.
So this is our Twitter angle and this is our rotation axis.
So let's try to from rotation matrix, we will try to find angle vector relation or axis angle representation.
We can say the same because our axis is unit vector.
OK, let's try to find Titov V.
OK, excuse me.
OK.
We have done something.
OK.
Miss Bill here two and go, OK.
There is no here.
This should be correct now.
Oh my gosh.
Let's copy that.
I don't know why.
Misspell?
OK.
No, it's correct.
OK.
As you can see it, this is our Tita angle rotation angle and this is our rotation axis.
As you as we have said before, we can find these, uh, axis of rotation.
And our rotation angle from eigenvalue and eigenvectors problem.
So eigenvalues and IGen vectors of rotation matrix are we will analyze this.
So first of all, let's try to find eigenvalues and eigenvectors.
We can ride up the built in function for doing that.
And if not, OK.
As you can see, this is our, uh, eigenvectors.
OK.
And this is our eigenvalues.
Don't be afraid.
The eigenvalues of our eigenvalues are on the diagonal.
As you can see, only these are our eigenvalues.
We have three eigenvalues, and for each of eigenvalues, we have eigenvectors, which are the columns
of this matrix.
As you can see, this is for the first one.
This is for the second eigenvalue, and this third column is for the third eigenvalue.
And what we have said before, we have to take the eigen vector corresponding to the eigenvalue of real
value old one, because that was giving our two US rotation matrix because this was the rotation, because
eigenvalue multiplied by eigenvalue one will not change the absolute value or length of the vector.
So this is our um rotation axis.
If you compare it, abore, as you can see, they are the same.
OK, they are the same as you can see from eigenvectors and eigenvalue and those as we can find their
rotation vector.
So how we can find the rotation angle, what we have said, we have said before that we can find our
angles from eigenvalues.
So our argument from by comparing our eigenvalues equals to cosine of titov plus or minus, I wrote
like that or excuse me, I don't.
I have tried it.
Not here, but here.
OK.
OK, Eichmann's equals the plus or minus I times sign off.
We can't use our rotation angle, so let's try to do this work.
First of all, let's try to find it up by function from Peter Caucus Library.
Let's right angle and give our eigenvalue to this and try to find Theta.
As you can see, this is our rotation angle, but how we can find if we compare this formula, for example,
with this eigenvalue, as you can see, cosine of Quita equals to this one.
So by our cosine, we can find angle.
Let's try it.
A cosine is, as you can see, we got the same angle.
OK.
So
then we can find what we will try to do now.
We will try to find rotation matrix from angle axis representation.
So from an angle vector or axis to rotation matrix, we will use here Rodrigues formula.
You can search for it and you can look videos of it.
However, it is not essential because it is applied inside the politico.com's library.
OK, angle vector two.
Ah, OK.
This is pi over.
Two.
OK.
We are.
Our rotation angle is PI over two and rotation axis is equal to one zero zero.
So we are.
What we are doing is we are rotating our vector or our rotation is about x axis and pi or two angle.
Let's check f nine.
OK.
This is our rotation axis.
Additionally, we can do compare it with like that rotation of x rotation x pi or two.
This will directly give us a rotation matrix.
Uh, pi over two around x.
As you can see, they are the same these zeros after proceedings, however, they are the same as you
can see.
OK.
Let me just make it bigger in order to be more clear.
OK.
So let's continue with unit cohesion.
You.
OK, now we come back to you and we come to you and quarter new unit quarter earnings, so let's define
two quarter earnings.
Q1.
I'll just copy and paste here in order to be to save time.
As you can see, we are using unit quarterly and class from Pethokoukis Library.
And also we are doing we are getting the second quarter in creating the second unit quarter union.
Let's see them press f line.
As you can see, we have two quarter earnings unit quarter earnings.
The first one, this is Scarlett apart, as you can see, and this is victor part leather part and victor
part.
What we have said, we have said that we can add and subtract, um, unit quarterly.
So let's excuse me, it was the key one plus Q2.
And there are some element wise, let's do.
As you can see, there are just some buy element.
Was this all resultant quarter new leads to also their multiplication because we have said that they
can be multiplied and they are representing what relative rotation.
So by post multiplying it, we are representing rotation about current axis.
So let's check that out.
What will it give to us?
And this is the resultant quarterly and we can check this quarter when you buy like that, for example,
first of all, try to, uh, get the first from RPI to a rotation axis to get our one.
We are just, uh, making this one.
I mean, we are taking this role PTO angle and convert rotation matrix and do the same for the second
one.
And what we can do we can make it are three equals two or one times are two because, uh, the rotation
is about the current axis.
So we had the post multiplied and what we can do now.
We can convert this rotation to quarterly and this Q five has to be equals to Q4 because they are doing
the same thing, essentially both of them representing the relative rotation.
So the resulting continuous will have to be the same.
Let's check that out.
Let's choose all of them and price if and this is our Q5, let's also Q4 in order to see them.
As you can see, they are exactly the same because they are doing the same thing.
You can do that for pretty multiplication in order to understand clearer, but they are essentially
the same.
We can find the inverse or contract of consequence of our rotation matrix.
This is nothing but, uh, just the sign of, as you can see, the sign.
Uh, this is our inverse or consequent, um, quarterly.
And let's write it here, OK?
Um, consequence of unit growth quarterly in the interesting thing is that if we multiply any quarter
you so Q1 times with its inverse what we do, we have to get we have to get only
identity quarterly, which represents it's right now rotation.
So there is no rotation.
OK, let's run this one and see what it will give to us.
As you can see, this is what this is.
I didn't do quarterly with well, one won and there is no rotation axis.
If there is no rotation axis, this means that there is no rotation.
There is no valid rotation.
OK, let's do.
Uh, how we let's see now how to convert from quarter new to rotation metrics.
It's very easy.
We just write are for our rotation, you know, to save our rotation mattress to one dot or we get the
V.
By doing that, we get rotation matrix of our from quarter new.
Let's run this.
OK, as you can see it, this is our rotation metrics.
And then we can even plugged our quarter new.
OK, uh, we can plot the orientation represented by.
Is quoting him.
OK, and then what we can do else, we can just, um, obtain rotated vector by multiplying so we can
rotate a vector by multiplying it with a crop, turning OK, by multiplying continuum with vector.
So let me just copy and paste it.
OK, this is our resultant vector.
This is our original vector.
We are multiplying it with our quaternary neon and we have to get new rotated vector.
Let's see this one f nine.
If this is our rotated vector, let's just visualize this by doing this.
Let me just copy and paste.
We are doing just what we are doing from zero.
I first plot our first original vector and then we are plotting our rotated vector from relative to
point zero.
As you can see, from point zero, this is the point of four x y z coordinates of first point.
And this is the X was it of our second point.
I mean, original one.
And also, this is the origin of our origin point.
So the point we refer to so zero zero zero and this is our resultant one result and two and resultant
three is just x y z of our rotated vector.
So without anything else, let's run this one.
And as you can see, as you can see, this is our original vector and this is, as you can see, this
is our rotated vector.
It's rotated by our criterion.
OK, see you on the next lesson.