[IONLAB Lectures] Quaternion Rotation Formula (Claire take)
Transcript
today we're going to talk about how quaternions can be used for rotation so for that matter we are going to start with two results the first result is the rotation formula so I will require this result that allows us to rotate a vector so we have uh if we have an axis of rotation given by a vector n and we want to rotate a vector V pull a left hand rotation of an angle Theta we have seen before that the formula that allows us to do that is a UV is a rotated Vector it's given by U cross let's say this is u and then the rotated Vector will be V so our V is given by U Dot N and 1 minus cosine of theta plus u cosine of theta plus u cross n sine of gamma so that's the result number one that I will require if it's so required and we also will require the definition of a quaternal product so the quaternal product is given by this formula so I will also use this result and today will be all about how these those two connect how can I use this algebra that of quaternions that is defined by a product like given by this how can I decode a rotation such as this one and uh this is no trivial result actually Hamilton many of you was walking uh when he produced this he was working on this for a very long time and was only when he was walking uh through the candle with his wife that out of the sudden he came up with this uh with this idea that the product should be done by this not exactly by this but by something extremely similar that falls now into this and he was so excited and uh and I read actually uh uh he was so excited that he felt the need to carve with a knife that result into a stone which is uh today in doubling if you want to see it which is quite uh which is quite uh fortunate because today is just one day after Saint Patrick's Day that we're shooting this video so we're gonna celebrate today quaternions and Hamilton in Dublin with that in any case uh for us to achieve that result I will decode or perhaps re-parametrize the quotarian as follows the quaternion any quaternion can be written as a norm so the norm of this quaternion is a plus a uh unitary direction of the quaternium in four dimensional space and that can be given by like this now I know that it it feels like I just [Music] um wrote this out of the blue and uh indeed I have so I know that the right result that we're looking for is this one but we are going to go the other way the the other way around right to talk several times for How many don't you come up with those equations so it's not trivial to go from what we want to do to those instead we will go from the right answer and show you that indeed it works so any quaternion can be parametrized as this as a norm times a direction in four dimensional space and this direction before the National Space can be further re-parametrized into an unitary vector plus a sign of an angle and the cosine of angle over here okay so take this so just believe just bear with me for a second with this formula and we're I'm gonna show you that if we do the following operation which is uh uh Q we will take the Q inverse multiply that by a quaternion that will construct like this will take zero real part plus a imaginary part of you and then multiply that by q and then I will show you that what we will have if we do this multiplication assume the quaternal is decoded by that we will in the end have this we will have yet another quaternion which would have zero part and V will be the rotated Vector according to this formula so this is how we decode the quaternion uh rotations this is how we can do rotations using only quaternions and then we will go through that so I want to explore that a little bit but just before so let's think just to make a parallel with complex numbers remember that a complex number was given by a phase oh sorry phase again plus a phase right and this when you multiplied another complex number this one this value would increase would work as a grain so this would increase the value of the gain and this was as a phase so you could use this as a game for the for the vector itself the complex number will increase by this Factor over here and also we have an additional phase an additional angle that is given by this and in a very similar way I want you to think now that this any quaternion can be written out as this which will be again so the norm of the quaternion is the gain and this would be in some sense a 3D phase okay so when you multiply quaternions this multiplication of a multiplication of quaternals will add a face and we'll add a gain and the way to rotate potential is given by that now we will go through this then just to show you that that is indeed the case and also to practice a little bit uh quaternal multiplication and other Concepts that we'll see very shortly so the inverse of a quaternion again the inverse of the quaternion is the inverse of the game times the conjugate the quaternal conjugate which if you remember we just need to invert the sign of the of the vector component so this will go cosine of data over 2 minus n sign of that over two multiplied by 0 and u multiplied by the quaternity itself so multiplied by a times cosine of that over 2 and sine of theta over 2. so if we work this a little bit you can see that this a will cancel with this a over here and now we need to choose a product to do quaternions product quaternion product is associative so we can choose to start either here or here I will start maybe perhaps over here so this will give us 1 over a cosine of Delta over 2 minus n sine of that over 2 quaternal product and now we do this product over here so notice that is the product of the real Parts which is zero times something you got zero minus the dot product of those two so it's minus a DOT product meaning that uh oops we're doing products of those two so it's minus you so this sign come over here sine of theta 2. U dot product n so this is what we get from the first part and then we need to do this other part over here which is the zero times this Vector plus cosine of that over 2 times this vector over here so we got the second one plus the cross product between those two so the cross product of U and n sine of theta over two so this is the object this is the the final product of those two first of those two elements and now we continue the product with the third one to see what we get I'm very sorry just this a was canceled so this a is not here anymore so what we have now same formula this element times that element over there will have cosine then the sine and there is a minus over here so there is a minus U dot product n and then you have the dot product between those two now it minus the dot product so these minus will cancel with this minus and you have a positive and is the dot product between this vector and those notice that this is parallel to n and this one this Vector over here is perpendicular to n and then you're going to do the dot product between a vector and a perpendicular vector and therefore this second component does not count it's gonna be zero and what you have is just sine of data 2 cosine of Delta 2 and n dot product U okay and now we're going to do the second line but notice for the first line that this term is equal to that term so you already have zero on the on the first line and therefore this result here is already valid but what we want to compute then it's what it's here and we want to see if this value over here it's indeed V so let's do that let's compute compute this expression which is P0 the first one so this expression here will be cosine of Delta 2. times this Vector over here so you have cosine squared time U times U Plus U n cosine Theta 2 sine Delta 2 sine Theta 2 plus that then you have now these value over here times this Vector so it's really minus with minus is a plus you get sine of Delta 2 and then n U Dot N and then then cross the the the the cross product of this vector and this Vector over here so the cross product okay so we'll add those up we will have Plus I'll put it in two lines so now we have a minus cross product of n sine of theta 2. n cross product U and then you have have also a cosine Delta 2.
minus sign Theta 2 squared with an n cross product with this guy over here now this is the moment where we can exercise some vector algebra and some trigonometry let's see what we can do to uh because in the end of the day we want to we are hoping to get this and we definitely don't have that yet but let's see what we can do about that uh first of all we do have those terms that look this term over here and this term over here that looks very much alike except that the dot product order is uh reversed and the one we are looking for is U cross n therefore I will change this one to you cross and instead and I'm allowed to change this order if I change the sign right so I'm taking the second one and if I do that those terms are exactly the same so I'm allowed to add them up and if you do that those two terms together when you add them up they will add them up to two sine of theta 2. cosine of Delta 2. you cross in and you can see from this coming back from trigonometry we have the double Arc formulas that tells us that if you have for instance sign of 2x that's given by two sine of x cosine of x and that's exactly what we have here except that X is Theta over 2 and therefore this sign is really 2 that over 2 which is sine of theta so in the end of the day this part here is sine of theta and then you have sine of theta U cross n as it should be so we did find our first Vector now we need to find those two so the other four the other term that I want to work a little bit is this one over here this is what is called a triple product and there is a Formula that could help us a lot here which is called the triple product expansion so the triple product expansion is the formula in general is given by this so if you have a cross B Cross C and the parenthesis they are right in this position this can be written as a b a DOT product I mean with c minus there's a miniment for that in English which is called the back the back cab the back cab formula so this is called the back okay the back of the cab formula that helps you remember that's how I remember so we can use that we can actually plug this over here if you do that if we if you uh if you use this expression in cross you cross and what you have is the back so B U H the back so a times the C minus C which is the last term and sorry this is n uh a b so A and B so n dot U okay so we have that notice that in uh cross an energy unitary Vector so the dot product of vector of itself is really uh the norm and the norm of this unitary Vector is just one right so this is really just U and therefore this term over here we can rewrite it as a sine squared of theta over 2. times U so there's a minus 0 keep that minus over there and minus this other term although if that minus become a plus okay so this minus with this minus is a plus of sine squared of theta 2. n dot U so you have that and now we have something very similar you have this term in this term which together gives you you cosine squared of Delta Dot over 2 minus Z squared of that over two and this term on the other hand it's yet another double Arc formula so this is for the double of sign but you also have the cosine of 2x which is given by cosine squared of uh of x minus the sine squared of X so this is the double formula for the cosine of x and in this case is exactly what we have over here so we can really write this as U this term here as the cosine as U cosine of data and we found this term so we have the second term and what on What remains should be this term over here and indeed it is so now the only two terms that remain are this term and this term so I just missed a squared over here and notice that this curve there came from the product of those two and therefore there was a sign that I missed but I'm putting it back and then you will see that those two sine squared here will give you um 2 sine squared right so here what you will have is to sine squared of theta over 2 n n plus u and you can play with this a little bit longer to find that if you use the fundamental trigonometry formula over here that this cosine is really 1 minus sine squared so then you have one minus sine squared with this sine Square becomes 2 sine squared and therefore you have that the sine is the two sine squared 2 sine squared is really equal to 1 minus the cosine of 2x and if that's data over 2 then it becomes 1 minus cosine of theta and you have this final term so this is really the final term that we have over there which is one minus cosine Theta and N over and therefore what you will have is the rotation formula downstairs so here this is really the that's what you have and the main or this was a great exercise to come up with a lot of Notions that you had before and how they build so you can become really intimate with this process but understand that the most important thing to the takeaway here is that you are able to do this quaternal multiplication and this uh process will give you the rotation of a vector itself and since this was a left hand rotation either of the vector you can see there's a left hand rotation of the vector or a right hand location rotation of the reference frame so if we rotate to the right a fixed Vector will rotate to the left so this formula can also see be seen as the right hand rotation of a reference frame so this is how the quaternal algebra comes together to help you to do rotations and notice that while here we need a trigonometric functions to perform this operation here we do not if I tell you what a quaternion is and that quaternity will be four numbers you can plug those four numbers here and do only polynomial operations and you perform a rotation so that's quite interesting and we have yet even more interesting properties that we will explore perhaps later but this was how Hamilton was so excited that he had to carve on the on the stone and that process up to this data is on a letter marked to his son but on the 16th day of the same month which happened to be a Monday and the council day of the royal Irish Academy I was walking into attend and preside and your mother was walking with me along the Royal Canal to which she had perhaps driven and although she talked with me now and then yet an undercurrent of thought was going on in my mind which gave at last a result whereof it is not too much to say that I felt it once the importance an electric circuit seemed to close and a spark flashed forth The Herald as I foresaw immediately of many long years to come of definitely directed thought and work by myself if spared and that all events on the part of others if I should even be allowed to live long enough distinctly to communicate the discovery nor could I resist the impulse unphilosophical as it may have been to cut with a knife on a stone of Bruin Bridge as we passed it the fundamental formula and the fundamental formula that he wrote were the bases that Define quaternal multiplication that allows us to do what we just did