Moving on, the last thing we want to talk about. There's lots of things we could discuss. But given the time, this is a really elegant method that I saw. Malcolm Shuster, in his paper on the survey of attitude parameterization has this cool formula that he shows. The geometric inside, and how you can do direct addition of Euler angles. We've discussed add orientations. The brute force never will fail, the way is simply to map everything to DCMs. Multiply the DCMs out correctly. Transpose ones as needed. Get your answer in the DCM. And then you can pull out whatever coordinates you want. This is particularly handy if you have mixed coordinates. If you have some quaternions, adding Euler angles, and the answer has to be in Rodriguez parameters. DCMs, map it, come back. So this is one method where if we have Euler angles of the same type. So let's say we have 3-1-3. They have to be symmetric. And if we have 3-1-3 angles, we can use a direct addition. So, we don't have to map to a DCM. Do two three by three multiplications. And then extract from a three by three DCM where we only use about half of the elements. The right inverse tangents and science functions and so forth. This is a way that we can get there directly. And there's some interesting twists with this story as well that you will validate. I'm showing you highlights here. In the homework you will actually process and fully develop this yourself. Doesn't take very long. So the first step is we have to deal with spherical trigonometry, right? So Euclidean geometry, if we're on a flat plane, a triangle. All the inner angles have to add up to 180 degrees. That's no longer true. If you're on a sphere, just think of these triangles now wrapped around the Earth and we forget J2. It's just going to be a perfectly spherical Earth. And you can hike in three straight lines and connect them to make a triangle. But that triangle is curved, wrapped across the surface of that sphere. That's what we're looking at. So what happens here, then, is instead of distances. We have these arc lengths. That say, look, across the globe, I went from 10-degree latitude up to 30 degree latitude. I traveled 20 degrees. You don't say you traveled this many kilometers, or miles, or whatever units you prefer. It's all in an angle form. And then these parts are exactly the same. Those are just the inner angles. Locally, if you go on that plane, look at it. And say, okay, that angle is about 85 degrees. That's what you have. We have laws of science and laws of co-science. For spherical coordinates. Actually, this morning quickly I went to Wiki. Always a good site. Just to review quickly if you have a classic flat triangle you can see the notation. a is the distance here. c is a distance. b is a distance. Big ABC are the inner angles. They really use the same notation. And then this is the classic laws of sines and cosines. In that triangle these ratios of opposite side over the sine of the inner angle and the other end. Have to be the same. And this is what you can use. If you know two, you can find the third, and so forth. Laws of sines. But we have little a's as distances. And if you look at laws of cosines. Very much the same. That's where you have c squared is a squared plus b squared minus ab cosign of the angle. So, c squared is this square. This square minus cosign of the angle opposite of c. And that's how you get there. But a, b, and c are distances. If you have spherical trigonometry. Then these As, Bs, and Cs are angular. Not actual meters in distances, but it's angles, degrees, and radius in distances. That's it. But it's the same ratios that are holding across. So if you know how to use laws of sines and cosines for regular triangles. You really know how to use it here. The math is tweaked. There's more sines and cosines in there. That's all. So we can use these ratios and we can use these ratios. So that's my review of spherical trigonometry. This is all you need. So if you haven't seen this before, practice quickly. Or you'll quickly get a hang of it. Wait, I'm going to go here. The next one. So now I have a favorite symmetric set. 3-1-3 is kind of our poster child of symmetric ones for our astrodynamics. Because, of course, we love orbits and orbits uses 3-1-3s. How can we combine this? So if you're thinking about this, a 3-1-3 and we're adding a 3-1-3. We're really doing a six rotation sequence. We're doing 3-1-3-3-1-3. So, in the middle, we're repeating three. If we repeat a rotation. If we have two rotations about the same axis, Andrew Before what did that mean? We only had three angles and I would have 1-1-2. I'm repeating about an axis, what happened then? >> You just rotate about that twice and add the angles. >> Yeah, what about if I try to invert the problem? Now going from that final attitude back to angles. >> Well you'd have an ambiguity variable? >> Exactly we'd have ambiguity and so forth. Her we won't be having ambiguities because we're actually using six angles. So if you have six, you can say look. We're not doing the inverse. Let me take that statement back. We'll get to that in a moment. So let's start looking here. The first rotation is really in dark grey. And I'm going to use the angles theta. Just we run out of letters. If I use gamma, theta, not the stuff, it gets very confusing. So I just have the first rotation is theta one, theta two, theta three, that's it. So I'm doing a 3. Inclination is 1. 3. That gets me there. Now I'm doing another 3-1-3. And I'm calling the second set of angles small phi 1, 2, 3. So you can see I went 3-1-3. Now I'm rotating again about 3. Doing again an inclination change. And a final 3. So that's that first rotation. That's in the same plane as the last one of the prior one. Led me to another plane change in orbit terms. And they may go up to the final orientation. And that will actually align with final frame. So we have the n frame. Then we have the b frame and then the f frame. The f frame is the final one. What we're really after is how do I go from n to f all in one. And again, we can map to DCMs pull them out. Do all that stuff. That works. But if you look at this figure carefully. You will see geometrically you'll find directly what the angles are. Once you see that, now we can use lots of sines and cosines to pull out the answer without ever touching a DCM. I need to go from here with my first access. We talked about the order. It's very important. This is the first one, then it goes here, then at the end, it has to be up here. So I want to go from here all the way to here. Using still a 3-1-3 rotation to get there. Does somebody see how far? So 3-1-3 we have to rotate first about this axis. Does somebody see how far to rotate on that axis? Yeah you're nodding your head, do you want to give it a try? >> [INAUDIBLE] >> What's the angular distance? How far would you have to go? >> [INAUDIBLE] >> Yeah, this is the script phi or [INAUDIBLE] as you call it. Yeah. I'm not sure. I don't know Greek. If I get my Greek letters wrong, it's just my ignorance. I confess. This one, [INAUDIBLE] I think is called [INAUDIBLE] who knows how you pronounce that. So we go this this far about the 3 axis. Then we have to do a 1 axis. And now our 1 axis has moved from here to here. This thin line is my new 1 axis. Now you're going to do a one-axis rotation by this angle, which I'm calling script phi 2. And then once you've got this plane, what you have to do is travel all this angular distance up to get here. Right, and that will get you the same place. And you can always do this. So if you have two sequences of symmetric angles, three-one-three, three-one-three, you've got this outer triangle, sometimes an inner one, depending on the signs of the angles. There's always this triangle that appears which I've highlighted in the old bold lines there. That's the one you want to look for. And now, we have to figure out what is this distance, in terms of the thetas and the regular phis and the same thing with this angular distance and this angular distance. So we have to figure those things out. That's it. We never have to go to the DCM. So if I pull this triangle out, and I'm just drawing it separately, you can see this inner angle Is just theta 2, right? I've drawn that. This angular distance, we know this part, that's theta 1, this angular distance is what we just called script phi 1. That's the one we're looking for. So this distance is the difference between this and this which is just script phi 1- theta 1. So that's this side of it, all right? Then you go on and say, okay, let's see, I need this angle. That's one I have. I know the total angle is 180. So the complement of this angle is going to be pi 180 minus 52. Right, then we've labeled that side. This one up here, we said when we go from this plane and we do the last the second three-one-three, the inclination change, we have this angle. So if that's phi 2, this is the one opposite. That's the same. So that angle would be phi 2. This distance, we know this distance. That was phi 3. And so skip phi 3- phi 3 gives you this angular distance. And then, finally, this one, that's where we're doing the three-one. Now we're doing a three and a three rotation twice. And that's what gives us the total arc length that we were talking about earlier. And that's just going to be theta 3 + phi 1, all right? So that's what you want to look for. In the homework, you're doing this for a different set of angles, not three-one-three, just something else. But you're really following the same steps. What people struggle with sometimes is seeing this geometry, all right? That's why I'm trying to give you as many hints and tips as I can to do that. Good, so if you have this now, now it's a matter of using laws of sines and cosines, where we can say, well, we know all the theta quantities and we know all the regular phi quantities. How can I come up with ratios of sines or using laws and cosines to find this? All right, and one example would be the law of cosine here. I've got cosine of phi- script phi's a cosine of this angle drawn in red now. It's going to be equal to basically cosine, was it minus cosine of theta 2 and phi 2 to cosine of the other two inner angles, times the sine of these two inner angles, times the cosine of the opposite arc length. So this is kind of equivalence in the laws of cosine. I don't memorize it either. I just go look at the formulas and I go, okay, this is the right terms that go in there. But we know the thetas. We know the phis. So from this, I can get to an inverse cosine and then solve for script phi 2 directly, right? So we can get one of the three with this law of cosine. [COUGH] And that we're doing an inverse cosine is good, right, the second angle. Here's a way to find between 0 and 180. An inverse cosine gives you exactly an angle between 0 and 180, just the calculator does. And it can result in the other multiple answers. And that's basically the answer. Now if you want to find the other two, we can use laws of sines or laws of cosines. And I'll let you do the details in the homework. There's no sense me kind of spoonfeeding every little piece to you here. Do this on your own. You'll quickly find these relationships and say, okay, here I have all the thetas and phis. I know script phi 2 already. I've already solved for that. And I could do an inverse sine and find it, or I know all this stuff. And I can do the inverse cosine and find theta 1. Yes? >> Are there any other advantages to this approach, just besides the inverse mapping reduction and [INAUDIBLE], or is that the primary reason we would? >> Primary reason is just computational speed. You can do this very, very quickly. Yeah, it'll be less math involved in your computer CPU to run this. So if you're really more speed sensitive, and you want to do it directly, it gives you essentially an analytic answer. I have a reasonably compact analytic answer that was here. This one. That's it. If you compare that at all to mapping angles to DCMs, carrying it all out, doing this, then you have to reduce it. It takes a lot of math to get there. This is a very compact analytic answer than if you're doing analysis with it, looking at sensitivities, have to take partial derivatives, I can do it analytically very quickly, versus having to use maybe computational numerical methods to get sensitivities. >> Okay. >> No, great question. Now here, back. >> Either one works. Can you add any two symmetric sets, or does it have to be the same? >> Has to be the same, because the trick to make all this work is we have a repeated access that stitches them together. I'm doing a three-one-three, three-one-three. That three-three is repeated. If you did a three-one-three and then a two, it doesn't work, which is the main reason why with yaw, pitch, roll, a very popular set for attitude dynamics, it's a three-two-one and then a three-two-one. That three in one, they don't line up, then you don't get this nice. There's still analytic answers. You could just run through all the matrix math and then pull out all the stuff. It'll be long and ugly. I don't have the nice spherical trigonometry interpretation of it. I just go to the matrix then. Yes, sir. >> Back to the equation you showed for Cailey. >> This one? >> Yes, where did the pi go? >> [INAUDIBLE] change. >> Yeah, I think. >> i minus theta is just cos theta, right? >> Yes, cosine of 180 minus that is the same as cosine of that. And then it goes, yes? The trig is everywhere. [LAUGH] Be aware of that. On the exam sheets, typically I actually give you several trig formulas. This is not a trigonometry class. I expect you to use these things. If you need laws of sines and cosines, I'm giving you that. It's how do you use it. Okay, good, well, so here now, we have two methods to get theta 1. And subscript phi 1 and script phi 3, we can use basically an inverse sine, or we could use the inverse cosine. Which one would you prefer in this situation? Cody? >> I'm not sure. >> Think about the range that you need on this angle. Where are the first and the third angle defined, over how many quadrants? >> First two quadrants? >> No, think of ascending node, for example. Do you only have ascending nodes 0 to 180, or did your ascending node really travel all the way across the plane? >> I'm not sure. >> What's the answer, how many quadrants? >> Four. >> Four, actually. That's why earlier, when we extracted Euler angles from the DCMs for the first and the third, we always look for an inverse tangent, right? And you have to keep the right numerator, denominator. Here, it's the same thing. You could just add an inverse sine. And you might get the right answer if you're lucky because it happens to give it in the right quadrant. But you just have to be lucky. To make it robust, you need to have a sine and a cosine, cause then you can do the ratio of these two and come up with an inverse tangent answer and now you get the correct answer always, in the right quadrant. So that's what we have down here. Basically, because I've used it to solve for script v- 1, with an inverse sine, script v -1 pretty most cosine and then the ratio those attention and the fader one. Which one goes where? It's not consistent. MathLab does one way, Mathmatica flips it. I think that's a light Mathmatica, I forget, anyway, but that's the answer. So now we have direct analytic, actually reasonably compact, considering we have to take the angles, map the 3x3's, do all this math,and strap things out again. Lots of reductions, lots of triggered entities to get to this form with spherical trigonometry, we can derive it directly, which is kind of cool and elegant. But here's the fun part, this is where it helps when you pay attention. In this homework, you're not doing a three, one, three. You're doing some other sequence, it turns out the math that I'm showing you, Is exactly the same regardless of the sequence. If it's a two, one, two, or one, two, one, a three, two, three, whatever it is, these sequences looks different. The triangle with the end, once you pull that out, will be exactly the same. That's a big tip, because that basically means you know what the answer is. The question is can you give me the path to that answer, right? And draw it out. You can use another tip looking at this kind of a things. No matter what the sequence is, I've called this one two or three. You can relabel those things. If I'm doing a one, two, one I'd have to rotate here, move around. All of this stuff will all of a sudden shift over, and how can you draw that? If this makes sense to you you can always pick your labels such that why not call one, two and three like that. because if you do one rotation, this part looks very, very similar, right? So that's as many tips as I'm going to give you on that one. So you know the answer, which is kind of an elegant thing, regardless of this, it's six sets. Regardless of what the sequence is, as long as you're doing two, one, two, two, one, two, this is the math. So from a programming perspective, I can write one function, give it three sets of angles, another three sets of angles. And if they're symmetric to symmetrics, same type, that function will return the right output. You don't have to write one for two, one, twos and a different function for one, two, ones. It's the same function that actually acts on six sets of coordinates. It does direct additions in a very compact way. So that's kind of a cool, elegant result that we have. How useful in every day life? Well, who knows. That's another question, but it is cool. Any questions on spherical trigonometry edition? You're working through a problem in the homework. You're basically duplicating a lot of this, but you're filling in all the blanks. Don't just gives us the steps as seen on the slide. It takes a few steps in between to go okay, not many, that you can show how it all works. This should make sense to you. It's a good skill to have, spherical trigonometry. Works for any symmetric Euler angle sets, you just have to add them of the same type. Subtraction, is really the same process. You run through it, you come up with same angles, but what is given and what you're seeking is different. So let's say we have thetas and we have script freeze. That basically means we know to go from n to b and we know how to go from n to f. I want to have the relative attitude from B to F, and with DCMs, we transpose one of them and multiply them out. So it's the same triangle, just to use different formulas now, because now all of a sudden, theta's a given and script phi's a given, and you're looking for regular phis. It's the same process, or vice versa if you have the second rotation and the overall was the first one, now you have to treat the theta's as on this and use the corresponding laws of sines and cosines and there you go. So it's completely analogous, once you can do one I'm not showing the sets to you that's what I expect you to do in your homework, fill it out flash it in once you see the pattern you can be done in ten minutes. Get this going but for some people thinking seeing that if you don't see it in the beginning hopefully these tips will help guide you on the right path or chat with each other, that's always a great way help each other understand this stuff.